One nice way to do it could be to use a <decision/> element in your flow. The <decision/> would use a Decider implementation that could read from the JobParameters. Then, when you launched the job, you could pass in a parameter to indicate whether the job should continue.
This simplified configuration might get you started:
Code:
<job>
<step id="step1" next="step2"/>
...
<step id="step5" next="continueDecision"/>
<decision id="continueDecision" decider="continueDecider">
<next on="CONTINUE" to="step6"/>
<end on="END"/>
</decision>
<step id="step6" next="step7"/>
...
<step id="step10"/>
</job>
<beans:bean id="continueDecider" class="ContinueDecider" scope="step">
<beans:property name="shouldContinue" value="#{jobParameters[should.continue]}"/>
</beans:bean>
Where the ContinueDecider looks like this:
Code:
public class ContinueDecider implements JobExecutionDecider {
private boolean shouldContinue; //setter omitted
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
if (this.shouldContinue) {
return new FlowExecutionStatus("CONTINUE");
}
else {
return new FlowExecutionStatus("END");
}
}
}