Skip to content

Commit

Permalink
Change StepBuilerHelper#enhance parameter type to AbstractStep
Browse files Browse the repository at this point in the history
  • Loading branch information
acktsap committed Nov 17, 2022
1 parent c0547c6 commit b4a6658
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
Expand Up @@ -21,12 +21,12 @@
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;
Expand Down Expand Up @@ -78,8 +78,8 @@ public AbstractTaskletStepBuilder(StepBuilderHelper<?> parent) {

/**
* 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() {
Expand Down
Expand Up @@ -42,6 +42,7 @@
*
* @author Dave Syer
* @author Michael Minella
* @author Taeik Lim
* @author Mahmoud Ben Hassine
* @since 2.2
*/
Expand Down Expand Up @@ -128,37 +129,30 @@ protected boolean isAllowStartIfComplete() {
return properties.allowStartIfComplete != null ? properties.allowStartIfComplete : false;
}

protected void enhance(Step target) {
protected void enhance(AbstractStep step) {
step.setJobRepository(properties.getJobRepository());

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);
}
ObservationRegistry observationRegistry = properties.getObservationRegistry();
if (observationRegistry != null) {
step.setObservationRegistry(observationRegistry);
}

Boolean allowStartIfComplete = properties.allowStartIfComplete;
if (allowStartIfComplete != null) {
step.setAllowStartIfComplete(allowStartIfComplete);
}
MeterRegistry meterRegistry = properties.getMeterRegistry();
if (meterRegistry != null) {
step.setMeterRegistry(meterRegistry);
}

step.setStartLimit(properties.startLimit);
Boolean allowStartIfComplete = properties.allowStartIfComplete;
if (allowStartIfComplete != null) {
step.setAllowStartIfComplete(allowStartIfComplete);
}

List<StepExecutionListener> listeners = properties.stepExecutionListeners;
if (!listeners.isEmpty()) {
step.setStepExecutionListeners(listeners.toArray(new StepExecutionListener[0]));
}
step.setStartLimit(properties.startLimit);

List<StepExecutionListener> listeners = properties.stepExecutionListeners;
if (!listeners.isEmpty()) {
step.setStepExecutionListeners(listeners.toArray(new StepExecutionListener[0]));
}

}

public static class CommonStepProperties {
Expand Down

0 comments on commit b4a6658

Please sign in to comment.