Skip to content

Instantly share code, notes, and snippets.

@bivas
Created March 30, 2011 22:24
Show Gist options
  • Save bivas/895434 to your computer and use it in GitHub Desktop.
Save bivas/895434 to your computer and use it in GitHub Desktop.
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