Class FlowBuilder<Q>

  • Type Parameters:
    Q - the type of object returned by the builder (by default a Flow)
    Direct Known Subclasses:
    JobFlowBuilder

    public class FlowBuilder<Q>
    extends java.lang.Object
    A builder for a flow of steps that can be executed as a job or as part of a job. Steps can be linked together with conditional transitions that depend on the exit status of the previous step.
    Since:
    2.2
    Author:
    Dave Syer, Michael Minella
    • Constructor Detail

      • FlowBuilder

        public FlowBuilder​(java.lang.String name)
    • Method Detail

      • build

        public Q build()
        Validate the current state of the builder and build a flow. Subclasses may override this to build an object of a different type that itself depends on the flow.
        Returns:
        a flow
      • next

        public FlowBuilder<Q> next​(Step step)
        Transition to the next step on successful completion of the current step. All other outcomes are treated as failures.
        Parameters:
        step - the next step
        Returns:
        this to enable chaining
      • start

        public FlowBuilder<Q> start​(Step step)
        Start a flow. If some steps are already registered, just a synonym for from(Step).
        Parameters:
        step - the step to start with
        Returns:
        this to enable chaining
      • from

        public FlowBuilder<Q> from​(Step step)
        Go back to a previously registered step and start a new path. If no steps are registered yet just a synonym for start(Step).
        Parameters:
        step - the step to start from (already registered)
        Returns:
        this to enable chaining
      • next

        public FlowBuilder.UnterminatedFlowBuilder<Q> next​(JobExecutionDecider decider)
        Transition to the decider on successful completion of the current step. All other outcomes are treated as failures.
        Parameters:
        decider - the JobExecutionDecider to determine the next step to execute
        Returns:
        this to enable chaining
      • next

        public FlowBuilder<Q> next​(Flow flow)
        Go next on successful completion to a subflow.
        Parameters:
        flow - the flow to go to
        Returns:
        a builder to enable chaining
      • from

        public FlowBuilder<Q> from​(Flow flow)
        Start again from a subflow that was already registered.
        Parameters:
        flow - the flow to start from (already registered)
        Returns:
        a builder to enable chaining
      • start

        public FlowBuilder<Q> start​(Flow flow)
        If a flow should start with a subflow use this as the first state.
        Parameters:
        flow - the flow to start from
        Returns:
        a builder to enable chaining
      • split

        public FlowBuilder.SplitBuilder<Q> split​(org.springframework.core.task.TaskExecutor executor)
        Parameters:
        executor - a task executor to execute the split flows
        Returns:
        a builder to enable fluent chaining
      • on

        public FlowBuilder.TransitionBuilder<Q> on​(java.lang.String pattern)
        Start a transition to a new state if the exit status from the previous state matches the pattern given. Successful completion normally results in an exit status equal to (or starting with by convention) "COMPLETED". See ExitStatus for commonly used values.
        Parameters:
        pattern - the pattern of exit status on which to take this transition
        Returns:
        a builder to enable fluent chaining
      • end

        public final Q end()
        A synonym for build() which callers might find useful. Subclasses can override build to create an object of the desired type (e.g. a parent builder or an actual flow).
        Returns:
        the result of the builder
      • flow

        protected Flow flow()
      • stop

        protected void stop​(java.lang.String pattern)
      • stop

        protected void stop​(java.lang.String pattern,
                            State restart)