Package org.axonframework.eventhandling
Class SimpleEventHandlerInvoker.Builder<B extends SimpleEventHandlerInvoker.Builder<?>>
java.lang.Object
org.axonframework.eventhandling.SimpleEventHandlerInvoker.Builder<B>
- Direct Known Subclasses:
DeadLetteringEventHandlerInvoker.Builder
- Enclosing class:
SimpleEventHandlerInvoker
public static class SimpleEventHandlerInvoker.Builder<B extends SimpleEventHandlerInvoker.Builder<?>>
extends Object
Builder class to instantiate a
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Initializes aSimpleEventHandlerInvokeras specified through this Builder.eventHandlers(Object... eventHandlers) Sets theeventHandlersthisEventHandlerInvokerwill forward all its events to.eventHandlers(List<?> eventHandlers) Sets theeventHandlersthisEventHandlerInvokerwill forward all its events to.handlerDefinition(HandlerDefinition handlerDefinition) Sets theHandlerDefinitionused to create concrete handlers in the annotated handlers in theAnnotationEventHandlerAdapterthisEventHandlerInvokerinstantiates.listenerInvocationErrorHandler(ListenerInvocationErrorHandler listenerInvocationErrorHandler) Sets theListenerInvocationErrorHandlerdealing withexceptionsthrown by the configuredevent handlers.parameterResolverFactory(ParameterResolverFactory parameterResolverFactory) Sets theParameterResolverFactoryused to resolve parameter values for annotated handlers in theAnnotationEventHandlerAdapterthisEventHandlerInvokerinstantiates.sequencingPolicy(SequencingPolicy<? super EventMessage<?>> sequencingPolicy) Sets theSequencingPolicyin charge of deciding whether a given event should be handled (throughEventHandlerInvoker.handle(EventMessage, Segment)) by the givenSegment.protected voidvalidate()Validates whether the fields contained in this Builder are set accordingly.wrapEventMessageHandler(Object eventHandler) Wrap a giveneventHandlerin anAnnotationEventHandlerAdapterto allow thisEventHandlerInvokerto correctly passEventMessages to it.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
eventHandlers
Sets theeventHandlersthisEventHandlerInvokerwill forward all its events to. If an event handler is assignable toEventMessageHandlerit will register as is. If not, it will be wrapped by a newAnnotationEventHandlerAdapter.- Parameters:
eventHandlers- an array ofObjects which can handle events- Returns:
- the current Builder instance, for fluent interfacing
-
eventHandlers
Sets theeventHandlersthisEventHandlerInvokerwill forward all its events to. If an event handler is assignable toEventMessageHandlerit will register as is. If not, it will be wrapped by a newAnnotationEventHandlerAdapter. -
parameterResolverFactory
Sets theParameterResolverFactoryused to resolve parameter values for annotated handlers in theAnnotationEventHandlerAdapterthisEventHandlerInvokerinstantiates. This invoker will only instantiate a newEventMessageHandlerif a given Event Handler (througheventHandlers(Object...)oreventHandlers(List)) is not assignable to EventMessageHandler.- Parameters:
parameterResolverFactory- theParameterResolverFactoryused to resolve parameter values for instantiatedAnnotationEventHandlerAdapters- Returns:
- the current Builder instance, for fluent interfacing
-
handlerDefinition
Sets theHandlerDefinitionused to create concrete handlers in the annotated handlers in theAnnotationEventHandlerAdapterthisEventHandlerInvokerinstantiates. This invoker will only instantiate a newEventMessageHandlerif a given Event Handler (througheventHandlers(Object...)oreventHandlers(List)) is not assignable to EventMessageHandler.- Parameters:
handlerDefinition- theHandlerDefinitionused to create concrete handlers in the instantiatedAnnotationEventHandlerAdapters- Returns:
- the current Builder instance, for fluent interfacing
-
listenerInvocationErrorHandler
public B listenerInvocationErrorHandler(@Nonnull ListenerInvocationErrorHandler listenerInvocationErrorHandler) Sets theListenerInvocationErrorHandlerdealing withexceptionsthrown by the configuredevent handlers. Defaults to aLoggingErrorHandler.- Parameters:
listenerInvocationErrorHandler- The error handler dealing withexceptionsthrown by the configuredevent handlers- Returns:
- the current Builder instance, for fluent interfacing
-
sequencingPolicy
Sets theSequencingPolicyin charge of deciding whether a given event should be handled (throughEventHandlerInvoker.handle(EventMessage, Segment)) by the givenSegment. Used when thisEventHandlerInvokeris invoked for multiple Segments (i.e. using parallel processing). Defaults to aSequentialPerAggregatePolicy,- Parameters:
sequencingPolicy- aSequencingPolicyin charge of deciding whether a given event should be handled by the givenSegment- Returns:
- the current Builder instance, for fluent interfacing
-
build
Initializes aSimpleEventHandlerInvokeras specified through this Builder.- Returns:
- a
SimpleEventHandlerInvokeras specified through this Builder
-
wrapEventMessageHandler
Wrap a giveneventHandlerin anAnnotationEventHandlerAdapterto allow thisEventHandlerInvokerto correctly passEventMessages to it. If aParameterResolverFactoryor both a ParameterResolverFactory andHandlerDefinitionare present, one/both will be given to the AnnotationEventHandlerAdapter- Parameters:
eventHandler- anObjectwhich will be wrapped in anAnnotationEventHandlerAdapter- Returns:
- an
AnnotationEventHandlerAdapterwhich the giveneventHandlerwill be wrapped in
-
validate
Validates whether the fields contained in this Builder are set accordingly.- Throws:
AxonConfigurationException- if one field is asserted to be incorrect according to the Builder's specifications
-