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
ConstructorsConstructorDescriptionDefault 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.FlowSessionImplcreateFlowSession(Flow flow, org.springframework.webflow.engine.impl.FlowSessionImpl parent) Create a new flow session object.protected RequestControlContextcreateRequestContext(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.booleanhasEnded()Returns a flag indicating if this execution has ended.booleanReturns a flag indicating if this execution has been started.booleanisActive()Is the flow execution active? A flow execution is active once it has anactive sessionand remains active until it has ended.voidvoidresume(ExternalContext externalContext) Resume this flow execution.voidsetCurrentState(String stateId) Jump to a state of the currently active flow.voidstart(MutableAttributeMap<?> input, ExternalContext externalContext) Start this flow execution.toString()voidviewRendered(View view, RequestContext context) voidviewRendering(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:FlowExecutionContextReturns the key assigned to this flow execution. The flow execution key is the flow execution's persistent identity.- Specified by:
getKeyin interfaceFlowExecutionContext- Returns:
- the flow execution key; may be
nullif a key has not yet been assigned.
-
getDefinition
Description copied from interface:FlowExecutionContextReturns 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:
getDefinitionin interfaceFlowExecutionContext- Returns:
- the root flow definition
-
hasStarted
public boolean hasStarted()Description copied from interface:FlowExecutionContextReturns 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:
hasStartedin interfaceFlowExecutionContext- Returns:
- true if started, false if not started
- See Also:
-
isActive
public boolean isActive()Description copied from interface:FlowExecutionContextIs the flow execution active? A flow execution is active once it has anactive sessionand remains active until it has ended.- Specified by:
isActivein 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:FlowExecutionContextReturns a flag indicating if this execution has ended. A flow execution that has ended has been started but is no longer active.- Specified by:
hasEndedin interfaceFlowExecutionContext- Returns:
- true if ended, false if not started or still active
- See Also:
-
getOutcome
Description copied from interface:FlowExecutionContextReturns the outcome reached by this execution, or null if this execution has not yet ended.- Specified by:
getOutcomein interfaceFlowExecutionContext- Returns:
- the outcome, or
nullif this execution has not yet ended
-
getActiveSession
Description copied from interface:FlowExecutionContextReturns 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:
getActiveSessionin interfaceFlowExecutionContext- Returns:
- the active flow session
- See Also:
-
getFlashScope
Description copied from interface:FlowExecutionContextReturns 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:
getFlashScopein interfaceFlowExecutionContext- Returns:
- flash scope
-
getConversationScope
Description copied from interface:FlowExecutionContextReturns 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:
getConversationScopein interfaceFlowExecutionContext- Returns:
- conversation scope
-
getAttributes
Description copied from interface:FlowExecutionContextReturns runtime execution attributes that may influence the behavior of flow artifacts, such as states and actions.- Specified by:
getAttributesin interfaceFlowExecutionContext- Returns:
- execution attributes
-
start
public void start(MutableAttributeMap<?> input, ExternalContext externalContext) throws FlowExecutionException, IllegalStateException Description copied from interface:FlowExecutionStart 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:
startin 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:FlowExecutionResume 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:
resumein 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:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
- Specified by:
writeExternalin 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
-