1 | package com.hammurapi.eventbus.tests; |
2 | |
3 | import com.hammurapi.eventbus.Handler; |
4 | import com.hammurapi.eventbus.local.LocalEventDispatchContext; |
5 | |
6 | public class ComplexHandler { |
7 | |
8 | @Handler |
9 | public void handle(LocalEventDispatchContext<Object, Integer, ?> ctx, String str) throws InterruptedException { |
10 | System.out.println("Handling with context '"+str+"' in "+Thread.currentThread()); |
11 | if ("mama".equals(str)) { |
12 | ctx.post("papa"); |
13 | } |
14 | Thread.sleep(100); |
15 | } |
16 | |
17 | @Handler("java(str)://\"papa\".equals(str)") |
18 | public String handle(String str) { |
19 | System.out.println("Handling '"+str+"' in "+Thread.currentThread()); |
20 | return "grand"; |
21 | } |
22 | |
23 | @Handler |
24 | public void handle(Integer num) { |
25 | System.out.println("Handling '"+num+"' in "+Thread.currentThread()); |
26 | } |
27 | |
28 | @Handler |
29 | public void handle(String str, Integer num) throws InterruptedException { |
30 | System.out.println("Joining "+str+" and "+num); |
31 | Thread.sleep(100); |
32 | } |
33 | |
34 | } |