Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support constructor binding on 3rd party classes #18935

Closed
philwebb opened this issue Nov 7, 2019 · 2 comments
Closed

Support constructor binding on 3rd party classes #18935

philwebb opened this issue Nov 7, 2019 · 2 comments
Assignees
Milestone

Comments

@philwebb
Copy link
Member

@philwebb philwebb commented Nov 7, 2019

We currently don't offer a good way to indicate that constructor binding should be used on a class that isn't under the users own control. See #18919 (comment) for details.

@philwebb

This comment has been minimized.

Copy link
Member Author

@philwebb philwebb commented Nov 8, 2019

We've discussed changing the logic again so that a @ConstructorBinding on a type indicates that any nested bind is also a candidate for constructor binding. To offer an escape hatch where constructor binding should not be used we could offer an exclude attribute.

@philwebb philwebb added this to the 2.2.x milestone Nov 8, 2019
@mbhave mbhave self-assigned this Nov 8, 2019
@mbhave

This comment has been minimized.

Copy link
Contributor

@mbhave mbhave commented Nov 13, 2019

It's not clear when someone would want to use exclude. Adding exclude would more often than not mean that setter binding should be attempted in which case a default constructor is required. Once there's a default constructor along with a parameterized constructor, constructor binding is automatically skipped because it checks for the presence of exactly one constructor that is parameterized. The exclude then does not provide any additional benefit. For this reason, we've decided not to rush into adding the exclude attribute till there is a solid use-case for it.

@mbhave mbhave closed this in b6ff0b7 Nov 13, 2019
@mbhave mbhave modified the milestones: 2.2.x, 2.2.2 Nov 14, 2019
mathieufortin01 added a commit to mathieufortin01/spring-boot that referenced this issue Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.