Package org.axonframework.modelling.saga
Class AnnotatedSagaManager.Builder<T>
java.lang.Object
org.axonframework.modelling.saga.AbstractSagaManager.Builder<T>
org.axonframework.modelling.saga.AnnotatedSagaManager.Builder<T>
- Type Parameters:
T- a generic specifying the Saga type managed by thisAbstractSagaManagerimplementation
- Enclosing class:
AnnotatedSagaManager<T>
Builder class to instantiate a
AnnotatedSagaManager.
The sagaFactory is defaulted to a sagaType.newInstance() call throwing a
SagaInstantiationException if it fails, the SpanFactory defaults to a
NoOpSpanFactory, and the ListenerInvocationErrorHandler is defaulted to
a LoggingErrorHandler.
This Builder either allows directly setting a SagaModel of generic type T, or it will generate
one based of the required sagaType field of type Class. Thus, either the SagaModel or the
sagaType should be provided. All Sagas managed by this instances must be instanceOf this saga
type. Additionally, the SagaRepository and sagaType are hard requirements and as such
should be provided.
-
Field Summary
Fields inherited from class org.axonframework.modelling.saga.AbstractSagaManager.Builder
sagaType -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Initializes aAnnotatedSagaManageras specified through this Builder.Instantiate theSagaModelof generic typeTdescribing the structure of the Saga thisAbstractSagaManagerimplementation will manage.handlerDefinition(HandlerDefinition handlerDefinition) Sets theHandlerDefinitionused to create concrete handlers for the givensagaType.listenerInvocationErrorHandler(ListenerInvocationErrorHandler listenerInvocationErrorHandler) Sets theListenerInvocationErrorHandlerinvoked when an error occurs.parameterResolverFactory(ParameterResolverFactory parameterResolverFactory) Sets theParameterResolverFactoryused to resolve parameters for annotated handlers for the givensagaType.sagaFactory(Supplier<T> sagaFactory) Sets thesagaFactoryof typeSupplierresponsible for creating new Saga instances.Sets theSagaModelof generic typeT, describing the structure of the Saga thisAbstractSagaManagerimplementation will manage.sagaRepository(SagaRepository<T> sagaRepository) Sets theSagaRepositoryof generic typeTused to save and load Saga instances.Sets thesagaTypeas aClassmanaged by this instance.spanFactory(SagaManagerSpanFactory spanFactory) Sets theSagaManagerSpanFactoryimplementation to use for providing tracing capabilities.spanFactory(SpanFactory spanFactory) Deprecated.Methods inherited from class org.axonframework.modelling.saga.AbstractSagaManager.Builder
validate
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
sagaRepository
Description copied from class:AbstractSagaManager.BuilderSets theSagaRepositoryof generic typeTused to save and load Saga instances.- Overrides:
sagaRepositoryin classAbstractSagaManager.Builder<T>- Parameters:
sagaRepository- aSagaRepositoryof generic typeTused to save and load Saga instances- Returns:
- the current Builder instance, for fluent interfacing
-
sagaType
Description copied from class:AbstractSagaManager.BuilderSets thesagaTypeas aClassmanaged by this instance.- Overrides:
sagaTypein classAbstractSagaManager.Builder<T>- Parameters:
sagaType- theClassspecifying the type of Saga managed by this instance- Returns:
- the current Builder instance, for fluent interfacing
-
sagaFactory
Description copied from class:AbstractSagaManager.BuilderSets thesagaFactoryof typeSupplierresponsible for creating new Saga instances. Defaults to asagaType.newInstance()call throwing aSagaInstantiationExceptionif it fails.- Overrides:
sagaFactoryin classAbstractSagaManager.Builder<T>- Parameters:
sagaFactory- aSupplierof Saga typeTresponsible for creating new Saga instances- Returns:
- the current Builder instance, for fluent interfacing
-
listenerInvocationErrorHandler
public AnnotatedSagaManager.Builder<T> listenerInvocationErrorHandler(ListenerInvocationErrorHandler listenerInvocationErrorHandler) Description copied from class:AbstractSagaManager.BuilderSets theListenerInvocationErrorHandlerinvoked when an error occurs. Defaults to aLoggingErrorHandler.- Overrides:
listenerInvocationErrorHandlerin classAbstractSagaManager.Builder<T>- Parameters:
listenerInvocationErrorHandler- aListenerInvocationErrorHandlerinvoked when an error occurs- Returns:
- the current Builder instance, for fluent interfacing
-
spanFactory
Deprecated.Description copied from class:AbstractSagaManager.BuilderSets theSpanFactoryimplementation to use for providing tracing capabilities. Defaults to aNoOpSpanFactory, which provides no tracing capabilities.- Overrides:
spanFactoryin classAbstractSagaManager.Builder<T>- Parameters:
spanFactory- TheSpanFactoryimplementation- Returns:
- The current Builder instance, for fluent interfacing.
-
spanFactory
Description copied from class:AbstractSagaManager.BuilderSets theSagaManagerSpanFactoryimplementation to use for providing tracing capabilities. Defaults to aDefaultSagaManagerSpanFactorybacked by aNoOpSpanFactoryby default, which provides no tracing capabilities.- Overrides:
spanFactoryin classAbstractSagaManager.Builder<T>- Parameters:
spanFactory- TheSagaManagerSpanFactoryimplementation- Returns:
- The current Builder instance, for fluent interfacing.
-
parameterResolverFactory
public AnnotatedSagaManager.Builder<T> parameterResolverFactory(ParameterResolverFactory parameterResolverFactory) Sets theParameterResolverFactoryused to resolve parameters for annotated handlers for the givensagaType. Only used to instantiate aSagaModelif no SagaModel has been provided directly.- Parameters:
parameterResolverFactory- aParameterResolverFactoryused to resolve parameters for annotated handlers contained in the Aggregate- Returns:
- the current Builder instance, for fluent interfacing
-
handlerDefinition
Sets theHandlerDefinitionused to create concrete handlers for the givensagaType. Only used to instantiate aSagaModelif no SagaModel has been provided directly.- Parameters:
handlerDefinition- aHandlerDefinitionused to create concrete handlers for the givensagaType.- Returns:
- the current Builder instance, for fluent interfacing
-
sagaModel
Sets theSagaModelof generic typeT, describing the structure of the Saga thisAbstractSagaManagerimplementation will manage. If this is not provided directly, thesagaTypewill be used to instantiate a SagaModel.- Parameters:
sagaModel- theSagaModelof generic typeTof the Saga thisAbstractSagaManagerimplementation will manage- Returns:
- the current Builder instance, for fluent interfacing
-
build
Initializes aAnnotatedSagaManageras specified through this Builder.- Returns:
- a
AnnotatedSagaManageras specified through this Builder
-
buildSagaModel
Instantiate theSagaModelof generic typeTdescribing the structure of the Saga thisAbstractSagaManagerimplementation will manage.- Returns:
- a
SagaModelof generic typeTdescribing the Saga thisAbstractSagaManagerimplementation will manage
-