public class SimpleFlow extends java.lang.Object implements Flow, org.springframework.beans.factory.InitializingBean
Flow
that branches conditionally depending on the exit status of
the last State
. The input parameters are the state transitions (in no
particular order). The start state name can be specified explicitly (and must
exist in the set of transitions), or computed from the existing transitions,
if unambiguous.Constructor and Description |
---|
SimpleFlow(java.lang.String name)
Create a flow with the given name.
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Locate start state and pre-populate data structures needed for execution.
|
java.lang.String |
getName()
Get the name for this flow.
|
State |
getStartState() |
State |
getState(java.lang.String stateName)
Retrieve the State with the given name.
|
protected java.util.Map<java.lang.String,State> |
getStateMap() |
java.util.Collection<State> |
getStates()
Convenient accessor for clients needing to explore the states of this
flow.
|
protected java.util.Map<java.lang.String,java.util.Set<StateTransition>> |
getTransitionMap() |
protected boolean |
isFlowContinued(State state,
FlowExecutionStatus status,
StepExecution stepExecution) |
protected State |
nextState(java.lang.String stateName,
FlowExecutionStatus status,
StepExecution stepExecution) |
FlowExecution |
resume(java.lang.String stateName,
FlowExecutor executor) |
void |
setStateTransitionComparator(java.util.Comparator<StateTransition> stateTransitionComparator) |
void |
setStateTransitions(java.util.List<StateTransition> stateTransitions)
Public setter for the stateTransitions.
|
FlowExecution |
start(FlowExecutor executor) |
public SimpleFlow(java.lang.String name)
name
- the name of the flowpublic void setStateTransitionComparator(java.util.Comparator<StateTransition> stateTransitionComparator)
public State getStartState()
public java.lang.String getName()
getName
in interface Flow
Flow.getName()
public void setStateTransitions(java.util.List<StateTransition> stateTransitions)
stateTransitions
- the stateTransitions to setpublic State getState(java.lang.String stateName)
public java.util.Collection<State> getStates()
public void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception
InitializingBean.afterPropertiesSet()
public FlowExecution start(FlowExecutor executor) throws FlowExecutionException
start
in interface Flow
executor
- the FlowExecutor
instance to use for the flow execution.FlowExecution
containing the exit status of the flow.FlowExecutionException
- thrown if error occurs during flow execution.Flow.start(FlowExecutor)
public FlowExecution resume(java.lang.String stateName, FlowExecutor executor) throws FlowExecutionException
resume
in interface Flow
stateName
- the name of the state to resume on.executor
- the context to be passed into each state executed.FlowExecution
containing the exit status of the flow.FlowExecutionException
- thrown if error occurs during flow execution.Flow.resume(String, FlowExecutor)
protected java.util.Map<java.lang.String,java.util.Set<StateTransition>> getTransitionMap()
protected java.util.Map<java.lang.String,State> getStateMap()
protected State nextState(java.lang.String stateName, FlowExecutionStatus status, StepExecution stepExecution) throws FlowExecutionException
stateName
- the name of the next state.status
- FlowExecutionStatus
instance.stepExecution
- StepExecution
instance.Step
(or null if this is the end)FlowExecutionException
- thrown if error occurs during nextState processing.protected boolean isFlowContinued(State state, FlowExecutionStatus status, StepExecution stepExecution)