Results 1 to 2 of 2

Thread: Get spring job params

  1. #1

    Default Get spring job params

    Hi

    Can anyone guide me as to how to get the job parametres whilst I am writing my data in a custom writer class

    Thanks

  2. #2
    Join Date
    Dec 2009
    Location
    Rabat,Morocco
    Posts
    3

    Default

    Greetings

    You can get them by adding a new listener on job
    public class ItemJobListener implements JobExecutionListener {
    public void afterJob(JobExecution jobExecution) {

    }
    public void beforeJob(JobExecution jobExecution) {

    String myParamValue = jobExecution.getJobInstance().getJobParameters()
    .getString("myParamKey");

    }
    }

    where the job is launched with myParamKey=myParamValue



    if you want to read parameters from application context.xml
    you can use :
    #{jobParameters[myParamKey]} as :
    <property name="resource" value="#{jobParameters[myParamKey]}" />

    and don't forget to make the bean step scoped



    Hope this can help

    Abdel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •