package org.springframework.batch.core;

import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;

import javax.annotation.Resource;

/**
 * In case of new instance for a job, this class provide the job parameters
 * incrementer by using a database sequence.
 *
 * @see org.springframework.batch.core.JobParametersIncrementer
 * @author Almex
 */
public class JobParametersSequenceIncrementer implements JobParametersIncrementer {

    /**
     * For legacy support we use the same name as the default one provided by
     * {@link org.springframework.batch.core.launch.support.RunIdIncrementer}
     */
    private static final String INCREMENTER_PARAMETER_NAME = "run.id";

    @Resource
    private DataFieldMaxValueIncrementer sequence;

    @Override
    public JobParameters getNext(final JobParameters jobParameters) {
        JobParametersBuilder builder = new JobParametersBuilder(jobParameters);

        builder.addLong(INCREMENTER_PARAMETER_NAME, sequence.nextLongValue());

        return builder.toJobParameters();
    }

    public void setSequence(final DataFieldMaxValueIncrementer sequence) {
        this.sequence = sequence;
    }

}


@@ -121,166 +121,333 @@
 r;%0A%0A
-import javax.annotation.Resource;%0A%0A/**%0A * In case of new instance for a job, this class provide the job parameters%0A * incrementer by using a database sequence
+/**%0A * In case of new %7B@code JobInstance%7D, this implementation provides an extra job parameter by using a database sequence.%0A * The main advantage of this implementation over the %7B@code RunIdIncrementer%7D is that in concurrent situation a%0A * database sequence call is %3Cb%3Ethread-safe%3C/b%3E (ensure uniqueness of the returned ids)
 .%0A *
@@ -486,29 +486,36 @@
 ch.core.
-JobParameters
+launch.support.RunId
 Incremen
@@ -872,22 +872,8 @@
 %22;%0A%0A
-    @Resource%0A
     

Update JobParametersSequenceIncrementer.java