Bugzilla – Bug 4554
Passing data around during a batch run and BatchContext's transient data
Last modified: 2013-03-01 18:50:03 UTC
In section 7.8.1 on page 90, the BatchContext is defined. Is there any way for me to store information in it? Say for example, I have a job that I want to pass information from one step to the next in. In Spring Batch, you can do that by using the ExecutionContext on the JobExeuction. Also, what is the intended use of the "transient user data"? If this is intended as a way for users to store information during a run, I would think that you would set some form of key/value relationship and retrieve that data via a key...
I also feel key-value pair is the common mechanism for storing and passing contextual information. Examples in EE are ServletContext.setAttribute, getAttribute. So a Map<?, ?> in BatchContext would be nice.
In the current form, BatchContext<T> lets user choose the actual T type for transient data, and P type for persistent data. As a result any impl classes would also bear these user defined types, which I think is a bit too tight coupled.
1) Yes, the batch context transient data is intended for sharing between steps.
2) I agree changing it to Map<?,?> is a good idea.
Let me clarify: The JobContext transient area is meant for sharing among steps.
For transient data, the user must still specify type <T>, but user can choose the convention and specify Java types, such as HashMap<String,String>.
For persistent data, the user must specify <P extends Serializable>, which allows more choices, including simple types, HashMap, and even Externalizable.
Changing this bug resolution "worksforme" since no change is being made in response to this bug. The change of Externalizable to Serializable is already being done by Bug 4679.