Replies: 1 comment 1 reply
-
|
Hi, thank you for your suggestion. That makes perfect sense! I will change this discussion into an issue and plan it for the next release. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First of all, I would like to express my sincere gratitude for your hard work in maintaining and evolving the Spring Batch framework.
Motivation
As a backend engineer heavily using Spring Batch with Java, I've observed that the current
.listener()method inStepBuilderandJobBuildercan sometimes be ambiguous.In the Spring ecosystem and general Java conventions, 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.The Problem
The current naming doesn't explicitly communicate its "additive" behavior:
.listener()will override previous ones.addListeneris a more intuitive name for cumulative behavior.Proposed Change
I suggest adding
addListener()as an alias or a preferred method for adding listeners in the Fluent DSL.Benefits
Backward Compatibility
To maintain backward compatibility, the existing .listener() method should remain. We could potentially mark it as the secondary option or keep both to support different coding styles (Fluent vs. Explicit).
Beta Was this translation helpful? Give feedback.
All reactions