private void handleTransition(Deque<Flow> resultFlowDeque, TaskAppNode taskAppNode) { String beanName = getBeanName(taskAppNode); Step currentStep = this.context.getBean(beanName, Step.class); FlowBuilder<Flow> builder = new FlowBuilder<Flow>(beanName) .from(currentStep); boolean wildCardPresent = false; for (TransitionNode transitionNode : taskAppNode.getTransitions()) { String transitionBeanName = getBeanName(transitionNode); wildCardPresent = transitionNode.getStatusToCheck().equals(WILD_CARD); Step transitionStep = this.context.getBean(transitionBeanName, Step.class); builder.on(transitionNode.getStatusToCheck()).to(transitionStep) .from(currentStep); } if (wildCardPresent && !resultFlowDeque.isEmpty()) { throw new IllegalStateException( "Invalid flow following '*' specifier."); } else { //if there are nodes are in the execution Deque. Make sure that //they are processed as a target of the wildcard instead of the //whole transition. if (!resultFlowDeque.isEmpty()) { builder.on(WILD_CARD).to(handleFlowForSegment(resultFlowDeque)).from(currentStep); } } resultFlowDeque.push(builder.end()); }
@Bean public Job conditionalJob(JobBuilderFactory jobs, Step conditionalStep1, Step conditionalStep2, Step conditionalStep3, Step conditionalStep4, Step conditionalStep5) throws Exception { return jobs.get("conditionalJob") .incrementer(new RunIdIncrementer()) .flow(conditionalStep1).on(ExitStatus.FAILED.getExitCode()).to(conditionalStep3) .from(conditionalStep1).on("HOGE").to(conditionalStep4) .from(conditionalStep1).on("*").to(conditionalStep2) .from(conditionalStep4).next(conditionalStep5).on("*").stop() .end() .build(); }
@Bean public Job transitionJobSimpleNext() { return jobBuilderFactory.get("transitionJobNext") .start(step1()) .on("COMPLETED").to(step2()) .from(step2()).on("COMPLETED").stopAndRestart(step3()) .from(step3()).end() .build(); } }
@Bean public Job job() { return jobBuilderFactory.get("job") .start(startStep()) .next(decider()) .from(decider()).on("ODD").to(oddStep()) .from(decider()).on("EVEN").to(evenStep()) .from(oddStep()).on("*").to(decider()) // .from(decider()).on("ODD").to(oddStep()) // .from(decider()).on("EVEN").to(evenStep()) .end() .build(); }