org.springframework.webflow.execution
Interface FlowExecution

All Superinterfaces:
FlowExecutionContext
All Known Implementing Classes:
FlowExecutionImpl

public interface FlowExecution
extends FlowExecutionContext

A top-level instance of a flow definition that carries out definition execution on behalf of a single client. Typically used to support the orchestration of a web conversation.

This is the central facade interface for manipulating one runtime execution of a flow definition. Implementations of this interface are the finite state machine that is the heart of Spring Web Flow.

Typically, when a client wants to launch a flow execution at production time, she passes the id of the governing flow definition to a coordinating flow executor. This coordinator then typically uses a flow execution factory to create an object implementing this interface, initializing it with the requested flow definition which becomes the execution's "root" or top-level flow.

After execution creation, the start operation is called, which causes this execution to activate a new session for its root flow definition. That session is then said to become the active flow. An execution request context is created, the Flow's start state is entered, and the request is processed.

In a distributed environment such as HTTP, after a call into this object has completed and control returns to the caller, this execution object (if still active) is typically saved out to a repository before the server request ends. For example it might be saved out to the HttpSession, a Database, or a client-side hidden form field for later restoration and manipulation. This execution persistence is the responsibility of the flow execution repository subsystem.

Subsequent requests from the client to manipuate this flow execution trigger restoration of this object, followed by an invocation of the signal event operation. The signalEvent operation resumes this execution by indicating what action the user took from within the current state; for example, the user may have pressed the "submit" button, or pressed "cancel". After the user event is processed, control again goes back to the caller and if this execution is still active, it is again saved out to the repository.

This process continues until a client event causes this flow execution to end (by the root flow reaching an end state). At that time this object is no longer active, and is removed from the repository and discarded.

Flow executions can have their lifecycle observed by listeners.

Author:
Keith Donald, Erwin Vervaet
See Also:
FlowDefinition, FlowSession, RequestContext, FlowExecutionListener, FlowExecutionRepository, FlowExecutor

Method Summary
 ViewSelection refresh(ExternalContext context)
          Refresh this flow execution, asking the current view selection to be reconstituted to support reissuing the last response.
 ViewSelection signalEvent(java.lang.String eventId, ExternalContext context)
          Signal an occurrence of the specified user event in the current state of this executing flow.
 ViewSelection start(MutableAttributeMap input, ExternalContext context)
          Start this flow execution, transitioning it to the root flow's start state and returning the starting view selection needed to issue an initial user response.
 
Methods inherited from interface org.springframework.webflow.execution.FlowExecutionContext
getActiveSession, getAttributes, getConversationScope, getDefinition, isActive
 

Method Detail

start

ViewSelection start(MutableAttributeMap input,
                    ExternalContext context)
                    throws FlowExecutionException
Start this flow execution, transitioning it to the root flow's start state and returning the starting view selection needed to issue an initial user response. Typically called by a flow executor on behalf of a browser client, but also from test code.

This will start the entire flow execution from scratch.

Parameters:
input - input attributes to pass to the flow, which the flow may choose to map into its scope
context - the external context in which the starting event occured
Returns:
the starting view selection, a value object to be used to issue a suitable response to the caller
Throws:
FlowExecutionException - if an exception was thrown within a state of the flow execution during request processing

signalEvent

ViewSelection signalEvent(java.lang.String eventId,
                          ExternalContext context)
                          throws FlowExecutionException
Signal an occurrence of the specified user event in the current state of this executing flow. The event will be processed in full and control will be returned once event processing is complete.

Parameters:
eventId - the identifier of the user event that occured
context - the external context in which the event occured
Returns:
the next view selection to render, used by the calling executor to issue a suitable response to the client
Throws:
FlowExecutionException - if an exception was thrown within a state of the resumed flow execution during event processing

refresh

ViewSelection refresh(ExternalContext context)
                      throws FlowExecutionException
Refresh this flow execution, asking the current view selection to be reconstituted to support reissuing the last response. This is an idempotent operation that may be safely called on a paused execution.

Parameters:
context - the externa context in which the refresh event occured
Returns:
the current view selection for this flow execution
Throws:
FlowExecutionException - if an exception was thrown within a state of the resumed flow execution during event processing


Copyright © 2004-2007. All Rights Reserved.