S - The concrete type of the state object.public class DefaultEventBus<S extends State> extends AbstractMessageBus<Event,EventHandler<S,Event>> implements EventBus<S>
EventBus.| Modifier and Type | Field and Description |
|---|---|
protected LoggerCollection<S> |
loggers
Used for logging the event handler operations.
|
protected StateManager<S> |
stateManager
Provides access to the current state.
|
messageHandlerMap, messageStore, onMessageAddedToStore| Constructor and Description |
|---|
DefaultEventBus(MessageStore messageStore,
LoggerCollection<S> loggers,
StateManager<S> stateManager) |
| Modifier and Type | Method and Description |
|---|---|
void |
addEventLogger(EventLogger<S> logger)
Add an event logger.
|
protected void |
executeHandler(Event event,
EventHandler<S,Event> eventHandler)
Actually execute the message handler for this message.
|
void |
handleEvent(Event event)
Execute the event handler that is mapped to this event type.
|
<E extends Event> |
mapEventHandler(Class<E> eventClass,
EventHandler<S,E> eventHandler)
Map a event handler for a concrete event type.
|
protected boolean |
shouldHandleMessageType(Message message)
Returns whether this message bus implementation should handle the concrete message object.
|
getMessageHandlers, handleMessage, mapMessageHandlerprotected final LoggerCollection<S extends State> loggers
protected final StateManager<S extends State> stateManager
public DefaultEventBus(MessageStore messageStore, LoggerCollection<S> loggers, StateManager<S> stateManager)
public void addEventLogger(EventLogger<S> logger)
EventLoggerAwareaddEventLogger in interface EventLoggerAware<S extends State>logger - The event logger to add.public void handleEvent(Event event)
EventBushandleEvent in interface EventBus<S extends State>event - The event to handle.EventBus.mapEventHandler(Class, EventHandler)public <E extends Event> void mapEventHandler(Class<E> eventClass, EventHandler<S,E> eventHandler)
EventBusmapEventHandler in interface EventBus<S extends State>E - The concrete event type that this handler will produce.eventClass - The concrete event type that this handler will handle.eventHandler - The handler that is executed when EventBus.handleEvent(Event) is
called.protected void executeHandler(Event event, EventHandler<S,Event> eventHandler)
AbstractMessageBusexecuteHandler in class AbstractMessageBus<Event,EventHandler<S extends State,Event>>event - The message to handle.eventHandler - The message handler that is associated with this message.protected boolean shouldHandleMessageType(Message message)
AbstractMessageBusshouldHandleMessageType in class AbstractMessageBus<Event,EventHandler<S extends State,Event>>message - The concrete message object.MCopyright © 2016 Cooking Fox. All rights reserved.