-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Ordered list access for BeanFactory.getBeanProvider(), superseding ObjectProvider<List> [SPR-17272] #21805
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
Comments
Juergen Hoeller commented As per an initial analysis, this is intentional since programmatic configuration means to avoid the semantic overload of |
Andy Wilkinson commented It's taken me a little while to get my head around this, but I like that Having said that, the current implementation and javadoc appear to be at odds with this goal. The javadoc of |
Dave Syer commented I wonder if anyone ever actually uses the default |
Juergen Hoeller commented Point taken, I'll revise the javadoc as part of this ticket. It currently documents the default implementation in the Also, good point about ordering... There is currently no sorting of elements (like for a |
Juergen Hoeller commented The idea behind the default implementation of |
Andy Wilkinson commented Thanks. Some discussion of |
Juergen Hoeller commented It'll be all matching instances, including the primary one. |
Juergen Hoeller commented BTW thanks for all the timely feedback here! This is the most important core container addition in 5.1, so we'd better take these extra cycles to refine it and document it based on common use cases... |
Juergen Hoeller commented I've added an |
Phil Webb commented I know I'm coming late to the party on this one, but what if we had two distinct interfaces for "single" vs "multiple" use? It feels like Put another way, the user of the |
Juergen Hoeller commented That's by design: It's a single handle that allows for any kind of reasoning here. For a multi-element match, If there is really only a single element to reason about, I wouldn't use |
Phil Webb commented Perhaps we just have some fairly unique requirements in Spring Boot. We've quite often used
The decision about supporting multiple beans has to be taken when the I guess I'm kind of seeing usage patterns in Boot that kind of mirror |
Juergen Hoeller commented Another way of seeing it: And since it exists next to |
Sébastien Deleuze commented Phil Webb Not sure if that's relevant, but we tend to differentiate |
Phil Webb commented Ignore me, I see that methods like |
Juergen Hoeller commented Fair enough, |
Phil Webb commented I hate to ask for another round on this, but can we reconsider the name of the
I wonder if changing it to something like
Usage would then look like this: public MyClass(ObjectProvider<Customer> customers) {
customers.getOrdered().forEach(...);
} |
Andy Wilkinson commented Looking at the lastest code in master, this doesn't feel quite right to me yet and I share Phil's feeling about the ordering. Why, if I want Rather than renaming One last point. The current distinction between lazily resolved and fully resolved leaves me a bit confused. Looking at the implementation, beans appear to be fully resolved in both cases. I may well have misunderstood the code, though. Assuming for a moment that I haven't, if |
Phil Webb commented
I was confused by that as well, but there are actually two different implementations. The |
Andy Wilkinson commented Ah, I see. I had only been looking at |
Juergen Hoeller commented As for lazy resolution, this was referring to on-the-fly resolution of target bean instances, in case they haven't been created yet. The instances are being created during iteration, and further bean creation stops if iteration terminates. Once
So regarding One more detail: |
Juergen Hoeller commented Reopened due to a lazy resolution ordering conflict raised in spring-projects/spring-boot#14467... |
Juergen Hoeller commented Resolved through explicitly triggering instance resolution for ordered streams now, delivering a consistent experience against early/lazy initialized beans and also against both kinds of |
Andy Wilkinson commented Looks good now. Thank you. |
Sébastien Deleuze opened SPR-17272 and commented
Unlike
DependencyObjectProvider
which seems to support this use case, theObjectProvider
implementation returned byDefaultListableBeanFactory#getBeanProvider(ResolvableType)
does not seems to supportList<Foo>
correctly.This test is green:
This test is red:
This difference of behavior prevents Kofu configuration and Dave Syer FuncApplication to instantiate
WebFluxAutoConfiguration.WebFluxConfig
in a functional way and get view resolution support.Affects: 5.1 RC3
Issue Links:
@Bean
methods@Qualifier
works with HashMap but not with MapReferenced from: commits 65c8fa4, 41d4cb5, 7562761
0 votes, 8 watchers
The text was updated successfully, but these errors were encountered: