public static class SimpleEventHandlerInvoker.Builder extends Object
SimpleEventHandlerInvoker
.
The ListenerInvocationErrorHandler
is defaulted to a LoggingErrorHandler
and the
SequencingPolicy
to a SequentialPerAggregatePolicy
. Providing at least one Event Handler is a
hard requirement and thus should be accounted for.
Constructor and Description |
---|
Builder() |
public SimpleEventHandlerInvoker.Builder eventHandlers(Object... eventHandlers)
eventHandlers
this EventHandlerInvoker
will forward all its events to. If an event
handler is assignable to EventMessageHandler
it will registered as is. If not, it will be wrapped by
a new AnnotationEventHandlerAdapter
.eventHandlers
- an array of Object
s which can handle eventspublic SimpleEventHandlerInvoker.Builder eventHandlers(List<?> eventHandlers)
eventHandlers
this EventHandlerInvoker
will forward all its events to. If an event
handler is assignable to EventMessageHandler
it will registered as is. If not, it will be wrapped by
a new AnnotationEventHandlerAdapter
.public SimpleEventHandlerInvoker.Builder parameterResolverFactory(ParameterResolverFactory parameterResolverFactory)
ParameterResolverFactory
used to resolve parameter values for annotated handlers in the
AnnotationEventHandlerAdapter
this EventHandlerInvoker
instantiates. This invoker will only
instantiate a new EventMessageHandler
if a given Event Handler (through
eventHandlers(Object...)
or eventHandlers(List)
) is not assignable to EventMessageHandler.parameterResolverFactory
- the ParameterResolverFactory
used to resolve parameter values for
instantiated AnnotationEventHandlerAdapter
spublic SimpleEventHandlerInvoker.Builder handlerDefinition(HandlerDefinition handlerDefinition)
HandlerDefinition
used to create concrete handlers in the annotated handlers in the
AnnotationEventHandlerAdapter
this EventHandlerInvoker
instantiates. This invoker will only
instantiate a new EventMessageHandler
if a given Event Handler
(through eventHandlers(Object...)
or eventHandlers(List)
) is not assignable to
EventMessageHandler.handlerDefinition
- the HandlerDefinition
used to create concrete handlers in the instantiated
AnnotationEventHandlerAdapter
spublic SimpleEventHandlerInvoker.Builder listenerInvocationErrorHandler(ListenerInvocationErrorHandler listenerInvocationErrorHandler)
ListenerInvocationErrorHandler
which deals with any Exception
s being thrown by the
EventListener
s. Defaults to a LoggingErrorHandler
.listenerInvocationErrorHandler
- a ListenerInvocationErrorHandler
which deals with any Exception
s being thrown by the EventListener
spublic SimpleEventHandlerInvoker.Builder sequencingPolicy(SequencingPolicy<? super EventMessage<?>> sequencingPolicy)
SequencingPolicy
in charge of deciding whether a given event should be handled (through
SimpleEventHandlerInvoker.handle(EventMessage, Segment)
) by the given Segment
. Used when this
EventHandlerInvoker
is invoked for multiple Segments (i.e. using parallel processing). Defaults to a
SequentialPerAggregatePolicy
,sequencingPolicy
- a SequencingPolicy
in charge of deciding whether a given event should be
handled by the given Segment
public SimpleEventHandlerInvoker build()
SimpleEventHandlerInvoker
as specified through this Builder.SimpleEventHandlerInvoker
as specified through this Builderpublic AnnotationEventHandlerAdapter wrapEventMessageHandler(Object eventHandler)
eventHandler
in an AnnotationEventHandlerAdapter
to allow this
EventHandlerInvoker
to correctly pass EventMessage
s to it. If a
ParameterResolverFactory
or both a ParameterResolverFactory and HandlerDefinition
are
present, one/both will be given to the AnnotationEventHandlerAdaptereventHandler
- an Object
which will be wrapped in an AnnotationEventHandlerAdapter
AnnotationEventHandlerAdapter
which the given eventHandler
will be wrapped inprotected void validate() throws AxonConfigurationException
AxonConfigurationException
- if one field is asserted to be incorrect according to the Builder's
specificationsCopyright © 2010–2020. All rights reserved.