Change StepBuilderHelper#enhance parameter type to AbstractStep

Issue #4220
This commit is contained in:
Taeik Lim
2022-11-18 04:41:23 +09:00
committed by Mahmoud Ben Hassine
parent 92238260f1
commit 3385a19cb4
2 changed files with 25 additions and 31 deletions

View File

@@ -21,12 +21,12 @@ import java.util.LinkedHashSet;
import java.util.Set;
import org.springframework.batch.core.ChunkListener;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.core.annotation.AfterChunk;
import org.springframework.batch.core.annotation.AfterChunkError;
import org.springframework.batch.core.annotation.BeforeChunk;
import org.springframework.batch.core.listener.StepListenerFactoryBean;
import org.springframework.batch.core.step.AbstractStep;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.core.step.tasklet.TaskletStep;
import org.springframework.batch.item.ItemStream;
@@ -78,8 +78,8 @@ public abstract class AbstractTaskletStepBuilder<B extends AbstractTaskletStepBu
/**
* Build the step from the components collected by the fluent setters. Delegates first
* to {@link #enhance(Step)} and then to {@link #createTasklet()} in subclasses to
* create the actual tasklet.
* to {@link #enhance(AbstractStep)} and then to {@link #createTasklet()} in
* subclasses to create the actual tasklet.
* @return a tasklet step fully configured and ready to execute
*/
public TaskletStep build() {

View File

@@ -42,6 +42,7 @@ import org.springframework.batch.support.ReflectionUtils;
*
* @author Dave Syer
* @author Michael Minella
* @author Taeik Lim
* @author Mahmoud Ben Hassine
* @since 2.2
*/
@@ -128,37 +129,30 @@ public abstract class StepBuilderHelper<B extends StepBuilderHelper<B>> {
return properties.allowStartIfComplete != null ? properties.allowStartIfComplete : false;
}
protected void enhance(Step target) {
if (target instanceof AbstractStep) {
AbstractStep step = (AbstractStep) target;
step.setJobRepository(properties.getJobRepository());
ObservationRegistry observationRegistry = properties.getObservationRegistry();
if (observationRegistry != null) {
step.setObservationRegistry(observationRegistry);
}
MeterRegistry meterRegistry = properties.getMeterRegistry();
if (meterRegistry != null) {
step.setMeterRegistry(meterRegistry);
}
Boolean allowStartIfComplete = properties.allowStartIfComplete;
if (allowStartIfComplete != null) {
step.setAllowStartIfComplete(allowStartIfComplete);
}
step.setStartLimit(properties.startLimit);
List<StepExecutionListener> listeners = properties.stepExecutionListeners;
if (!listeners.isEmpty()) {
step.setStepExecutionListeners(listeners.toArray(new StepExecutionListener[0]));
}
protected void enhance(AbstractStep step) {
step.setJobRepository(properties.getJobRepository());
ObservationRegistry observationRegistry = properties.getObservationRegistry();
if (observationRegistry != null) {
step.setObservationRegistry(observationRegistry);
}
MeterRegistry meterRegistry = properties.getMeterRegistry();
if (meterRegistry != null) {
step.setMeterRegistry(meterRegistry);
}
Boolean allowStartIfComplete = properties.allowStartIfComplete;
if (allowStartIfComplete != null) {
step.setAllowStartIfComplete(allowStartIfComplete);
}
step.setStartLimit(properties.startLimit);
List<StepExecutionListener> listeners = properties.stepExecutionListeners;
if (!listeners.isEmpty()) {
step.setStepExecutionListeners(listeners.toArray(new StepExecutionListener[0]));
}
}
public static class CommonStepProperties {