public interface EventBus
An event bus is the central place where publishers (posting the messages) and the subscribers (event handlers) are registered.
| Modifier and Type | Method and Description |
|---|---|
void |
addExceptionHandler(ExceptionHandler handler)
Adds the specified exception handler that will be notified whenever and exception is thrown when an event is
being dispatched or processed by an event handler.
|
void |
addUndeliveredEventHandler(EventHandler<Object> handler)
Adds the specified event handler that will process events that have not been processed by any event handler
registered with
subscribe(Topic, Channel, EventFilter, EventHandler). |
void |
dispose()
Disposes the event bus by removing all event handlers, undelivered event handlers, stopping the dispatching
threads, etc.
|
<C> void |
publish(Topic<C> topic,
Channel channel,
C content)
Sends the specified content for the specified topic on the specified channel.
|
void |
removeExceptionHandler(ExceptionHandler handler)
Removes the specified exception handler
|
void |
removeUndeliveredEventHandler(EventHandler<Object> handler)
Removes the specified undelievered event handler.
|
<C> int |
subscribe(Topic<C> topic,
Channel channel,
EventFilter<? super C> filter,
EventHandler<? super C> handler)
Registers a subscriber for the specified topic on the specified channel with the specified filter by adding an
event handler.
|
void |
unsubscribe(int id)
Unregisters a subscriber that was previously registered.
|
void addExceptionHandler(ExceptionHandler handler)
handler - Exception handler to be added.void removeExceptionHandler(ExceptionHandler handler)
handler - Exception handler to be removed.void addUndeliveredEventHandler(EventHandler<Object> handler)
subscribe(Topic, Channel, EventFilter, EventHandler).handler - Undelivered event handler to be added.void removeUndeliveredEventHandler(EventHandler<Object> handler)
handler - Undelivered event handler to be removed.<C> int subscribe(Topic<C> topic, Channel channel, EventFilter<? super C> filter, EventHandler<? super C> handler)
C - Type of content to subscribe for.topic - Topic to subscribe for.channel - Channel on which the events should be received.filter - Additional filter that should be applied before receiving the events.handler - Event handler that will process the received events.unsubscribe(int).unsubscribe(int)void unsubscribe(int id)
id - Identifier of a previous subscription.subscribe(Topic, Channel, EventFilter, EventHandler)<C> void publish(Topic<C> topic, Channel channel, C content)
The content will be wrapped in an Event that will be dispatched to the registered event handlers.
C - Type of content to be dispatched.topic - Topic for which the content must be dispatched.channel - Channel on which the event must be dispatched.content - Content to be dispatched.void dispose()
After calling this method, the event bus may no longer be used, depending on the implementation.
Copyright © 2017. All rights reserved.