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?
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.
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
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.
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.
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.