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 SlowPostingHandler {
008
009 private volatile int counter;
010
011 @Handler("java(str)://str.equals(\"World\")")
012 public String handleWorld(String str) throws InterruptedException {
013 Thread.sleep(50);
014 ++counter;
015 return "!";
016 }
017
018 @Handler
019 public void handleEm(LocalEventDispatchContext<Object, Integer, Object> context, @Condition("\"!\".equals(str)") String str) throws InterruptedException {
020 Thread.sleep(100);
021 ++counter;
022 context.post("Hello");
023 }
024
025 public int getCounter() {
026 return counter;
027 }
028 }