Class AnnotatedSagaManager<T>

java.lang.Object
org.axonframework.modelling.saga.AbstractSagaManager<T>
org.axonframework.modelling.saga.AnnotatedSagaManager<T>
Type Parameters:
T - The type of Saga managed by this instance
All Implemented Interfaces:
org.axonframework.eventhandling.EventHandlerInvoker, org.axonframework.messaging.ScopeAware

public class AnnotatedSagaManager<T> extends AbstractSagaManager<T>
Implementation of the SagaManager that uses annotations on the Sagas to describe the lifecycle management. This implementation can manage several types of Saga in a single AnnotatedSagaManager.
Since:
0.7
Author:
Allard Buijze
  • Constructor Details

  • Method Details

    • builder

      public static <T> AnnotatedSagaManager.Builder<T> builder()
      Instantiate a Builder to be able to create a AnnotatedSagaManager.

      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 is defaulted to a DefaultSagaManagerSpanFactory backed by a NoOpSpanFactory.

      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.

      Type Parameters:
      T - a generic specifying the Saga type managed by this AbstractSagaManager implementation
      Returns:
      a Builder to be able to create a AnnotatedSagaManager
    • canHandle

      public boolean canHandle(@Nonnull org.axonframework.eventhandling.EventMessage<?> eventMessage, @Nonnull org.axonframework.eventhandling.Segment segment)
    • getSagaCreationPolicy

      protected SagaInitializationPolicy getSagaCreationPolicy(org.axonframework.eventhandling.EventMessage<?> event)
      Description copied from class: AbstractSagaManager
      Returns the Saga Initialization Policy for a Saga of the given sagaType and event. This policy provides the conditions to create new Saga instance, as well as the initial association of that saga.
      Specified by:
      getSagaCreationPolicy in class AbstractSagaManager<T>
      Parameters:
      event - The Event that is being dispatched to Saga instances
      Returns:
      the initialization policy for the Saga
    • extractAssociationValues

      protected Set<AssociationValue> extractAssociationValues(org.axonframework.eventhandling.EventMessage<?> event)
      Description copied from class: AbstractSagaManager
      Extracts the AssociationValues from the given event as relevant for a Saga of given sagaType. A single event may be associated with multiple values.
      Specified by:
      extractAssociationValues in class AbstractSagaManager<T>
      Parameters:
      event - The event containing the association information
      Returns:
      the AssociationValues indicating which Sagas should handle given event