openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1590909 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject: AbstractInjectable.java InjectableConstructor.java InjectableMethod.java
Date Tue, 29 Apr 2014 08:09:25 GMT
Author: arne
Date: Tue Apr 29 08:09:25 2014
New Revision: 1590909

URL: http://svn.apache.org/r1590909
Log:
OWB-949: Implemented @TransientReference

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableConstructor.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethod.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java?rev=1590909&r1=1590908&r2=1590909&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
Tue Apr 29 08:09:25 2014
@@ -24,7 +24,9 @@ import java.util.ArrayList;
 import java.util.List;
 
 import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.IllegalProductException;
+import javax.enterprise.inject.TransientReference;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.Producer;
@@ -53,11 +55,14 @@ public abstract class AbstractInjectable
     private Producer<?> owner;
     
     protected final CreationalContextImpl<?> creationalContext;
+    
+    protected CreationalContextImpl<?> transientCreationalContext;
 
     protected AbstractInjectable(Producer<?> owner, CreationalContextImpl<?>
creationalContext)
     {
         this.owner = owner;
         this.creationalContext = creationalContext;
+        this.transientCreationalContext = creationalContext.getWebBeansContext().getBeanManagerImpl().createCreationalContext(creationalContext.getContextual());
     }
 
     /**
@@ -90,9 +95,19 @@ public abstract class AbstractInjectable
                 }
             }
         }
+        
+        CreationalContext<?> injectionPointContext;
+        if (injectionPoint.getAnnotated().isAnnotationPresent(TransientReference.class))
+        {
+            injectionPointContext = transientCreationalContext;
+        }
+        else
+        {
+            injectionPointContext = creationalContext;
+        }
 
         //Gets injectable reference for injected bean
-        injected = (T) beanManager.getInjectableReference(injectionPoint, creationalContext);
+        injected = (T) beanManager.getInjectableReference(injectionPoint, injectionPointContext);
 
         if (injected == null && beanManager.isNormalScope(injectedBean.getScope()))
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableConstructor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableConstructor.java?rev=1590909&r1=1590908&r2=1590909&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableConstructor.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableConstructor.java
Tue Apr 29 08:09:25 2014
@@ -70,6 +70,7 @@ public class InjectableConstructor<T> ex
             }
             
             instance = con.newInstance(createParameters());
+            transientCreationalContext.release();
             return instance;
         }
         catch (Exception e)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethod.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethod.java?rev=1590909&r1=1590908&r2=1590909&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethod.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethod.java
Tue Apr 29 08:09:25 2014
@@ -159,6 +159,10 @@ public class InjectableMethod<T> extends
         {
             throw new WebBeansException(e);
         }
+        finally
+        {
+            transientCreationalContext.release();
+        }
     }
 
     //X TODO is this still needed? If not we can also drop the whole dependentParameters...



Mime
View raw message