001    package com.hammurapi.eventbus.tests;
002    
003    import java.util.concurrent.atomic.AtomicReference;
004    
005    import com.hammurapi.common.Condition;
006    import com.hammurapi.eventbus.EventHandlerBase.Mode;
007    import com.hammurapi.eventbus.local.LocalEventDispatchContext;
008    import com.hammurapi.eventbus.Handler;
009    
010    public class RemoveHandler2 {
011            
012            private Object expectedWorld;
013            
014            public void setExpectedWorld(Object expectedWorld) {
015                    this.expectedWorld = expectedWorld;
016            }
017            
018            private int worldCounter;
019            private boolean worldOk;
020            
021            public int getWorldCounter() {
022                    return worldCounter;
023            }
024    
025            public boolean isWorldOk() {
026                    return worldOk;
027            }
028    
029            @Handler(value="java(*)://strRef.get().equals(\"World\")", mode=Mode.REMOVE)
030            public void handleWorld(AtomicReference<String> strRef) {
031                    ++worldCounter;
032                    worldOk = expectedWorld == strRef;
033            }
034            
035            private int emCounter;
036            private boolean emOk;
037            
038            public int getEmCounter() {
039                    return emCounter;
040            }
041    
042            public boolean isEmOk() {
043                    return emOk;
044            }
045    
046            @Handler(mode=Mode.REMOVE)
047            public void handleEm(
048                            LocalEventDispatchContext<Object, Integer, Object> context, @Condition("\"!\".equals(strRef.get())") AtomicReference<String> strRef) {
049                    ++emCounter;
050                    emOk = "!".equals(strRef.get());
051            }
052            
053            
054    }