Reputation: 6285
Having a spring job definition:
<job id="footballJob">
<!-- Step bean details ommitted for clarity -->
<step id="playerload" next="gameLoad"/>
<step id="gameLoad" next="playerSummarization"/>
<step id="playerSummarization"/>
</job>
Can I progmatically figure out the order of steps to execute?
Upvotes: 2
Views: 2286
Reputation: 22549
Steps will execute in order that you listed in your example.
In case you'd like to specify the order you can do:
<job id="job">
<step id="stepA" parent="s1" next="stepB" />
<step id="stepB" parent="s2" next="stepC"/>
<step id="stepC" parent="s3" />
</job>
In case you'd like a non sequential step execution / conditional flow, you can do:
<job id="job">
<step id="stepA" parent="s1">
<next on="*" to="stepB" />
<next on="FAILED" to="stepC" />
</step>
<step id="stepB" parent="s2" next="stepC" />
<step id="stepC" parent="s3" />
</job>
In order to control the flow programmatically, depending on ExitStatus
, you can inject your own decider
:
public class MyDecider implements JobExecutionDecider {
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
if (someCondition) {
return "FAILED";
}
else {
return "COMPLETED";
}
}
}
In the job configuration, a "decision" tag will specify the decider to use as well as all of the transitions:
<job id="job">
<step id="step1" parent="s1" next="decision" />
<decision id="decision" decider="decider">
<next on="FAILED" to="step2" />
<next on="COMPLETED" to="step3" />
</decision>
<step id="step2" parent="s2" next="step3"/>
<step id="step3" parent="s3" />
</job>
<beans:bean id="decider" class="com.MyDecider"/>
EDIT:
If you are looking to get a dependency graph
, you can just use Spring Tool Suite to visualize the flow, here is a simple example.
Upvotes: 1
Reputation: 6630
Can I progmatically figure out the order of steps to execute?
by taking your question literally there are some options:
i would go with a simple xml parser
Upvotes: 1