Package org.springframework.batch.item

Examples of org.springframework.batch.item.ExecutionContext


        return FlowExecutionStatus.UNKNOWN;
      }

      if (getStatus().isStop()) {
        JobExecution jobExecution = stepExecution.getJobExecution();
        ExecutionContext executionContext = jobExecution.getExecutionContext();
        executionContext.put("batch.restartStep", restart);
        executionContext.put("batch.stoppedStep", stepExecution.getStepName());
        jobRepository.updateExecutionContext(jobExecution);

        if (!executor.isRestart()) {
          /*
           * If there are step executions, then we are not at the
View Full Code Here


    assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
    assertEquals(4, stepExecution.getWriteCount());
    assertEquals(6, stepExecution.getReadCount());

    fail = false;
    ExecutionContext executionContext = stepExecution.getExecutionContext();
    stepExecution = new StepExecution(step.getName(), jobExecution);
    stepExecution.setExecutionContext(executionContext);
    repository.add(stepExecution);
    step.execute(stepExecution);
View Full Code Here

    assertEquals(8, count);
  }

  @Test
  public void testOpen() throws Exception {
    ExecutionContext context = new ExecutionContext();
    for (int i=0; i<4; i++) {
      reader.read();
    }
    reader.update(context);
    reader.open(context);
View Full Code Here

    assertEquals(4, count);   
  }

  @Test
  public void testFailAndRestart() throws Exception {
    ExecutionContext context = new ExecutionContext();
    ExampleItemReader.fail = true;
    for (int i=0; i<4; i++) {
      reader.read();
      reader.update(context);
    }
View Full Code Here

        if(plan.getPartitionsOverride()) {
          partitionStepExecutions = applyPartitionPlan(stepExecution, plan, false);

          for (StepExecution curStepExecution : partitionStepExecutions) {
            curStepExecution.setExecutionContext(new ExecutionContext());
          }
        } else {
          Properties[] partitionProps = plan.getPartitionProperties();

          plan = (PartitionPlanState) stepExecution.getExecutionContext().get("partitionPlanState");
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  @Override
  protected void doExecute(StepExecution stepExecution) throws Exception {
    ExecutionContext executionContext = stepExecution.getJobExecution().getExecutionContext();
    List<javax.batch.runtime.StepExecution> stepExecutions = new ArrayList<javax.batch.runtime.StepExecution>();

    if(executionContext.containsKey("batch.lastSteps")) {
      List<String> stepNames = (List<String>) executionContext.get("batch.lastSteps");

      for (String stepName : stepNames) {
        StepExecution curStepExecution = getJobRepository().getLastStepExecution(stepExecution.getJobExecution().getJobInstance(), stepName);
        stepExecutions.add(new JsrStepExecution(curStepExecution));
      }
    } else {
      Collection<StepExecution> currentRunStepExecutions = stepExecution.getJobExecution().getStepExecutions();

      StepExecution lastExecution = null;

      if(stepExecutions != null) {
        for (StepExecution curStepExecution : currentRunStepExecutions) {
          if(lastExecution == null || (curStepExecution.getEndTime() != null && curStepExecution.getEndTime().after(lastExecution.getEndTime()))) {
            lastExecution = curStepExecution;
          }
        }

        stepExecutions.add(new JsrStepExecution(lastExecution));
      }
    }

    try {
      ExitStatus exitStatus = new ExitStatus(decider.decide(stepExecutions.toArray(new javax.batch.runtime.StepExecution[0])));

      stepExecution.getJobExecution().setExitStatus(exitStatus);
      stepExecution.setExitStatus(exitStatus);

      if(executionContext.containsKey("batch.lastSteps")) {
        executionContext.remove("batch.lastSteps");
      }
    } catch (Exception e) {
      stepExecution.setTerminateOnly();
      stepExecution.addFailureException(e);
      throw e;
View Full Code Here

   * Save execution context and retrieve it.
   */
  @Transactional
  @Test
  public void testSaveExecutionContext() throws Exception {
    @SuppressWarnings("serial")
    ExecutionContext ctx = new ExecutionContext() {
      {
        putLong("crashedPosition", 7);
      }
    };
    JobExecution jobExec = jobRepository.createJobExecution(job.getName(), jobParameters);
View Full Code Here

    for(int i = 0; i < gridSize; i++) {
      String stepName = this.stepName + ":partition" + i;
      JobExecution curJobExecution = new JobExecution(jobExecution);
      StepExecution curStepExecution = new StepExecution(stepName, curJobExecution);

      if(!restoreState || getStartable(curStepExecution, new ExecutionContext())) {
        executions.add(curStepExecution);
      }
    }

    jobRepository.addAll(executions);
View Full Code Here

    reader.close();
   
    reader.setResource(new ByteArrayResource("<foos />".getBytes()));
    reader.afterPropertiesSet();
   
    reader.open(new ExecutionContext());
  }
View Full Code Here

  public void setUp() throws Exception {
    File directory = new File("build/data");
    directory.mkdirs();
    resource = new FileSystemResource(File.createTempFile("StaxEventWriterOutputSourceTests", ".xml", directory));
    writer = createItemWriter();
    executionContext = new ExecutionContext();
    jaxbMarshaller = new Jaxb2Marshaller();
    jaxbMarshaller.setClassesToBeBound(JAXBItem.class);
  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.item.ExecutionContext

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.