- All Known Implementing Classes:
- SimpleDispatcher
public interface EventDispatcher<E extends Event,R extends ListenerRegistry>
This interface abstracts the function of dispatching an event to one or many Listeners.
ListenerRegistry is injected as a dependency, the registry is to be used for discovering
registered Listeners.
Listener modes:
Listeners are registered to be invoked in blocking and non-blocking modes.
Invoking blocking Listeners must cause the dispatcher to wait until Listener returns. That is,
dispatchEvent must not return until blocking Listeners are executed completely.
It is generally adviced to execute all blocking Listenrs in the same thread that dispatcher was notified in.
Not doing so will have transaction and visibility restrictions, so please use such techniques in well understood cases.
All non-blocking Listeners are to be invoked in a non-blokcing fashion, that is dispatchEvent() returns right away.
In either case, implementation decides the order of invocation and timeouts (if any).
Implementations also decide queuing and what happens to queued Listeners when they are subsequenly unregistered.