openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1293457 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/InjectionPointBean.java container/BeanManagerImpl.java
Date Fri, 24 Feb 2012 22:31:50 GMT
Author: struberg
Date: Fri Feb 24 22:31:49 2012
New Revision: 1293457

URL: http://svn.apache.org/viewvc?rev=1293457&view=rev
Log:
OWB-648 fix TCK

txs to Romain Manni-Bucau for the patch!

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java?rev=1293457&r1=1293456&r2=1293457&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java
Fri Feb 24 22:31:49 2012
@@ -31,7 +31,6 @@ public class InjectionPointBean extends 
 {
     private static final WebBeansLogger logger = WebBeansLogger.getLogger(InjectionPointBean.class);
     
-    //X TODO refactor. public static variables are utterly ugly
     private static ThreadLocal<Stack<InjectionPoint>> localThreadlocalStack =
new ThreadLocal<Stack<InjectionPoint>>();
 
     private static Stack<InjectionPoint> getStackOfInjectionPoints()
@@ -80,6 +79,11 @@ public class InjectionPointBean extends 
         addApiType(Object.class);
     }
 
+    public static boolean isStackEmpty()
+    {
+        return getStackOfInjectionPoints().isEmpty();
+    }
+
     @Override
     protected InjectionPoint createInstance(CreationalContext<InjectionPoint> creationalContext)
     {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=1293457&r1=1293456&r2=1293457&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
Fri Feb 24 22:31:49 2012
@@ -62,6 +62,7 @@ import javax.naming.Referenceable;
 import javax.naming.StringRefAddr;
 import org.apache.webbeans.component.AbstractOwbBean;
 import org.apache.webbeans.component.EnterpriseBeanMarker;
+import org.apache.webbeans.component.InjectionPointBean;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.InjectionTargetWrapper;
 import org.apache.webbeans.component.JmsBeanMarker;
@@ -827,17 +828,34 @@ public class BeanManagerImpl implements 
             InjectionResolver.injectionPoints.set(injectionPoint);
         }
 
-        if(WebBeansUtil.isDependent(injectedBean))
-        {        
-            //Using owner creational context
-            //Dependents use parent creational context
-            instance = getReference(injectedBean, injectionPoint.getType(), ownerCreationalContext);
+        boolean ijbSet = false;
+        if (InjectionPointBean.isStackEmpty())
+        {
+            ijbSet = true;
+            InjectionPointBean.setThreadLocal(injectionPoint);
         }
-        else
-        {   
-            //New creational context for normal scoped beans
-            CreationalContextImpl<Object> injectedCreational = (CreationalContextImpl<Object>)createCreationalContext(injectedBean);
           
-            instance = getReference(injectedBean, injectionPoint.getType(), injectedCreational);
+
+        try
+        {
+            if(WebBeansUtil.isDependent(injectedBean))
+            {
+                //Using owner creational context
+                //Dependents use parent creational context
+                instance = getReference(injectedBean, injectionPoint.getType(), ownerCreationalContext);
+            }
+            else
+            {
+                //New creational context for normal scoped beans
+                CreationalContextImpl<Object> injectedCreational = (CreationalContextImpl<Object>)createCreationalContext(injectedBean);
+                instance = getReference(injectedBean, injectionPoint.getType(), injectedCreational);
+            }
+        }
+        finally
+        {
+            if (ijbSet)
+            {
+                InjectionPointBean.unsetThreadLocal();
+            }
         }
 
         if(isSetIPForProducers)



Mime
View raw message