Package org.springframework.batch.core.job.flow

Examples of org.springframework.batch.core.job.flow.State


  @Test
  public void testStoppingStep() throws Exception {
    SimpleFlow flow = new JsrFlow("job");
    List<StateTransition> transitions = new ArrayList<StateTransition>();
    transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "step2"));
    State state2 = new StateSupport("step2", FlowExecutionStatus.FAILED);
    transitions.add(StateTransition.createStateTransition(state2, ExitStatus.FAILED.getExitCode(), "end0"));
    transitions.add(StateTransition.createStateTransition(state2, ExitStatus.COMPLETED.getExitCode(), "end1"));
    transitions.add(StateTransition.createStateTransition(new EndState(FlowExecutionStatus.STOPPED, "end0"),
        "step3"));
    transitions.add(StateTransition.createEndStateTransition(new EndState(FlowExecutionStatus.COMPLETED, "end1")));
View Full Code Here


  @Override
  public FlowExecution start(FlowExecutor executor) throws FlowExecutionException {
    if (startState == null) {
      initializeTransitions();
    }
    State state = startState;
    String stateName = state.getName();
    return resume(stateName, executor);
  }
View Full Code Here

   */
  @Override
  public FlowExecution resume(String stateName, FlowExecutor executor) throws FlowExecutionException {

    FlowExecutionStatus status = FlowExecutionStatus.UNKNOWN;
    State state = stateMap.get(stateName);

    logger.debug("Resuming state="+stateName+" with status="+status);
    StepExecution stepExecution = null;

    // Terminate if there are no more states
    while (isFlowContinued(state, status, stepExecution)) {
      stateName = state.getName();

      try {
        logger.debug("Handling state="+stateName);
        status = state.handle(executor);
        stepExecution = executor.getStepExecution();
      }
      catch (FlowExecutionException e) {
        executor.close(new FlowExecution(stateName, status));
        throw e;
View Full Code Here

    if (stateTransitions.isEmpty()) {
      throw new IllegalArgumentException("No start state was found. You must specify at least one step in a job.");
    }

    for (StateTransition stateTransition : stateTransitions) {
      State state = stateTransition.getState();
      String stateName = state.getName();
      stateMap.put(stateName, state);
    }

    for (StateTransition stateTransition : stateTransitions) {

      State state = stateTransition.getState();

      if (!stateTransition.isEnd()) {

        String next = stateTransition.getNext();

        if (!stateMap.containsKey(next)) {
          throw new IllegalArgumentException("Missing state for [" + stateTransition + "]");
        }

      }
      else {
        hasEndStep = true;
      }

      String name = state.getName();

      Set<StateTransition> set = transitionMap.get(name);
      if (set == null) {
        // If no comparator is provided, we will maintain the order of insertion
        if(stateTransitionComparator == null) {
View Full Code Here

  private void doNext(Object input) {
    if (this.currentState == null) {
      doStart(input);
    }
    State next = createState(input);
    addTransition("COMPLETED", next);
    addTransition("*", failedState);
    this.currentState = next;
  }
View Full Code Here

  private void doFrom(Object input) {
    if (currentState == null) {
      doStart(input);
    }
    State state = createState(input);
    tos.put(currentState.getName(), currentState);
    this.currentState = state;
  }
View Full Code Here

    tos.put(currentState.getName(), currentState);
    this.currentState = state;
  }

  private State createState(Object input) {
    State result;
    if (input instanceof Step) {
      if (!states.containsKey(input)) {
        Step step = (Step) input;
        states.put(input, new StepState(prefix + step.getName(), step));
      }
View Full Code Here

    StepExecution stepExecution = new StepExecution("step1", new JobExecution(5L));
    stepExecution.setExitStatus(new ExitStatus("unmapped exit code"));
    stepExecution.setStatus(BatchStatus.FAILED);
    executor = new FlowExecutor(stepExecution);

    State startState = new StateSupport("step1", new FlowExecutionStatus("unmapped exit code"));
    State endState = new StateSupport("failed", FlowExecutionStatus.FAILED);

    StateTransition failureTransition = StateTransition.createStateTransition(startState, "FAILED", "failed");
    StateTransition endTransition = StateTransition.createEndStateTransition(endState);
    flow.setStateTransitions(collect(failureTransition, endTransition));
    flow.afterPropertiesSet();
View Full Code Here

  @Test
  public void testGetStateExists() throws Exception {
    flow.setStateTransitions(Collections.singletonList(StateTransition.createEndStateTransition(new StubState(
        "step1"))));
    flow.afterPropertiesSet();
    State state = flow.getState("step1");
    assertNotNull(state);
    assertEquals("step1", state.getName());
  }
View Full Code Here

  @Test
  public void testGetStateDoesNotExist() throws Exception {
    flow.setStateTransitions(Collections.singletonList(StateTransition.createEndStateTransition(new StubState(
        "step1"))));
    flow.afterPropertiesSet();
    State state = flow.getState("bar");
    assertNull(state);
  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.core.job.flow.State

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.