Package org.springframework.batch.core

Examples of org.springframework.batch.core.StepContribution


        Tasklet tasklet = new Tasklet() {
            public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
                return RepeatStatus.FINISHED;
            }
        };
        StepContribution contribution = Mockito.mock(StepContribution.class);
        StepExecution stepExecution = createStepExecution("testExecuteJob", "testExecuteStep");
        StepContext stepContext = Mockito.mock(StepContext.class);
        Mockito.when(stepContext.getStepExecution()).thenReturn(stepExecution);

        ChunkContext chunkContext = Mockito.mock(ChunkContext.class);
View Full Code Here


  }

  public Collection<StepContribution> getStepContributions() {
    List<StepContribution> contributions = new ArrayList<StepContribution>();
    for (ChunkResponse response : localState.pollChunkResponses()) {
      StepContribution contribution = response.getStepContribution();
      if (logger.isDebugEnabled()) {
        logger.debug("Applying: " + response);
      }
      contributions.add(contribution);
    }
View Full Code Here

  @ServiceActivator
  public ChunkResponse handleChunk(ChunkRequest<S> chunkRequest) throws Exception {

    logger.debug("Handling chunk: " + chunkRequest);

    StepContribution stepContribution = chunkRequest.getStepContribution();

    Throwable failure = process(chunkRequest, stepContribution);
    if (failure != null) {
      logger.debug("Failed chunk", failure);
      return new ChunkResponse(false, chunkRequest.getSequence(), chunkRequest.getJobId(), stepContribution, failure.getClass().getName()
View Full Code Here

    handler.setChunkProcessor(new ChunkProcessor<Object>() {
      public void process(StepContribution contribution, Chunk<Object> chunk) throws Exception {
        count += chunk.size();
      }
    });
    StepContribution stepContribution = MetaDataInstanceFactory.createStepExecution().createStepContribution();
    ChunkResponse response = handler.handleChunk(new ChunkRequest<Object>(0, StringUtils
            .commaDelimitedListToSet("foo,bar"), 12L, stepContribution));
    assertEquals(stepContribution, response.getStepContribution());
    assertEquals(12, response.getJobId().longValue());
    assertTrue(response.isSuccessful());
View Full Code Here

   * @param string
   * @return
   */
  @SuppressWarnings({"unchecked", "rawtypes"})
  private GenericMessage<ChunkRequest> getSimpleMessage(String string, Long jobId) {
    StepContribution stepContribution = new JobExecution(new JobInstance(0L, "job"), new JobParameters())
    .createStepExecution("step").createStepContribution();
    ChunkRequest chunk = new ChunkRequest(0, StringUtils.commaDelimitedListToSet(string), jobId, stepContribution);
    GenericMessage<ChunkRequest> message = new GenericMessage<ChunkRequest>(chunk);
    return message;
  }
View Full Code Here

   * @param string
   * @return
   */
  @SuppressWarnings({"unchecked", "rawtypes"})
  private GenericMessage<ChunkRequest> getSimpleMessage(String string, Long jobId) {
    StepContribution stepContribution = new JobExecution(new JobInstance(0L, "job"), new JobParameters())
    .createStepExecution("step").createStepContribution();
    ChunkRequest chunk = new ChunkRequest(0, StringUtils.commaDelimitedListToSet(string), jobId, stepContribution);
    GenericMessage<ChunkRequest> message = new GenericMessage<ChunkRequest>(chunk);
    return message;
  }
View Full Code Here

      @Override
      public void process(StepContribution contribution, Chunk<String> chunk) {
        contribution.incrementWriteCount(1);
      }
    });
    StepContribution contribution = new StepContribution(new StepExecution("foo", new JobExecution(new JobInstance(
        123L, "job"),new JobParameters())));
    handler.execute(contribution, context);
    assertEquals(1, contribution.getReadCount());
    assertEquals(1, contribution.getWriteCount());
    assertEquals(0, context.attributeNames().length);
  }
View Full Code Here

      @Override
      public void process(StepContribution contribution, Chunk<String> chunk) {
        fail("Not expecting to get this far");
      }
    });
    StepContribution contribution = new StepContribution(new StepExecution("foo", new JobExecution(new JobInstance(
        123L, "job"), new JobParameters())));
    try {
      handler.execute(contribution, context);
      fail("Expected RuntimeException");
    }
    catch (RuntimeException e) {
      assertEquals("Foo!", e.getMessage());
    }
    assertEquals(0, contribution.getReadCount());
  }
View Full Code Here

      @Override
      public void process(StepContribution contribution, Chunk<String> chunk) {
        contribution.incrementWriteCount(1);
      }
    });
    StepContribution contribution = new StepContribution(new StepExecution("foo", new JobExecution(new JobInstance(
        123L, "job"), new JobParameters())));
    ExitStatus expected = contribution.getExitStatus();
    handler.execute(contribution, context);
    // The tasklet does not change the exit code
    assertEquals(expected, contribution.getExitStatus());
  }
View Full Code Here

    public RepeatStatus doInTransaction(TransactionStatus status) {
      TransactionSynchronizationManager.registerSynchronization(this);

      RepeatStatus result = RepeatStatus.CONTINUABLE;

      StepContribution contribution = stepExecution.createStepContribution();

      chunkListener.beforeChunk(chunkContext);

      // In case we need to push it back to its old value
      // after a commit fails...
View Full Code Here

TOP

Related Classes of org.springframework.batch.core.StepContribution

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.