A simple Flow definition could do nothing more than execute an action and display a view all in one request. A more elaborate Flow definition may be long-lived and execute across a series of requests, invoking many possible paths, actions, and subflows.
Especially in Intranet applications there are often "controlled navigations" where the user is not free to do what he or she wants but must follow the guidelines provided by the system to complete a process that is transactional in nature (the quintessential example would be a 'checkout' flow of a shopping cart application). This is a typical use case appropriate to model as a flow.
Structurally a Flow is composed of a set of states. A {@link State} is a point in a flow where a behavior isexecuted; for example, showing a view, executing an action, spawning a subflow, or terminating the flow. Different types of states execute different behaviors in a polymorphic fashion.
Each {@link TransitionableState} type has one or more transitions that when executed move a flow to another state.These transitions define the supported paths through the flow.
A state transition is triggered by the occurrence of an event. An event is something that happens the flow should respond to, for example a user input event like ("submit") or an action execution result event like ("success"). When an event occurs in a state of a Flow that event drives a state transition that decides what to do next.
Each Flow has exactly one start state. A start state is simply a marker noting the state executions of this Flow definition should start in. The first state added to the flow will become the start state by default.
Flow definitions may have one or more flow exception handlers. A {@link FlowExecutionExceptionHandler} can executecustom behavior in response to a specific exception (or set of exceptions) that occur in a state of one of this flow's executions.
Instances of this class are typically built by {@link org.springframework.webflow.engine.builder.FlowBuilder}implementations but may also be directly instantiated.
This class and the rest of the Spring Web Flow (SWF) engine have been designed with minimal dependencies on other libraries. Spring Web Flow is usable in a standalone fashion. The engine system is fully usable outside an HTTP servlet environment, for example in portlets, tests, or standalone applications. One of the major architectural benefits of Spring Web Flow is the ability to design reusable, high-level controller modules that may be executed in any environment.
Note: flows are singleton definition objects so they should be thread-safe. You can think a flow definition as analogous to a Java class, defining all the behavior of an application module. The core behaviors {@link #start(RequestControlContext,MutableAttributeMap) start}, {@link #resume(RequestControlContext)}, {@link #handleEvent(RequestControlContext) on event}, {@link #end(RequestControlContext,String,MutableAttributeMap) end}, and {@link #handleException(FlowExecutionException,RequestControlContext)}. Each method accepts a {@link RequestContext request context} that allows for this flow to access execution state in a thread safe manner. A flow execution iswhat models a running instance of this flow definition, somewhat analogous to a java object that is an instance of a class. @see org.springframework.webflow.engine.State @see org.springframework.webflow.engine.ActionState @see org.springframework.webflow.engine.ViewState @see org.springframework.webflow.engine.SubflowState @see org.springframework.webflow.engine.EndState @see org.springframework.webflow.engine.DecisionState @see org.springframework.webflow.engine.Transition @see org.springframework.webflow.engine.FlowExecutionExceptionHandler @author Keith Donald @author Erwin Vervaet @author Colin Sampaleanu @author Jeremy Grelle
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|