-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Kind of wish LookupIfProperty and LookupUnlessProperty were a little more powerful #40717
Comments
Well, that's the purpose of CDI alternatives - to help the container to resolve the ambiguity. And the spec is pretty clear that
I'm not quite sure I fully understand this use case but if |
I don't think this suggestion makes sense because you making two assumptions that don't work in CDI. Firstly, Secondly, the transitive chain of |
I think I wrote that when I was tired because it's missing some details heh.. Let me try again: For the first suggestion currently if you have two alternative beans with a priority of 100 and 50, and the first is suppressed with a LookupIfProperty, the Instance<> will say it's unresolved because the 50 one was filtered out before it got to the LookupIfProperty logic. I think it would be useful if the bean at priority 50 could be resolved since it doesn't have a LookupIfProperty. For the second suggestion. I'm only talking about the situation where B is a direct dependency of A. I know that Instance can always be injected. It seems to me if A depends on B directly and you are asking for programmatic lookup on A you could add B's programmatic lookup logic to the Instance and say it's unresolvable since you couldn't supply it with a programmatically LookupIfProperty suppressed B. On the other hand this is kind of a giant can of worms wrt what people might expect to also work if Instance<> was changed to do some logic with transitive dependencies so this one isn't a strong suggestion from me. |
I see but it works exactly as defined 🤷. |
ok thanks for the info |
Description
When using Alternative/Priority, currently
ArcContainerImpl#resolve
will make sure that only the beans with the highest priority number are put into theInstance
. It would be nice if the lesser priority beans that are not suppressed are able to be injected.I also kind of wish that
Instance
could transitively evaluate these things. Like if you have anInstance<A>
andA
depends onB
andB
has aLookupIfProperty
thatInstance<A>.isResolvable()
could check B'sLookupIfProperty
. IfB
gets excluded though I'm not sure if the expectation would be for a lower priority B alternative to be found or to just come back and say it's not resolvable. The former kind of gets you to full blown dynamic bean resolution as long as it's on the other side of anInstance
which I know you all are trying to avoid.Implementation ideas
If you implemented something for the first suggestion it occurs to me that you could still filter out lower priority beans that come after a bean that doesn't have a Lookup* annotation.
The text was updated successfully, but these errors were encountered: