/** * @return a new {@link TaskletStep} */ protected TaskletStep createTaskletStep() { TaskletStepBuilder builder = new StepBuilder(name).tasklet(tasklet); enhanceTaskletStepBuilder(builder); return builder.build(); }
/** * Build a step with a custom tasklet, not necessarily item processing. * * @param tasklet a tasklet * @return a {@link TaskletStepBuilder} */ public TaskletStepBuilder tasklet(Tasklet tasklet) { return new TaskletStepBuilder(this).tasklet(tasklet); }
@Test public void testAnnotationBasedChunkListenerForTaskletStep() throws Exception { JobRepository jobRepository = new MapJobRepositoryFactoryBean().getObject(); StepExecution execution = jobRepository.createJobExecution("foo", new JobParameters()).createStepExecution("step"); jobRepository.add(execution); PlatformTransactionManager transactionManager = new ResourcelessTransactionManager(); TaskletStepBuilder builder = new StepBuilder("step") .repository(jobRepository) .transactionManager(transactionManager) .tasklet((contribution, chunkContext) -> null) .listener(new AnnotationBasedChunkListener()); builder.build().execute(execution); assertEquals(BatchStatus.COMPLETED, execution.getStatus()); assertEquals(1, AnnotationBasedChunkListener.beforeChunkCount); assertEquals(1, AnnotationBasedChunkListener.afterChunkCount); }
super.enhance(step);
@Bean public Step workerStep() { return this.workerStepBuilderFactory.get("workerStep") .inputChannel(requests()) .tasklet(tasklet(null)) .build(); }
/** * Build a step with a custom tasklet, not necessarily item processing. * * @param tasklet a tasklet * @return a {@link TaskletStepBuilder} */ public TaskletStepBuilder tasklet(Tasklet tasklet) { return new TaskletStepBuilder(this).tasklet(tasklet); }
super.enhance(step);
@Bean protected Step step1() throws Exception { return steps.get("step1").tasklet(new Tasklet() { @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return null; } }).build(); }
/** * Build a step with a custom tasklet, not necessarily item processing. * * @param tasklet a tasklet * @return a {@link TaskletStepBuilder} */ public TaskletStepBuilder tasklet(Tasklet tasklet) { return new TaskletStepBuilder(this).tasklet(tasklet); }
super.enhance(step);
@Bean public Step step() { return stepBuilderFactory.get("step1").tasklet(new Tasklet() { @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return null; } }).build(); }
/** * Build a step with a custom tasklet, not necessarily item processing. * * @param tasklet a tasklet * @return a {@link TaskletStepBuilder} */ public TaskletStepBuilder tasklet(Tasklet tasklet) { return new TaskletStepBuilder(this).tasklet(tasklet); }
@Bean protected Step step3() throws Exception { return steps.get("step3").tasklet(new Tasklet() { @Override public RepeatStatus execute(StepContribution contribution, ChunkContext context) throws Exception { return RepeatStatus.FINISHED; } }).build(); } }
@Bean public Step firstStep() { return stepBuilderFactory.get("firstStep") .tasklet(new Tasklet() { @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { System.out.println(">> Beginning concurrent job test"); return RepeatStatus.FINISHED; } }).build(); }
@Bean public Step lastStep() { return stepBuilderFactory.get("lastStep") .tasklet(new Tasklet() { @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { System.out.println(">> Ending concurrent job test"); return RepeatStatus.FINISHED; } }).build(); }
@Bean Step step1 () { return stepFactory.get("step1").tasklet(new Tasklet() { @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return RepeatStatus.FINISHED; } }).build(); }
@Bean protected Step step3() throws Exception { return steps.get("step3").tasklet(tasklet).build(); }
@Bean public Step workerStep() { return this.workerStepBuilderFactory.get("workerStep") .inputChannel(requests()) .outputChannel(replies()) .tasklet(tasklet(null)) .build(); }
@Bean protected Step step1() throws Exception { return steps.get("step1").tasklet(tasklet()).build(); }