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:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Builds any end actions to execute when the flow ends.
    void
    Creates and adds all exception handlers to the flow built by this builder.
    void
    Builds any transitions shared by all states of the flow.
    void
    Builds the input mapper responsible for mapping flow input on start.
    void
    Builds the output mapper responsible for mapping flow output on end.
    void
    Builds any start actions to execute when the flow starts.
    void
    Builds the states of the flow.
    void
    Builds any variables initialized by the flow when it starts.
    void
    Shutdown the builder, releasing any resources it holds.
    Get the fully constructed and configured Flow object.
    Returns a string describing the location of the flow resource; the logical location where the source code can be found.
    boolean
    As the underlying flow managed by this builder changed since the last build occurred?
    void
    Initialize this builder.
  • Method Details

    • 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

      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