public interface EventBus
Represents a generic event bus mechanisms with support for multiple listeners per event type. Events posted via dispatchEvent(Event)
are dispatched to all interested
listeners registered via register(EventHandler, Class)
, based on the type of the Event
.
<p>
Aspects like event persistence, reliability, and synchronous/asynchronous delivery of events is subject to the implementation.
Modifier and Type | Method and Description |
---|---|
void |
dispatchEvent(Event event)
Dispatches the event to all event handlers registered for the corresponding event type or event supertype.
|
<E extends Event> |
register(EventHandler<? super E> eventHandler,
Class<E> eventType)
Registers the event handler for being notified on events of the specified type and all subtypes.
|
<E extends Event> |
unregister(EventHandler<? super E> eventHandler,
Class<E> eventType)
Unregisters the event handler from being notified on events of the specified type and all subtypes.
|
<E extends Event> void register(EventHandler<? super E> eventHandler, Class<E> eventType)
Registers the event handler for being notified on events of the specified type and all subtypes. Registering the same event handler for different event types is supported, as long as the event type is compatible with the event type expected by the event handler. Registering an already registered event handler for the same event type has no effect. <p> Explicitly registering an event handler for an event type and for a subtype of that event type is seen as two separate, unrelated registrations, and thus, events of the subtype will be dispatched to the event handler twice.
eventHandler
- the event handler to be registeredeventType
- the type of the event to register the event handler with<E extends Event> void unregister(EventHandler<? super E> eventHandler, Class<E> eventType)
Unregisters the event handler from being notified on events of the specified type and all subtypes. Other registrations of the same event handler for different event types are not affected. If the event handler has not been registered for the corresponding event type, this operation has no effect. <p> Unregistering the event handler for a specific event type does not automatically unregister the same event handler from all subtypes of that event type, in case the event handler has explicitly been registered for both the event type and the event subtype.
eventHandler
- the event handler to be unregisteredeventType
- the type of the event to unregister the event handler fromvoid dispatchEvent(Event event)
Dispatches the event to all event handlers registered for the corresponding event type or event supertype. If no event handlers are registered for this event type, this operation has no effect.
event
- the event to be dispatchedCopyright © 2010 - 2019 edorasware ag. All Rights Reserved.