public static class SimpleEventHandlerInvoker.Builder<B extends 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 as such should be provided.
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
SimpleEventHandlerInvoker |
build()
Initializes a
SimpleEventHandlerInvoker as specified through this Builder. |
B |
eventHandlers(List<?> eventHandlers)
Sets the
eventHandlers this EventHandlerInvoker will forward all its events to. |
B |
eventHandlers(Object... eventHandlers)
Sets the
eventHandlers this EventHandlerInvoker will forward all its events to. |
B |
handlerDefinition(HandlerDefinition handlerDefinition)
Sets the
HandlerDefinition used to create concrete handlers in the annotated handlers in the AnnotationEventHandlerAdapter this EventHandlerInvoker instantiates. |
B |
listenerInvocationErrorHandler(ListenerInvocationErrorHandler listenerInvocationErrorHandler)
Sets the
ListenerInvocationErrorHandler dealing with exceptions thrown by the
configured event handlers . |
B |
parameterResolverFactory(ParameterResolverFactory parameterResolverFactory)
Sets the
ParameterResolverFactory used to resolve parameter values for annotated handlers in the
AnnotationEventHandlerAdapter this EventHandlerInvoker instantiates. |
B |
sequencingPolicy(SequencingPolicy<? super EventMessage<?>> sequencingPolicy)
Sets the
SequencingPolicy in charge of deciding whether a given event should be handled (through
EventHandlerInvoker.handle(EventMessage, Segment) ) by the given Segment . |
protected void |
validate()
Validates whether the fields contained in this Builder are set accordingly.
|
AnnotationEventHandlerAdapter |
wrapEventMessageHandler(Object eventHandler)
Wrap a given
eventHandler in an AnnotationEventHandlerAdapter to allow this EventHandlerInvoker to correctly pass EventMessage s to it. |
public B eventHandlers(Object... eventHandlers)
eventHandlers
this EventHandlerInvoker
will forward all its events to. If an event
handler is assignable to EventMessageHandler
it will register as is. If not, it will be wrapped by a
new AnnotationEventHandlerAdapter
.eventHandlers
- an array of Object
s which can handle eventspublic B eventHandlers(@Nonnull List<?> eventHandlers)
eventHandlers
this EventHandlerInvoker
will forward all its events to. If an event
handler is assignable to EventMessageHandler
it will register as is. If not, it will be wrapped by a
new AnnotationEventHandlerAdapter
.public B parameterResolverFactory(@Nonnull 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 B handlerDefinition(@Nonnull 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 B listenerInvocationErrorHandler(@Nonnull ListenerInvocationErrorHandler listenerInvocationErrorHandler)
ListenerInvocationErrorHandler
dealing with exceptions
thrown by the
configured event handlers
. Defaults to a LoggingErrorHandler
.listenerInvocationErrorHandler
- The error handler dealing with exceptions
thrown by
the configured event handlers
public B sequencingPolicy(@Nonnull SequencingPolicy<? super EventMessage<?>> sequencingPolicy)
SequencingPolicy
in charge of deciding whether a given event should be handled (through
EventHandlerInvoker.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(@Nonnull 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–2024. All rights reserved.