001    package com.hammurapi.eventbus.tests;
002    
003    import com.hammurapi.common.Condition;
004    import com.hammurapi.eventbus.Handler;
005    import com.hammurapi.eventbus.local.LocalEventDispatchContext;
006    
007    public class PostingHandler {
008            
009            private int worldCounter;
010            private boolean worldOk;
011            
012            private int emCounter;
013            private boolean emOk;
014            
015            public int getWorldCounter() {
016                    return worldCounter;
017            }
018    
019            public boolean isWorldOk() {
020                    return worldOk;
021            }
022    
023            public int getEmCounter() {
024                    return emCounter;
025            }
026    
027            public boolean isEmOk() {
028                    return emOk;
029            }
030    
031            @Handler("java(str)://str.equals(\"World\")")
032            public String handleWorld(String str) {
033                    ++worldCounter;
034                    worldOk = "World".equals(str);
035                    return "!";
036            }
037            
038            @Handler //("\"!\".equals(args[0])")
039            public void handleEm(LocalEventDispatchContext<Object, Integer, Object> context, @Condition("\"!\".equals(str)") String str) {
040                    ++emCounter;
041                    emOk = "!".equals(str);
042                    context.post("Hello");
043            }
044    }