Class FlowExecutionImpl

java.lang.Object
org.springframework.webflow.engine.impl.FlowExecutionImpl
All Implemented Interfaces:
Externalizable, Serializable, FlowExecution, FlowExecutionContext

public class FlowExecutionImpl extends Object implements FlowExecution, Externalizable
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 Details

    • FlowExecutionImpl

      public FlowExecutionImpl()
      Default constructor required for externalizable serialization. Should NOT be called programmatically.
    • FlowExecutionImpl

      public FlowExecutionImpl(Flow flow)
      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

      public String getCaption()
    • getKey

      public FlowExecutionKey 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 interface FlowExecutionContext
      Returns:
      the flow execution key; may be null if a key has not yet been assigned.
    • getDefinition

      public FlowDefinition 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 interface FlowExecutionContext
      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 interface FlowExecutionContext
      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 an active session and remains active until it has ended.
      Specified by:
      isActive in interface FlowExecutionContext
      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 interface FlowExecutionContext
      Returns:
      true if ended, false if not started or still active
      See Also:
    • getOutcome

      public FlowExecutionOutcome 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 interface FlowExecutionContext
      Returns:
      the outcome, or null if this execution has not yet ended
    • getActiveSession

      public FlowSession 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 interface FlowExecutionContext
      Returns:
      the active flow session
      See Also:
    • getFlashScope

      public MutableAttributeMap<Object> 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 interface FlowExecutionContext
      Returns:
      flash scope
    • getConversationScope

      public MutableAttributeMap<Object> 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 interface FlowExecutionContext
      Returns:
      conversation scope
    • getAttributes

      public AttributeMap<Object> 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 interface FlowExecutionContext
      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 interface FlowExecution
      Parameters:
      input - flow execution input
      externalContext - the external context representing the calling environment
      Throws:
      FlowExecutionException - if an exception was thrown within a state of the flow execution during request processing
      IllegalStateException
    • 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 interface FlowExecution
      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 processing
      IllegalStateException
    • setCurrentState

      public void setCurrentState(String stateId)
      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 the start(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

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException
      ClassNotFoundException
    • writeExternal

      public void writeExternal(ObjectOutput out) throws IOException
      Specified by:
      writeExternal in interface Externalizable
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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 session
      parent - the flow session that should be the parent of the newly created flow session (may be null)
      Returns:
      the newly created flow session
    • viewRendering

      public void viewRendering(View view, RequestContext context)
    • viewRendered

      public void viewRendered(View view, RequestContext context)