Search in sources :

Example 1 with StepBuilderFactory

use of org.springframework.batch.core.configuration.annotation.StepBuilderFactory in project spring-boot by spring-projects.

the class JobLauncherCommandLineRunnerTests method init.

@Before
public void init() throws Exception {
    this.context.register(BatchConfiguration.class);
    this.context.refresh();
    JobRepository jobRepository = this.context.getBean(JobRepository.class);
    this.jobLauncher = this.context.getBean(JobLauncher.class);
    this.jobs = new JobBuilderFactory(jobRepository);
    PlatformTransactionManager transactionManager = this.context.getBean(PlatformTransactionManager.class);
    this.steps = new StepBuilderFactory(jobRepository, transactionManager);
    this.step = this.steps.get("step").tasklet(new Tasklet() {

        @Override
        public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
            return null;
        }
    }).build();
    this.job = this.jobs.get("job").start(this.step).build();
    this.jobExplorer = this.context.getBean(JobExplorer.class);
    this.runner = new JobLauncherCommandLineRunner(this.jobLauncher, this.jobExplorer);
    this.context.getBean(BatchConfiguration.class).clear();
}
Also used : SimpleJobLauncher(org.springframework.batch.core.launch.support.SimpleJobLauncher) JobLauncher(org.springframework.batch.core.launch.JobLauncher) StepContribution(org.springframework.batch.core.StepContribution) StepBuilderFactory(org.springframework.batch.core.configuration.annotation.StepBuilderFactory) JobRepository(org.springframework.batch.core.repository.JobRepository) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) Tasklet(org.springframework.batch.core.step.tasklet.Tasklet) ChunkContext(org.springframework.batch.core.scope.context.ChunkContext) JobBuilderFactory(org.springframework.batch.core.configuration.annotation.JobBuilderFactory) RepeatStatus(org.springframework.batch.repeat.RepeatStatus) JobExplorer(org.springframework.batch.core.explore.JobExplorer) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)1 StepContribution (org.springframework.batch.core.StepContribution)1 JobBuilderFactory (org.springframework.batch.core.configuration.annotation.JobBuilderFactory)1 StepBuilderFactory (org.springframework.batch.core.configuration.annotation.StepBuilderFactory)1 JobExplorer (org.springframework.batch.core.explore.JobExplorer)1 JobLauncher (org.springframework.batch.core.launch.JobLauncher)1 SimpleJobLauncher (org.springframework.batch.core.launch.support.SimpleJobLauncher)1 JobRepository (org.springframework.batch.core.repository.JobRepository)1 ChunkContext (org.springframework.batch.core.scope.context.ChunkContext)1 Tasklet (org.springframework.batch.core.step.tasklet.Tasklet)1 RepeatStatus (org.springframework.batch.repeat.RepeatStatus)1 PlatformTransactionManager (org.springframework.transaction.PlatformTransactionManager)1