Reputation: 951
I have a batchlet that gets a file from a FTP server and stores it in a temporary folder. I would like to set the path of that folder as a batch job parameter, so that other steps can access the file. Is this possible and if so, how? My JSR 352 implementation is spring batch.
Edit: I am using Spring Batch 3.0 Milestone 3.
Upvotes: 2
Views: 3326
Reputation: 951
Thanks to Michael Minella I found out I could inject the JobContext in my Batchlet.
@Inject
private JobContext jobContext;
Now I can use this jobContext to set properties.
jobContext.setTransientUserData(myData);
Upvotes: 2
Reputation: 21463
You can pass in the location of the file as a job parameter using JSR-352's facilities as follows:
<step id="step1">
<batchlet ref="fooBatchlet">
<properties>
<property name="fileName" value="#{jobParameters['testParam']}"/>
</properties>
</batchlet>
</step>
The above assumes you're using either the batch.xml or Spring DI to define fooBatchlet. Otherwise, fooBatchlet would need to be the fully qualified class name.
Upvotes: 3
Reputation: 19
What version of Spring are you using?
Assuming v3, you can store information to pass to other job steps either in the StepContext or the JobExecutionContext. You can retrieve the StepContext from the ChunkContext which is passed into the BatchletAdapter RepeatStatus method.
Or you could set a JVM parameter, but that feels a bit clunky given that Spring offers the above methods.
Upvotes: 1