Add ability to start a job flow with a decider

Resolves #4411
This commit is contained in:
Kim Seon Woo
2023-08-03 23:37:31 +09:00
committed by Mahmoud Ben Hassine
parent 2e8d5063f7
commit 3fe3b7fc5d
3 changed files with 42 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2011 the original author or authors.
* Copyright 2006-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.job.flow.Flow;
import org.springframework.batch.core.job.flow.FlowJob;
import org.springframework.batch.core.job.flow.JobExecutionDecider;
import org.springframework.batch.core.step.builder.StepBuilderException;
/**
@@ -61,6 +62,16 @@ public class FlowJobBuilder extends JobBuilderHelper<FlowJobBuilder> {
return new JobFlowBuilder(this, step);
}
/**
* Start a job with this decider, but expect to transition from there to other flows
* or steps.
* @param decider the decider to start with
* @return a builder to enable fluent chaining
*/
public JobFlowBuilder start(JobExecutionDecider decider) {
return new JobFlowBuilder(this, decider);
}
/**
* Provide a single flow to execute as the job.
* @param flow the flow to execute

View File

@@ -17,6 +17,7 @@ package org.springframework.batch.core.job.builder;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.job.flow.Flow;
import org.springframework.batch.core.job.flow.JobExecutionDecider;
import org.springframework.batch.core.repository.JobRepository;
/**
@@ -61,16 +62,25 @@ public class JobBuilder extends JobBuilderHelper<JobBuilder> {
/**
* Create a new job builder that will execute a flow.
* @param flow a flow to execute
* @return a {@link SimpleJobBuilder}
* @return a {@link JobFlowBuilder}
*/
public JobFlowBuilder start(Flow flow) {
return new FlowJobBuilder(this).start(flow);
}
/**
* Create a new job builder that will start with a decider.
* @param decider a decider to start with
* @return a {@link JobFlowBuilder}
*/
public JobFlowBuilder start(JobExecutionDecider decider) {
return new FlowJobBuilder(this).start(decider);
}
/**
* Create a new job builder that will execute a step or sequence of steps.
* @param step a step to execute
* @return a {@link SimpleJobBuilder}
* @return a {@link JobFlowBuilder}
*/
public JobFlowBuilder flow(Step step) {
return new FlowJobBuilder(this).start(step);