| 1 | package com.hammurapi.eventbus.tests; |
| 2 | |
| 3 | import com.hammurapi.common.Condition; |
| 4 | import com.hammurapi.eventbus.Handler; |
| 5 | import com.hammurapi.eventbus.local.LocalEventDispatchContext; |
| 6 | |
| 7 | public class PostingHandler { |
| 8 | |
| 9 | private int worldCounter; |
| 10 | private boolean worldOk; |
| 11 | |
| 12 | private int emCounter; |
| 13 | private boolean emOk; |
| 14 | |
| 15 | public int getWorldCounter() { |
| 16 | return worldCounter; |
| 17 | } |
| 18 | |
| 19 | public boolean isWorldOk() { |
| 20 | return worldOk; |
| 21 | } |
| 22 | |
| 23 | public int getEmCounter() { |
| 24 | return emCounter; |
| 25 | } |
| 26 | |
| 27 | public boolean isEmOk() { |
| 28 | return emOk; |
| 29 | } |
| 30 | |
| 31 | @Handler("java(str)://str.equals(\"World\")") |
| 32 | public String handleWorld(String str) { |
| 33 | ++worldCounter; |
| 34 | worldOk = "World".equals(str); |
| 35 | return "!"; |
| 36 | } |
| 37 | |
| 38 | @Handler //("\"!\".equals(args[0])") |
| 39 | public void handleEm(LocalEventDispatchContext<Object, Integer, Object> context, @Condition("\"!\".equals(str)") String str) { |
| 40 | ++emCounter; |
| 41 | emOk = "!".equals(str); |
| 42 | context.post("Hello"); |
| 43 | } |
| 44 | } |