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, Taeik Lim
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Locate 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 boolean
isFlowContinued
(State state, FlowExecutionStatus status, StepExecution stepExecution) protected State
nextState
(String stateName, FlowExecutionStatus status, StepExecution stepExecution) resume
(String stateName, FlowExecutor executor) void
setStateTransitionComparator
(Comparator<StateTransition> stateTransitionComparator) void
setStateTransitions
(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:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
- See Also:
-
InitializingBean.afterPropertiesSet()
-
start
- Specified by:
start
in interfaceFlow
- Parameters:
executor
- theFlowExecutor
instance to use for the flow execution.- Returns:
- a
FlowExecution
containing the exit status of the flow. - Throws:
FlowExecutionException
- thrown if error occurs during flow execution.- See Also:
-
resume
- Specified by:
resume
in interfaceFlow
- Parameters:
stateName
- the name of the state to resume on.executor
- the context to be passed into each state executed.- Returns:
- a
FlowExecution
containing 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
-FlowExecutionStatus
instance.stepExecution
-StepExecution
instance.- 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)
-