-
1. Re: Can a step give a job property a new value
richardmoore Aug 25, 2016 12:28 PM (in response to richardmoore)I have tried the following -
@Inject
JobContext jobContext;
private Properties jobProperties;
...
jobProperties = jobContext.getProperties();
String jobProp1 = jobProperties.getProperty("jobProp1");
log.log(Level.INFO, jobProp1);
jobProperties.setProperty("jobProp1", "a brand new value");
The next step is displaying the jobProp1 and it is the original starting value, not "a brand new value".
-
2. Re: Can a step give a job property a new value
cfang Aug 25, 2016 12:43 PM (in response to richardmoore)No, but you can declare other properties based on some existing batch properties, for example
<property name="p2" value="Add this #{jobProperties['X']} and this"/>
If you are using partitions, partitioin properties are always late-binding, i.e., the same step-level property that references a partition-level batch property will have different actual values in different partition.
-
3. Re: Can a step give a job property a new value
cfang Aug 25, 2016 12:49 PM (in response to richardmoore)job properties from jobContext.getProperties(); are read-only.
if you want to pass application data, consider using
javax.batch.runtime.context.JobContext#getTransientUserData
javax.batch.runtime.context.JobContext#setTransientUserData
javax.batch.runtime.context.StepContext#setTransientUserData
javax.batch.runtime.context.StepContext#getTransientUserData
javax.batch.runtime.context.StepContext#setPersistentUserData
javax.batch.runtime.context.StepContext#getPersistentUserData
or application-provided types (e.g., CDI beans) for keeping state.
-
4. Re: Can a step give a job property a new value
richardmoore Aug 25, 2016 1:50 PM (in response to cfang)Where do I find the Transient and Persistent User Data in the user guide? or GitHub examples?
-
5. Re: Can a step give a job property a new value
richardmoore Aug 25, 2016 2:04 PM (in response to richardmoore)Can you access the transient and persistent user data from within the JSL?
-
6. Re: Can a step give a job property a new value
cfang Aug 25, 2016 2:06 PM (in response to richardmoore)no, they are for programmatic access, and they can be any complex types, not just strings.
-
7. Re: Can a step give a job property a new value
cfang Aug 25, 2016 2:10 PM (in response to richardmoore)it's standard batch API, pls see EE 7 javadoc: Java(TM) EE 7 Specification APIs
Some test classes where they are used:
jsr352/ItemReader1.java at master · jberet/jsr352 · GitHub