Author: pete.muir(a)jboss.org
Date: 2009-07-31 11:45:48 -0400 (Fri, 31 Jul 2009)
New Revision: 3388
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
Log:
Wire in use of SessionObjectReference.getFieldValue() in producer fields
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-07-31
14:48:47 UTC (rev 3387)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-07-31
15:45:48 UTC (rev 3388)
@@ -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;
@@ -84,7 +86,20 @@
@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);
+ }
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java 2009-07-31
14:48:47 UTC (rev 3387)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java 2009-07-31
15:45:48 UTC (rev 3388)
@@ -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
@@ -40,4 +41,6 @@
public void destroy(Marker marker, EnterpriseBean<?> enterpriseBean,
CreationalContext<?> creationalContext);
+ public SessionObjectReference getSessionObjectReference(Marker marker);
+
}
Show replies by date