-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
EachBean: Allow to inject the origin bean and the registration #10902
Conversation
* @return The qualifier | ||
* @since 4.6 | ||
*/ | ||
public static <T> Qualifier<T> eachBeanOf(BeanDefinition<?> beanDefinition) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think we should make this public API since it quite internal specific. Either way I would name it childOf
or descendedFrom
something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made private
|
||
@Override | ||
public String toString() { | ||
return "EachBeanQualifier('" + beanDefinition + "')"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens with a qualifier like this when I inject Map<String, Foo>
? Please add tests for maps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this moment, it fails because there is no name. I think in this case we should throw an error saying that Map
cannot be used on multiple beans that don't have the name defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the message a bit reflecting that it doesn't need to be each bean + tests
I created the 4.6.x branch please target that. Also could you describe what issue this is trying to solve? |
I want to add:
But Jax-Rs "beans" don't have any qualifier that fails when the origin bean is injected into the constructor. |
|
For each bean functionality, we require a qualifier to properly identify the origin bean, but there are use cases where the bean cannot be modified.
Previously, we would allow each bean without a qualifier, but that will fail when you want to inject an origin; this PR is allowing to inject it.
Another solution for the qualifiers would be to add a qualifier that matches the bean type by the exact class, and maybe it can be reused elsewhere.
This should target 4.6 after it's created