Package org.axonframework.modelling.saga
Class SagaLifecycle
java.lang.Object
org.axonframework.messaging.Scope
org.axonframework.modelling.saga.SagaLifecycle
- Direct Known Subclasses:
AnnotatedSaga
Abstract base class of a component that models a saga's life cycle.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassociateWith(String associationKey, Number associationValue) Registers a AssociationValue with the currently active saga.static voidassociateWith(String associationKey, String associationValue) Registers a AssociationValue with the currently active saga.static voidassociateWith(AssociationValue associationValue) Registers a AssociationValue with the currently active saga.static Set<AssociationValue> Retrieves theAssociationValuesthat have been associated with the current Saga so far.Provide a description of thisScope.protected abstract voiddoAssociateWith(AssociationValue associationValue) SagaLifecycleinstance method to register the givenassociationValue.protected abstract voiddoEnd()SagaLifecycleinstance method to mark the current saga as ended.protected abstract voiddoRemoveAssociation(AssociationValue associationValue) SagaLifecycleinstance method to remove the givenassociationValue.static voidend()Marks the saga as ended.protected voidSagaLifecycleinstance method to execute giventaskin the context of this SagaLifeCycle.protected abstract AssociationValuesSagaLifecycleinstance method to retrieve theAssociationValuesof the currently active Saga.protected static SagaLifecycleGet the currentSagaLifecycleinstance for the current thread.protected abstract StringRetrieve aStringdenoting the identifier of this Saga.static voidremoveAssociationWith(String associationKey, Number associationValue) Removes the given association from the currently active Saga.static voidremoveAssociationWith(String associationKey, String associationValue) Removes the given association from the currently active Saga.protected abstract Stringtype()Retrieve aStringdenoting the type of this Saga.Methods inherited from class org.axonframework.messaging.Scope
describeCurrentScope, endScope, executeWithResult, getCurrentScope, startScope
-
Constructor Details
-
SagaLifecycle
public SagaLifecycle()
-
-
Method Details
-
associateWith
Registers a AssociationValue with the currently active saga. When the saga is committed, it can be found using the registered property. If the saga already has the given association, nothing happens.- Parameters:
associationKey- The key of the association value to associate this saga with.associationValue- The value of the association value to associate this saga with.
-
associateWith
Registers a AssociationValue with the currently active saga. When the saga is committed, it can be found using the registered property. The number value will be converted to a string. If the saga already has the given association, nothing happens.- Parameters:
associationKey- The key of the association value to associate this saga with.associationValue- The value of the association value to associate this saga with.
-
associateWith
Registers a AssociationValue with the currently active saga. When the saga is committed, it can be found using the registered property. If the saga already has the given association, nothing happens.- Parameters:
associationValue- The association to associate this saga with.
-
removeAssociationWith
Removes the given association from the currently active Saga. When the saga is committed, it can no longer be found using the given association value. If the given saga wasn't associated with given values, nothing happens.- Parameters:
associationKey- The key of the association value to remove from this saga.associationValue- The value of the association value to remove from this saga.
-
removeAssociationWith
Removes the given association from the currently active Saga. When the saga is committed, it can no longer be found using the given association value. If the given saga wasn't associated with given values, nothing happens. The number value will be converted to a string.- Parameters:
associationKey- The key of the association value to remove from this saga.associationValue- The value of the association value to remove from this saga.
-
end
public static void end()Marks the saga as ended. Ended saga's may be cleaned up by the repository when they are committed. -
associationValues
Retrieves theAssociationValuesthat have been associated with the current Saga so far. This includes the uncommitted ones, so adding or removing aAssociationValue} throughinvalid @link
{@link @linkassociateWith(AssociationValue)or any other method will have an immediate effect.- Returns:
- The
AssociationValuesthat have been associated with the Saga so far
-
doEnd
protected abstract void doEnd()SagaLifecycleinstance method to mark the current saga as ended. -
doRemoveAssociation
SagaLifecycleinstance method to remove the givenassociationValue. If the current saga is not associated with given value, this should do nothing.- Parameters:
associationValue- the association value to remove
-
doAssociateWith
SagaLifecycleinstance method to register the givenassociationValue. If the current saga is already associated with given value, this should do nothing.- Parameters:
associationValue- the association value to add
-
getAssociationValues
SagaLifecycleinstance method to retrieve theAssociationValuesof the currently active Saga.- Returns:
- The
AssociationValuesof the current saga.
-
getInstance
Get the currentSagaLifecycleinstance for the current thread. If none exists anIllegalStateExceptionis thrown.- Returns:
- the thread's current
SagaLifecycle
-
execute
SagaLifecycleinstance method to execute giventaskin the context of this SagaLifeCycle. This updates the thread's current saga lifecycle before executing the task. If a lifecycle is already registered with the current thread that one will be temporarily replaced with this lifecycle until the task completes.- Parameters:
task- the task to execute
-
type
Retrieve aStringdenoting the type of this Saga.- Returns:
- a
Stringdenoting the type of this Saga
-
getSagaIdentifier
Retrieve aStringdenoting the identifier of this Saga.- Returns:
- a
Stringdenoting the identifier of this Saga
-
describeScope
Description copied from class:ScopeProvide a description of thisScope.- Specified by:
describeScopein classScope- Returns:
- a
ScopeDescriptordescribing thisScope
-