001 package com.hammurapi.eventbus.tests;
002
003 import com.hammurapi.eventbus.Handler;
004 import com.hammurapi.eventbus.local.LocalEventDispatchContext;
005
006 public class ComplexHandler {
007
008 @Handler
009 public void handle(LocalEventDispatchContext<Object, Integer, ?> ctx, String str) throws InterruptedException {
010 System.out.println("Handling with context '"+str+"' in "+Thread.currentThread());
011 if ("mama".equals(str)) {
012 ctx.post("papa");
013 }
014 Thread.sleep(100);
015 }
016
017 @Handler("java(str)://\"papa\".equals(str)")
018 public String handle(String str) {
019 System.out.println("Handling '"+str+"' in "+Thread.currentThread());
020 return "grand";
021 }
022
023 @Handler
024 public void handle(Integer num) {
025 System.out.println("Handling '"+num+"' in "+Thread.currentThread());
026 }
027
028 @Handler
029 public void handle(String str, Integer num) throws InterruptedException {
030 System.out.println("Joining "+str+" and "+num);
031 Thread.sleep(100);
032 }
033
034 }