openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1606571 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/java/org/apache/webbeans/container/ webbeans-impl/src/main/java/org/apache/webbeans/context/creational/ webbeans-impl/src/main...
Date Sun, 29 Jun 2014 19:17:06 GMT
Author: rmannibucau
Date: Sun Jun 29 19:17:05 2014
New Revision: 1606571

URL: http://svn.apache.org/r1606571
Log:
ensuring Instance.get() calls are separated and can be destroyed indenpendently + org.apache.webbeans.application.supportsProducerInterception
property

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanCacheKey.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerFieldProducer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerMethodProducer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/managed/instance/InjectedInstanceComponentTest.java
    openwebbeans/trunk/webbeans-tck/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
    openwebbeans/trunk/webbeans-tck/testng-dev.xml

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1606571&r1=1606570&r2=1606571&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
Sun Jun 29 19:17:05 2014
@@ -558,7 +558,7 @@ public class BeansDeployer
         
         if (beans != null && beans.size() > 0)
         {
-           Stack<String> beanNames = new Stack<String>();
+            Stack<String> beanNames = new Stack<String>();
             for (Bean<?> bean : beans)
             {
                 if (bean instanceof OwbBean && !((OwbBean)bean).isEnabled())
@@ -642,6 +642,7 @@ public class BeansDeployer
             
             //Clear Names
             beanNames.clear();
+
         }
         
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java?rev=1606571&r1=1606570&r2=1606571&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
Sun Jun 29 19:17:05 2014
@@ -102,6 +102,9 @@ public class OpenWebBeansConfiguration
     /**Supports conversations*/
     public static final String APPLICATION_SUPPORTS_CONVERSATION = "org.apache.webbeans.application.supportsConversation";
 
+    /** @Produces with interceptor/decorator support */
+    public static final String PRODUCER_INTERCEPTION_SUPPORT = "org.apache.webbeans.application.supportsProducerInterception";
+
     /**EL Adaptor*/
     public static final String EL_ADAPTOR_CLASS = "org.apache.webbeans.spi.adaptor.ELAdaptor";
 
@@ -321,4 +324,8 @@ public class OpenWebBeansConfiguration
         return ignoredInterfaces;
     }
 
+    public boolean supportsInterceptionOnProducers()
+    {
+        return "true".equals(getProperty(PRODUCER_INTERCEPTION_SUPPORT, "true"));
+    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanCacheKey.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanCacheKey.java?rev=1606571&r1=1606570&r2=1606571&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanCacheKey.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanCacheKey.java
Sun Jun 29 19:17:05 2014
@@ -89,7 +89,7 @@ public final class BeanCacheKey
         {
             return false;
         }
-        if (qualifier != null ? !qualifierEquals(qualifier, cacheKey.qualifier) : cacheKey.qualifier
!= null)
+        if (qualifier != null && cacheKey.qualifier != null ? !qualifierEquals(qualifier,
cacheKey.qualifier) : false)
         {
             return false;
         }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=1606571&r1=1606570&r2=1606571&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
Sun Jun 29 19:17:05 2014
@@ -208,7 +208,6 @@ public class InjectionResolver
                                                       " type is primitive but resolved bean
can have nullable objects!");
             }
         }
-
     }
 
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java?rev=1606571&r1=1606570&r2=1606571&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
Sun Jun 29 19:17:05 2014
@@ -251,7 +251,10 @@ public class CreationalContextImpl<T> im
                     Contextual<X> dependentContextual = (Contextual<X>)dependentContext.getContextual();
                     CreationalContext<X> creationalContext = (CreationalContext<X>)this;
                     dependentContextual.destroy(instance, creationalContext);
-                    i.remove();
+                    if (dependentObjects != null)
+                    {
+                        i.remove();
+                    } // else previous destroy removed it
                     break;
                 }
             }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java?rev=1606571&r1=1606570&r2=1606571&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
Sun Jun 29 19:17:05 2014
@@ -25,11 +25,14 @@ import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
+import javax.enterprise.context.Dependent;
 import javax.enterprise.context.spi.AlterableContext;
 import javax.enterprise.context.spi.Context;
 import javax.enterprise.context.spi.CreationalContext;
@@ -72,8 +75,9 @@ public class InstanceImpl<T> implements 
 
     private WebBeansContext webBeansContext;
 
+    private Map<Object, CreationalContextImpl<?>> creationalContexts;
     private CreationalContextImpl<?> parentCreationalContext;
-    
+
     /**
      * Creates new instance.
      * 
@@ -121,7 +125,7 @@ public class InstanceImpl<T> implements 
         }
 
         // since Instance<T> is Dependent, we we gonna use the parent CreationalContext
by default
-        CreationalContext<?> creationalContext = parentCreationalContext;
+        CreationalContextImpl<?> creationalContext = beanManager.createCreationalContext(parentCreationalContext.getContextual());
 
         boolean isDependentBean = WebBeansUtil.isDependent(bean);
 
@@ -138,7 +142,17 @@ public class InstanceImpl<T> implements 
         ((CreationalContextImpl<?>)creationalContext).putInjectionPoint(injectionPoint);
         try
         {
-            return (T) beanManager.getReference(bean, injectionClazz, creationalContext);
+            final T reference = (T) beanManager.getReference(bean, injectionClazz, creationalContext);
+            if (creationalContexts == null)
+            {
+                creationalContexts = new HashMap<Object, CreationalContextImpl<?>>();
+            }
+            creationalContexts.put(reference, creationalContext);
+            if (Dependent.class == bean.getScope())
+            {
+                parentCreationalContext.addDependent(bean, reference);
+            }
+            return reference;
         }
         finally
         {
@@ -308,7 +322,12 @@ public class InstanceImpl<T> implements 
         }
         else
         {
-            parentCreationalContext.destroyDependent(instance);
+            final CreationalContextImpl<?> creationalContext = creationalContexts.remove(instance);
+            if (creationalContext == null)
+            {
+                throw new IllegalArgumentException("instance " + instance + " not produced
with this Instance<?>");
+            }
+            creationalContext.destroyDependent(instance);
         }
     }
     

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerFieldProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerFieldProducer.java?rev=1606571&r1=1606570&r2=1606571&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerFieldProducer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerFieldProducer.java
Sun Jun 29 19:17:05 2014
@@ -26,6 +26,7 @@ import java.util.Map;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.Interceptor;
@@ -56,6 +57,15 @@ public class ProducerFieldProducer<T, P>
     }
 
     @Override
+    public void defineInterceptorStack(final Bean<T> bean, final AnnotatedType<T>
annotatedType, final WebBeansContext webBeansContext)
+    {
+        if (webBeansContext.getOpenWebBeansConfiguration().supportsInterceptionOnProducers())
+        {
+            super.defineInterceptorStack(bean, annotatedType, webBeansContext);
+        }
+    }
+
+    @Override
     protected T produce(Map<Interceptor<?>, ?> interceptors, CreationalContextImpl<T>
creationalContext)
     {
         T instance = null;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerMethodProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerMethodProducer.java?rev=1606571&r1=1606570&r2=1606571&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerMethodProducer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerMethodProducer.java
Sun Jun 29 19:17:05 2014
@@ -25,6 +25,7 @@ import java.util.Set;
 
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.Interceptor;
@@ -86,6 +87,15 @@ public class ProducerMethodProducer<T, P
     }
 
     @Override
+    public void defineInterceptorStack(final Bean<T> bean, final AnnotatedType<T>
annotatedType, final WebBeansContext webBeansContext)
+    {
+        if (webBeansContext.getOpenWebBeansConfiguration().supportsInterceptionOnProducers())
+        {
+            super.defineInterceptorStack(bean, annotatedType, webBeansContext);
+        }
+    }
+
+    @Override
     protected T produce(Map<Interceptor<?>, ?> interceptors, CreationalContextImpl<T>
creationalContext)
     {
         P parentInstance = null;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=1606571&r1=1606570&r2=1606571&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Sun Jun 29 19:17:05 2014
@@ -1552,6 +1552,4 @@ public final class WebBeansUtil
 
         return builder.toString();
     }
-
-
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/managed/instance/InjectedInstanceComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/managed/instance/InjectedInstanceComponentTest.java?rev=1606571&r1=1606570&r2=1606571&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/managed/instance/InjectedInstanceComponentTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/managed/instance/InjectedInstanceComponentTest.java
Sun Jun 29 19:17:05 2014
@@ -45,7 +45,7 @@ import org.junit.Test;
 public class InjectedInstanceComponentTest extends AbstractUnitTest
 {
 
-        @Test
+    @Test
     public void testInstanceInjectedComponent()
     {
         Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();

Modified: openwebbeans/trunk/webbeans-tck/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1606571&r1=1606570&r2=1606571&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tck/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
(original)
+++ openwebbeans/trunk/webbeans-tck/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
Sun Jun 29 19:17:05 2014
@@ -27,6 +27,8 @@
 # this is the tck configuration, thus it has a very high ordinal of 150
 configuration.ordinal=150
 
+org.apache.webbeans.application.supportsProducerInterception = false
+
 org.apache.webbeans.spi.ConversationService = org.apache.openwebbeans.tck.conversation.TckConversationService
 
 # we have to switch back to the un-cached version of the normal scoping handler 

Modified: openwebbeans/trunk/webbeans-tck/testng-dev.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/testng-dev.xml?rev=1606571&r1=1606570&r2=1606571&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tck/testng-dev.xml (original)
+++ openwebbeans/trunk/webbeans-tck/testng-dev.xml Sun Jun 29 19:17:05 2014
@@ -19,7 +19,7 @@
   <test name="JSR-346 TCK">
     <classes>
       <class
-          name="org.jboss.cdi.tck.tests.decorators.definition.producer.DecoratorNotAppliedToResultOfProducerTest"/>
+          name="org.jboss.cdi.tck.tests.lookup.dynamic.destroy.dependent.DestroyingDependentInstanceTest"
/>
     </classes>
     <groups>
       <run>



Mime
View raw message