Author: rmannibucau
Date: Mon Apr 15 10:08:06 2013
New Revision: 1467924

URL: http://svn.apache.org/r1467924
Log:
OWB-834 OWB-833 disposal injection points are not injection points for the spec 
+ lifecycle for selfinterceptors

Modified:
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/SelfInterceptorBean.java
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethod.java
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerMethodProducer.java

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java?rev=1467924&r1=1467923&r2=1467924&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
 Mon Apr 15 10:08:06 2013
@@ -30,6 +30,7 @@ import java.util.Collections;
 import java.util.Map;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.container.InjectionTargetFactoryImpl;
 import org.apache.webbeans.container.InterceptorInjectionTargetFactory;
 import org.apache.webbeans.util.ExceptionUtil;
 
@@ -54,18 +55,19 @@ public abstract class InterceptorBean<T>
      */
     private Method aroundInvokeMethod = null;
 
-    public InterceptorBean(WebBeansContext webBeansContext, 
-                           AnnotatedType<T> annotatedType,
-                           BeanAttributesImpl<T> beanAttributes,
-                           Class<T> beanClass,
-                           Map<InterceptionType, Method[]> interceptionMethods)
+    protected InterceptorBean(WebBeansContext webBeansContext,
+                                  AnnotatedType<T> annotatedType,
+                                  BeanAttributesImpl<T> beanAttributes,
+                                  Class<T> beanClass,
+                                  Map<InterceptionType, Method[]> 
interceptionMethods,
+                                  InjectionTargetFactoryImpl<T> factory)
     {
         super(webBeansContext,
-              WebBeansType.INTERCEPTOR,
-              annotatedType,
-              beanAttributes,
-              beanClass,
-              new InterceptorInjectionTargetFactory<T>(annotatedType, 
webBeansContext));
+                WebBeansType.INTERCEPTOR,
+                annotatedType,
+                beanAttributes,
+                beanClass,
+                factory);
         this.interceptionMethods = 
Collections.unmodifiableMap(interceptionMethods);
 
         for (Method[] methods: interceptionMethods.values())
@@ -85,6 +87,16 @@ public abstract class InterceptorBean<T>
         }
     }
 
+    public InterceptorBean(WebBeansContext webBeansContext, 
+                           AnnotatedType<T> annotatedType,
+                           BeanAttributesImpl<T> beanAttributes,
+                           Class<T> beanClass,
+                           Map<InterceptionType, Method[]> interceptionMethods)
+    {
+        this(webBeansContext, annotatedType, beanAttributes, beanClass, 
interceptionMethods,
+                new InterceptorInjectionTargetFactory<T>(annotatedType, 
webBeansContext));
+    }
+
     /**
      * Interceptors are by default &#064;Dependent scoped.
      */

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/SelfInterceptorBean.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/SelfInterceptorBean.java?rev=1467924&r1=1467923&r2=1467924&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/SelfInterceptorBean.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/SelfInterceptorBean.java
 Mon Apr 15 10:08:06 2013
@@ -29,6 +29,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.container.InjectionTargetFactoryImpl;
 import org.apache.webbeans.exception.WebBeansException;
 
 /**
@@ -47,7 +48,8 @@ public class SelfInterceptorBean<T> exte
                                Class<T> beanClass,
                                Map<InterceptionType, Method[]> 
interceptionMethods)
     {
-        super(webBeansContext, annotatedType, beanAttributes, beanClass, 
interceptionMethods);
+        super(webBeansContext, annotatedType, beanAttributes, beanClass, 
interceptionMethods,
+                new InjectionTargetFactoryImpl<T>(annotatedType, 
webBeansContext));
     }
 
     /**

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java?rev=1467924&r1=1467923&r2=1467924&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java
 Mon Apr 15 10:08:06 2013
@@ -63,7 +63,13 @@ public class MethodProducerFactory<P> im
     @Override
     public <T> Producer<T> createProducer(Bean<T> bean)
     {
-        Producer<T> producer = new ProducerMethodProducer<T, P>(parent, 
producerMethod, disposalMethod, createInjectionPoints(bean), webBeansContext);
+        Set<InjectionPoint> disposalIPs = null;
+        if (disposalMethod != null)
+        {
+            disposalIPs = new 
HashSet<InjectionPoint>(webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean,
 disposalMethod));
+        }
+
+        Producer<T> producer = new ProducerMethodProducer<T, P>(parent, 
producerMethod, disposalMethod, createInjectionPoints(bean), disposalIPs, 
webBeansContext);
         return 
webBeansContext.getWebBeansUtil().fireProcessProducerEvent(producer, 
producerMethod);
     }
 
@@ -175,11 +181,6 @@ public class MethodProducerFactory<P> im
 
     protected Set<InjectionPoint> createInjectionPoints(Bean<?> bean)
     {
-        Set<InjectionPoint> injectionPoints = new 
HashSet<InjectionPoint>(webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean,
 producerMethod));
-        if (disposalMethod != null)
-        {
-            
injectionPoints.addAll(webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean,
 disposalMethod));
-        }
-        return injectionPoints;
+        return new 
HashSet<InjectionPoint>(webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean,
 producerMethod));
     }
 }

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=1467924&r1=1467923&r2=1467924&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
 Mon Apr 15 10:08:06 2013
@@ -130,6 +130,11 @@ public abstract class AbstractInjectable
      */
     protected List<InjectionPoint> getInjectionPoints(Member member)
     {
+        return createInjectionPoints(owner, member);
+    }
+
+    protected static List<InjectionPoint> createInjectionPoints(Producer<?> 
owner, Member member)
+    {
         List<InjectionPoint> injectionPoints = new ArrayList<InjectionPoint>();
         for (InjectionPoint injectionPoint : owner.getInjectionPoints())
         {

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=1467924&r1=1467923&r2=1467924&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
 Mon Apr 15 10:08:06 2013
@@ -21,8 +21,10 @@ package org.apache.webbeans.inject;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.Disposes;
@@ -56,17 +58,25 @@ public class InjectableMethod<T> extends
     
     private Map<Bean<?>, Object> dependentParameters = new HashMap<Bean<?>, 
Object>();
 
+    private Set<InjectionPoint> injectionPoints;
+
+    public InjectableMethod(Method m, Object instance, Producer<T> owner, 
CreationalContextImpl<T> creationalContext)
+    {
+        this(m, instance, owner, creationalContext, new 
HashSet<InjectionPoint>(createInjectionPoints(owner, m)));
+    }
+
     /**
      * Constructs new instance.
      * 
      * @param m injectable method
      * @param instance component instance
      */
-    public InjectableMethod(Method m, Object instance, Producer<T> owner, 
CreationalContextImpl<T> creationalContext)
+    public InjectableMethod(Method m, Object instance, Producer<T> owner, 
CreationalContextImpl<T> creationalContext, Set<InjectionPoint> ips)
     {
         super(owner,creationalContext);
         method = m;
         this.ownerInstance = instance;
+        this.injectionPoints = ips;
     }
 
     /*
@@ -81,13 +91,12 @@ public class InjectableMethod<T> extends
             owner = NormalScopeProxyFactory.unwrapInstance(owner);
         }
 
-        List<InjectionPoint> injectedPoints = getInjectionPoints(method);
         List<Object> list = new ArrayList<Object>();
                 
         
-        for(int i=0;i<injectedPoints.size();i++)
+        for(int i=0;i<injectionPoints.size();i++)
         {
-            for(InjectionPoint point : injectedPoints)
+            for(InjectionPoint point : injectionPoints)
             {                
                 AnnotatedParameter<?> parameter = 
(AnnotatedParameter<?>)point.getAnnotated();
                 if (parameter.getPosition() == i)

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=1467924&r1=1467923&r2=1467924&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
 Mon Apr 15 10:08:06 2013
@@ -43,11 +43,13 @@ public class ProducerMethodProducer<T, P
     private WebBeansContext webBeansContext;
     private Method producerMethod;
     private Method disposalMethod;
+    private Set<InjectionPoint> disposalIPs;
 
     public ProducerMethodProducer(Bean<P> owner,
                                   AnnotatedMethod<? super P> producerMethod,
                                   AnnotatedMethod<? super P> disposerMethod,
                                   Set<InjectionPoint> points,
+                                  Set<InjectionPoint> disposalIPs,
                                   WebBeansContext webBeansContext)
     {
         super(points);
@@ -60,6 +62,7 @@ public class ProducerMethodProducer<T, P
         }
         this.owner = owner;
         this.webBeansContext = webBeansContext;
+        this.disposalIPs = disposalIPs;
 
         final OpenWebBeansEjbPlugin ejbPlugin = 
webBeansContext.getPluginLoader().getEjbPlugin();
         if (ejbPlugin != null)
@@ -131,7 +134,7 @@ public class ProducerMethodProducer<T, P
                     parentInstance = 
(P)webBeansContext.getBeanManagerImpl().getReference(owner, 
owner.getBeanClass(), parentCreationalContext);
                 }
 
-                m = new InjectableMethod<T>(disposalMethod, parentInstance, 
this, (CreationalContextImpl<T>) parentCreationalContext);
+                m = new InjectableMethod<T>(disposalMethod, parentInstance, 
this, (CreationalContextImpl<T>) parentCreationalContext, disposalIPs);
                 m.setDisposable(true);
                 m.setProducerMethodInstance(instance);
 


Reply via email to