Announcement Announcement Module
Collapse
No announcement yet.
Retrieving Job Scope ExecutionContext from within a step in 1.1.0. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 03:14 PM.

  • #2
    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.

    Comment


    • #3
      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?

      Comment


      • #4
        Ah, sorry, use a StepExecutionListener.

        Comment


        • #5
          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!!

          Comment


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

            Comment


            • #7
              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

              Comment


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

                Comment


                • #9
                  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.

                  Comment

                  Working...
                  X