Class AbstractFlowExecutionRepository
java.lang.Object
org.springframework.webflow.execution.repository.support.AbstractFlowExecutionRepository
- All Implemented Interfaces:
FlowExecutionKeyFactory
,FlowExecutionRepository
- Direct Known Subclasses:
AbstractSnapshottingFlowExecutionRepository
public abstract class AbstractFlowExecutionRepository
extends Object
implements FlowExecutionRepository, FlowExecutionKeyFactory
Abstract base class for flow execution repository implementations. Does not make any assumptions about the storage
medium used to store active flow executions. Mandates the use of a
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
.
- Author:
- Keith Donald, Erwin Vervaet
-
Field Summary
Modifier and TypeFieldDescriptionprotected final org.apache.commons.logging.Log
Logger, usable in subclasses -
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractFlowExecutionRepository
(ConversationManager conversationManager) Constructor for use in subclasses. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 descriptiveconversation parameters
object.boolean
The flag indicating if a newFlowExecutionKey
should always be generated before each put call.protected Conversation
getConversation
(Serializable executionId) Returns the conversation governing the logical flow execution with the given execution id.protected Conversation
Returns the conversation governing theFlowExecution
with the provided key.The conversation service to delegate to for managing conversations initiated by this repository.abstract FlowExecution
Return theFlowExecution
indexed by the provided key.getKey
(FlowExecution execution) Get the key to assign to the flow execution.getLock
(FlowExecutionKey key) Return the lock for the flow execution, allowing for the lock to be acquired or released.protected abstract Serializable
nextSnapshotId
(Serializable executionId) The next snapshot id to use for aFlowExecution
instance.parseFlowExecutionKey
(String encodedKey) Parse the string-encoded flow execution key into its object form.abstract void
putFlowExecution
(FlowExecution flowExecution) Place theFlowExecution
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 newFlowExecutionKey
should always be generated before each put call.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.webflow.execution.FlowExecutionKeyFactory
removeAllFlowExecutionSnapshots, removeFlowExecutionSnapshot, updateFlowExecutionSnapshot
-
Field Details
-
logger
protected final org.apache.commons.logging.Log loggerLogger, usable in subclasses
-
-
Constructor Details
-
AbstractFlowExecutionRepository
Constructor for use in subclasses.- Parameters:
conversationManager
- the conversation manager to use
-
-
Method Details
-
getConversationManager
The conversation service to delegate to for managing conversations initiated by this repository. -
getAlwaysGenerateNewNextKey
public boolean getAlwaysGenerateNewNextKey()The flag indicating if a newFlowExecutionKey
should always be generated before each put call. -
setAlwaysGenerateNewNextKey
public void setAlwaysGenerateNewNextKey(boolean alwaysGenerateNewNextKey) Sets the flag indicating if a newFlowExecutionKey
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. -
getKey
Description copied from interface:FlowExecutionKeyFactory
Get the key to assign to the flow execution. This factory simply generates the key to assign, it does not actually perform the key assignment.- Specified by:
getKey
in interfaceFlowExecutionKeyFactory
- Parameters:
execution
- the flow execution- Returns:
- the key to assign to the flow execution
-
parseFlowExecutionKey
public FlowExecutionKey parseFlowExecutionKey(String encodedKey) throws FlowExecutionRepositoryException Description copied from interface:FlowExecutionRepository
Parse the string-encoded flow execution key into its object form. Essentially, the reverse ofFlowExecutionKey.toString()
.- Specified by:
parseFlowExecutionKey
in interfaceFlowExecutionRepository
- Parameters:
encodedKey
- the string encoded key- Returns:
- the parsed flow execution key, the persistent identifier for exactly one flow execution
- Throws:
FlowExecutionRepositoryException
-
getLock
Description copied from interface:FlowExecutionRepository
Return the lock for the flow execution, allowing for the lock to be acquired or released. Caution: care should be made not to allow for a deadlock situation. If you acquire a lock make sure you release it when you are done. The general pattern for safely doing work against a locked conversation follows:FlowExecutionLock lock = repository.getLock(key); lock.lock(); try { FlowExecution execution = repository.getFlowExecution(key); // do work } finally { lock.unlock(); }
- Specified by:
getLock
in interfaceFlowExecutionRepository
- Parameters:
key
- the identifier of the flow execution to lock- Returns:
- the lock
- Throws:
FlowExecutionRepositoryException
- a problem occurred accessing the lock object
-
removeFlowExecution
public void removeFlowExecution(FlowExecution flowExecution) throws FlowExecutionRepositoryException Description copied from interface:FlowExecutionRepository
Remove the flow execution from the repository. This should be called when the flow execution ends (is no longer active). Before calling this method, you should acquire the lock for the keyed flow execution.- Specified by:
removeFlowExecution
in interfaceFlowExecutionRepository
- Parameters:
flowExecution
- the flow execution- Throws:
FlowExecutionRepositoryException
- the flow execution could not be removed.
-
nextSnapshotId
The next snapshot id to use for aFlowExecution
instance. Called whengetting a flow execution key
.- Returns:
- the id of the flow execution
-
getFlowExecution
public abstract FlowExecution getFlowExecution(FlowExecutionKey key) throws FlowExecutionRepositoryException Description copied from interface:FlowExecutionRepository
Return theFlowExecution
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.- Specified by:
getFlowExecution
in interfaceFlowExecutionRepository
- Parameters:
key
- the flow execution key- Returns:
- the flow execution, fully hydrated and ready to resume
- Throws:
FlowExecutionRepositoryException
- if no flow execution was indexed with the key provided
-
putFlowExecution
public abstract void putFlowExecution(FlowExecution flowExecution) throws FlowExecutionRepositoryException Description copied from interface:FlowExecutionRepository
Place theFlowExecution
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.- Specified by:
putFlowExecution
in interfaceFlowExecutionRepository
- Parameters:
flowExecution
- the flow execution- Throws:
FlowExecutionRepositoryException
- the flow execution could not be stored
-
createConversationParameters
Factory method that maps a new flow execution to a descriptiveconversation parameters
object.- Parameters:
flowExecution
- the new flow execution- Returns:
- the conversation parameters object to pass to the conversation manager when the conversation is started
-
getConversation
Returns the conversation governing theFlowExecution
with the provided key.- Parameters:
key
- the flow execution key- Returns:
- the governing conversation
- Throws:
NoSuchFlowExecutionException
- when the conversation for identified flow execution cannot be found
-
getConversation
Returns the conversation governing the logical flow execution with the given execution id.- Parameters:
executionId
- the flow execution id- Returns:
- the governing conversation
- Throws:
NoSuchConversationException
- when the conversation for identified flow execution cannot be found
-
assertKeySet
Assert that a flow execution key has been assigned to the execution.- Parameters:
execution
- the flow execution- Throws:
IllegalStateException
- if a key has not yet been assigned as expected
-