Skip to content

Commit

Permalink
Wire in use of SessionObjectReference.getFieldValue() in producer fields
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@3388 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Jul 31, 2009
1 parent fb6409f commit 7abddd7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Expand Up @@ -24,6 +24,8 @@
import javax.enterprise.context.spi.CreationalContext;

import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.bean.proxy.EnterpriseBeanInstance;
import org.jboss.webbeans.bean.proxy.Marker;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.introspector.WBField;
import org.jboss.webbeans.util.Names;
Expand Down Expand Up @@ -84,7 +86,20 @@ public void initialize(BeanDeployerEnvironment environment)
@Override
protected T produceInstance(CreationalContext<T> creationalContext)
{
return field.get(getReceiver(creationalContext));
Object receiver = getReceiver(creationalContext);
if (getDeclaringBean() instanceof EnterpriseBean<?> && receiver instanceof EnterpriseBeanInstance)
{
EnterpriseBeanInstance declaringInstance = (EnterpriseBeanInstance) receiver;
Object object = declaringInstance.getSessionObjectReference(Marker.INSTANCE).getFieldValue(field.getDeclaringType().getJavaClass(), field.getName());

@SuppressWarnings("unchecked")
T instance = (T) object;
return instance;
}
else
{
return field.get(receiver);
}
}


Expand Down
Expand Up @@ -19,6 +19,7 @@
import javax.enterprise.context.spi.CreationalContext;

import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.ejb.api.SessionObjectReference;

/**
* Interface implemented by all enterprise bean proxies to query/control the proxy
Expand All @@ -40,4 +41,6 @@ public interface EnterpriseBeanInstance

public void destroy(Marker marker, EnterpriseBean<?> enterpriseBean, CreationalContext<?> creationalContext);

public SessionObjectReference getSessionObjectReference(Marker marker);

}

0 comments on commit 7abddd7

Please sign in to comment.