title: When creating a java batch job, is it possible to reuse a step element within several flow elements?
body: <p>I'm creating the XML that will define a relatively simple Java Batch Job (see JSR 352).</p>
  
  <p>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. </p>
  
  <p>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.</p>
  
  <p>My decider xml will look something like this:</p>
  
  <pre><code>...
  &lt;decision id="jobDecisionTree" ref="MyDecider"&gt;
      &lt;next on="default" to="defaultFlow"/&gt;
      &lt;next on="stepOneOnly" to="stepOneOnlyFlow"/&gt;
      ...
  &lt;/decision&gt;
  ...
  </code></pre>
  
  <p>I'm thinking the best way is to use several <code>&lt;flow&gt;</code> elements to define the different possibilities.  For example, here are just two of the possible flow elements that I can define:</p>
  
  <pre><code>...   
  &lt;flow id="defaultFlow"&gt;
    &lt;step id="stepOne" next="stepTwo"&gt;
      &lt;chunk checkpoint-policy="item" item-count="20"&gt;
          &lt;reader ref="MyStepOneReader"/&gt;
          &lt;processor ref="MyStepOneProcessor"/&gt;
          &lt;writer ref="MyStepOneWriter"/&gt;
      &lt;/chunk&gt;
    &lt;/step&gt;
    &lt;step id="stepTwo" next="stepThree"&gt;
      &lt;chunk checkpoint-policy="item" item-count="20"&gt;
          &lt;reader ref="MyStepTwoReader"/&gt;
          &lt;processor ref="MyStepTwoProcessor"/&gt;
          &lt;writer ref="MyStepTwoWriter"/&gt;
      &lt;/chunk&gt;
    &lt;/step&gt;
    &lt;step id="stepThree"&gt;
      &lt;chunk checkpoint-policy="item" item-count="20"&gt;
          &lt;reader ref="MyStepThreeReader"/&gt;
          &lt;processor ref="MyStepThreeProcessor"/&gt;
          &lt;writer ref="MyStepThreeWriter"/&gt;
      &lt;/chunk&gt;
    &lt;/step&gt;
  &lt;/flow&gt;
  
  &lt;flow id="stepOneOnlyFlow"&gt;
    &lt;step id="stepOne"&gt;
      &lt;chunk checkpoint-policy="item" item-count="20"&gt;
          &lt;reader ref="MyStepOneReader"/&gt;
          &lt;processor ref="MyStepOneProcessor"/&gt;
          &lt;writer ref="MyStepOneWriter"/&gt;
      &lt;/chunk&gt;
    &lt;/step&gt;
  &lt;/flow&gt;
  ...
  </code></pre>
  
  <p>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.</p>
  
  <p>Is there a way I can just reference a step from within a flow element without having to fully define it each time?</p>