Results 1 to 5 of 5

Thread: ExecutionContext handle in ItemProcessor<T>

  1. #1
    Join Date
    Jun 2009
    Location
    Jersey City, NJ
    Posts
    14

    Default ExecutionContext handle in ItemProcessor<T>

    How do we get the handle of ExecutionContext (Job or Step) inside the ItemProcessor?

    I don't want it to implement this in StepListener, which has the handle to ExecutionContext.

    Could anyone help?
    Data lives more than Programs.
    Programs live more than Programmers.

  2. #2
    Join Date
    Mar 2006
    Posts
    312

    Default

    You can leverage the @BeforeStep listener annotation to grab the StepExecution before the step is started. From there you can get whatever you're after from StepExecution.

    See the ItemWriter example in the reference docs.
    http://static.springsource.org/sprin...aToFutureSteps

  3. #3
    Join Date
    Jun 2009
    Location
    Jersey City, NJ
    Posts
    14

    Default

    Thanks jglynn.

    My bad. I entirely missed that chapter. I focused on Configuring a Step chapter.

    Thanks Again.
    Data lives more than Programs.
    Programs live more than Programmers.

  4. #4

    Default ExecutionContext

    Is ExecutionContext thread safe? If i configure my batch as to run in multi-thread, does it gives me any problem when using values from ExecutionContext? I am planning to set a Map in the context.

  5. #5
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    ExecutionContext is just backed by a Map and has no intrinsic guarantees about thread safety, i.e. it's up to clients of the context to synchronize access to it if necessary. However, I would say it is likely to be a bad move to use the context outside the ItemStream and StepExecutionListener interfaces, and access in those places will (I think) be synchronized by the framework.

Posting Permissions

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