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:
- Initialize this builder, creating the initial flow definition, by calling
init(FlowBuilderContext)
. - Call
buildVariables()
to create any variables of the flow and add them to the flow definition. - Call
buildInputMapper()
to create and set the input mapper for the flow. - Call
buildStartActions()
to create and add any start actions to the flow. - Call
buildStates()
to create the states of the flow and add them to the flow definition. - Call
buildGlobalTransitions()
to create any transitions shared by all states of the flow and add them to the flow definition. - Call
buildEndActions()
to create and add any end actions to the flow. - Call
buildOutputMapper()
to create and set the output mapper for the flow. - Call
buildExceptionHandlers()
to create the exception handlers of the flow and add them to the flow definition. - Call
getFlow()
to return the fully-builtFlow
definition. - 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 TypeMethodDescriptionvoid
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
dispose()
Shutdown the builder, releasing any resources it holds.getFlow()
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
init
(FlowBuilderContext context) Initialize this builder.
-
Method Details
-
init
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
Builds any variables initialized by the flow when it starts.- Throws:
FlowBuilderException
- an exception occurred building the flow
-
buildInputMapper
Builds the input mapper responsible for mapping flow input on start.- Throws:
FlowBuilderException
- an exception occurred building the flow
-
buildStartActions
Builds any start actions to execute when the flow starts.- Throws:
FlowBuilderException
- an exception occurred building the flow
-
buildStates
Builds the states of the flow.- Throws:
FlowBuilderException
- an exception occurred building the flow
-
buildGlobalTransitions
Builds any transitions shared by all states of the flow.- Throws:
FlowBuilderException
- an exception occurred building the flow
-
buildEndActions
Builds any end actions to execute when the flow ends.- Throws:
FlowBuilderException
- an exception occurred building the flow
-
buildOutputMapper
Builds the output mapper responsible for mapping flow output on end.- Throws:
FlowBuilderException
- an exception occurred building the flow
-
buildExceptionHandlers
Creates and adds all exception handlers to the flow built by this builder.- Throws:
FlowBuilderException
- an exception occurred building this flow
-
getFlow
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
Shutdown the builder, releasing any resources it holds. A new flow construction process should start with another call to theinit(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
-