Created
March 30, 2011 22:24
-
-
Save bivas/895434 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.eventroaster.example; | |
import org.eventroaster.annotation.Event; | |
import org.eventroaster.EventServiceFactory; | |
import org.eventroaster.annotation.EventHandler; | |
import org.eventroaster.EventService; | |
import org.eventroaster.EventServiceFactory; | |
@Event | |
public class EchoEvent {} | |
public class EchoHandler { | |
EchoHandler() { | |
EventServiceFactory.getEventService(EchoServiceKey.ECHO_SERVICE_KEY).register(this); | |
} | |
@EventHandler(event = EchoEvent.class) | |
public void handle() { | |
System.out.println("I got the event!"); | |
} | |
@EventHandler(event = EchoEvent.class) | |
public void handleEvent(final EchoEvent echoEvent) { | |
System.out.println("I got event =" + echoEvent); | |
} | |
} | |
public class EchoPublisher { | |
private final EventService eventService; | |
public EchoPublisher() { | |
eventService = EventServiceFactory.getEventService(EchoServiceKey.ECHO_SERVICE_KEY); | |
} | |
public void callMe() { | |
eventService.fire(new EchoEvent()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment