Class AnnotatedSagaRepository.Builder<T>
java.lang.Object
org.axonframework.modelling.saga.repository.LockingSagaRepository.Builder<T>
org.axonframework.modelling.saga.repository.AnnotatedSagaRepository.Builder<T>
- Type Parameters:
T- a generic specifying the Saga type contained in thisSagaRepositoryimplementation
- Enclosing class:
AnnotatedSagaRepository<T>
Builder class to instantiate a
AnnotatedSagaRepository.
The ResourceInjector is defaulted to a NoResourceInjector. 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 in this repository must be instanceOf this saga type. Additionally, the
sagaType and SagaStore are hard requirements and as such should be provided.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Initializes aAnnotatedSagaRepositoryas specified through this Builder.protected MessageHandlerInterceptorMemberChain<T> Instantiate theMessageHandlerInterceptorMemberChainof generic typeTas the Saga type to be stored.Instantiate theSagaModelof generic typeTdescribing the structure of the Saga thisSagaRepositorywill store.handlerDefinition(HandlerDefinition handlerDefinition) Sets theHandlerDefinitionused to create concrete handlers for the givensagaType.interceptorMemberChain(MessageHandlerInterceptorMemberChain<T> interceptorMemberChain) Sets theMessageHandlerInterceptorMemberChainof generic typeT, describing the structure of the Saga thisSagaRepositoryimplementation will store.lockFactory(LockFactory lockFactory) Sets theLockFactoryused to lock a saga.parameterResolverFactory(ParameterResolverFactory parameterResolverFactory) Sets theParameterResolverFactoryused to resolve parameters for annotated handlers for the givensagaType.resourceInjector(ResourceInjector resourceInjector) Sets theResourceInjectorused to initializeSagainstances after a target instance is created or loaded from the store.Sets theSagaModelof generic typeT, describing the structure of the Saga thisSagaRepositoryimplementation will store.Sets theSagaStoreused to save and load saga instances.protected voidvalidate()Validates whether the fields contained in this Builder are set accordingly.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
lockFactory
Description copied from class:LockingSagaRepository.BuilderSets theLockFactoryused to lock a saga. Defaults to a pessimistic locking strategy, implemented in thePessimisticLockFactory.- Overrides:
lockFactoryin classLockingSagaRepository.Builder<T>- Parameters:
lockFactory- aLockFactoryused to lock an aggregate- Returns:
- the current Builder instance, for fluent interfacing
-
sagaType
Sets thesagaTypeas aClass, specifying the type of Saga thisSagaRepositorywill store. If noSagaModelis specified directly, a model will be derived from this type.- Parameters:
sagaType- theClassspecifying the type of Saga thisSagaRepositorywill store- Returns:
- the current Builder instance, for fluent interfacing
-
parameterResolverFactory
public AnnotatedSagaRepository.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 for the givensagaType- 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 thisSagaRepositoryimplementation will store. If this is not provided directly, thesagaTypewill be used to instantiate a SagaModel.- Parameters:
sagaModel- theSagaModelof generic typeTof the Saga thisSagaRepositoryimplementation will store- Returns:
- the current Builder instance, for fluent interfacing
-
sagaStore
Sets theSagaStoreused to save and load saga instances.- Parameters:
sagaStore- theSagaStoreused to save and load saga instances- Returns:
- the current Builder instance, for fluent interfacing
-
resourceInjector
Sets theResourceInjectorused to initializeSagainstances after a target instance is created or loaded from the store. Defaults to aNoResourceInjector.- Parameters:
resourceInjector- aResourceInjectorused to initializeSagainstances after a target instance is created or loaded from the store- Returns:
- the current Builder instance, for fluent interfacing
-
interceptorMemberChain
public AnnotatedSagaRepository.Builder<T> interceptorMemberChain(MessageHandlerInterceptorMemberChain<T> interceptorMemberChain) Sets theMessageHandlerInterceptorMemberChainof generic typeT, describing the structure of the Saga thisSagaRepositoryimplementation will store. To be used in handling the event messages.- Parameters:
interceptorMemberChain- theMessageHandlerInterceptorMemberChainof generic typeTof the Saga thisSagaRepositoryimplementation will store- Returns:
- the current Builder instance, for fluent interfacing
-
build
Initializes aAnnotatedSagaRepositoryas specified through this Builder.- Returns:
- a
AnnotatedSagaRepositoryas specified through this Builder
-
buildSagaModel
Instantiate theSagaModelof generic typeTdescribing the structure of the Saga thisSagaRepositorywill store.- Returns:
- a
SagaModelof generic typeTdescribing the Saga thisSagaRepositoryimplementation will store
-
buildChainedInterceptor
Instantiate theMessageHandlerInterceptorMemberChainof generic typeTas the Saga type to be stored. To be used in handling the event messages.- Returns:
- a
MessageHandlerInterceptorMemberChainof generic typeT. To be used in handling the event messages.
-
validate
Validates whether the fields contained in this Builder are set accordingly.- Overrides:
validatein classLockingSagaRepository.Builder<T>- Throws:
AxonConfigurationException- if one field is asserted to be incorrect according to the Builder's specifications
-