Class AbstractSagaManager.Builder<T>

java.lang.Object
org.axonframework.modelling.saga.AbstractSagaManager.Builder<T>
Type Parameters:
T - a generic specifying the Saga type managed by this implementation
Direct Known Subclasses:
AnnotatedSagaManager.Builder
Enclosing class:
AbstractSagaManager<T>

public abstract static class AbstractSagaManager.Builder<T> extends Object
Abstract Builder class to instantiate AbstractSagaManager implementations.

The sagaFactory is defaulted to a sagaType.newInstance() call throwing a SagaInstantiationException if it fails, the ListenerInvocationErrorHandler is defaulted to a LoggingErrorHandler and the SagaManagerSpanFactory defaults to a DefaultSagaManagerSpanFactory backed by a NoOpSpanFactory. The SagaRepository and sagaType are hard requirements and as such should be provided.

  • Field Details

    • sagaType

      protected Class<T> sagaType
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • sagaRepository

      public AbstractSagaManager.Builder<T> sagaRepository(SagaRepository<T> sagaRepository)
      Sets the SagaRepository of generic type T used to save and load Saga instances.
      Parameters:
      sagaRepository - a SagaRepository of generic type T used to save and load Saga instances
      Returns:
      the current Builder instance, for fluent interfacing
    • sagaType

      public AbstractSagaManager.Builder<T> sagaType(Class<T> sagaType)
      Sets the sagaType as a Class managed by this instance.
      Parameters:
      sagaType - the Class specifying the type of Saga managed by this instance
      Returns:
      the current Builder instance, for fluent interfacing
    • sagaFactory

      public AbstractSagaManager.Builder<T> sagaFactory(Supplier<T> sagaFactory)
      Sets the sagaFactory of type Supplier responsible for creating new Saga instances. Defaults to a sagaType.newInstance() call throwing a SagaInstantiationException if it fails.
      Parameters:
      sagaFactory - a Supplier of Saga type T responsible for creating new Saga instances
      Returns:
      the current Builder instance, for fluent interfacing
    • listenerInvocationErrorHandler

      public AbstractSagaManager.Builder<T> listenerInvocationErrorHandler(org.axonframework.eventhandling.ListenerInvocationErrorHandler listenerInvocationErrorHandler)
      Sets the ListenerInvocationErrorHandler invoked when an error occurs. Defaults to a LoggingErrorHandler.
      Parameters:
      listenerInvocationErrorHandler - a ListenerInvocationErrorHandler invoked when an error occurs
      Returns:
      the current Builder instance, for fluent interfacing
    • spanFactory

      @Deprecated public AbstractSagaManager.Builder<T> spanFactory(org.axonframework.tracing.SpanFactory spanFactory)
      Sets the SpanFactory implementation to use for providing tracing capabilities. Defaults to a NoOpSpanFactory, which provides no tracing capabilities.
      Parameters:
      spanFactory - The SpanFactory implementation
      Returns:
      The current Builder instance, for fluent interfacing.
    • spanFactory

      public AbstractSagaManager.Builder<T> spanFactory(SagaManagerSpanFactory spanFactory)
      Sets the SagaManagerSpanFactory implementation to use for providing tracing capabilities. Defaults to a DefaultSagaManagerSpanFactory backed by a NoOpSpanFactory by default, which provides no tracing capabilities.
      Parameters:
      spanFactory - The SagaManagerSpanFactory implementation
      Returns:
      The current Builder instance, for fluent interfacing.
    • validate

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