Class FlowExecutionImpl
java.lang.Object
org.springframework.webflow.engine.impl.FlowExecutionImpl
- All Implemented Interfaces:
Externalizable
,Serializable
,FlowExecution
,FlowExecutionContext
Default implementation of FlowExecution that uses a stack-based data structure to manage spawned flow sessions. This
class is closely coupled with package-private
FlowSessionImpl
and RequestControlContextImpl
. The three classes work together to form a complete flow execution implementation based on a finite state machine.
This implementation of FlowExecution is serializable so it can be safely stored in an HTTP session or other
persistent store such as a file, database, or client-side form field. Once deserialized, the
FlowExecutionImplFactory
is expected to be used to restore the execution to a usable state.
- Author:
- Keith Donald, Erwin Vervaet, Jeremy Grelle
- See Also:
-
Constructor Summary
ConstructorDescriptionDefault constructor required for externalizable serialization.FlowExecutionImpl
(Flow flow) Create a new flow execution executing the provided flow. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.webflow.engine.impl.FlowSessionImpl
createFlowSession
(Flow flow, org.springframework.webflow.engine.impl.FlowSessionImpl parent) Create a new flow session object.protected RequestControlContext
createRequestContext
(ExternalContext externalContext, MessageContext messageContext) Create a flow execution control context.Returns the active flow session of this flow execution.Returns runtime execution attributes that may influence the behavior of flow artifacts, such as states and actions.Returns a mutable map for data held in "conversation scope".Returns the root flow definition associated with this executing flow.Returns a mutable map for data held in "flash scope".getKey()
Returns the key assigned to this flow execution.Returns the outcome reached by this execution, or null if this execution has not yet ended.boolean
hasEnded()
Returns a flag indicating if this execution has ended.boolean
Returns a flag indicating if this execution has been started.boolean
isActive()
Is the flow execution active? A flow execution is active once it has anactive session
and remains active until it has ended.void
void
resume
(ExternalContext externalContext) Resume this flow execution.void
setCurrentState
(String stateId) Jump to a state of the currently active flow.void
start
(MutableAttributeMap<?> input, ExternalContext externalContext) Start this flow execution.toString()
void
viewRendered
(View view, RequestContext context) void
viewRendering
(View view, RequestContext context) void
-
Constructor Details
-
FlowExecutionImpl
public FlowExecutionImpl()Default constructor required for externalizable serialization. Should NOT be called programmatically. -
FlowExecutionImpl
Create a new flow execution executing the provided flow. Flow executions are normally created by a flow execution factory.- Parameters:
flow
- the root flow of this flow execution
-
-
Method Details
-
getCaption
-
getKey
Description copied from interface:FlowExecutionContext
Returns the key assigned to this flow execution. The flow execution key is the flow execution's persistent identity.- Specified by:
getKey
in interfaceFlowExecutionContext
- Returns:
- the flow execution key; may be
null
if a key has not yet been assigned.
-
getDefinition
Description copied from interface:FlowExecutionContext
Returns the root flow definition associated with this executing flow.A call to this method always returns the same flow definition -- the top-level "root" -- no matter what flow may actually be active (for example, if subflows have been spawned).
- Specified by:
getDefinition
in interfaceFlowExecutionContext
- Returns:
- the root flow definition
-
hasStarted
public boolean hasStarted()Description copied from interface:FlowExecutionContext
Returns a flag indicating if this execution has been started. A flow execution that has started and is active is currently in progress. A flow execution that has started and is not active has ended.- Specified by:
hasStarted
in interfaceFlowExecutionContext
- Returns:
- true if started, false if not started
- See Also:
-
isActive
public boolean isActive()Description copied from interface:FlowExecutionContext
Is the flow execution active? A flow execution is active once it has anactive session
and remains active until it has ended.- Specified by:
isActive
in interfaceFlowExecutionContext
- Returns:
- true if active, false if the flow execution has terminated or has not yet been started
-
hasEnded
public boolean hasEnded()Description copied from interface:FlowExecutionContext
Returns a flag indicating if this execution has ended. A flow execution that has ended has been started but is no longer active.- Specified by:
hasEnded
in interfaceFlowExecutionContext
- Returns:
- true if ended, false if not started or still active
- See Also:
-
getOutcome
Description copied from interface:FlowExecutionContext
Returns the outcome reached by this execution, or null if this execution has not yet ended.- Specified by:
getOutcome
in interfaceFlowExecutionContext
- Returns:
- the outcome, or
null
if this execution has not yet ended
-
getActiveSession
Description copied from interface:FlowExecutionContext
Returns the active flow session of this flow execution. The active flow session is the currently executing session. It may be the "root flow" session, or it may be a subflow session if this flow execution has spawned a subflow.- Specified by:
getActiveSession
in interfaceFlowExecutionContext
- Returns:
- the active flow session
- See Also:
-
getFlashScope
Description copied from interface:FlowExecutionContext
Returns a mutable map for data held in "flash scope". Attributes in this map are cleared out on the next view rendering. Flash attributes survive flow execution refresh operations.- Specified by:
getFlashScope
in interfaceFlowExecutionContext
- Returns:
- flash scope
-
getConversationScope
Description copied from interface:FlowExecutionContext
Returns a mutable map for data held in "conversation scope". Conversation scope is a data structure that exists for the life of this flow execution and is accessible to all flow sessions.- Specified by:
getConversationScope
in interfaceFlowExecutionContext
- Returns:
- conversation scope
-
getAttributes
Description copied from interface:FlowExecutionContext
Returns runtime execution attributes that may influence the behavior of flow artifacts, such as states and actions.- Specified by:
getAttributes
in interfaceFlowExecutionContext
- Returns:
- execution attributes
-
start
public void start(MutableAttributeMap<?> input, ExternalContext externalContext) throws FlowExecutionException, IllegalStateException Description copied from interface:FlowExecution
Start this flow execution. This method should only be called once.When this method returns, execution status is either "paused" or "ended". If ended, the flow execution cannot be used again. If "paused", the flow execution may be
resumed
.- Specified by:
start
in interfaceFlowExecution
- Parameters:
input
- flow execution inputexternalContext
- the external context representing the calling environment- Throws:
FlowExecutionException
- if an exception was thrown within a state of the flow execution during request processingIllegalStateException
-
resume
public void resume(ExternalContext externalContext) throws FlowExecutionException, IllegalStateException Description copied from interface:FlowExecution
Resume this flow execution. May be called when the flow execution is paused. When this method returns, execution status is either "paused" or "ended". If ended, the flow execution cannot be used again. If "paused", the flow execution may be resumed again.- Specified by:
resume
in interfaceFlowExecution
- Parameters:
externalContext
- the external context, representing the calling environment, where something happened this flow execution should respond to- Throws:
FlowExecutionException
- if an exception was thrown within a state of the resumed flow execution during event processingIllegalStateException
-
setCurrentState
Jump to a state of the currently active flow. If this execution has not been started, a new session will be activated and its current state will be set. This is a implementation-internal method that bypasses thestart(MutableAttributeMap, ExternalContext)
operation and allows for jumping to an arbitrary flow state. Useful for testing.- Parameters:
stateId
- the identifier of the state to jump to
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
toString
-
createRequestContext
protected RequestControlContext createRequestContext(ExternalContext externalContext, MessageContext messageContext) Create a flow execution control context.- Parameters:
externalContext
- the external context triggering this request
-
createFlowSession
protected org.springframework.webflow.engine.impl.FlowSessionImpl createFlowSession(Flow flow, org.springframework.webflow.engine.impl.FlowSessionImpl parent) Create a new flow session object. Subclasses can override this to return a special implementation if required.- Parameters:
flow
- the flow that should be associated with the flow sessionparent
- the flow session that should be the parent of the newly created flow session (may be null)- Returns:
- the newly created flow session
-
viewRendering
-
viewRendered
-