diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/JobBuilderHelper.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/JobBuilderHelper.java index 54d7859310..b5ef7203ec 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/JobBuilderHelper.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/JobBuilderHelper.java @@ -154,6 +154,28 @@ public B listener(JobExecutionListener listener) { return result; } + /** + * Add a {@link JobExecutionListener} to the job. + * This method makes the additive nature of adding listeners explicit. + * @param listener the job execution listener to add + * @return this for fluent chaining + * @since 6.1 + */ + public B addListener(JobExecutionListener listener) { + return listener(listener); + } + + /** + * Add a job execution listener using annotation-based configuration. + * This method makes the additive nature of adding listeners explicit. + * @param listener the object that has a method configured with listener annotation + * @return this for fluent chaining + * @since 6.1 + */ + public B addListener(Object listener) { + return listener(listener); + } + /** * Set a flag to prevent restart an execution of this job even if it has failed. * @return this to enable fluent chaining diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/StepBuilderHelper.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/StepBuilderHelper.java index da00172ffe..86434afca4 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/StepBuilderHelper.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/StepBuilderHelper.java @@ -117,6 +117,28 @@ public B listener(StepExecutionListener listener) { return self(); } + /** + * Add a {@link StepExecutionListener} to the step. + * This method makes the additive nature of adding listeners explicit. + * @param listener the step execution listener to add + * @return this for fluent chaining + * @since 6.1 + */ + public B addListener(StepExecutionListener listener) { + return listener(listener); + } + + /** + * Add a step execution listener using annotation-based configuration. + * This method makes the additive nature of adding listeners explicit. + * @param listener the object that has a method configured with listener annotation + * @return this for fluent chaining + * @since 6.1 + */ + public B addListener(Object listener) { + return listener(listener); + } + public B allowStartIfComplete(boolean allowStartIfComplete) { properties.allowStartIfComplete = allowStartIfComplete; return self();