You must add code to the configure method of your Guice Module (see Creating a Guice module) to "wire" your listeners to your events.
Note that no Guice configuration is required to simply declare an event interface and dispatch events on it. Configuration is only required for implementations of the event interface. You need similar configuration for each implementation of the event interface, although this can be split across as many Guice modules as you want. The Multibinder syntax in the figure below ensures that no matter how many implementations and modules you provide, they all end up in the same set of event listeners.
@Override public void configure() { /* * Get the listener set */ Multibinder<MyEventSource.Event> myEventListeners = Multibinder .newSetBinder(binder(), MyEventSource.Event.class); /* * Add a listener */ myEventListeners.addBinding().to(MyListener.class); }
preDoSomething event was raised from object curam.mypackage.MyEventSource@125d06e Do something! postDoSomething event was raised from object curam.mypackage.MyEventSource@125d06e