public abstract class SagaLifecycle extends Object
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.
|
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 <V> V |
executeWithResult(Callable<V> task)
SagaLifecycle instance method to execute given task in the context of this SagaLifeCycle. |
protected static SagaLifecycle |
getInstance()
Get the current
SagaLifecycle instance for the current thread. |
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.
|
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()
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
. 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 static SagaLifecycle getInstance()
SagaLifecycle
instance for the current thread. If none exists an IllegalStateException
is thrown.SagaLifecycle
protected <V> V executeWithResult(Callable<V> task) throws Exception
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. This
method returns the execution result of the task.V
- the type of execution result of the tasktask
- the task to executeException
- if executing the task results in an exceptionprotected 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 executeCopyright © 2010–2017. All rights reserved.