openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r925458 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/ context/creational/ decorator/ event/ inject/ intercept/ portable/events/discovery/
Date Fri, 19 Mar 2010 22:11:52 GMT
Author: gerdogdu
Date: Fri Mar 19 22:11:51 2010
New Revision: 925458

URL: http://svn.apache.org/viewvc?rev=925458&view=rev
Log:
[OWB-332] Destroy Depdent Of Producer Method Beans when Invocation Completes

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.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/decorator/DecoratorsManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java?rev=925458&r1=925457&r2=925458&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
Fri Mar 19 22:11:51 2010
@@ -170,6 +170,7 @@ public class ProducerMethodBean<T> exten
         T instance = null;
         Object parentInstance = null;
         CreationalContext<?> parentCreational = null;
+        InjectableMethods<T> m = null;
         try
         {
             parentCreational = getManager().createCreationalContext(this.ownerComponent);
@@ -179,8 +180,8 @@ public class ProducerMethodBean<T> exten
                 parentInstance = getParentInstance(parentCreational);
             }
 
-            InjectableMethods<T> m = new InjectableMethods<T>(creatorMethod,
parentInstance, this, creationalContext);
-
+            m = new InjectableMethods<T>(creatorMethod, parentInstance, this, creationalContext);
+            //Injection of parameters
             instance = m.doInjection();
 
         }
@@ -190,6 +191,9 @@ public class ProducerMethodBean<T> exten
             {
                 destroyBean(getParent(), parentInstance, parentCreational);
             }
+            
+            //Remove any dependent objects
+            m.destroyDependentInjectionPoints();
         }
 
         return instance;
@@ -231,6 +235,7 @@ public class ProducerMethodBean<T> exten
         {
             Object parentInstance = null;
             CreationalContext<?> parentCreational = null;
+            InjectableMethods<T> m = null;
             try
             {
                 parentCreational = getManager().createCreationalContext(this.ownerComponent);
@@ -240,7 +245,7 @@ public class ProducerMethodBean<T> exten
                     parentInstance = getParentInstance(parentCreational);
                 }
 
-                InjectableMethods<T> m = new InjectableMethods<T>(disposalMethod,
parentInstance, this.ownerComponent, creationalContext);
+                m = new InjectableMethods<T>(disposalMethod, parentInstance, this.ownerComponent,
creationalContext);
                 m.setDisposable(true);
                 m.setProducerMethodInstance(instance);
 
@@ -252,8 +257,10 @@ public class ProducerMethodBean<T> exten
                 if (getParent().getScope().equals(Dependent.class))
                 {
                     destroyBean(getParent(), parentInstance, parentCreational);
-
                 }
+                
+                //Remove any dependent objects
+                m.destroyDependentInjectionPoints();
             }
         }
     }

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=925458&r1=925457&r2=925458&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
Fri Mar 19 22:11:51 2010
@@ -250,7 +250,7 @@ public class CreationalContextImpl<T> im
      * Removes dependent objects.
      */
     @SuppressWarnings("unchecked")
-    private void  removeDependents()
+    public void  removeDependents()
     {
         Collection<?> values = this.dependentObjects.keySet();
         Iterator<?> iterator = values.iterator();

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java?rev=925458&r1=925457&r2=925458&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java
Fri Mar 19 22:11:51 2010
@@ -44,12 +44,6 @@ public class DecoratorsManager
         Asserts.assertNotNull(decoratorClazz, "decoratorClazz parameter can not be emtpy");
         if (!enabledDecorators.contains(decoratorClazz))
         {
-            if(!decoratorClazz.isAnnotationPresent(Decorator.class))
-            {
-                //Maybe custom
-                BeanManagerImpl.getManager().addCustomDecoratorClass(decoratorClazz);
-            }
-            
             enabledDecorators.add(decoratorClazz);
         }                
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java?rev=925458&r1=925457&r2=925458&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
Fri Mar 19 22:11:51 2010
@@ -235,7 +235,7 @@ public class ObserverMethodImpl<T> imple
             {
                 for(ObserverParams param : obargs)
                 {
-                    if(param.isBean)
+                    if(param.isBean && param.bean.getScope().equals(Dependent.class))
                     {
                         param.bean.destroy(param.instance, param.creational);
                     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java?rev=925458&r1=925457&r2=925458&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java
Fri Mar 19 22:11:51 2010
@@ -28,6 +28,7 @@ import org.apache.webbeans.annotation.De
 import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.component.ProducerMethodBean;
 import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.exception.WebBeansException;
 
 @SuppressWarnings("unchecked")
@@ -36,12 +37,15 @@ public class InjectableMethods<T> extend
     /** Injectable method */
     protected Method method;
 
-    /** Component instance that owns the method */
+    /** Bean parent instance that owns the method */
     protected Object instance;
     
+    /**If this method is dispose method*/
     private boolean disposable;
     
+    /**Used in dispose method, represents produces method parameter instance*/
     private Object producerMethodInstance = null;
+    
 
     /**
      * Constructs new instance.
@@ -122,6 +126,15 @@ public class InjectableMethods<T> extend
             throw new WebBeansException(e);
         }
     }
+    
+    /**
+     * Destroy dependent objects of the bean.
+     */
+    public void destroyDependentInjectionPoints()
+    {
+        CreationalContextImpl<?> ownerCreational = (CreationalContextImpl<?>)
this.injectionOwnerCreationalContext;
+        ownerCreational.removeDependents();
+    }
 
     /**
      * @return the disposable

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java?rev=925458&r1=925457&r2=925458&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
Fri Mar 19 22:11:51 2010
@@ -45,12 +45,6 @@ public class InterceptorsManager
         if (!enabledInterceptors.contains(interceptorClazz))
         {
             getInstance().enabledInterceptors.add(interceptorClazz);
-
-            if(!interceptorClazz.isAnnotationPresent(Interceptor.class))
-            {
-                //Maybe custom
-                BeanManagerImpl.getManager().addCustomInterceptorClass(interceptorClazz);
-            }
         }
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java?rev=925458&r1=925457&r2=925458&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
Fri Mar 19 22:11:51 2010
@@ -74,6 +74,7 @@ public class AfterBeanDiscoveryImpl impl
             CustomInterceptor<?> interceptor = new CustomInterceptor(managedBean, (Interceptor<?>)bean);
             
             this.beanManager.addInterceptor(interceptor);
+            BeanManagerImpl.getManager().addCustomInterceptorClass(bean.getBeanClass());
         }
         
         else if(bean instanceof Decorator)
@@ -84,6 +85,7 @@ public class AfterBeanDiscoveryImpl impl
             managedBean = WebBeansUtil.defineManagedBean(managedBeanCreator, annotatedType);
             
             this.beanManager.addDecorator(new WebBeansDecorator(managedBean, (Decorator)bean));
+            BeanManagerImpl.getManager().addCustomInterceptorClass(bean.getBeanClass());
           
         }
         else
         {



Mime
View raw message