|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.webflow.engine.builder.BaseFlowBuilder
org.springframework.webflow.engine.builder.AbstractFlowBuilder
public abstract class AbstractFlowBuilder
Base class for flow builders that programmatically build flows in Java configuration code.
To give you an example of what a simple Java-based web flow builder definition might look like, the following example defines the 'dynamic' web flow roughly equivalent to the work flow statically implemented in Spring MVC's simple form controller:
public class CustomerDetailFlowBuilder extends AbstractFlowBuilder {
public void buildStates() {
// get customer information
addActionState("getDetails", action("customerAction"), transition(on(success()), to("displayDetails")));
// view customer information
addViewState("displayDetails", "customerDetails", transition(on(submit()), to("bindAndValidate")));
// bind and validate customer information updates
addActionState("bindAndValidate", action("customerAction"), new Transition[] {
transition(on(error()), to("displayDetails")), transition(on(success()), to("finish")) });
// finish
addEndState("finish");
}
}
What this Java-based FlowBuilder implementation does is add four states to a
flow. These include a "get" ActionState (the start state), a
ViewState state, a "bind and validate"
ActionState, and an end marker state (EndState).
The first state, an action state, will be assigned the indentifier
getDetails. This action state will automatically be
configured with the following defaults:
customerAction. This is the
Action implementation that will execute when this state is
entered. In this example, that Action will go out to the DB,
load the Customer, and put it in the Flow's request context.
success transition to a default view state, called
displayDetails. This means when the Action
returns a success result event (aka outcome), the
displayDetails state will be entered.
The second state, a view state, will be identified as
displayDetails. This view state will automatically be
configured with the following defaults:
customerDetails. This is the logical
name of a view resource. This logical view name gets mapped to a physical
view resource (jsp, etc.) by the calling front controller (via a Spring view
resolver, or a Struts action forward, for example).
submit transition to a bind and validate action state,
indentified by the default id bindAndValidate. This means
when a submit event is signaled by the view (for example, on a
submit button click), the bindAndValidate action state will be entered and
the bindAndValidate method of the
customerAction Action implementation will be
executed.
The third state, an action state, will be indentified as
bindAndValidate. This action state will automatically be
configured with the following defaults:
customerAction -- this is the name
of the Action implementation exported in the application
context that will execute when this state is entered. In this example, the
Action has a "bindAndValidate" method that will bind form
input in the HTTP request to a backing Customer form object, validate it, and
update the DB.
success transition to a default end state, called
finish. This means if the Action returns a
success result, the finish end state will be
transitioned to and the flow will terminate.
error transition back to the form view. This means if
the Action returns an error event, the
displayDetails view state will be transitioned back to.
The fourth and last state, an end state, will be indentified with the default
end state id finish. This end state is a marker that signals
the end of the flow. When entered, the flow session terminates, and if this
flow is acting as a root flow in the current flow execution, any
flow-allocated resources will be cleaned up. An end state can optionally be
configured with a logical view name to forward to when entered. It will also
trigger a state transition in a resuming parent flow if this flow was
participating as a spawned 'subflow' within a suspended parent flow.
| Constructor Summary | |
|---|---|
protected |
AbstractFlowBuilder()
Default constructor for subclassing. |
protected |
AbstractFlowBuilder(FlowServiceLocator flowServiceLocator)
Create an instance of an abstract flow builder, using the specified locator to obtain needed flow services at build time. |
| Method Summary | |
|---|---|
protected Action |
action(org.springframework.binding.expression.Expression expression)
Creates an evaluate action that evaluates the expression when executed. |
protected Action |
action(org.springframework.binding.expression.Expression expression,
ActionResultExposer resultExposer)
Creates an evaluate action that evaluates the expression when executed. |
protected Action |
action(java.lang.String id)
Resolves the action with the specified id. |
protected Action |
action(java.lang.String beanId,
org.springframework.binding.method.MethodSignature methodSignature)
Creates a bean invoking action that invokes the method identified by the signature on the bean associated with the action identifier. |
protected Action |
action(java.lang.String beanId,
org.springframework.binding.method.MethodSignature methodSignature,
ActionResultExposer resultExposer)
Creates a bean invoking action that invokes the method identified by the signature on the bean associated with the action identifier. |
protected java.lang.String |
add()
Creates the add event id. |
protected State |
addActionState(java.lang.String stateId,
Action[] entryActions,
Action[] actions,
Transition[] transitions,
FlowExecutionExceptionHandler[] exceptionHandlers,
Action[] exitActions,
AttributeMap attributes)
Adds an action state to the flow built by this builder. |
protected State |
addActionState(java.lang.String stateId,
Action action,
Transition transition)
Adds an action state to the flow built by this builder. |
protected State |
addActionState(java.lang.String stateId,
Action action,
Transition[] transitions)
Adds an action state to the flow built by this builder. |
protected State |
addActionState(java.lang.String stateId,
Action action,
Transition transition,
FlowExecutionExceptionHandler exceptionHandler)
Adds an action state to the flow built by this builder. |
protected State |
addDecisionState(java.lang.String stateId,
Action[] entryActions,
Transition[] transitions,
FlowExecutionExceptionHandler[] exceptionHandlers,
Action[] exitActions,
AttributeMap attributes)
Adds a decision state to the flow built by this builder. |
protected State |
addDecisionState(java.lang.String stateId,
Transition[] transitions)
Adds a decision state to the flow built by this builder. |
protected State |
addDecisionState(java.lang.String stateId,
TransitionCriteria decisionCriteria,
java.lang.String trueStateId,
java.lang.String falseStateId)
Adds a decision state to the flow built by this builder. |
protected State |
addEndState(java.lang.String stateId)
Adds an end state to the flow built by this builder. |
protected State |
addEndState(java.lang.String stateId,
Action[] entryActions,
ViewSelector viewSelector,
org.springframework.binding.mapping.AttributeMapper outputMapper,
FlowExecutionExceptionHandler[] exceptionHandlers,
AttributeMap attributes)
Adds an end state to the flow built by this builder. |
protected State |
addEndState(java.lang.String stateId,
java.lang.String viewName)
Adds an end state to the flow built by this builder. |
protected State |
addEndState(java.lang.String stateId,
java.lang.String viewName,
org.springframework.binding.mapping.AttributeMapper outputMapper)
Adds an end state to the flow built by this builder. |
protected State |
addSubflowState(java.lang.String stateId,
Action[] entryActions,
Flow subflow,
FlowAttributeMapper attributeMapper,
Transition[] transitions,
FlowExecutionExceptionHandler[] exceptionHandlers,
Action[] exitActions,
AttributeMap attributes)
Adds a subflow state to the flow built by this builder. |
protected State |
addSubflowState(java.lang.String stateId,
Flow subflow,
FlowAttributeMapper attributeMapper,
Transition transition)
Adds a subflow state to the flow built by this builder. |
protected State |
addSubflowState(java.lang.String stateId,
Flow subflow,
FlowAttributeMapper attributeMapper,
Transition[] transitions)
Adds a subflow state to the flow built by this builder. |
protected State |
addViewState(java.lang.String stateId,
Action[] entryActions,
ViewSelector viewSelector,
Action[] renderActions,
Transition[] transitions,
FlowExecutionExceptionHandler[] exceptionHandlers,
Action[] exitActions,
AttributeMap attributes)
Adds a view state to the flow built by this builder. |
protected State |
addViewState(java.lang.String stateId,
java.lang.String viewName,
Action renderAction,
Transition transition)
Adds a view state to the flow built by this builder. |
protected State |
addViewState(java.lang.String stateId,
java.lang.String viewName,
Action renderAction,
Transition[] transitions)
Adds a view state to the flow built by this builder. |
protected State |
addViewState(java.lang.String stateId,
java.lang.String viewName,
Transition transition)
Adds a view state to the flow built by this builder. |
protected State |
addViewState(java.lang.String stateId,
java.lang.String viewName,
Transition[] transitions)
Adds a view state to the flow built by this builder. |
protected FlowAttributeMapper |
attributeMapper(java.lang.String id)
Request that the attribute mapper with the specified name be used to map attributes between a parent flow and a spawning subflow when the subflow state being constructed is entered. |
protected java.lang.String |
back()
Creates the back event id. |
protected java.lang.String |
cancel()
Creates the cancel event id. |
protected java.lang.String |
delete()
Creates the delete event id. |
protected java.lang.String |
edit()
Creates the edit event id. |
protected java.lang.String |
error()
Creates the error event id. |
protected org.springframework.binding.expression.Expression |
expression(java.lang.String expressionString)
Parses the expression string into a evaluatable Expression
object. |
protected java.lang.String |
finish()
Creates the finish event id. |
protected Flow |
flow(java.lang.String id)
Request that the Flow with the specified flowId be spawned
as a subflow when the subflow state being built is entered. |
protected AttributeMap |
flowAttributes()
Hook subclasses may override to provide additional properties for the flow built by this builder. |
EventFactorySupport |
getEventFactorySupport()
Returns the configured event factory support helper for creating commonly used event identifiers that drive transitions created by this builder. |
protected TransitionCriteria |
ifReturnedSuccess(Action action)
Creates a TransitionCriteria that will execute the
specified action when the Transition is executed but before the
transition's target state is entered. |
void |
init(java.lang.String flowId,
AttributeMap attributes)
Initialize this builder. |
protected AnnotatedAction |
invoke(java.lang.String methodName,
MultiAction multiAction)
Creates an annotated action decorator that instructs the specified method be invoked on the multi action when it is executed. |
protected org.springframework.binding.mapping.MappingBuilder |
mapping()
Factory method that returns a new, fully configured mapping builder to assist with building Mapping objects used by a
FlowAttributeMapper to map attributes. |
protected org.springframework.binding.method.MethodSignature |
method(java.lang.String method)
Convert the encoded method signature string to a MethodSignature
object. |
protected java.lang.String |
no()
Creates the no event id. |
protected TransitionCriteria |
on(java.lang.String transitionCriteriaExpression)
Creates a transition criteria that is used to match a Transition. |
protected ActionResultExposer |
result(java.lang.String resultName)
Factory method for a result exposer. |
protected ActionResultExposer |
result(java.lang.String resultName,
ScopeType resultScope)
Factory method for a result exposer. |
protected java.lang.String |
select()
Creates the select event id. |
void |
setEventFactorySupport(EventFactorySupport eventFactorySupport)
Sets the event factory support helper to use to create commonly used event identifiers that drive transitions created by this builder. |
protected java.lang.String |
submit()
Creates the submit event id. |
protected java.lang.String |
success()
Creates the success event id. |
protected TargetStateResolver |
to(java.lang.String targetStateIdExpression)
Creates a target state resolver for the given state id expression. |
protected Transition |
transition(TransitionCriteria matchingCriteria,
TargetStateResolver targetStateResolver)
Creates a new transition. |
protected Transition |
transition(TransitionCriteria matchingCriteria,
TargetStateResolver targetStateResolver,
TransitionCriteria executionCriteria)
Creates a new transition. |
protected Transition |
transition(TransitionCriteria matchingCriteria,
TargetStateResolver targetStateResolver,
TransitionCriteria executionCriteria,
AttributeMap attributes)
Creates a new transition. |
ViewSelector |
viewSelector(java.lang.String viewName)
Factory method that creates a view selector from an encoded view name. |
protected java.lang.String |
yes()
Creates the yes event id. |
| Methods inherited from class org.springframework.webflow.engine.builder.BaseFlowBuilder |
|---|
buildEndActions, buildExceptionHandlers, buildGlobalTransitions, buildInlineFlows, buildInputMapper, buildOutputMapper, buildStartActions, buildStates, buildVariables, dispose, fromStringTo, fromStringTo, getFlow, getFlowServiceLocator, setFlow, setFlowServiceLocator |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected AbstractFlowBuilder()
protected AbstractFlowBuilder(FlowServiceLocator flowServiceLocator)
flowServiceLocator - the locator for services needed by this builder
to build its Flow| Method Detail |
|---|
public EventFactorySupport getEventFactorySupport()
public void setEventFactorySupport(EventFactorySupport eventFactorySupport)
public void init(java.lang.String flowId,
AttributeMap attributes)
throws FlowBuilderException
FlowBuilder
init in interface FlowBuilderinit in class BaseFlowBuilderflowId - the identifier to assign to the flowattributes - custom attributes to assign to the flow
FlowBuilderException - an exception occured building the flowprotected AttributeMap flowAttributes()
protected State addViewState(java.lang.String stateId,
java.lang.String viewName,
Transition transition)
stateId - the state identifierviewName - the string-encoded view selectortransition - the sole transition (path) out of this state
protected State addViewState(java.lang.String stateId,
java.lang.String viewName,
Transition[] transitions)
stateId - the state identifierviewName - the string-encoded view selectortransitions - the transitions (paths) out of this state
protected State addViewState(java.lang.String stateId,
java.lang.String viewName,
Action renderAction,
Transition transition)
stateId - the state identifierviewName - the string-encoded view selectorrenderAction - the action to execute on state entry and refresh; may
be nulltransition - the sole transition (path) out of this state
protected State addViewState(java.lang.String stateId,
java.lang.String viewName,
Action renderAction,
Transition[] transitions)
stateId - the state identifierviewName - the string-encoded view selectorrenderAction - the action to execute on state entry and refresh; may
be nulltransitions - the transitions (paths) out of this state
protected State addViewState(java.lang.String stateId,
Action[] entryActions,
ViewSelector viewSelector,
Action[] renderActions,
Transition[] transitions,
FlowExecutionExceptionHandler[] exceptionHandlers,
Action[] exitActions,
AttributeMap attributes)
stateId - the state identifierentryActions - the actions to execute when the state is enteredviewSelector - the view selector that will make the view selection
when the state is enteredrenderActions - any 'render actions' to execute on state entry and
refresh; may be nulltransitions - the transitions (path) out of this stateexceptionHandlers - any exception handlers to attach to the stateexitActions - the actions to execute when the state exitsattributes - attributes to assign to the state that may be used to
affect state construction and execution
protected State addActionState(java.lang.String stateId,
Action action,
Transition transition)
stateId - the state identifieraction - the single action to execute when the state is enteredtransition - the single transition (path) out of this state
protected State addActionState(java.lang.String stateId,
Action action,
Transition[] transitions)
stateId - the state identifieraction - the single action to execute when the state is enteredtransitions - the transitions (paths) out of this state
protected State addActionState(java.lang.String stateId,
Action action,
Transition transition,
FlowExecutionExceptionHandler exceptionHandler)
stateId - the state identifieraction - the single action to execute when the state is enteredtransition - the single transition (path) out of this stateexceptionHandler - the exception handler to handle exceptions thrown
by the action
protected State addActionState(java.lang.String stateId,
Action[] entryActions,
Action[] actions,
Transition[] transitions,
FlowExecutionExceptionHandler[] exceptionHandlers,
Action[] exitActions,
AttributeMap attributes)
stateId - the state identifierentryActions - any generic entry actions to add to the stateactions - the actions to execute in a chain when the state is
enteredtransitions - the transitions (paths) out of this stateexceptionHandlers - the exception handlers to handle exceptions
thrown by the actionsexitActions - the exit actions to execute when the state exitsattributes - attributes to assign to the state that may be used to
affect state construction and execution
protected State addDecisionState(java.lang.String stateId,
Transition[] transitions)
stateId - the state identifiertransitions - the transitions (paths) out of this state
protected State addDecisionState(java.lang.String stateId,
TransitionCriteria decisionCriteria,
java.lang.String trueStateId,
java.lang.String falseStateId)
stateId - the state identifierdecisionCriteria - the criteria that defines the decisiontrueStateId - the target state on a "true" decisionfalseStateId - the target state on a "false" decision
protected State addDecisionState(java.lang.String stateId,
Action[] entryActions,
Transition[] transitions,
FlowExecutionExceptionHandler[] exceptionHandlers,
Action[] exitActions,
AttributeMap attributes)
stateId - the state identifierentryActions - the entry actions to execute when the state enterstransitions - the transitions (paths) out of this stateexceptionHandlers - the exception handlers to handle exceptions
thrown by the stateexitActions - the exit actions to execute when the state exitsattributes - attributes to assign to the state that may be used to
affect state construction and execution
protected State addSubflowState(java.lang.String stateId,
Flow subflow,
FlowAttributeMapper attributeMapper,
Transition transition)
stateId - the state identifiersubflow - the flow that will act as the subflowattributeMapper - the mapper to map subflow input and output
attributestransition - the single transition (path) out of the state
protected State addSubflowState(java.lang.String stateId,
Flow subflow,
FlowAttributeMapper attributeMapper,
Transition[] transitions)
stateId - the state identifiersubflow - the flow that will act as the subflowattributeMapper - the mapper to map subflow input and output
attributestransitions - the transitions (paths) out of the state
protected State addSubflowState(java.lang.String stateId,
Action[] entryActions,
Flow subflow,
FlowAttributeMapper attributeMapper,
Transition[] transitions,
FlowExecutionExceptionHandler[] exceptionHandlers,
Action[] exitActions,
AttributeMap attributes)
stateId - the state identifierentryActions - the entry actions to execute when the state enterssubflow - the flow that will act as the subflowattributeMapper - the mapper to map subflow input and output
attributestransitions - the transitions (paths) out of this stateexceptionHandlers - the exception handlers to handle exceptions
thrown by the stateexitActions - the exit actions to execute when the state exitsattributes - attributes to assign to the state that may be used to
affect state construction and execution
protected State addEndState(java.lang.String stateId)
stateId - the state identifier
protected State addEndState(java.lang.String stateId,
java.lang.String viewName)
stateId - the state identifierviewName - the string-encoded view selector
protected State addEndState(java.lang.String stateId,
java.lang.String viewName,
org.springframework.binding.mapping.AttributeMapper outputMapper)
stateId - the state identifierviewName - the string-encoded view selectoroutputMapper - the output mapper to map output attributes for the
end state (a flow outcome)
protected State addEndState(java.lang.String stateId,
Action[] entryActions,
ViewSelector viewSelector,
org.springframework.binding.mapping.AttributeMapper outputMapper,
FlowExecutionExceptionHandler[] exceptionHandlers,
AttributeMap attributes)
stateId - the state identifierentryActions - the actions to execute when the state is enteredviewSelector - the view selector that will make the view selection
when the state is enteredoutputMapper - the output mapper to map output attributes for the
end state (a flow outcome)exceptionHandlers - any exception handlers to attach to the stateattributes - attributes to assign to the state that may be used to
affect state construction and execution
public ViewSelector viewSelector(java.lang.String viewName)
TextToViewSelector for information on the
conversion rules.
viewName - the encoded view selector
protected Action action(java.lang.String id)
throws FlowArtifactLookupException
id - the action id
FlowArtifactLookupException - the action could not be resolved
protected Action action(java.lang.String beanId,
org.springframework.binding.method.MethodSignature methodSignature)
throws FlowArtifactLookupException
beanId - the id identifying an arbitrary
java.lang.Object to be used as an actionmethodSignature - the signature of the method to invoke on the POJO
FlowArtifactLookupException - the action could not be resolved
protected Action action(java.lang.String beanId,
org.springframework.binding.method.MethodSignature methodSignature,
ActionResultExposer resultExposer)
throws FlowArtifactLookupException
beanId - the id identifying an arbitrary
java.lang.Object to be used as an actionmethodSignature - the signature of the method to invoke on the POJO
FlowArtifactLookupException - the action could not be resolvedprotected Action action(org.springframework.binding.expression.Expression expression)
expression - the expression to evaluate
protected Action action(org.springframework.binding.expression.Expression expression,
ActionResultExposer resultExposer)
expression - the expression to evaluateresultExposer - the evaluation result exposerprotected org.springframework.binding.expression.Expression expression(java.lang.String expressionString)
Expression
object.
expressionString - the expression string, e.g. flowScope.order.number
protected org.springframework.binding.method.MethodSignature method(java.lang.String method)
MethodSignature
object. Method signatures are used to match methods on POJO services to
invoke on a bean invoking action.
Encoded method signature format: Method without arguments:
${methodName}
Method with arguments:
${methodName}(${arg1}, ${arg2}, ${arg n})
method - the encoded method signature
action(String, MethodSignature, ActionResultExposer)protected ActionResultExposer result(java.lang.String resultName)
result exposer. A
result exposer is used to expose an action result such as a method return
value or expression evaluation result to the calling flow.
resultName - the result name
action(String, MethodSignature, ActionResultExposer)
protected ActionResultExposer result(java.lang.String resultName,
ScopeType resultScope)
result exposer. A
result exposer is used to expose an action result such as a method return
value or expression evaluation result to the calling flow.
resultName - the result nameresultScope - the scope of the result
action(String, MethodSignature, ActionResultExposer)
protected AnnotatedAction invoke(java.lang.String methodName,
MultiAction multiAction)
throws FlowArtifactLookupException
method(String) factory
method when working with
bean invoking actions.
methodName - the name of the method on the multi action instancemultiAction - the multi action
FlowArtifactLookupException
protected FlowAttributeMapper attributeMapper(java.lang.String id)
throws FlowArtifactLookupException
id - the id of the attribute mapper that will map attributes between
the flow built by this builder and the subflow
FlowArtifactLookupException - no FlowAttributeMapper implementation
was exported with the specified id
protected Flow flow(java.lang.String id)
throws FlowArtifactLookupException
Flow with the specified flowId be spawned
as a subflow when the subflow state being built is entered. Simply
resolves the subflow definition by id and returns it; throwing a
fail-fast exception if it does not exist.
id - the flow definition id
FlowArtifactLookupException - when the flow cannot be resolvedprotected TransitionCriteria on(java.lang.String transitionCriteriaExpression)
transitionCriteriaExpression - the transition criteria expression,
typically simply a static event identifier (e.g. "submit")
protected TargetStateResolver to(java.lang.String targetStateIdExpression)
targetStateIdExpression - the target state id expression
protected Transition transition(TransitionCriteria matchingCriteria,
TargetStateResolver targetStateResolver)
matchingCriteria - the criteria that determines when the transition
matchestargetStateResolver - the resolver of the transition's target state
protected Transition transition(TransitionCriteria matchingCriteria,
TargetStateResolver targetStateResolver,
TransitionCriteria executionCriteria)
matchingCriteria - the criteria that determines when the transition
matchestargetStateResolver - the resolver of the transition's target stateexecutionCriteria - the criteria that determines if a matched
transition is allowed to execute
protected Transition transition(TransitionCriteria matchingCriteria,
TargetStateResolver targetStateResolver,
TransitionCriteria executionCriteria,
AttributeMap attributes)
matchingCriteria - the criteria that determines when the transition
matchestargetStateResolver - the resolver of the transition's target stateexecutionCriteria - the criteria that determines if a matched
transition is allowed to executeattributes - transition attributes
protected TransitionCriteria ifReturnedSuccess(Action action)
TransitionCriteria that will execute the
specified action when the Transition is executed but before the
transition's target state is entered.
This criteria will only allow the Transition to complete execution if the Action completes successfully.
action - the action to execute after a transition is matched but
before it transitions to its target state
protected java.lang.String success()
success event id. "Success" indicates that an
action completed successfuly.
protected java.lang.String error()
error event id. "Error" indicates that an
action completed with an error status.
protected java.lang.String submit()
submit event id. "Submit" indicates the user
submitted a request (form) for processing.
protected java.lang.String back()
back event id. "Back" indicates the user wants
to go to the previous step in the flow.
protected java.lang.String cancel()
cancel event id. "Cancel" indicates the flow
was aborted because the user changed their mind.
protected java.lang.String finish()
finish event id. "Finish" indicates the flow
has finished processing.
protected java.lang.String select()
select event id. "Select" indicates an object
was selected for processing or display.
protected java.lang.String edit()
edit event id. "Edit" indicates an object was
selected for creation or updating.
protected java.lang.String add()
add event id. "Add" indicates a child object
is being added to a parent collection.
protected java.lang.String delete()
delete event id. "Delete" indicates a object
is being removed.
protected java.lang.String yes()
yes event id. "Yes" indicates a true result
was returned.
protected java.lang.String no()
no event id. "False" indicates a false result
was returned.
protected org.springframework.binding.mapping.MappingBuilder mapping()
Mapping objects used by a
FlowAttributeMapper to map attributes.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||