[
https://issues.jboss.org/browse/CDI-562?page=com.atlassian.jira.plugin.sy...
]
Martin Kouba commented on CDI-562:
----------------------------------
I think there are two similar open issues which might offer a better solution for this use
case:
# CDI-515 - allow to obtain Bean metadata from {{javax.enterprise.inject.Instance}}, so
that if a user wants to get the metadata the programmatic lookup would help
# CDI-10 - if we introduce a marking interface for client proxies, e.g. {{BeanProxy}}, we
could also probably add {{getBean()}} method
I'm not so sure it's a good idea to add a method to the BeanManager. Let's
have the following producer:
{code:java}
clas FooProducer {
@Alpha // qualifier
@Produces
Foo produceAlphaFoo() {
...
}
@Bravo // qualifier
@Produces
Foo produceBravoFoo() {
...
}
}
{code}
How to identify a bean for any {{Foo}} instance? We would have to use some internal
construct even for contextual instances of dependent beans with no
interceptors/decorators. And that's not possible - such a bean does not have to be
proxyable. Or am I missing something?
Add the possibility to retrieve {{Bean<T>}} from one of its
instance
--------------------------------------------------------------------
Key: CDI-562
URL:
https://issues.jboss.org/browse/CDI-562
Project: CDI Specification Issues
Issue Type: Feature Request
Components: Beans
Affects Versions: 1.2.Final, 2.0-EDR1
Reporter: Antoine Sabot-Durand
Since CDI 1.1 it's possible to inject its meta data in a bean instance wit {{@Inject
Bean<T> meta;}}. Its very useful to get information like actual class or qualifier
on the current bean.
This feature is great when we own the code and can add the injection point but when the
bean is defined in a third party lib this information are not reachable.
It would be nice to have a method in the {{BeanManager}} or elsewhere being able to
return the Bean<T> corresponding to a T instance or {{null}} if the instance is not
managed.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)