public abstract class SagaLifecycle extends Scope
Constructor and Description |
---|
SagaLifecycle() |
Modifier and Type | Method and Description |
---|---|
static void |
associateWith(AssociationValue associationValue)
Registers a AssociationValue with the currently active saga.
|
static void |
associateWith(String associationKey,
Number associationValue)
Registers a AssociationValue with the currently active saga.
|
static void |
associateWith(String associationKey,
String associationValue)
Registers a AssociationValue with the currently active saga.
|
static Set<AssociationValue> |
associationValues()
Retrieves the
AssociationValues that have been associated with the current Saga so far. |
ScopeDescriptor |
describeScope()
Provide a description of this
Scope . |
protected abstract void |
doAssociateWith(AssociationValue associationValue)
SagaLifecycle instance method to register the given associationValue . |
protected abstract void |
doEnd()
SagaLifecycle instance method to mark the current saga as ended. |
protected abstract void |
doRemoveAssociation(AssociationValue associationValue)
SagaLifecycle instance method to remove the given associationValue . |
static void |
end()
Marks the saga as ended.
|
protected void |
execute(Runnable task)
SagaLifecycle instance method to execute given task in the context of this SagaLifeCycle. |
protected abstract AssociationValues |
getAssociationValues()
SagaLifecycle instance method to retrieve the AssociationValues of the currently active Saga. |
protected static SagaLifecycle |
getInstance()
Get the current
SagaLifecycle instance for the current thread. |
protected abstract String |
getSagaIdentifier()
Retrieve a
String denoting the identifier of this Saga. |
static void |
removeAssociationWith(String associationKey,
Number associationValue)
Removes the given association from the currently active Saga.
|
static void |
removeAssociationWith(String associationKey,
String associationValue)
Removes the given association from the currently active Saga.
|
protected abstract String |
type()
Retrieve a
String denoting the type of this Saga. |
describeCurrentScope, endScope, executeWithResult, getCurrentScope, startScope
public static void associateWith(String associationKey, String associationValue)
associationKey
- The key of the association value to associate this saga with.associationValue
- The value of the association value to associate this saga with.public static void associateWith(String associationKey, Number associationValue)
associationKey
- The key of the association value to associate this saga with.associationValue
- The value of the association value to associate this saga with.public static void associateWith(AssociationValue associationValue)
associationValue
- The association to associate this saga with.public static void removeAssociationWith(String associationKey, String associationValue)
associationKey
- The key of the association value to remove from this saga.associationValue
- The value of the association value to remove from this saga.public static void removeAssociationWith(String associationKey, Number associationValue)
associationKey
- The key of the association value to remove from this saga.associationValue
- The value of the association value to remove from this saga.public static void end()
public static Set<AssociationValue> associationValues()
AssociationValues
that have been associated with the current Saga so far.
This includes the uncommitted ones, so adding or removing a AssociationValue
through
associateWith(AssociationValue)
or any other method will have an immediate effect.AssociationValues
that have been associated with the Saga so farprotected abstract void doEnd()
SagaLifecycle
instance method to mark the current saga as ended.protected abstract void doRemoveAssociation(AssociationValue associationValue)
SagaLifecycle
instance method to remove the given associationValue
. If the current saga is not
associated with given value, this should do nothing.associationValue
- the association value to removeprotected abstract void doAssociateWith(AssociationValue associationValue)
SagaLifecycle
instance method to register the given associationValue
. If the current saga is
already associated with given value, this should do nothing.associationValue
- the association value to addprotected abstract AssociationValues getAssociationValues()
SagaLifecycle
instance method to retrieve the AssociationValues
of the currently active Saga.AssociationValues
of the current saga.protected static SagaLifecycle getInstance()
SagaLifecycle
instance for the current thread. If none exists an IllegalStateException
is thrown.SagaLifecycle
protected void execute(Runnable task)
SagaLifecycle
instance method to execute given task
in 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.task
- the task to executeprotected abstract String type()
String
denoting the type of this Saga.String
denoting the type of this Sagaprotected abstract String getSagaIdentifier()
String
denoting the identifier of this Saga.String
denoting the identifier of this Sagapublic ScopeDescriptor describeScope()
Scope
Scope
.describeScope
in class Scope
ScopeDescriptor
describing this Scope
Copyright © 2010–2024. All rights reserved.