Introduce addListener method in StepBuilder and JobBuilder for better clarity#5323
Open
nikitanagar08 wants to merge 1 commit intospring-projects:mainfrom
Open
Conversation
… clarity Fixes spring-projects#5321 Add addListener() methods as aliases that delegate to the existing listener() methods. The new method names make the additive behavior of adding listeners explicit and improve API consistency. Changes: - StepBuilderHelper.addListener(StepExecutionListener) - delegates to listener() - StepBuilderHelper.addListener(Object) - delegates to listener() for annotation-based config - JobBuilderHelper.addListener(JobExecutionListener) - delegates to listener() - JobBuilderHelper.addListener(Object) - delegates to listener() for annotation-based config The existing listener() methods remain for backward compatibility. Signed-off-by: Nikita Nagar <permanayan84@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5321
Motivation
The current
.listener()method inStepBuilderandJobBuildercan be ambiguous. A method named after a property (without a prefix) often implies setting a single value, potentially overwriting previous ones. However, in Spring Batch, calling.listener()multiple times actually appends the listeners to an internal list rather than replacing them.Proposed Change
Added
addListener()methods as aliases that delegate to the existinglistener()methods. The new method names make the additive behavior explicit and improve API consistency.Benefits
addListenermakes it clear that the listener is being added to a collectionadd*is used for collection-based propertiesChanges
StepBuilderHelper.addListener(StepExecutionListener)- delegates tolistener()StepBuilderHelper.addListener(Object)- delegates tolistener()for annotation-based configJobBuilderHelper.addListener(JobExecutionListener)- delegates tolistener()JobBuilderHelper.addListener(Object)- delegates tolistener()for annotation-based configBackward Compatibility
The existing
.listener()methods remain for full backward compatibility.