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

An ObjectFactory variant with lenient not-unique handling [SPR-13943] #18515

Closed
spring-projects-issues opened this issue Feb 12, 2016 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Feb 12, 2016

Stéphane Nicoll opened SPR-13943 and commented

In Spring Boot it is very common to associate a bean to something if it is found in the context. If there is more than one instance but one is flagged as primary then we're fine as well. If there are more than one instance and the user did not mark a preference for one, then we don't know which one to use.

We would need a first class support of that use case, maybe based on the ObjectFactory. Something that would return the candidate bean or null if none was found.


Issue Links:

Referenced from: commits ed98393, 343bb2f

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Feb 12, 2016

Juergen Hoeller commented

I've introduced a SmartObjectFactory sub-interface with getIfAvailable() and getIfUnique() variants, allowing for programmatic optionality and lenient not-unique handling.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Feb 23, 2016

Juergen Hoeller commented

Renamed to ObjectProvider (extends ObjectFactory), as per our discussion today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants