public abstract class AbstractFlowExecutionRepository extends java.lang.Object implements FlowExecutionRepository, FlowExecutionKeyFactory
FlowExecutionStateRestorer
, used to
rehydrate a flow execution after it has been obtained from storage from resume.
The configured FlowExecutionStateRestorer
should be compatible with the chosen FlowExecution
implementation and its FlowExecutionFactory
.
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger
Logger, usable in subclasses
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractFlowExecutionRepository(ConversationManager conversationManager)
Constructor for use in subclasses.
|
Modifier and Type | Method and Description |
---|---|
protected void |
assertKeySet(FlowExecution execution)
Assert that a flow execution key has been assigned to the execution.
|
protected ConversationParameters |
createConversationParameters(FlowExecution flowExecution)
Factory method that maps a new flow execution to a descriptive
conversation
parameters object. |
boolean |
getAlwaysGenerateNewNextKey()
The flag indicating if a new
FlowExecutionKey should always be generated before each put call. |
protected Conversation |
getConversation(FlowExecutionKey key)
Returns the conversation governing the
FlowExecution with the provided key. |
protected Conversation |
getConversation(java.io.Serializable executionId)
Returns the conversation governing the logical flow execution with the given execution id.
|
ConversationManager |
getConversationManager()
The conversation service to delegate to for managing conversations initiated by this repository.
|
abstract FlowExecution |
getFlowExecution(FlowExecutionKey key)
Return the
FlowExecution indexed by the provided key. |
FlowExecutionKey |
getKey(FlowExecution execution)
Get the key to assign to the flow execution.
|
FlowExecutionLock |
getLock(FlowExecutionKey key)
Return the lock for the flow execution, allowing for the lock to be acquired or released.
|
protected abstract java.io.Serializable |
nextSnapshotId(java.io.Serializable executionId)
The next snapshot id to use for a
FlowExecution instance. |
FlowExecutionKey |
parseFlowExecutionKey(java.lang.String encodedKey)
Parse the string-encoded flow execution key into its object form.
|
abstract void |
putFlowExecution(FlowExecution flowExecution)
Place the
FlowExecution in this repository under the provided key. |
void |
removeFlowExecution(FlowExecution flowExecution)
Remove the flow execution from the repository.
|
void |
setAlwaysGenerateNewNextKey(boolean alwaysGenerateNewNextKey)
Sets the flag indicating if a new
FlowExecutionKey should always be generated before each put call. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
removeAllFlowExecutionSnapshots, removeFlowExecutionSnapshot, updateFlowExecutionSnapshot
protected final org.apache.commons.logging.Log logger
protected AbstractFlowExecutionRepository(ConversationManager conversationManager)
conversationManager
- the conversation manager to usepublic ConversationManager getConversationManager()
public boolean getAlwaysGenerateNewNextKey()
FlowExecutionKey
should always be generated before each put call.public void setAlwaysGenerateNewNextKey(boolean alwaysGenerateNewNextKey)
FlowExecutionKey
should always be generated before each put call. By
setting this to false a FlowExecution can remain identified by the same key throughout its life.public FlowExecutionKey getKey(FlowExecution execution)
FlowExecutionKeyFactory
getKey
in interface FlowExecutionKeyFactory
execution
- the flow executionpublic FlowExecutionKey parseFlowExecutionKey(java.lang.String encodedKey) throws FlowExecutionRepositoryException
FlowExecutionRepository
FlowExecutionKey.toString()
.parseFlowExecutionKey
in interface FlowExecutionRepository
encodedKey
- the string encoded keyFlowExecutionRepositoryException
public FlowExecutionLock getLock(FlowExecutionKey key) throws FlowExecutionRepositoryException
FlowExecutionRepository
FlowExecutionLock lock = repository.getLock(key); lock.lock(); try { FlowExecution execution = repository.getFlowExecution(key); // do work } finally { lock.unlock(); }
getLock
in interface FlowExecutionRepository
key
- the identifier of the flow execution to lockFlowExecutionRepositoryException
- a problem occurred accessing the lock objectpublic void removeFlowExecution(FlowExecution flowExecution) throws FlowExecutionRepositoryException
FlowExecutionRepository
removeFlowExecution
in interface FlowExecutionRepository
flowExecution
- the flow executionFlowExecutionRepositoryException
- the flow execution could not be removed.protected abstract java.io.Serializable nextSnapshotId(java.io.Serializable executionId)
FlowExecution
instance. Called when getting a flow execution key
.public abstract FlowExecution getFlowExecution(FlowExecutionKey key) throws FlowExecutionRepositoryException
FlowExecutionRepository
FlowExecution
indexed by the provided key. The returned flow execution represents the
restored state of an executing flow from a point in time. This should be called to resume a persistent flow
execution. Before calling this method, you should acquire the lock for the keyed flow execution.getFlowExecution
in interface FlowExecutionRepository
key
- the flow execution keyFlowExecutionRepositoryException
- if no flow execution was indexed with the key providedpublic abstract void putFlowExecution(FlowExecution flowExecution) throws FlowExecutionRepositoryException
FlowExecutionRepository
FlowExecution
in this repository under the provided key. This should be called to save or
update the persistent state of an active (but paused) flow execution. Before calling this method, you should
acquire the lock for the keyed flow execution.putFlowExecution
in interface FlowExecutionRepository
flowExecution
- the flow executionFlowExecutionRepositoryException
- the flow execution could not be storedprotected ConversationParameters createConversationParameters(FlowExecution flowExecution)
conversation
parameters
object.flowExecution
- the new flow executionprotected Conversation getConversation(FlowExecutionKey key) throws NoSuchFlowExecutionException
FlowExecution
with the provided key.key
- the flow execution keyNoSuchFlowExecutionException
- when the conversation for identified flow execution cannot be foundprotected Conversation getConversation(java.io.Serializable executionId) throws NoSuchConversationException
executionId
- the flow execution idNoSuchConversationException
- when the conversation for identified flow execution cannot be foundprotected void assertKeySet(FlowExecution execution) throws java.lang.IllegalStateException
execution
- the flow executionjava.lang.IllegalStateException
- if a key has not yet been assigned as expected