[cdi-dev] [JBoss JIRA] (CDI-10) Add ability to access a bean instance from a proxy

Antoine Sabot-Durand (JIRA) issues at jboss.org
Mon Nov 23 04:42:00 EST 2015

    [ https://issues.jboss.org/browse/CDI-10?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13132494#comment-13132494 ] 

Antoine Sabot-Durand commented on CDI-10:

I think there are mixed needs here. And as we have tickets exposing similar needs (CDI-562, CDI-561and CDI-515), I think interesting to start from use cases. I see 2 of them (please add others if I missed one):

# Getting class of the bean to "read" meta-data. IMO in this case accessing the class is not the best solution: meta-data may have been overridden and as section 11.4 states : {quote}The container must use the operations of Annotated and its subinterfaces to discover program element types and annotations. The container must not directly call the Java Reflection API{quote}
# Getting the actual unwrap instance to have an unmanaged version of the instance (as described in CDI-561). But the use case are less obvious and the fact that other proxies may be injected in the instance make this rather hard to specify.

If we focus on 1st use case (having a way to read meta-data). We have to provide a way to retrieve the {{Bean}} from the instance and add a way to easily discover the nature of a given {{Bean}} (managed bean, session, bean, producer, custom). Having this info will help user to know where to find meta-data...

Regarding second point, every body interested should describe a user case from user POV to see if it's worth digging in that direction.

> Add ability to access a bean instance from a proxy
> --------------------------------------------------
>                 Key: CDI-10
>                 URL: https://issues.jboss.org/browse/CDI-10
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Beans
>    Affects Versions: 1.0
>            Reporter: Stuart Douglas
>             Fix For: 2.0 (discussion)
> There are occasions when it would be useful to access a bean instance directly from a proxy. This could be achieved by making all proxies assignable to an interface (say BeanProxy) that provides a getBeanInstance() method. 
> Client code that needs access to the actual instance can check if the object is assignable to the BeanProxy interface and then call getBeanInstance() to get the actual instance if required.
> This is something that is probably more useful to extension writers than the end user, but there have already been a few requests on the weld forum about this so it is probably worth considering.

This message was sent by Atlassian JIRA

More information about the cdi-dev mailing list