Feb 2nd, 2010, 01:33 PM
Fresh Application Context for each job Execution
Going through a section on Job Configuration in spring batch (http://static.springsource.org/sprin...ponentsInSteps)
I saw that it recommends creating a new Application Context for each job Execution.
4.1.4. JobFactory and Stateful Components in Steps
Unlike many traditional Spring applications, many of the components of a batch application are stateful; the file readers and writers are obvious examples. The recommended way to deal with this is to create a fresh ApplicationContext for each job execution.
I think i'm missing the idea behind this. Why would you need to refresh the context at each job start and close it at job end?
If its about closing Streams/destroying resources etc.- doesn't the ItemStream interface callback's close() etc. provide that already?
Could someone enlighten...
Feb 2nd, 2010, 01:55 PM
Ignore that (it's a remnant from 1.1.x). Just use scope="step" in your stateful components. I thought the user guide had been updated but that must have been in a different chapter.