Class SimpleFlow
java.lang.Object
org.springframework.batch.core.job.flow.support.SimpleFlow
- All Implemented Interfaces:
Flow,org.springframework.beans.factory.InitializingBean
public class SimpleFlow
extends Object
implements Flow, org.springframework.beans.factory.InitializingBean
A
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.- Since:
- 2.0
- Author:
- Dave Syer, Michael Minella, Mahmoud Ben Hassine
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidLocate start state and pre-populate data structures needed for execution.getName()Get the name for this flow.Retrieve the State with the given name.Convenient accessor for clients needing to explore the states of this flow.protected Map<String,Set<StateTransition>> protected booleanisFlowContinued(State state, FlowExecutionStatus status, StepExecution stepExecution) protected StatenextState(String stateName, FlowExecutionStatus status, StepExecution stepExecution) resume(String stateName, FlowExecutor executor) voidsetStateTransitionComparator(Comparator<StateTransition> stateTransitionComparator) voidsetStateTransitions(List<StateTransition> stateTransitions) Public setter for the stateTransitions.start(FlowExecutor executor)
-
Constructor Details
-
SimpleFlow
Create a flow with the given name.- Parameters:
name- the name of the flow
-
-
Method Details
-
setStateTransitionComparator
-
getStartState
-
getName
Get the name for this flow. -
setStateTransitions
Public setter for the stateTransitions.- Parameters:
stateTransitions- the stateTransitions to set
-
getState
Retrieve the State with the given name. If there is no State with the given name, then return null. -
getStates
Convenient accessor for clients needing to explore the states of this flow. -
afterPropertiesSet
Locate start state and pre-populate data structures needed for execution.- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception- See Also:
-
InitializingBean.afterPropertiesSet()
-
start
- Specified by:
startin interfaceFlow- Parameters:
executor- theFlowExecutorinstance to use for the flow execution.- Returns:
- a
FlowExecutioncontaining the exit status of the flow. - Throws:
FlowExecutionException- thrown if error occurs during flow execution.- See Also:
-
resume
- Specified by:
resumein interfaceFlow- Parameters:
stateName- the name of the state to resume on.executor- the context to be passed into each state executed.- Returns:
- a
FlowExecutioncontaining the exit status of the flow. - Throws:
FlowExecutionException- thrown if error occurs during flow execution.- See Also:
-
getTransitionMap
-
getStateMap
-
nextState
protected State nextState(String stateName, FlowExecutionStatus status, StepExecution stepExecution) throws FlowExecutionException - Parameters:
stateName- the name of the next state.status-FlowExecutionStatusinstance.stepExecution-StepExecutioninstance.- Returns:
- the next
Step(or null if this is the end) - Throws:
FlowExecutionException- thrown if error occurs during nextState processing.
-
isFlowContinued
protected boolean isFlowContinued(State state, FlowExecutionStatus status, StepExecution stepExecution)
-