public class SimpleEventHandlerInvoker extends Object implements EventHandlerInvoker
EventHandlerInvoker
that forwards events to a list of registered EventListeners
.Constructor and Description |
---|
SimpleEventHandlerInvoker(List<?> eventListeners,
ListenerInvocationErrorHandler listenerInvocationErrorHandler)
Initializes a
SimpleEventHandlerInvoker containing the given list of eventListeners . |
SimpleEventHandlerInvoker(List<?> eventListeners,
ListenerInvocationErrorHandler listenerInvocationErrorHandler,
SequencingPolicy<? super EventMessage<?>> sequencingPolicy)
Initialize the EventHandlerInvoker to invoke the given
eventListeners , using the given
listenerInvocationErrorHandler when an error occurs invoking these handlers and the given
sequencingPolicy to describe the expected sequencing of event messages |
SimpleEventHandlerInvoker(List<?> eventListeners,
ParameterResolverFactory parameterResolverFactory,
ListenerInvocationErrorHandler listenerInvocationErrorHandler)
Initializes a
SimpleEventHandlerInvoker containing the given list of eventListeners . |
SimpleEventHandlerInvoker(List<?> eventListeners,
ParameterResolverFactory parameterResolverFactory,
ListenerInvocationErrorHandler listenerInvocationErrorHandler,
SequencingPolicy<? super EventMessage<?>> sequencingPolicy)
Initializes a
SimpleEventHandlerInvoker containing the given list of eventListeners . |
SimpleEventHandlerInvoker(Object... eventListeners)
Initializes a
SimpleEventHandlerInvoker containing one or more eventListeners . |
Modifier and Type | Method and Description |
---|---|
boolean |
canHandle(EventMessage<?> eventMessage,
Segment segment)
Check whether or not this invoker has handlers that can handle the given
eventMessage for a given
segment . |
void |
handle(EventMessage<?> message,
Segment segment)
Handle the given
message for the given segment . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handle
public SimpleEventHandlerInvoker(Object... eventListeners)
SimpleEventHandlerInvoker
containing one or more eventListeners
. If an event
listener is assignable to EventListener
it will registered as is. If not, it will be wrapped by a new
AnnotationEventListenerAdapter
.
Events handled by the invoker will be passed to all the given eventListeners
. If an exception is
triggered during event handling it will be logged using a LoggingErrorHandler
but otherwise
ignored.
When this invoker is invoked for multiple Segments (i.e. using parallel processing), events from the same
Aggregate are guaranteed to be processed in sequence (see SequentialPerAggregatePolicy
).
eventListeners
- one or more event listeners to register with this invokerpublic SimpleEventHandlerInvoker(List<?> eventListeners, ListenerInvocationErrorHandler listenerInvocationErrorHandler)
SimpleEventHandlerInvoker
containing the given list of eventListeners
. If an event
listener is assignable to EventListener
it will registered as is. If not, it will be wrapped by a new
AnnotationEventListenerAdapter
.
Events handled by the invoker will be passed to all the given eventListeners
. If an exception is
triggered during event handling it will be handled by the given listenerErrorHandler
.
When this invoker is invoked for multiple Segments (i.e. using parallel processing), events from the same
Aggregate are guaranteed to be processed in sequence (see SequentialPerAggregatePolicy
).
eventListeners
- list of event listeners to register with this invokerlistenerInvocationErrorHandler
- error handler that handles exceptions during processingpublic SimpleEventHandlerInvoker(List<?> eventListeners, ListenerInvocationErrorHandler listenerInvocationErrorHandler, SequencingPolicy<? super EventMessage<?>> sequencingPolicy)
eventListeners
, using the given
listenerInvocationErrorHandler
when an error occurs invoking these handlers and the given
sequencingPolicy
to describe the expected sequencing of event messageseventListeners
- The listeners to invokelistenerInvocationErrorHandler
- The error handler to invoke when an error occurssequencingPolicy
- The policy describing the expectations of sequential processingpublic SimpleEventHandlerInvoker(List<?> eventListeners, ParameterResolverFactory parameterResolverFactory, ListenerInvocationErrorHandler listenerInvocationErrorHandler)
SimpleEventHandlerInvoker
containing the given list of eventListeners
. If an event
listener is assignable to EventListener
it will registered as is. If not, it will be wrapped by a new
AnnotationEventListenerAdapter
.
Events handled by the invoker will be passed to all the given eventListeners
. If an exception is
triggered during event handling it will be handled by the given listenerErrorHandler
.
eventListeners
- list of event listeners to register with this invokerparameterResolverFactory
- The parameter resolver factory to resolve parameters of the Event Handler methods withlistenerInvocationErrorHandler
- error handler that handles exceptions during processingpublic SimpleEventHandlerInvoker(List<?> eventListeners, ParameterResolverFactory parameterResolverFactory, ListenerInvocationErrorHandler listenerInvocationErrorHandler, SequencingPolicy<? super EventMessage<?>> sequencingPolicy)
SimpleEventHandlerInvoker
containing the given list of eventListeners
. If an event
listener is assignable to EventListener
it will registered as is. If not, it will be wrapped by a new
AnnotationEventListenerAdapter
.
Events handled by the invoker will be passed to all the given eventListeners
. If an exception is
triggered during event handling it will be handled by the given listenerErrorHandler
.
eventListeners
- list of event listeners to register with this invokerparameterResolverFactory
- The parameter resolver factory to resolve parameters of the Event Handler methods withlistenerInvocationErrorHandler
- error handler that handles exceptions during processingsequencingPolicy
- The policy describing the expectations of sequential processingpublic void handle(EventMessage<?> message, Segment segment) throws Exception
EventHandlerInvoker
message
for the given segment
.
Callers are recommended to invoke EventHandlerInvoker.canHandle(EventMessage, Segment)
prior to invocation, but aren't
required to do so. Implementations must ensure to take the given segment into account when processing messages.
handle
in interface EventHandlerInvoker
message
- The message to handlesegment
- The segment for which to handle the messageException
- when an exception occurs while handling the messagepublic boolean canHandle(EventMessage<?> eventMessage, Segment segment)
EventHandlerInvoker
eventMessage
for a given
segment
.canHandle
in interface EventHandlerInvoker
eventMessage
- The message to be processedsegment
- The segment for which the event handler should be invokedtrue
if the invoker has one or more handlers that can handle the given message, false
otherwiseCopyright © 2010–2017. All rights reserved.