Announcement Announcement Module
Collapse
No announcement yet.
understanding dynamic job parameter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • understanding dynamic job parameter

    Hi,

    I have developed an small application for spring batch...in order to understand its complete functionality but on class dynamic job parameter is being used , i didn't understand that why it is being used and it is also configured in xml file also...I am sending u the code have a look @ it...and plz explain.......


    DynamicJobParameters
    import java.util.Date;
    import org.springframework.batch.core.JobParameters;
    import org.springframework.batch.core.JobParametersBuilde r;
    import org.springframework.batch.core.JobParametersIncrem enter;


    public class DynamicJobParameters implements JobParametersIncrementer {

    public JobParameters getNext(JobParameters parameters) {

    parameters = new JobParametersBuilder().addDate("schedule.time",new Date()).toJobParameters();
    return parameters;
    }
    }


    file2file.xml
    *********

    <beans:bean id="dynamicJobParameters" class="com.ecomputercoach.file.DynamicJobParameter s"/>


    <job id="careerProcessorJob" job-repository="jobRepository" incrementer="dynamicJobParameters"> <step id="step1">
    <tasklet transaction-manager="jobRepository-transactionManager" >
    <chunk reader="playerFileItemReader" processor="careerProcessor" writer="playerFileItemWriter"
    commit-interval="10" />
    </tasklet>
    </step>
    </job>
    </beans:beans>

  • #2
    I don't understand your question but one problem I see in your code example is that you're not propagating any existing job parameters, so if you had any when the job started, they'd be lost.

    Code:
    public class DynamicJobParameters implements JobParametersIncrementer {
        public JobParameters getNext(JobParameters parameters) {
            if (parameters == null) {
                parameters = new JobParameters();
            }
    
            parameters = new JobParametersBuilder(parameters).addDate("schedule.time",new Date()).toJobParameters();
    
            return parameters; 
        }
    }

    Comment

    Working...
    X