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

arjan tijms (JIRA) issues at jboss.org
Sun Nov 9 14:05:30 EST 2014


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

arjan tijms commented on CDI-10:
--------------------------------

{quote}If an Extension hacker really needs such a hardcore hack, then he might as well take the direct route:{quote}

Given an unknown proxy, how do you know the scope, type and qualifiers?

I think the original request is stall valid, for instance for those case where you need to take action based on a bean's class (it's class name may be a key into some map for instance) but all you got is the proxy.

The workaround seems a bit circular, but maybe I misunderstood. If you want to find out the original bean type of a proxy, you need the type to obtain a Bean instance via which you can obtain the original type. But if I had the type already, I wouldn't need to obtain a Bean instance in the first place.

See also http://stackoverflow.com/questions/14511433/original-class-name-of-a-proxy-without-manual-string-manipulation



> 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
>
> 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
(v6.3.8#6338)


More information about the cdi-dev mailing list