public abstract class AbstractEventSubscriber extends java.lang.Object implements EventDispatcher, EventSubscriber
EventBus
.
Objects may also receive events via EventDispatcher
s that can be
registered with EventBus
.
Bus.register(MessageDispatcher)
,
Subscribe
Constructor and Description |
---|
AbstractEventSubscriber() |
Modifier and Type | Method and Description |
---|---|
boolean |
canDispatch(EventEnvelope event)
Checks if this dispatcher can dispatch the given message.
|
void |
dispatch(EventEnvelope event)
Dispatches the event to the handling method.
|
com.google.common.collect.ImmutableSet<EventClass> |
domesticEventClasses()
Obtains classes of domestic events processed by this dispatcher.
|
com.google.common.collect.ImmutableSet<EventClass> |
externalEventClasses()
Obtains classes of external events processed by this dispatcher.
|
protected void |
handle(EventEnvelope event)
Handles an event dispatched to this subscriber instance.
|
boolean |
isRegistered() |
com.google.common.collect.ImmutableSet<EventClass> |
messageClasses()
Obtains a set of message classes that can be processed by this dispatcher.
|
void |
registerWith(BoundedContext context) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
dispatchesEvents, dispatchesExternalEvents, eventClasses
public void registerWith(BoundedContext context)
public boolean isRegistered()
public final void dispatch(EventEnvelope event)
dispatch
in interface MessageDispatcher<EventClass,EventEnvelope>
event
- the envelope with the eventprotected void handle(EventEnvelope event)
By default, passes the event to the corresponding subscriber method of the entity.
public boolean canDispatch(EventEnvelope event)
MessageDispatcher
This method does not check that the type of the message is one of the dispatched message classes. Instead, it validates the message upon some custom rules of this dispatcher.
Extend this method to forbid messages from being dispatched to this instance.
canDispatch
in interface MessageDispatcher<EventClass,EventEnvelope>
event
- the message to checktrue
is the given message can be dispatched by this dispatcher,
false
otherwisepublic com.google.common.collect.ImmutableSet<EventClass> messageClasses()
MessageDispatcher
messageClasses
in interface MessageDispatcher<EventClass,EventEnvelope>
public com.google.common.collect.ImmutableSet<EventClass> externalEventClasses()
EventDispatcher
externalEventClasses
in interface EventDispatcher
public com.google.common.collect.ImmutableSet<EventClass> domesticEventClasses()
EventDispatcher
domesticEventClasses
in interface EventDispatcher