Class DefaultFlowExecutionRepository
java.lang.Object
org.springframework.webflow.execution.repository.support.AbstractFlowExecutionRepository
org.springframework.webflow.execution.repository.snapshot.AbstractSnapshottingFlowExecutionRepository
org.springframework.webflow.execution.repository.impl.DefaultFlowExecutionRepository
- All Implemented Interfaces:
FlowExecutionKeyFactory
,FlowExecutionRepository
The default flow execution repository implementation. Takes one to
max
flow
execution snapshots, where each snapshot represents a copy of a FlowExecution
taken at a point in time.
Snapshots are created via a FlowExecutionSnapshotFactory
and that may or may not involve creating a copy of a
flow execution through Java serialization. In particular when the flow-execution-repository element is configured
with max-execution-snapshots="0", creating snapshot copies is effectively turned off.
The set of active flow executions are managed by a ConversationManager
implementation, which this repository
delegates to.
This repository is responsible for:
- Beginning a new
Conversation
when aFlowExecution
is assigned a persistent key. Each conversation is assigned a unique conversation id which forms one part of the flow execution key. - Taking
execution snapshots
to persist flow execution state. A snapshot is a copy of the execution created at a point in time that can be restored and continued. Snapshotting supports users going back in their browser to continue their flow execution from a previoius point. - Ending conversations when flow executions end.
This repository implementation also provides support for execution invalidation after completion, where once a logical flow execution completes, it and all of its snapshots are removed. This cleans up memory and prevents the possibility of duplicate submission after completion.
- Author:
- Keith Donald
-
Field Summary
Fields inherited from class org.springframework.webflow.execution.repository.support.AbstractFlowExecutionRepository
logger
-
Constructor Summary
ConstructorDescriptionDefaultFlowExecutionRepository
(ConversationManager conversationManager, FlowExecutionSnapshotFactory snapshotFactory) Create a new default flow execution repository using the given state restorer, conversation manager, and snapshot factory. -
Method Summary
Modifier and TypeMethodDescriptionprotected FlowExecutionSnapshotGroup
Return theFlowExecution
indexed by the provided key.int
Returns the max number of snapshots allowed per flow execution by this repository.protected FlowExecutionSnapshotGroup
getSnapshotGroup
(Conversation conversation) Returns the snapshot group associated with the governing conversation.protected Serializable
nextSnapshotId
(Serializable executionId) The next snapshot id to use for aFlowExecution
instance.void
putFlowExecution
(FlowExecution flowExecution) Place theFlowExecution
in this repository under the provided key.void
removeAllFlowExecutionSnapshots
(FlowExecution execution) Remove all snapshots associated with the flow execution from storage, invalidating all history.void
removeFlowExecutionSnapshot
(FlowExecution execution) Remove the snapshot that was used to restore this flow execution, discarding it for future use.void
setMaxSnapshots
(int maxSnapshots) Sets the maximum number of snapshots allowed per flow execution by this repository.void
updateFlowExecutionSnapshot
(FlowExecution execution) Capture the current state of the flow execution by updating its snapshot in storage.Methods inherited from class org.springframework.webflow.execution.repository.snapshot.AbstractSnapshottingFlowExecutionRepository
getSnapshotFactory, getSnapshotId, putConversationScope, restoreFlowExecution, snapshot
Methods inherited from class org.springframework.webflow.execution.repository.support.AbstractFlowExecutionRepository
assertKeySet, createConversationParameters, getAlwaysGenerateNewNextKey, getConversation, getConversation, getConversationManager, getKey, getLock, parseFlowExecutionKey, removeFlowExecution, setAlwaysGenerateNewNextKey
-
Constructor Details
-
DefaultFlowExecutionRepository
public DefaultFlowExecutionRepository(ConversationManager conversationManager, FlowExecutionSnapshotFactory snapshotFactory) Create a new default flow execution repository using the given state restorer, conversation manager, and snapshot factory.- Parameters:
conversationManager
- the conversation manager to usesnapshotFactory
- the flow execution snapshot factory to use
-
-
Method Details
-
getMaxSnapshots
public int getMaxSnapshots()Returns the max number of snapshots allowed per flow execution by this repository. -
setMaxSnapshots
public void setMaxSnapshots(int maxSnapshots) Sets the maximum number of snapshots allowed per flow execution by this repository. Use -1 for unlimited. The default is 30. -
nextSnapshotId
Description copied from class:AbstractFlowExecutionRepository
The next snapshot id to use for aFlowExecution
instance. Called whengetting a flow execution key
.- Specified by:
nextSnapshotId
in classAbstractFlowExecutionRepository
- Returns:
- the id of the flow execution
-
getFlowExecution
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
- Specified by:
getFlowExecution
in classAbstractFlowExecutionRepository
- Parameters:
key
- the flow execution key- Returns:
- the flow execution, fully hydrated and ready to resume
-
putFlowExecution
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
- Specified by:
putFlowExecution
in classAbstractFlowExecutionRepository
- Parameters:
flowExecution
- the flow execution
-
updateFlowExecutionSnapshot
Description copied from interface:FlowExecutionKeyFactory
Capture the current state of the flow execution by updating its snapshot in storage. Does nothing if the no key has been assigned or no snapshot has already been taken.- Parameters:
execution
- the flow execution
-
removeFlowExecutionSnapshot
Description copied from interface:FlowExecutionKeyFactory
Remove the snapshot that was used to restore this flow execution, discarding it for future use. Does nothing if the no key been assigned or no snapshot has been taken.- Parameters:
execution
- the flow execution
-
removeAllFlowExecutionSnapshots
Description copied from interface:FlowExecutionKeyFactory
Remove all snapshots associated with the flow execution from storage, invalidating all history. Does nothing if no key has been assigned or no snapshots have been taken.- Parameters:
execution
- the flow execution
-
createFlowExecutionSnapshotGroup
-
getSnapshotGroup
Returns the snapshot group associated with the governing conversation.- Parameters:
conversation
- the conversation where the snapshot group is stored- Returns:
- the snapshot group
-