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

Stuart Douglas (JIRA) jira-events at lists.jboss.org
Thu Jan 27 01:19:58 EST 2011

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

Stuart Douglas commented on CDI-10:

Say we have a bean:

class MyBean {
  private String field;

It may be that a portable extension needs to read the value of field, but atm that is not possible, as the proxies field will be read instead. I propose that we allow something like this:

MyBean proxy = injectedProxyInstance;
MyBean underlying = ((BeanProxy)injectedProxyInstance).getUnderlyingBean();

I am not really sure that this is such a good idea any more, but this was the original intent.

> 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: TBD
> 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 is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the cdi-dev mailing list