Spring Web Flow

org.springframework.webflow.engine.builder
Interface FlowBuilder

All Known Implementing Classes:
AbstractFlowBuilder, FlowModelFlowBuilder

public interface FlowBuilder

Builder interface used to build a flow definition. The process of building a flow consists of the following steps:

  1. Initialize this builder, creating the initial flow definition, by calling init(FlowBuilderContext).
  2. Call buildVariables() to create any variables of the flow and add them to the flow definition.
  3. Call buildInputMapper() to create and set the input mapper for the flow.
  4. Call buildStartActions() to create and add any start actions to the flow.
  5. Call buildStates() to create the states of the flow and add them to the flow definition.
  6. Call buildGlobalTransitions() to create any transitions shared by all states of the flow and add them to the flow definition.
  7. Call buildEndActions() to create and add any end actions to the flow.
  8. Call buildOutputMapper() to create and set the output mapper for the flow.
  9. Call buildExceptionHandlers() to create the exception handlers of the flow and add them to the flow definition.
  10. Call getFlow() to return the fully-built Flow definition.
  11. Dispose this builder, releasing any resources allocated during the building process by calling dispose().

Implementations should encapsulate flow construction logic, either for a specific kind of flow, for example, an OrderFlowBuilder built in Java code, or a generic flow builder strategy, like the XmlFlowBuilder, for building flows from an XML-definition.

Flow builders are used by the FlowAssembler, which acts as an assembler (director). Flow Builders may be reused, however, exercise caution when doing this as these objects are not thread safe. Also, for each use be sure to call init, followed by the build* methods, getFlow, and dispose completely in that order.

This is a good example of the classic GoF builder pattern.

Author:
Keith Donald, Erwin Vervaet
See Also:
Flow, FlowBuilderContext, FlowAssembler

Method Summary
 void buildEndActions()
          Builds any end actions to execute when the flow ends.
 void buildExceptionHandlers()
          Creates and adds all exception handlers to the flow built by this builder.
 void buildGlobalTransitions()
          Builds any transitions shared by all states of the flow.
 void buildInputMapper()
          Builds the input mapper responsible for mapping flow input on start.
 void buildOutputMapper()
          Builds the output mapper responsible for mapping flow output on end.
 void buildStartActions()
          Builds any start actions to execute when the flow starts.
 void buildStates()
          Builds the states of the flow.
 void buildVariables()
          Builds any variables initialized by the flow when it starts.
 void dispose()
          Shutdown the builder, releasing any resources it holds.
 Flow getFlow()
          Get the fully constructed and configured Flow object.
 java.lang.String getFlowResourceString()
          Returns a string describing the location of the flow resource; the logical location where the source code can be found.
 boolean hasFlowChanged()
          As the underlying flow managed by this builder changed since the last build occurred?
 void init(FlowBuilderContext context)
          Initialize this builder.
 

Method Detail

init

void init(FlowBuilderContext context)
          throws FlowBuilderException
Initialize this builder. This could cause the builder to open a stream to an externalized resource representing the flow definition, for example.

Parameters:
context - the flow builder context
Throws:
FlowBuilderException - an exception occurred building the flow

buildVariables

void buildVariables()
                    throws FlowBuilderException
Builds any variables initialized by the flow when it starts.

Throws:
FlowBuilderException - an exception occurred building the flow

buildInputMapper

void buildInputMapper()
                      throws FlowBuilderException
Builds the input mapper responsible for mapping flow input on start.

Throws:
FlowBuilderException - an exception occurred building the flow

buildStartActions

void buildStartActions()
                       throws FlowBuilderException
Builds any start actions to execute when the flow starts.

Throws:
FlowBuilderException - an exception occurred building the flow

buildStates

void buildStates()
                 throws FlowBuilderException
Builds the states of the flow.

Throws:
FlowBuilderException - an exception occurred building the flow

buildGlobalTransitions

void buildGlobalTransitions()
                            throws FlowBuilderException
Builds any transitions shared by all states of the flow.

Throws:
FlowBuilderException - an exception occurred building the flow

buildEndActions

void buildEndActions()
                     throws FlowBuilderException
Builds any end actions to execute when the flow ends.

Throws:
FlowBuilderException - an exception occurred building the flow

buildOutputMapper

void buildOutputMapper()
                       throws FlowBuilderException
Builds the output mapper responsible for mapping flow output on end.

Throws:
FlowBuilderException - an exception occurred building the flow

buildExceptionHandlers

void buildExceptionHandlers()
                            throws FlowBuilderException
Creates and adds all exception handlers to the flow built by this builder.

Throws:
FlowBuilderException - an exception occurred building this flow

getFlow

Flow getFlow()
             throws FlowBuilderException
Get the fully constructed and configured Flow object. Called by the builder's assembler (director) after assembly. When this method is called by the assembler, it is expected flow construction has completed and the returned flow is fully configured and ready for use.

Throws:
FlowBuilderException - an exception occurred building this flow

dispose

void dispose()
             throws FlowBuilderException
Shutdown the builder, releasing any resources it holds. A new flow construction process should start with another call to the init(FlowBuilderContext) method.

Throws:
FlowBuilderException - an exception occurred building this flow

hasFlowChanged

boolean hasFlowChanged()
As the underlying flow managed by this builder changed since the last build occurred?

Returns:
true if changed, false if not

getFlowResourceString

java.lang.String getFlowResourceString()
Returns a string describing the location of the flow resource; the logical location where the source code can be found. Used for informational purposes.

Returns:
the flow resource string

Spring Web Flow