6

Is there any suggestions to the way to transfrom this xml config to javaconfig:

<job id="job">
    <step id="step1" >
        <next on="FAILED" to="step2"/>
        <next on="*" to="step3"/> 
    </step>
    <step id="step2"/>
    <step id="step3"next="step4"/>
    <step id="step4"/>
</job>  

I was able to create a job having one step leading to another step on success and to a different one on failure:

SimpleJobBuilder builder = new JobBuilder("job").repository(jobRepository)
.start(step1()).next(step2())
.on("FAILED").to(step3()).build();  
Aacini
  • 65,180
  • 12
  • 72
  • 108
user3469745
  • 63
  • 1
  • 3

1 Answers1

13

Maybe like this:

jobs.get("job")
    .start(step1())
        .on("FAILED").to(step2())
        .next(step3())
    .from(step1())
        .next(step3())
        .next(step4())
.build().build();

(Step 2 is only executed if step 1 finished with status 'FAILED'. All other steps are executed in order. Is that what you intended?)

Geniy
  • 395
  • 3
  • 18
Dave Syer
  • 56,583
  • 10
  • 155
  • 143
  • Thank you this will help, I'm trying to develop an application that generates a new job that depends on user input (steps and their successors on failure and on success) – user3469745 Mar 27 '14 at 22:11
  • Thank you for this answer. I was looking the exact solution! – Kumar Manish Aug 05 '15 at 16:37