Package org.springframework.batch.repeat.policy

Examples of org.springframework.batch.repeat.policy.SimpleCompletionPolicy


  @Override
  public void beforeStep(StepExecution stepExecution) {
    JobParameters jobParameters = stepExecution.getJobParameters();
    Assert.state(jobParameters.getParameters().containsKey(keyName),
        "JobParameters do not contain Long parameter with key=[" + keyName + "]");
    delegate = new SimpleCompletionPolicy(jobParameters.getLong(keyName).intValue());
  }
View Full Code Here


  private TaskletStep getStep(String[] strings, int commitInterval) throws Exception {
    TaskletStep step = new TaskletStep("stepName");
    // Only process one item:
    RepeatTemplate template = new RepeatTemplate();
    template.setCompletionPolicy(new SimpleCompletionPolicy(commitInterval));
    step.setTasklet(new TestingChunkOrientedTasklet<String>(getReader(strings), itemWriter, template));
    step.setJobRepository(new JobRepositorySupport());
    step.setTransactionManager(transactionManager);
    return step;
  }
View Full Code Here

  public void setUp() throws Exception {

    transactionManager = new ResourcelessTransactionManager();

    RepeatTemplate template = new RepeatTemplate();
    template.setCompletionPolicy(new SimpleCompletionPolicy(1));

    step = getStep(new String[] { "foo", "bar", "spam" });
    step.setStepOperations(template);

    job = new JobSupport("FOO");
View Full Code Here

        return customStatus;
      }
    } });

    RepeatTemplate stepTemplate = new RepeatTemplate();
    stepTemplate.setCompletionPolicy(new SimpleCompletionPolicy(5));
    step.setStepOperations(stepTemplate);

    JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
    StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);
    step.execute(stepExecution);
View Full Code Here

    ResourcelessTransactionManager transactionManager = new ResourcelessTransactionManager();
    step.setTransactionManager(transactionManager);

    RepeatTemplate chunkTemplate = new RepeatTemplate();
    chunkTemplate.setCompletionPolicy(new SimpleCompletionPolicy(2));
    step.setTasklet(new TestingChunkOrientedTasklet<String>(new ListItemReader<String>(items), itemProcessor, itemWriter,
        chunkTemplate));

    jobRepository = new JobRepositorySupport();
    step.setJobRepository(jobRepository);
View Full Code Here

    step.setJobRepository(jobRepository);
    step.setTransactionManager(transactionManager);

    // Only process one item:
    chunkOperations = new RepeatTemplate();
    chunkOperations.setCompletionPolicy(new SimpleCompletionPolicy(1));

    job = new JobSupport("FOO");

    TaskExecutorRepeatTemplate repeatTemplate = new TaskExecutorRepeatTemplate();
    repeatTemplate.setThrottleLimit(2);
View Full Code Here

    Thread processingThread = createThread(stepExecution);

    RepeatTemplate template = new RepeatTemplate();
    // N.B, If we don't set the completion policy it might run forever
    template.setCompletionPolicy(new SimpleCompletionPolicy(2));
    step.setTasklet(new TestingChunkOrientedTasklet<Object>(new ItemReader<Object>() {
      @Override
      public Object read() throws Exception {
        // do something non-trivial (and not Thread.sleep())
        double foo = 1;
View Full Code Here

    step.setJobRepository(jobRepository);
    step.setTransactionManager(transactionManager);

    // Only process one item:
    chunkOperations = new RepeatTemplate();
    chunkOperations.setCompletionPolicy(new SimpleCompletionPolicy(1));

    job = new JobSupport("FOO");

    step.setTransactionManager(transactionManager);
View Full Code Here

  public void testVoidServiceSunnyDay() throws Exception {
    ((Advised) service).addAdvice(interceptor);
    RepeatTemplate template = new RepeatTemplate();
    // N.B. the default completion policy results in an infinite loop, so we
    // need to set the chunk size.
    template.setCompletionPolicy(new SimpleCompletionPolicy(2));
    interceptor.setRepeatOperations(template);
    service.alternate();
    assertEquals(2, target.count);
  }
View Full Code Here

  public void testCallbackWithBoolean() throws Exception {
    RepeatTemplate template = new RepeatTemplate();
    // N.B. the default completion policy results in an infinite loop, so we
    // need to set the chunk size.
    template.setCompletionPolicy(new SimpleCompletionPolicy(2));
    interceptor.setRepeatOperations(template);
    ((Advised) service).addAdvice(interceptor);
    assertTrue(service.isContinuable());
    assertEquals(2, target.count);
  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.repeat.policy.SimpleCompletionPolicy

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.