I'm creating the XML that will define a relatively simple Java Batch Job (see JSR 352).
I have three steps in my job, and I'd like to provide the ability to dynamically let the user decide if they want to execute all three steps, or just Step One, or Just Step Two, or Just Step One and Three, or Just Step Two and Three, etc. etc. Essentially I want to give the user all the possible combinations of running a subset of the steps in order.
Where I'm perplexed is with defining this behavior in the job xml. I have an implementation of the javax.batch.api.Decider, and it will return a particular value based on what the user wants to do.
My decider xml will look something like this:
...
<decision id="jobDecisionTree" ref="MyDecider">
<next on="default" to="defaultFlow"/>
<next on="stepOneOnly" to="stepOneOnlyFlow"/>
...
</decision>
...
I'm thinking the best way is to use several <flow>
elements to define the different possibilities. For example, here are just two of the possible flow elements that I can define:
...
<flow id="defaultFlow">
<step id="stepOne" next="stepTwo">
<chunk checkpoint-policy="item" item-count="20">
<reader ref="MyStepOneReader"/>
<processor ref="MyStepOneProcessor"/>
<writer ref="MyStepOneWriter"/>
</chunk>
</step>
<step id="stepTwo" next="stepThree">
<chunk checkpoint-policy="item" item-count="20">
<reader ref="MyStepTwoReader"/>
<processor ref="MyStepTwoProcessor"/>
<writer ref="MyStepTwoWriter"/>
</chunk>
</step>
<step id="stepThree">
<chunk checkpoint-policy="item" item-count="20">
<reader ref="MyStepThreeReader"/>
<processor ref="MyStepThreeProcessor"/>
<writer ref="MyStepThreeWriter"/>
</chunk>
</step>
</flow>
<flow id="stepOneOnlyFlow">
<step id="stepOne">
<chunk checkpoint-policy="item" item-count="20">
<reader ref="MyStepOneReader"/>
<processor ref="MyStepOneProcessor"/>
<writer ref="MyStepOneWriter"/>
</chunk>
</step>
</flow>
...
The issue is that I don't want to have to type all of my steps over and over again, because my steps are quite a bit more intricate than what I've presented here. I have partitions, and properties for each step, and the amount of redundant xml would be huge if I had to put the full definition for each step several times through out the job xml file.
Is there a way I can just reference a step from within a flow element without having to fully define it each time?