I have a spring-batch job that converts various bank statements into my app. There is a different reader for each bank statement type and only one writer for all of them. The job is very simple – read, process and write:
<batch:job id="importer" restartable="true">
<batch:step id="import">
<batch:tasklet>
<batch:chunk reader="reader" writer="writer" processor="processor" commit-interval="10" />
</batch:tasklet>
</batch:step>
</batch:job>
Now, I would like the end user to provide a statement file as well as bank information and then choose a corresponding spring-batch reader at runtime for this job to run. Ideally it would be great if I could read-ahead in a first step and tried to “guess” the bank form statement format first. But I digress.
Is it possible to inject a reader into a job prior to running it? Or is there a better way to achieve my goal?
You can set the reader from an input parameter/or a propeties file:
Also you could consider late binding of job and step attributes, here is the link from spring-batch step-scope