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
Conversationwhen aFlowExecutionis assigned a persistent key. Each conversation is assigned a unique conversation id which forms one part of the flow execution key. - Taking
execution snapshotsto 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
ConstructorsConstructorDescriptionDefaultFlowExecutionRepository(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 FlowExecutionSnapshotGroupReturn theFlowExecutionindexed by the provided key.intReturns the max number of snapshots allowed per flow execution by this repository.protected FlowExecutionSnapshotGroupgetSnapshotGroup(Conversation conversation) Returns the snapshot group associated with the governing conversation.protected SerializablenextSnapshotId(Serializable executionId) The next snapshot id to use for aFlowExecutioninstance.voidputFlowExecution(FlowExecution flowExecution) Place theFlowExecutionin this repository under the provided key.voidremoveAllFlowExecutionSnapshots(FlowExecution execution) Remove all snapshots associated with the flow execution from storage, invalidating all history.voidremoveFlowExecutionSnapshot(FlowExecution execution) Remove the snapshot that was used to restore this flow execution, discarding it for future use.voidsetMaxSnapshots(int maxSnapshots) Sets the maximum number of snapshots allowed per flow execution by this repository.voidupdateFlowExecutionSnapshot(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, snapshotMethods 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:AbstractFlowExecutionRepositoryThe next snapshot id to use for aFlowExecutioninstance. Called whengetting a flow execution key.- Specified by:
nextSnapshotIdin classAbstractFlowExecutionRepository- Returns:
- the id of the flow execution
-
getFlowExecution
Description copied from interface:FlowExecutionRepositoryReturn theFlowExecutionindexed 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:
getFlowExecutionin interfaceFlowExecutionRepository- Specified by:
getFlowExecutionin classAbstractFlowExecutionRepository- Parameters:
key- the flow execution key- Returns:
- the flow execution, fully hydrated and ready to resume
-
putFlowExecution
Description copied from interface:FlowExecutionRepositoryPlace theFlowExecutionin 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:
putFlowExecutionin interfaceFlowExecutionRepository- Specified by:
putFlowExecutionin classAbstractFlowExecutionRepository- Parameters:
flowExecution- the flow execution
-
updateFlowExecutionSnapshot
Description copied from interface:FlowExecutionKeyFactoryCapture 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:FlowExecutionKeyFactoryRemove 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:FlowExecutionKeyFactoryRemove 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
-