Example usage for org.springframework.batch.core.job.flow FlowExecutionException FlowExecutionException

List of usage examples for org.springframework.batch.core.job.flow FlowExecutionException FlowExecutionException

Introduction

In this page you can find the example usage for org.springframework.batch.core.job.flow FlowExecutionException FlowExecutionException.

Prototype

public FlowExecutionException(String message) 

Source Link

Usage

From source file:org.springframework.batch.core.job.flow.support.SimpleFlow.java

/**
 * @return the next {@link Step} (or null if this is the end)
 * @throws org.springframework.batch.core.job.flow.FlowExecutionException
 *//* ww w  .j a v  a 2  s .  c o  m*/
protected State nextState(String stateName, FlowExecutionStatus status, StepExecution stepExecution)
        throws FlowExecutionException {
    Set<StateTransition> set = transitionMap.get(stateName);

    if (set == null) {
        throw new FlowExecutionException(
                String.format("No transitions found in flow=%s for state=%s", getName(), stateName));
    }

    String next = null;
    String exitCode = status.getName();

    for (StateTransition stateTransition : set) {
        if (stateTransition.matches(exitCode)
                || (exitCode.equals("PENDING") && stateTransition.matches("STOPPED"))) {
            if (stateTransition.isEnd()) {
                // End of job
                return null;
            }
            next = stateTransition.getNext();
            break;
        }
    }

    if (next == null) {
        throw new FlowExecutionException(
                String.format("Next state not found in flow=%s for state=%s with exit status=%s", getName(),
                        stateName, status.getName()));
    }

    if (!stateMap.containsKey(next)) {
        throw new FlowExecutionException(
                String.format("Next state not specified in flow=%s for next=%s", getName(), next));
    }

    return stateMap.get(next);

}