Results 1 to 9 of 9

Thread: Retrieving Job Scope ExecutionContext from within a step in 1.1.0.

  1. #1

    Default Retrieving Job Scope ExecutionContext from within a step in 1.1.0.

    Hi,

    I just started working with 1.1.0, I have been checking the code for a while now and simply don't know how I can access the Job Scope ExecutionContext within a step, for example, within the ItemWriter, since it appears that only the step scope execution context is passed around, so I don't know how I can achieve this without some heavy customization from the ItemOrientedStep downwards, is there an easier way to get to it? I'm not exactly sure how the new Job Scope is meant to be used honestly also.

    Thanks and regards,
    Angel
    Last edited by Angel; Jul 16th, 2008 at 02:14 PM.

  2. #2
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    You can access the 'Job Scoped' excecution context by calling stepExecution.getJobExecution().getExecutionContex t(), as oppose to just calling getExecutionContext() on the StepExecution directly. The only difference between the two is that the job level context will always exists for all steps, whereas the one associated with the step will only be valid for the current step.

  3. #3

    Default

    Quote Originally Posted by lucasward View Post
    You can access the 'Job Scoped' excecution context by calling stepExecution.getJobExecution().getExecutionContex t(), as oppose to just calling getExecutionContext() on the StepExecution directly. The only difference between the two is that the job level context will always exists for all steps, whereas the one associated with the step will only be valid for the current step.
    Thanks for the quick reply Lucas, but how do I access the stepExecution from say the ItemWriter, which only recieved the step scope execution context from the AbstractStep?

  4. #4
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    Ah, sorry, use a StepExecutionListener.

  5. #5

    Default

    Quote Originally Posted by lucasward View Post
    Ah, sorry, use a StepExecutionListener.
    Oh ok, so I have to copy from job scope to step scope and vice versa inside the listener. Dunno how I missed this, thanks!!

  6. #6
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    You shouldn't have to copy from one ExecutionContext to another, although I suppose it depends upon what you're using the values for.

  7. #7

    Default

    Well my job will have about 4 steps all of which will need to share some data, for example
    1) step 1 will process records and output to a flatfile
    2) step 2 will work on the same file but output a header record at the top of the file based on data collected from step 2
    3) step 3 will insert a database record with the output filename and send an email.

    So I have a situation where the output of 1 step will be the input to the second.


    Angel

  8. #8
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    Right, couldn't Step1 put the file name in the job ExecutionContext, and Step2 pull them from the same?

  9. #9

    Default

    Yes, but the file name is only one of the things I need to pass on to a later step, during processing I need to store information collected during the run, like sums of balances for all records, number of records processed, etc.

Posting Permissions

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