Class AbstractSagaManager<T>

java.lang.Object
org.axonframework.modelling.saga.AbstractSagaManager<T>
All Implemented Interfaces:
org.axonframework.eventhandling.EventHandlerInvoker, org.axonframework.messaging.ScopeAware
Direct Known Subclasses:
AnnotatedSagaManager

public abstract class AbstractSagaManager<T> extends Object implements org.axonframework.eventhandling.EventHandlerInvoker, org.axonframework.messaging.ScopeAware
Abstract implementation of the SagaManager interface that provides basic functionality required by most SagaManager implementations. Provides support for Saga lifecycle management and asynchronous handling of events.
Since:
0.7
Author:
Allard Buijze
  • Constructor Details

  • Method Details

    • handle

      public void handle(@Nonnull org.axonframework.eventhandling.EventMessage<?> event, @Nonnull org.axonframework.eventhandling.Segment segment) throws Exception
      Specified by:
      handle in interface org.axonframework.eventhandling.EventHandlerInvoker
      Throws:
      Exception
    • createSagaIdentifier

      protected String createSagaIdentifier(org.axonframework.eventhandling.Segment segment)
      Creates a Saga identifier that will cause a Saga instance to be considered part of the given segment.
      Parameters:
      segment - The segment the identifier must match with
      Returns:
      an identifier for a newly created Saga
      Implementation Requirements:
      This implementation will repeatedly generate identifier using the IdentifierFactory, until one is returned that matches the given segment. See matchesSegment(Segment, String).
    • matchesSegment

      protected boolean matchesSegment(org.axonframework.eventhandling.Segment segment, String sagaId)
      Checks whether the given sagaId matches with the given segment.

      For any complete set of segments, exactly one segment matches with any value.

      Parameters:
      segment - The segment to validate the identifier for
      sagaId - The identifier to test
      Returns:
      true if the identifier matches the segment, otherwise false
      Implementation Requirements:
      This implementation uses the Segment.matches(Object) to match against the Saga identifier
    • getSagaCreationPolicy

      protected abstract SagaInitializationPolicy getSagaCreationPolicy(org.axonframework.eventhandling.EventMessage<?> event)
      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.
      Parameters:
      event - The Event that is being dispatched to Saga instances
      Returns:
      the initialization policy for the Saga
    • extractAssociationValues

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

      public Class<T> getSagaType()
      Returns the class of Saga managed by this SagaManager
      Returns:
      the managed saga type
    • supportsReset

      public boolean supportsReset()
      Specified by:
      supportsReset in interface org.axonframework.eventhandling.EventHandlerInvoker
    • performReset

      public void performReset()
      Specified by:
      performReset in interface org.axonframework.eventhandling.EventHandlerInvoker
    • performReset

      public void performReset(Object resetContext)
      Specified by:
      performReset in interface org.axonframework.eventhandling.EventHandlerInvoker
    • send

      public void send(org.axonframework.messaging.Message<?> message, org.axonframework.messaging.ScopeDescriptor scopeDescription) throws Exception
      Specified by:
      send in interface org.axonframework.messaging.ScopeAware
      Throws:
      Exception
    • canResolve

      public boolean canResolve(org.axonframework.messaging.ScopeDescriptor scopeDescription)
      Specified by:
      canResolve in interface org.axonframework.messaging.ScopeAware