Package org.springframework.batch.repeat.support

Examples of org.springframework.batch.repeat.support.RepeatTemplate


  }

  protected RepeatOperations createChunkOperations() {
    RepeatOperations repeatOperations = chunkOperations;
    if (repeatOperations == null) {
      RepeatTemplate repeatTemplate = new RepeatTemplate();
      repeatTemplate.setCompletionPolicy(getChunkCompletionPolicy());
      repeatOperations = repeatTemplate;
    }
    return repeatOperations;
  }
View Full Code Here


      step.setTransactionAttribute(transactionAttribute);
    }

    if (stepOperations == null) {

      stepOperations = new RepeatTemplate();

      if (taskExecutor != null) {
        TaskExecutorRepeatTemplate repeatTemplate = new TaskExecutorRepeatTemplate();
        repeatTemplate.setTaskExecutor(taskExecutor);
        repeatTemplate.setThrottleLimit(throttleLimit);
View Full Code Here

      new JobInstance(123L, "job"), new JobParameters())));

  @Test
  public void testProvide() throws Exception {
    provider = new FaultTolerantChunkProvider<String>(new ListItemReader<String>(Arrays.asList("foo", "bar")),
        new RepeatTemplate());
    Chunk<String> chunk = provider.provide(contribution);
    assertNotNull(chunk);
    assertEquals(2, chunk.getItems().size());
  }
View Full Code Here

    provider = new FaultTolerantChunkProvider<String>(new ItemReader<String>() {
      @Override
      public String read() throws Exception, UnexpectedInputException, ParseException {
        throw new RuntimeException("Planned");
      }
    }, new RepeatTemplate());
    provider.setSkipPolicy(new LimitCheckingItemSkipPolicy(Integer.MAX_VALUE, Collections.<Class<? extends Throwable>,Boolean>singletonMap(Exception.class, Boolean.TRUE)));
    provider.setMaxSkipsOnRead(10);
    Chunk<String> chunk = null;
    chunk = provider.provide(contribution);
    assertNotNull(chunk);
View Full Code Here

      step.setTransactionAttribute(getTransactionAttribute());
    }

    if (getStepOperations() == null) {

      stepOperations(new RepeatTemplate());

      if (getTaskExecutor() != null) {
        TaskExecutorRepeatTemplate repeatTemplate = new TaskExecutorRepeatTemplate();
        repeatTemplate.setTaskExecutor(getTaskExecutor());
        repeatTemplate.setThrottleLimit(getThrottleLimit());
View Full Code Here

    tasklet.setBuffering(!isReaderTransactionalQueue());
    return tasklet;
  }

  private RepeatOperations createRepeatOperations() {
    RepeatTemplate repeatOperations = new RepeatTemplate();
    repeatOperations.setCompletionPolicy(getChunkCompletionPolicy());
    repeatOperations.setExceptionHandler(getExceptionHandler());
    return repeatOperations;
  }
View Full Code Here

      step.setTransactionAttribute(getTransactionAttribute());
    }

    if (getStepOperations() == null) {

      stepOperations(new RepeatTemplate());

      if (getTaskExecutor() != null) {
        TaskExecutorRepeatTemplate repeatTemplate = new TaskExecutorRepeatTemplate();
        repeatTemplate.setTaskExecutor(getTaskExecutor());
        repeatTemplate.setThrottleLimit(getThrottleLimit());
View Full Code Here

public class RepeatListenerTests extends TestCase {

  int count = 0;

  public void testBeforeInterceptors() throws Exception {
    RepeatTemplate template = new RepeatTemplate();
    final List<Object> calls = new ArrayList<Object>();
    template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
            @Override
      public void before(RepeatContext context) {
        calls.add("1");
      }
    }, new RepeatListenerSupport() {
            @Override
      public void before(RepeatContext context) {
        calls.add("2");
      }
    } });
    template.iterate(new RepeatCallback() {
            @Override
      public RepeatStatus doInIteration(RepeatContext context) throws Exception {
        count++;
        return RepeatStatus.continueIf(count <= 1);
      }
View Full Code Here

    // ... but the interceptor before() was called:
    assertEquals("[1, 2, 1, 2]", calls.toString());
  }

  public void testBeforeInterceptorCanVeto() throws Exception {
    RepeatTemplate template = new RepeatTemplate();
    final List<Object> calls = new ArrayList<Object>();
    template.registerListener(new RepeatListenerSupport() {
            @Override
      public void before(RepeatContext context) {
        calls.add("1");
        context.setCompleteOnly();
      }
    });
    template.iterate(new RepeatCallback() {
            @Override
      public RepeatStatus doInIteration(RepeatContext context) throws Exception {
        count++;
        return RepeatStatus.FINISHED;
      }
View Full Code Here

    // ... but the interceptor before() was called:
    assertEquals("[1]", calls.toString());
  }

  public void testAfterInterceptors() throws Exception {
    RepeatTemplate template = new RepeatTemplate();
    final List<Object> calls = new ArrayList<Object>();
    template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
            @Override
      public void after(RepeatContext context, RepeatStatus result) {
        calls.add("1");
      }
    }, new RepeatListenerSupport() {
            @Override
      public void after(RepeatContext context, RepeatStatus result) {
        calls.add("2");
      }
    } });
    template.iterate(new RepeatCallback() {
            @Override
      public RepeatStatus doInIteration(RepeatContext context) throws Exception {
        count++;
        return RepeatStatus.continueIf(count <= 1);
      }
View Full Code Here

TOP

Related Classes of org.springframework.batch.repeat.support.RepeatTemplate

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.