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 this SagaRepository implementation
Enclosing class:
AnnotatedSagaRepository<T>

public static class AnnotatedSagaRepository.Builder<T> extends LockingSagaRepository.Builder<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 Details

    • Builder

      public Builder()
  • Method Details

    • lockFactory

      public AnnotatedSagaRepository.Builder<T> lockFactory(org.axonframework.common.lock.LockFactory lockFactory)
      Description copied from class: LockingSagaRepository.Builder
      Sets the LockFactory used to lock a saga. Defaults to a pessimistic locking strategy, implemented in the PessimisticLockFactory.
      Overrides:
      lockFactory in class LockingSagaRepository.Builder<T>
      Parameters:
      lockFactory - a LockFactory used to lock an aggregate
      Returns:
      the current Builder instance, for fluent interfacing
    • sagaType

      public AnnotatedSagaRepository.Builder<T> sagaType(Class<T> sagaType)
      Sets the sagaType as a Class, specifying the type of Saga this SagaRepository will store. If no SagaModel is specified directly, a model will be derived from this type.
      Parameters:
      sagaType - the Class specifying the type of Saga this SagaRepository will store
      Returns:
      the current Builder instance, for fluent interfacing
    • parameterResolverFactory

      public AnnotatedSagaRepository.Builder<T> parameterResolverFactory(org.axonframework.messaging.annotation.ParameterResolverFactory parameterResolverFactory)
      Sets the ParameterResolverFactory used to resolve parameters for annotated handlers for the given sagaType. Only used to instantiate a SagaModel if no SagaModel has been provided directly.
      Parameters:
      parameterResolverFactory - a ParameterResolverFactory used to resolve parameters for annotated handlers for the given sagaType
      Returns:
      the current Builder instance, for fluent interfacing
    • handlerDefinition

      public AnnotatedSagaRepository.Builder<T> handlerDefinition(org.axonframework.messaging.annotation.HandlerDefinition handlerDefinition)
      Sets the HandlerDefinition used to create concrete handlers for the given sagaType. Only used to instantiate a SagaModel if no SagaModel has been provided directly.
      Parameters:
      handlerDefinition - a HandlerDefinition used to create concrete handlers for the given sagaType.
      Returns:
      the current Builder instance, for fluent interfacing
    • sagaModel

      public AnnotatedSagaRepository.Builder<T> sagaModel(SagaModel<T> sagaModel)
      Sets the SagaModel of generic type T, describing the structure of the Saga this SagaRepository implementation will store. If this is not provided directly, the sagaType will be used to instantiate a SagaModel.
      Parameters:
      sagaModel - the SagaModel of generic type T of the Saga this SagaRepository implementation will store
      Returns:
      the current Builder instance, for fluent interfacing
    • sagaStore

      public AnnotatedSagaRepository.Builder<T> sagaStore(SagaStore<? super T> sagaStore)
      Sets the SagaStore used to save and load saga instances.
      Parameters:
      sagaStore - the SagaStore used to save and load saga instances
      Returns:
      the current Builder instance, for fluent interfacing
    • resourceInjector

      public AnnotatedSagaRepository.Builder<T> resourceInjector(ResourceInjector resourceInjector)
      Sets the ResourceInjector used to initialize Saga instances after a target instance is created or loaded from the store. Defaults to a NoResourceInjector.
      Parameters:
      resourceInjector - a ResourceInjector used to initialize Saga instances 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(org.axonframework.messaging.annotation.MessageHandlerInterceptorMemberChain<T> interceptorMemberChain)
      Sets the MessageHandlerInterceptorMemberChain of generic type T, describing the structure of the Saga this SagaRepository implementation will store. To be used in handling the event messages.
      Parameters:
      interceptorMemberChain - the MessageHandlerInterceptorMemberChain of generic type T of the Saga this SagaRepository implementation will store
      Returns:
      the current Builder instance, for fluent interfacing
    • build

      public AnnotatedSagaRepository<T> build()
      Initializes a AnnotatedSagaRepository as specified through this Builder.
      Returns:
      a AnnotatedSagaRepository as specified through this Builder
    • buildSagaModel

      protected SagaModel<T> buildSagaModel()
      Instantiate the SagaModel of generic type T describing the structure of the Saga this SagaRepository will store.
      Returns:
      a SagaModel of generic type T describing the Saga this SagaRepository implementation will store
    • buildChainedInterceptor

      protected org.axonframework.messaging.annotation.MessageHandlerInterceptorMemberChain<T> buildChainedInterceptor()
      Instantiate the MessageHandlerInterceptorMemberChain of generic type T as the Saga type to be stored. To be used in handling the event messages.
      Returns:
      a MessageHandlerInterceptorMemberChain of generic type T. To be used in handling the event messages.
    • validate

      protected void validate() throws org.axonframework.common.AxonConfigurationException
      Validates whether the fields contained in this Builder are set accordingly.
      Overrides:
      validate in class LockingSagaRepository.Builder<T>
      Throws:
      org.axonframework.common.AxonConfigurationException - if one field is asserted to be incorrect according to the Builder's specifications