Example usage for org.springframework.batch.core.configuration.annotation StepBuilderFactory StepBuilderFactory

List of usage examples for org.springframework.batch.core.configuration.annotation StepBuilderFactory StepBuilderFactory

Introduction

In this page you can find the example usage for org.springframework.batch.core.configuration.annotation StepBuilderFactory StepBuilderFactory.

Prototype

public StepBuilderFactory(JobRepository jobRepository, PlatformTransactionManager transactionManager) 

Source Link

Usage

From source file:de.langmi.spring.batch.examples.basics.purejava.PureJavaJobFactory.java

public static Job createJob(JobRepository jobRepository, PlatformTransactionManager transactionManager) {
    JobBuilderFactory jobBuilderFactory = new JobBuilderFactory(jobRepository);
    StepBuilderFactory stepBuilderFactory = new StepBuilderFactory(jobRepository, transactionManager);

    Step step = stepBuilderFactory.get("step1").tasklet(new Tasklet() {

        @Override/*from w w  w.  j a  va  2s .c om*/
        public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
            // why not using println? because it makes testing harder, *nix and
            // windows think different about new line as in \n vs \r\n
            System.out.print("Hello World!");

            // we want the step to stop here, the other status 
            // RepeatStatus.CONTINUABLE would start an endless loop
            return RepeatStatus.FINISHED;

        }
    }).build();

    return jobBuilderFactory.get("job1").start(step).build();
}