java.lang.Object
org.axonframework.extensions.mongo.eventhandling.saga.repository.SagaEntry<T>
Type Parameters:
T - the type of saga stored in this entry

public class SagaEntry<T> extends Object
Java representation of sagas stored in a mongo instance
Since:
2.0
Author:
Jettro Coenradie
  • Constructor Details

    • SagaEntry

      public SagaEntry(String identifier, T saga, Set<AssociationValue> associationValues, Converter converter)
      Constructs a new SagaEntry for the given saga. The given saga must be convertible to a byte array. The provided saga is not modified by this operation.
      Parameters:
      identifier - The identifier of the saga
      saga - The saga to store
      associationValues - The associations of the saga
      converter - The conversion mechanism to convert the Saga to a byte stream
    • SagaEntry

      public SagaEntry(org.bson.Document dbSaga)
      Initializes a Saga entry using a Document containing the Mongo Document
      Parameters:
      dbSaga - The mongo Document containing the converted saga
  • Method Details

    • getSaga

      public T getSaga(Converter converter, Class<T> sagaType)
      Returns the Saga instance stored in this entry, converted into the given sagaType.

      Takes the target type because a Converter needs one, where the Serializer this replaces resolved it from the type name stored alongside the saga. That name is still written, so a reader outside this module can tell what a document holds, but conversion goes by what the caller asked for.

      Parameters:
      converter - The converter to convert the Saga with
      sagaType - The class to convert the stored saga into
      Returns:
      the Saga instance stored in this entry
    • getSagaId

      public String getSagaId()
      Get the identifier of this Saga.
      Returns:
      the saga identifier
    • getAssociationValues

      public Set<AssociationValue> getAssociationValues()
      Get a set of all the Saga's associations.
      Returns:
      association values of this Saga
    • asDocument

      public org.bson.Document asDocument()
      Returns the Mongo Document representing the Saga provided in this entry.
      Returns:
      the Mongo Document representing the Saga provided in this entry
    • queryByIdentifier

      public static org.bson.conversions.Bson queryByIdentifier(String identifier)
      Returns the Mongo Query to find a Saga based on its identifier.
      Parameters:
      identifier - The identifier of the saga to find
      Returns:
      the Query (as Bson) to find a Saga in a Mongo Database