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

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

Introduction

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

Prototype

public StepBuilder get(String name) 

Source Link

Document

Creates a step builder and initializes its job repository and transaction manager.

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/*w  ww.j  a v  a 2 s.  c o  m*/
        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();
}

From source file:io.spring.marchmadness.MooreStatConfiguration.java

@Bean
public Step step1(StepBuilderFactory stepBuilderFactory, ItemReader<MooreNcaaStat> reader,
        ItemWriter<MooreNcaaStat> writer) {
    return stepBuilderFactory.get("step1").<MooreNcaaStat, MooreNcaaStat>chunk(10).reader(reader).writer(writer)
            .build();//from   ww  w. j  a v  a2  s. com
}

From source file:io.spring.marchmadness.NcaaStatConfiguration.java

@Bean
public Step step1(StepBuilderFactory stepBuilderFactory, ItemReader<NcaaStats> reader,
        ItemWriter<NcaaStats> writer, ItemProcessor<NcaaStats, NcaaStats> processor) {
    return stepBuilderFactory.get("step1").<NcaaStats, NcaaStats>chunk(10).reader(reader).processor(processor)
            .writer(writer).build();//w ww  . ja v a 2  s. c  o  m
}

From source file:org.wallerlab.yoink.config.BatchConfig.java

/**
 * build executing steps/*from  w  ww  .  jav a 2s .c o m*/
 *
 * @param stepBuilderFactory
 *            -
 *            {@link org.springframework.batch.core.configuration.annotation.StepBuilderFactory}
 * @param cmlFilesRequest
 *            -{@link org.springframework.batch.item.ItemReader}
 * @param adaptiveQMMMProcessor
 *            -{@link org.springframework.batch.item.ItemProcessor}
 * @param cmlFilesResponse
 *            -{@link org.springframework.batch.item.ItemWriter}
 * @return Step -{@link org.springframework.batch.core.Step}
 */
@Bean
public Step jmsStep(StepBuilderFactory stepBuilderFactory) {
    return stepBuilderFactory
            .get("adaptiveQMMMJms").<String, org.wallerlab.yoink.api.model.bootstrap.Job>chunk(1)
            .reader(jmsRequestReader())
            .processor((ItemProcessor<String, org.wallerlab.yoink.api.model.bootstrap.Job>) appContext
                    .getBean("stringAdaptiveQMMMProcessor"))
            .writer(jmsJobItemWriter()).build();
}

From source file:com.github.jrrdev.mantisbtsync.core.jobs.JobIssuesConfiguration.java

/**
 * Build the step for portal authentication at the begining of the job.
 *
 * @param stepBuilderFactory/*from   w ww .  j a  va2 s.  c  o m*/
 *          The step builder factory
 * @param authTasklet
 *          The tasklet performing the authentication
 * @return the step
 */
@Bean
public Step authIssuesStep(final StepBuilderFactory stepBuilderFactory,
        final MethodInvokingTaskletAdapter authTasklet) {

    return stepBuilderFactory.get("authIssuesStep").allowStartIfComplete(true).tasklet(authTasklet).build();
}

From source file:com.github.jrrdev.mantisbtsync.core.jobs.JobProjectsConfiguration.java

/**
 * Build the step for portal authentication at the begining of the job.
 *
 * @param stepBuilderFactory//w  w w. ja v a  2 s  .c o  m
 *          The step builder factory
 * @param authTasklet
 *          The tasklet performing the authentication
 * @return the step
 */
@Bean
public Step authProjectsStep(final StepBuilderFactory stepBuilderFactory,
        final MethodInvokingTaskletAdapter authTasklet) {

    return stepBuilderFactory.get("authProjectsStep").allowStartIfComplete(true).tasklet(authTasklet).build();
}

From source file:com.github.jrrdev.mantisbtsync.core.jobs.JobEnumsConfiguration.java

/**
 * Build the step for portal authentication at the begining of the job.
 *
 * @param stepBuilderFactory/*ww  w  .j  a v  a  2 s  .  c o  m*/
 *          The step builder factory
 * @param authTasklet
 *          The tasklet performing the authentication
 * @return the step
 */
@Bean
public Step authEnumsStep(final StepBuilderFactory stepBuilderFactory,
        final MethodInvokingTaskletAdapter authTasklet) {

    return stepBuilderFactory.get("authEnumsStep").allowStartIfComplete(true).tasklet(authTasklet).build();
}

From source file:com.github.jrrdev.mantisbtsync.core.jobs.JobEnumsConfiguration.java

/**
 * Build the step with the given name, reader and writer.
 *
 * @param stepName/*from  w w w .j  a  va 2 s .c o m*/
 *          The step name
 * @param stepBuilderFactory
 *          The step builder factory
 * @param reader
 *          The reader
 * @param writer
 *          The writer
 * @return the step
 */
private Step getEnumStep(final String stepName, final StepBuilderFactory stepBuilderFactory,
        final ItemReader<ObjectRef> reader, final ItemWriter<ObjectRef> writer) {

    return stepBuilderFactory.get(stepName).<ObjectRef, ObjectRef>chunk(10).reader(reader).writer(writer)
            .build();
}

From source file:com.github.jrrdev.mantisbtsync.core.jobs.JobProjectsConfiguration.java

/**
 * Build the step syncing users related to this project.
 *
 * @param stepBuilderFactory/*  w ww.  j  ava  2s  . co  m*/
 *          The step builder factory
 * @param projectUsersReader
 *          The reader
 * @param projectUsersWriter
 *          The writer
 * @return the step
 */
@Bean
public Step projectUsersStep(final StepBuilderFactory stepBuilderFactory,
        final ItemReader<AccountData> projectUsersReader, final ItemWriter<AccountData> projectUsersWriter) {

    return stepBuilderFactory.get("projectUsersStep").<AccountData, AccountData>chunk(10)
            .reader(projectUsersReader).writer(projectUsersWriter).build();
}

From source file:com.github.jrrdev.mantisbtsync.core.jobs.JobProjectsConfiguration.java

/**
 * Build the step retrieving the access_level.
 *
 * @param stepBuilderFactory//from w  ww  . j  a  v a 2 s . c o m
 *          The step builder factory
 * @param mantisLoginTasklet
 *          The tasklet calling mc_login to get the user_acces_level
 * @param mantisLoginPromotionListener
 *          The execution promotion listener used to store the access level
 * @return the step
 */
@Bean
public Step mantisLoginStep(final StepBuilderFactory stepBuilderFactory,
        final MantisLoginTasklet mantisLoginTasklet, final StepExecutionListener mantisLoginPromotionListener) {

    return stepBuilderFactory.get("mantisLoginStep").tasklet(mantisLoginTasklet)
            .listener(mantisLoginPromotionListener).build();
}