I am refactoring a legacy Spring Batch XML based application to use annotation configuration instead. I want to understand how I can convert the following XML files into annotation based configuration and maintain the same separation of concern.
Here is a simple example for the sake of discussion.
job-config-1.xml
<job id="job1" xmlns="http://www.springframework.org/schema/batch">
<batch:step id="step1">
<batch:tasklet throttle-limit="20" task-executor="taskExecutor">
<batch:chunk reader="reader1"
writer="writer1" commit-interval="500" />
</batch:tasklet>
</batch:step>
</job>
job-config-2.xml
<job id="job2" xmlns="http://www.springframework.org/schema/batch">
<batch:step id="step2">
<batch:tasklet throttle-limit="20" task-executor="taskExecutor">
<batch:chunk reader="reader2"
writer="writer2" commit-interval="500" />
</batch:tasklet>
</batch:step>
</job>
job-config-3.xml
<import
resource="classpath*:/spring/jobs/job-config-1.xml" />
<import
resource="classpath*:/spring/jobs/job-config-2.xml" />
<batch:job id="jobFlow">
<batch:step id="step1" next="step2">
<job ref="job1" job-launcher="jobLauncher" />
</batch:step>
<batch:step id="step2">
<job ref="job2" job-launcher="jobLauncher" />
</batch:step>
</batch:job>
What I want to move from XML configuration to Java configuration. I want to create 3 job configuration classes for each of the XMLs. Lets say JobConfig1.java, JobConfig2.java and JobConfig3.java.
JobConfig3.java would import JobConfig1.java and JobConfig2.java; however, I was unable to find an example for this kind of structure in the docs. How do I go about doing this?
Note : I am not looking to use Spring Boot. Just regular Spring Batch through annotation configuration.