public class DefaultFlowExecutionRepository extends AbstractSnapshottingFlowExecutionRepository
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:
Conversation
when a FlowExecution
is assigned a persistent key. Each conversation
is assigned a unique conversation id which forms one part of the flow execution key.
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.
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.
logger
Constructor and Description |
---|
DefaultFlowExecutionRepository(ConversationManager conversationManager,
FlowExecutionSnapshotFactory snapshotFactory)
Create a new default flow execution repository using the given state restorer, conversation manager, and snapshot
factory.
|
Modifier and Type | Method and Description |
---|---|
protected FlowExecutionSnapshotGroup |
createFlowExecutionSnapshotGroup() |
FlowExecution |
getFlowExecution(FlowExecutionKey key)
Return the
FlowExecution indexed by the provided key. |
int |
getMaxSnapshots()
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 java.io.Serializable |
nextSnapshotId(java.io.Serializable executionId)
The next snapshot id to use for a
FlowExecution instance. |
void |
putFlowExecution(FlowExecution flowExecution)
Place the
FlowExecution 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.
|
getSnapshotFactory, getSnapshotId, putConversationScope, restoreFlowExecution, snapshot
assertKeySet, createConversationParameters, getAlwaysGenerateNewNextKey, getConversation, getConversation, getConversationManager, getKey, getLock, parseFlowExecutionKey, removeFlowExecution, setAlwaysGenerateNewNextKey
public DefaultFlowExecutionRepository(ConversationManager conversationManager, FlowExecutionSnapshotFactory snapshotFactory)
conversationManager
- the conversation manager to usesnapshotFactory
- the flow execution snapshot factory to usepublic int getMaxSnapshots()
public void setMaxSnapshots(int maxSnapshots)
protected java.io.Serializable nextSnapshotId(java.io.Serializable executionId)
AbstractFlowExecutionRepository
FlowExecution
instance. Called when getting a flow execution key
.nextSnapshotId
in class AbstractFlowExecutionRepository
public FlowExecution getFlowExecution(FlowExecutionKey key)
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
getFlowExecution
in class AbstractFlowExecutionRepository
key
- the flow execution keypublic void putFlowExecution(FlowExecution flowExecution)
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
putFlowExecution
in class AbstractFlowExecutionRepository
flowExecution
- the flow executionpublic void updateFlowExecutionSnapshot(FlowExecution execution)
FlowExecutionKeyFactory
execution
- the flow executionpublic void removeFlowExecutionSnapshot(FlowExecution execution)
FlowExecutionKeyFactory
execution
- the flow executionpublic void removeAllFlowExecutionSnapshots(FlowExecution execution)
FlowExecutionKeyFactory
execution
- the flow executionprotected FlowExecutionSnapshotGroup createFlowExecutionSnapshotGroup()
protected FlowExecutionSnapshotGroup getSnapshotGroup(Conversation conversation)
conversation
- the conversation where the snapshot group is stored