openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1623574 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/creation/ config/ portable/ util/
Date Mon, 08 Sep 2014 20:59:47 GMT
Author: rmannibucau
Date: Mon Sep  8 20:59:47 2014
New Revision: 1623574

URL: http://svn.apache.org/r1623574
Log:
disposal methods for field producers

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BaseProducerFactory.java
      - copied, changed from r1623449, openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/BaseProducerProducer.java
      - copied, changed from r1623478, 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/creation/AbstractBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/FieldProducerFactory.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/component/creation/ProducerMethodBeansBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.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

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java?rev=1623574&r1=1623573&r2=1623574&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java Mon Sep  8 20:59:47 2014
@@ -26,6 +26,7 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.AnnotatedType;
 import java.util.Set;
 
+import org.apache.webbeans.component.ProducerFieldBean;
 import org.apache.webbeans.component.ProducerMethodBean;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.util.GenericsUtil;
@@ -41,7 +42,9 @@ public abstract class AbstractBeanBuilde
      * @param annotatedMethods of the given bean class
      * @param producerBeans or an empty Set
      */
-    protected void validateNoDisposerWithoutProducer(Set<AnnotatedMethod<? super T>> annotatedMethods, Set<ProducerMethodBean<?>> producerBeans)
+    protected void validateNoDisposerWithoutProducer(Set<AnnotatedMethod<? super T>> annotatedMethods,
+                                                     Set<ProducerMethodBean<?>> producerBeans,
+                                                     Set<ProducerFieldBean<?>> producerFields)
     {
         for (final AnnotatedMethod<?> annotatedMethod : annotatedMethods)
         {
@@ -60,7 +63,18 @@ public abstract class AbstractBeanBuilde
                     }
                     if (!found)
                     {
-                        throw new WebBeansConfigurationException("@Disposes without @Produces " + annotatedMethod.getJavaMember());
+                        for (final ProducerFieldBean<?> field : producerFields)
+                        {
+                            if (GenericsUtil.satisfiesDependency(false, field.getCreatorField().getType(), param.getBaseType()))
+                            {
+                                found = true;
+                                break;
+                            }
+                        }
+                        if (!found)
+                        {
+                            throw new WebBeansConfigurationException("@Disposes without @Produces " + annotatedMethod.getJavaMember());
+                        }
                     }
                     break;
                 }

Copied: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BaseProducerFactory.java (from r1623449, 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/BaseProducerFactory.java?p2=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BaseProducerFactory.java&p1=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java&r1=1623449&r2=1623574&rev=1623574&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/BaseProducerFactory.java Mon Sep  8 20:59:47 2014
@@ -18,71 +18,61 @@
  */
 package org.apache.webbeans.component.creation;
 
-import java.lang.annotation.Annotation;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import org.apache.webbeans.annotation.AnyLiteral;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.util.AnnotationUtil;
+import org.apache.webbeans.util.Asserts;
+import org.apache.webbeans.util.GenericsUtil;
 
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Default;
 import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.AnnotatedMember;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.DefinitionException;
 import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.Producer;
+import javax.enterprise.inject.spi.ProducerFactory;
 import javax.inject.Inject;
 import javax.inject.Named;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
 
-import javax.enterprise.inject.spi.ProducerFactory;
-import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.portable.ProducerMethodProducer;
-import org.apache.webbeans.util.AnnotationUtil;
-import org.apache.webbeans.util.Asserts;
-import org.apache.webbeans.util.GenericsUtil;
-
-public class MethodProducerFactory<P> implements ProducerFactory<P>
+public abstract class BaseProducerFactory<P> implements ProducerFactory<P>
 {
 
-    private AnnotatedMethod<? super P> producerMethod;
-    private AnnotatedMethod<? super P> disposalMethod;
-    private Bean<P> parent;
-    private WebBeansContext webBeansContext;
+    protected AnnotatedMethod<? super P> disposalMethod;
+    protected Bean<P> parent;
+    protected WebBeansContext webBeansContext;
 
-    public MethodProducerFactory(AnnotatedMethod<? super P> producerMethod, Bean<P> parent, WebBeansContext webBeansContext)
+    public BaseProducerFactory(Bean<P> parent, WebBeansContext webBeansContext)
     {
-        Asserts.assertNotNull(producerMethod, "producer method may not be null");
         Asserts.assertNotNull(webBeansContext, "WebBeansContext may not be null");
-        this.producerMethod = producerMethod;
         this.parent = parent;
         this.webBeansContext = webBeansContext;
-        defineDisposalMethod();
     }
 
-    public Class<?> getReturnType()
-    {
-        return producerMethod.getJavaMember().getReturnType();
-    }
-
-    @Override
-    public <T> Producer<T> createProducer(Bean<T> bean)
+    protected <T> Set<InjectionPoint> getInjectionPoints(final Bean<T> bean)
     {
         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);
+        return disposalIPs;
     }
 
-    private void defineDisposalMethod()
+    protected void defineDisposalMethod()
     {
-        Set<Annotation> producerQualifiers = webBeansContext.getAnnotationManager().getQualifierAnnotations(producerMethod.getAnnotations());
+        final AnnotatedMember<? super P> producer = producerType();
+        Set<Annotation> producerQualifiers = webBeansContext.getAnnotationManager().getQualifierAnnotations(producer.getAnnotations());
         if (producerQualifiers.size() == 1 && producerQualifiers.iterator().next().annotationType().equals(Default.class))
         {
             producerQualifiers = Collections.emptySet();
@@ -95,17 +85,23 @@ public class MethodProducerFactory<P> im
                 producerQualifiersWithoutNamed.add(qualifier);
             }
         }
-        Set<AnnotatedMethod<? super P>> annotatedMethods
-            = (Set<AnnotatedMethod<? super P>>)(Set<?>)webBeansContext.getAnnotatedElementFactory().getFilteredAnnotatedMethods(producerMethod.getDeclaringType());        
+
+        final AnnotatedType declaringType = producer.getDeclaringType();
+        final Type producerBaseType = producerType().getBaseType();
+        final Set<AnnotatedMethod<? super P>> annotatedMethods =
+                webBeansContext.getAnnotatedElementFactory().getFilteredAnnotatedMethods(declaringType);
+
+        AnnotatedMethod<? super P> anyDisposal = null;
+
         for (AnnotatedMethod<? super P> annotatedMethod : annotatedMethods)
-        {            
-            if (annotatedMethod.getDeclaringType().equals(producerMethod.getDeclaringType()))
+        {
+            if (annotatedMethod.getDeclaringType().equals(declaringType))
             {
                 for (AnnotatedParameter<? super P> annotatedParameter : annotatedMethod.getParameters())
                 {
                     if (annotatedParameter.isAnnotationPresent(Disposes.class))
                     {
-                        if (!GenericsUtil.satisfiesDependency(false, producerMethod.getBaseType(), annotatedParameter.getBaseType()))
+                        if (!GenericsUtil.satisfiesDependency(false, producerBaseType, annotatedParameter.getBaseType()))
                         {
                             continue;
                         }
@@ -126,10 +122,10 @@ public class MethodProducerFactory<P> im
                             continue;
                         }
                         boolean same = true;
-                        for (Annotation disposalQualifier: disposalQualifiers)
+                        for (Annotation disposalQualifier : disposalQualifiers)
                         {
                             boolean found = false;
-                            for (Annotation producerQualifier: producerQualifiers)
+                            for (Annotation producerQualifier : producerQualifiers)
                             {
                                 if (AnnotationUtil.isCdiAnnotationEqual(producerQualifier, disposalQualifier))
                                 {
@@ -145,6 +141,10 @@ public class MethodProducerFactory<P> im
                         }
                         if (!same)
                         {
+                            if (disposalQualifiers.size() == 1 && AnyLiteral.INSTANCE.equals(disposalQualifiers.iterator().next()))
+                            {
+                                anyDisposal = annotatedMethod;
+                            }
                             continue;
                         }
                         if (disposalMethod != null)
@@ -153,19 +153,31 @@ public class MethodProducerFactory<P> im
                                     + disposalMethod.getJavaMember().getName() + " in class : "
                                     + annotatedMethod.getDeclaringType().getJavaClass());
                         }
-                        if (!annotatedMethod.getDeclaringType().equals(producerMethod.getDeclaringType()))
-                        {
-                            throw new WebBeansConfigurationException("Producer method component of the disposal method : "
-                                    + annotatedMethod.getJavaMember().getName() + " in class : "
-                                    + annotatedMethod.getDeclaringType().getJavaClass() + " must be in the same class!");
-                        }
-                        checkDisposalMethod(annotatedMethod);
-                        disposalMethod = (AnnotatedMethod<P>)annotatedMethod;
+                        validateDisposalMethod(declaringType, annotatedMethod);
+                        disposalMethod = annotatedMethod;
                     }
                 }
             }
         }
-    }    
+        if (disposalMethod == null && anyDisposal != null)
+        {
+            validateDisposalMethod(declaringType, anyDisposal);
+            disposalMethod = anyDisposal;
+        }
+    }
+
+    private void validateDisposalMethod(final AnnotatedType declaringType, final AnnotatedMethod<? super P> annotatedMethod)
+    {
+        if (!annotatedMethod.getDeclaringType().equals(declaringType))
+        {
+            throw new WebBeansConfigurationException("Producer method component of the disposal method : "
+                    + annotatedMethod.getJavaMember().getName() + " in class : "
+                    + annotatedMethod.getDeclaringType().getJavaClass() + " must be in the same class!");
+        }
+        checkDisposalMethod(annotatedMethod);
+    }
+
+    protected abstract AnnotatedMember<? super P> producerType();
 
     private void checkDisposalMethod(AnnotatedMethod<? super P> annotatedMethod)
     {
@@ -200,9 +212,4 @@ public class MethodProducerFactory<P> im
             }
         }
     }
-
-    protected Set<InjectionPoint> createInjectionPoints(Bean<?> bean)
-    {
-        return new HashSet<InjectionPoint>(webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean, producerMethod));
-    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java?rev=1623574&r1=1623573&r2=1623574&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java Mon Sep  8 20:59:47 2014
@@ -57,7 +57,7 @@ public class CdiInterceptorBeanBuilder<T
         validateNoProducerMethod(annotatedType);
 
         // make sure that CDI interceptors do not have a Disposes method
-        validateNoDisposerWithoutProducer(webBeansContext.getAnnotatedElementFactory().getFilteredAnnotatedMethods(annotatedType), Collections.EMPTY_SET);
+        validateNoDisposerWithoutProducer(webBeansContext.getAnnotatedElementFactory().getFilteredAnnotatedMethods(annotatedType), Collections.EMPTY_SET, Collections.emptySet());
     }
 
     @Override

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java?rev=1623574&r1=1623573&r2=1623574&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java Mon Sep  8 20:59:47 2014
@@ -135,7 +135,8 @@ public class DecoratorBeanBuilder<T> ext
         validateNoProducerMethod(annotatedType);
 
         // make sure that CDI Decorator do not have a Disposes method
-        validateNoDisposerWithoutProducer(webBeansContext.getAnnotatedElementFactory().getFilteredAnnotatedMethods(annotatedType), Collections.EMPTY_SET);
+        validateNoDisposerWithoutProducer(
+                webBeansContext.getAnnotatedElementFactory().getFilteredAnnotatedMethods(annotatedType), Collections.EMPTY_SET, Collections.emptySet());
 
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/FieldProducerFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/FieldProducerFactory.java?rev=1623574&r1=1623573&r2=1623574&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/FieldProducerFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/FieldProducerFactory.java Mon Sep  8 20:59:47 2014
@@ -18,32 +18,29 @@
  */
 package org.apache.webbeans.component.creation;
 
-import javax.enterprise.inject.spi.AnnotatedField;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.Producer;
-
-import javax.enterprise.inject.spi.ProducerFactory;
-import javax.inject.Inject;
-
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.portable.ProducerFieldProducer;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
 
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMember;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.Producer;
+import javax.inject.Inject;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.util.Set;
 
-public class FieldProducerFactory<P> implements ProducerFactory<P>
+public class FieldProducerFactory<P> extends BaseProducerFactory<P>
 {
-
     private AnnotatedField<? super P> producerField;
-    private Bean<P> parent;
-    private WebBeansContext webBeansContext;
 
     public FieldProducerFactory(AnnotatedField<? super P> producerField, Bean<P> parent, WebBeansContext webBeansContext)
     {
+        super(parent, webBeansContext);
         Asserts.assertNotNull(producerField, "producer method may not be null");
-        Asserts.assertNotNull(webBeansContext, "WebBeansContext may not be null");
 
         if (producerField.isAnnotationPresent(Inject.class))
         {
@@ -63,14 +60,14 @@ public class FieldProducerFactory<P> imp
         }
 
         this.producerField = producerField;
-        this.parent = parent;
-        this.webBeansContext = webBeansContext;
+        defineDisposalMethod();
     }
 
     @Override
     public <T> Producer<T> createProducer(Bean<T> bean)
     {
-        Producer<T> producer = new ProducerFieldProducer<T, P>(parent, producerField, webBeansContext);
+        final Set<InjectionPoint> disposalIPs = getInjectionPoints(bean);
+        final Producer<T> producer = new ProducerFieldProducer<T, P>(parent, producerField, disposalMethod, disposalIPs, webBeansContext);
         return webBeansContext.getWebBeansUtil().fireProcessProducerEvent(producer, producerField);
     }
 
@@ -78,4 +75,10 @@ public class FieldProducerFactory<P> imp
     {
         return producerField.getJavaMember().getType();
     }
+
+    @Override
+    protected AnnotatedMember<? super P> producerType()
+    {
+        return producerField;
+    }
 }

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=1623574&r1=1623573&r2=1623574&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 Sep  8 20:59:47 2014
@@ -18,50 +18,36 @@
  */
 package org.apache.webbeans.component.creation;
 
-import java.lang.annotation.Annotation;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.portable.ProducerMethodProducer;
+import org.apache.webbeans.util.Asserts;
 
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Default;
-import javax.enterprise.inject.Disposes;
-import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.AnnotatedMember;
 import javax.enterprise.inject.spi.AnnotatedMethod;
-import javax.enterprise.inject.spi.AnnotatedParameter;
 import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.DefinitionException;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.Producer;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import javax.enterprise.inject.spi.ProducerFactory;
-import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.portable.ProducerMethodProducer;
-import org.apache.webbeans.util.AnnotationUtil;
-import org.apache.webbeans.util.Asserts;
-import org.apache.webbeans.util.GenericsUtil;
+import java.util.HashSet;
+import java.util.Set;
 
-public class MethodProducerFactory<P> implements ProducerFactory<P>
+public class MethodProducerFactory<P> extends BaseProducerFactory<P>
 {
-
     private AnnotatedMethod<? super P> producerMethod;
-    private AnnotatedMethod<? super P> disposalMethod;
-    private Bean<P> parent;
-    private WebBeansContext webBeansContext;
 
     public MethodProducerFactory(AnnotatedMethod<? super P> producerMethod, Bean<P> parent, WebBeansContext webBeansContext)
     {
+        super(parent, webBeansContext);
         Asserts.assertNotNull(producerMethod, "producer method may not be null");
-        Asserts.assertNotNull(webBeansContext, "WebBeansContext may not be null");
         this.producerMethod = producerMethod;
-        this.parent = parent;
-        this.webBeansContext = webBeansContext;
         defineDisposalMethod();
     }
 
+    @Override
+    protected AnnotatedMember<? super P> producerType()
+    {
+        return producerMethod;
+    }
+
     public Class<?> getReturnType()
     {
         return producerMethod.getJavaMember().getReturnType();
@@ -70,137 +56,11 @@ public class MethodProducerFactory<P> im
     @Override
     public <T> Producer<T> createProducer(Bean<T> bean)
     {
-        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);
+        final Set<InjectionPoint> disposalIPs = getInjectionPoints(bean);
+        final Producer<T> producer = new ProducerMethodProducer<T, P>(parent, producerMethod, disposalMethod, createInjectionPoints(bean), disposalIPs, webBeansContext);
         return webBeansContext.getWebBeansUtil().fireProcessProducerEvent(producer, producerMethod);
     }
 
-    private void defineDisposalMethod()
-    {
-        Set<Annotation> producerQualifiers = webBeansContext.getAnnotationManager().getQualifierAnnotations(producerMethod.getAnnotations());
-        if (producerQualifiers.size() == 1 && producerQualifiers.iterator().next().annotationType().equals(Default.class))
-        {
-            producerQualifiers = Collections.emptySet();
-        }
-        Set<Annotation> producerQualifiersWithoutNamed = new HashSet<Annotation>();
-        for (Annotation qualifier: producerQualifiers)
-        {
-            if (!qualifier.annotationType().equals(Named.class))
-            {
-                producerQualifiersWithoutNamed.add(qualifier);
-            }
-        }
-        Set<AnnotatedMethod<? super P>> annotatedMethods
-            = (Set<AnnotatedMethod<? super P>>)(Set<?>)webBeansContext.getAnnotatedElementFactory().getFilteredAnnotatedMethods(producerMethod.getDeclaringType());        
-        for (AnnotatedMethod<? super P> annotatedMethod : annotatedMethods)
-        {            
-            if (annotatedMethod.getDeclaringType().equals(producerMethod.getDeclaringType()))
-            {
-                for (AnnotatedParameter<? super P> annotatedParameter : annotatedMethod.getParameters())
-                {
-                    if (annotatedParameter.isAnnotationPresent(Disposes.class))
-                    {
-                        if (!GenericsUtil.satisfiesDependency(false, producerMethod.getBaseType(), annotatedParameter.getBaseType()))
-                        {
-                            continue;
-                        }
-
-                        Set<Annotation> producerQualifiersToCompare = producerQualifiers;
-                        Set<Annotation> disposalQualifiers = webBeansContext.getAnnotationManager().getQualifierAnnotations(annotatedParameter.getAnnotations());
-                        if (disposalQualifiers.size() == 1 && disposalQualifiers.iterator().next().annotationType().equals(Default.class))
-                        {
-                            disposalQualifiers = Collections.emptySet();
-                        }
-                        if (disposalQualifiers.size() == producerQualifiersToCompare.size() - 1)
-                        {
-                            // when @Named is present at the producer it may be ignored at the disposal
-                            producerQualifiersToCompare = producerQualifiersWithoutNamed;
-                        }
-                        if (disposalQualifiers.size() != producerQualifiersToCompare.size())
-                        {
-                            continue;
-                        }
-                        boolean same = true;
-                        for (Annotation disposalQualifier: disposalQualifiers)
-                        {
-                            boolean found = false;
-                            for (Annotation producerQualifier: producerQualifiers)
-                            {
-                                if (AnnotationUtil.isCdiAnnotationEqual(producerQualifier, disposalQualifier))
-                                {
-                                    found = true;
-                                    break;
-                                }
-                            }
-                            if (!found)
-                            {
-                                same = false;
-                                break;
-                            }
-                        }
-                        if (!same)
-                        {
-                            continue;
-                        }
-                        if (disposalMethod != null)
-                        {
-                            throw new WebBeansConfigurationException("There are multiple disposal method for the producer method : "
-                                    + disposalMethod.getJavaMember().getName() + " in class : "
-                                    + annotatedMethod.getDeclaringType().getJavaClass());
-                        }
-                        if (!annotatedMethod.getDeclaringType().equals(producerMethod.getDeclaringType()))
-                        {
-                            throw new WebBeansConfigurationException("Producer method component of the disposal method : "
-                                    + annotatedMethod.getJavaMember().getName() + " in class : "
-                                    + annotatedMethod.getDeclaringType().getJavaClass() + " must be in the same class!");
-                        }
-                        checkDisposalMethod(annotatedMethod);
-                        disposalMethod = (AnnotatedMethod<P>)annotatedMethod;
-                    }
-                }
-            }
-        }
-    }    
-
-    private void checkDisposalMethod(AnnotatedMethod<? super P> annotatedMethod)
-    {
-        boolean found = false;
-        for (AnnotatedParameter<?> parameter : annotatedMethod.getParameters())
-        {
-            if(parameter.isAnnotationPresent(Disposes.class))
-            {
-                if(found)
-                {
-                    throw new WebBeansConfigurationException("Error in definining disposal method of annotated method : " + annotatedMethod
-                            + ". Multiple disposes annotation.");
-                }
-                found = true;
-            }
-        }
-        
-        if(annotatedMethod.isAnnotationPresent(Inject.class) 
-            || AnnotationUtil.hasAnnotatedMethodParameterAnnotation(annotatedMethod, Observes.class)
-            || annotatedMethod.isAnnotationPresent(Produces.class))
-        {
-            throw new DefinitionException("Error in definining disposal method of annotated method : " + annotatedMethod
-                    + ". Disposal methods  can not be annotated with" + " @Initializer/@Destructor/@Produces annotation or has a parameter annotated with @Observes.");
-        }
-
-        for (AnnotatedParameter param : annotatedMethod.getParameters())
-        {
-            if (param.getBaseType().equals(InjectionPoint.class))
-            {
-                throw new DefinitionException("Error in definining disposal method of annotated method : " + annotatedMethod
-                    + ". Disposal methods must not have an InjectionPoint.");
-            }
-        }
-    }
-
     protected Set<InjectionPoint> createInjectionPoints(Bean<?> bean)
     {
         return new HashSet<InjectionPoint>(webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean, producerMethod));

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java?rev=1623574&r1=1623573&r2=1623574&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java Mon Sep  8 20:59:47 2014
@@ -19,6 +19,7 @@
 package org.apache.webbeans.component.creation;
 
 import org.apache.webbeans.component.InjectionTargetBean;
+import org.apache.webbeans.component.ProducerFieldBean;
 import org.apache.webbeans.component.ProducerMethodBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
@@ -61,7 +62,7 @@ public class ProducerMethodBeansBuilder<
     /**
      * {@inheritDoc}
      */
-    public Set<ProducerMethodBean<?>> defineProducerMethods(InjectionTargetBean<T> bean)
+    public Set<ProducerMethodBean<?>> defineProducerMethods(InjectionTargetBean<T> bean, Set<ProducerFieldBean<?>> producerFields)
     {
         Set<ProducerMethodBean<?>> producerBeans = new HashSet<ProducerMethodBean<?>>();
         Set<AnnotatedMethod<? super T>> annotatedMethods = webBeansContext.getAnnotatedElementFactory().getFilteredAnnotatedMethods(annotatedType);
@@ -113,7 +114,7 @@ public class ProducerMethodBeansBuilder<
         }
 
         // valid all @Disposes have a @Produces
-        validateNoDisposerWithoutProducer(annotatedMethods, producerBeans);
+        validateNoDisposerWithoutProducer(annotatedMethods, producerBeans, producerFields);
 
         return producerBeans;
     }

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=1623574&r1=1623573&r2=1623574&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 Mon Sep  8 20:59:47 2014
@@ -61,7 +61,7 @@ import org.apache.webbeans.intercept.Int
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.portable.AbstractProducer;
 import org.apache.webbeans.portable.AnnotatedElementFactory;
-import org.apache.webbeans.portable.ProducerMethodProducer;
+import org.apache.webbeans.portable.BaseProducerProducer;
 import org.apache.webbeans.portable.events.ProcessAnnotatedTypeImpl;
 import org.apache.webbeans.portable.events.ProcessBeanImpl;
 import org.apache.webbeans.portable.events.ProcessSyntheticAnnotatedTypeImpl;
@@ -305,11 +305,12 @@ public class BeansDeployer
         {
             if (ProducerMethodBean.class.isInstance(bean))
             {
-                final Producer<?> producer = ProducerMethodBean.class.cast(bean).getProducer();
-                if (ProducerMethodProducer.class.isInstance(producer))
+                final Producer<?> producer = AbstractProducerBean.class.cast(bean).getProducer();
+                if (BaseProducerProducer.class.isInstance(producer))
                 {
-                    final Set<InjectionPoint> disposalIPs = ProducerMethodProducer.class.cast(producer).getDisposalIPs();
-                    if (disposalIPs != null)
+                    final BaseProducerProducer producerProducer = BaseProducerProducer.class.cast(producer);
+                    final Set<InjectionPoint> disposalIPs = producerProducer.getDisposalIPs();
+                    if (disposalIPs != null && !producerProducer.isAnyDisposal()) // any can be ambiguous but that's not an issue
                     {
                         webBeansUtil.validate(disposalIPs, bean);
                     }
@@ -1404,13 +1405,20 @@ public class BeansDeployer
                     logger.log(Level.FINE, "Found Managed Bean with class name : [{0}]", annotatedType.getJavaClass().getName());
                 }
 
-                Set<ObserverMethod<?>> observerMethods = new HashSet<ObserverMethod<?>>();
+                final Set<ObserverMethod<?>> observerMethods;
+                final AnnotatedType<T> beanAnnotatedType = bean.getAnnotatedType();
                 if(bean.isEnabled())
                 {
-                    observerMethods = new ObserverMethodsBuilder<T>(webBeansContext, bean.getAnnotatedType()).defineObserverMethods(bean);
+                    observerMethods = new ObserverMethodsBuilder<T>(webBeansContext, beanAnnotatedType).defineObserverMethods(bean);
                 }
-                Set<ProducerMethodBean<?>> producerMethods = new ProducerMethodBeansBuilder(bean.getWebBeansContext(), bean.getAnnotatedType()).defineProducerMethods(bean);
-                Set<ProducerFieldBean<?>> producerFields = new ProducerFieldBeansBuilder(bean.getWebBeansContext(), bean.getAnnotatedType()).defineProducerFields(bean);
+                else
+                {
+                    observerMethods = new HashSet<ObserverMethod<?>>();
+                }
+
+                final WebBeansContext wbc = bean.getWebBeansContext();
+                Set<ProducerFieldBean<?>> producerFields = new ProducerFieldBeansBuilder(wbc, beanAnnotatedType).defineProducerFields(bean);
+                Set<ProducerMethodBean<?>> producerMethods = new ProducerMethodBeansBuilder(wbc, beanAnnotatedType).defineProducerMethods(bean, producerFields);
 
                 ManagedBean<T> managedBean = (ManagedBean<T>)bean;
                 Map<ProducerMethodBean<?>,AnnotatedMethod<?>> annotatedMethods =

Copied: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/BaseProducerProducer.java (from r1623478, 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/BaseProducerProducer.java?p2=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/BaseProducerProducer.java&p1=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerMethodProducer.java&r1=1623478&r2=1623574&rev=1623574&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/BaseProducerProducer.java Mon Sep  8 20:59:47 2014
@@ -18,54 +18,41 @@
  */
 package org.apache.webbeans.portable;
 
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Map;
-import java.util.Set;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.context.creational.CreationalContextImpl;
+import org.apache.webbeans.inject.InjectableMethod;
+import org.apache.webbeans.spi.plugins.OpenWebBeansEjbPlugin;
+import org.apache.webbeans.util.Asserts;
 
 import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedParameter;
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.Interceptor;
-
-import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.context.creational.CreationalContextImpl;
-import org.apache.webbeans.inject.InjectableMethod;
-import org.apache.webbeans.spi.plugins.OpenWebBeansEjbPlugin;
-import org.apache.webbeans.util.Asserts;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Set;
 
-/**
- * A {@link javax.enterprise.inject.spi.Producer} for producer-method beans.
- */
-public class ProducerMethodProducer<T, P> extends AbstractProducer<T>
+public abstract class BaseProducerProducer<T, P> extends AbstractProducer<T>
 {
 
-    private Bean<P> owner;
-    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)
+    protected Bean<P> owner;
+    protected WebBeansContext webBeansContext;
+    protected Method disposalMethod;
+    protected Set<InjectionPoint> disposalIPs;
+    protected boolean isAnyDisposal;
+
+    public BaseProducerProducer(Bean<P> owner,
+                                AnnotatedMethod<? super P> disposerMethod,
+                                Set<InjectionPoint> points,
+                                Set<InjectionPoint> disposalIPs,
+                                WebBeansContext webBeansContext)
     {
         super(points);
-        if (owner == null && !producerMethod.isStatic())
-        {
-            throw new IllegalArgumentException("owner may not be null");
-        }
-        Asserts.assertNotNull(producerMethod, "method may not be null");
         Asserts.assertNotNull(webBeansContext, "WebBeansContext may not be null");
-        if (!producerMethod.isStatic())
-        {
-            Asserts.assertNotNull(owner, "owner may not be null for non-static producer method");
-        }
         this.owner = owner;
         this.webBeansContext = webBeansContext;
         this.disposalIPs = disposalIPs;
@@ -73,7 +60,6 @@ public class ProducerMethodProducer<T, P
         final OpenWebBeansEjbPlugin ejbPlugin = webBeansContext.getPluginLoader().getEjbPlugin();
         if (ejbPlugin != null)
         {
-            this.producerMethod = ejbPlugin.resolveViewMethod(owner, producerMethod.getJavaMember());
             if (disposerMethod != null)
             {
                 disposalMethod = ejbPlugin.resolveViewMethod(owner, disposerMethod.getJavaMember());
@@ -81,12 +67,22 @@ public class ProducerMethodProducer<T, P
         }
         else
         {
-            this.producerMethod = producerMethod.getJavaMember();
             if (disposerMethod != null)
             {
                 disposalMethod = disposerMethod.getJavaMember();
             }
         }
+        if (disposerMethod != null)
+        {
+            for (final AnnotatedParameter<?> param : disposerMethod.getParameters())
+            {
+                if (param.isAnnotationPresent(Disposes.class))
+                {
+                    isAnyDisposal = param.isAnnotationPresent(Any.class);
+                    break;
+                }
+            }
+        }
     }
 
     @Override
@@ -99,35 +95,6 @@ public class ProducerMethodProducer<T, P
     }
 
     @Override
-    protected T produce(Map<Interceptor<?>, ?> interceptors, CreationalContextImpl<T> creationalContext)
-    {
-        P parentInstance = null;
-        CreationalContext<P> parentCreationalContext = null;
-        InjectableMethod<T> m;
-        try
-        {
-            parentCreationalContext = webBeansContext.getBeanManagerImpl().createCreationalContext(owner);
-
-            if (!Modifier.isStatic(producerMethod.getModifiers()))
-            {
-                parentInstance = (P)webBeansContext.getBeanManagerImpl().getReference(owner, owner.getBeanClass(), parentCreationalContext);
-            }
-            
-            m = new InjectableMethod<T>(producerMethod, parentInstance, this, (CreationalContextImpl<T>) creationalContext);
-            
-            return m.doInjection();
-
-        }
-        finally
-        {
-            if (parentCreationalContext != null)
-            {
-                parentCreationalContext.release();
-            }
-        }
-    }
-
-    @Override
     public void dispose(T instance)
     {
         if (disposalMethod != null)
@@ -162,4 +129,9 @@ public class ProducerMethodProducer<T, P
     {
         return disposalIPs;
     }
+
+    public boolean isAnyDisposal()
+    {
+        return isAnyDisposal;
+    }
 }

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=1623574&r1=1623573&r2=1623574&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 Mon Sep  8 20:59:47 2014
@@ -18,57 +18,46 @@
  */
 package org.apache.webbeans.portable;
 
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.Collections;
-import java.util.Map;
+import org.apache.webbeans.component.AbstractOwbBean;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.context.creational.CreationalContextImpl;
+import org.apache.webbeans.exception.WebBeansException;
+import org.apache.webbeans.util.Asserts;
+import org.apache.webbeans.util.WebBeansUtil;
 
 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.AnnotatedMethod;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.Interceptor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
 
-import org.apache.webbeans.component.AbstractOwbBean;
-import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.context.creational.CreationalContextImpl;
-import org.apache.webbeans.exception.WebBeansException;
-import org.apache.webbeans.util.Asserts;
-import org.apache.webbeans.util.WebBeansUtil;
-
-public class ProducerFieldProducer<T, P> extends AbstractProducer<T>
+public class ProducerFieldProducer<T, P> extends BaseProducerProducer<T, P>
 {
-
-    private Bean<P> owner;
-    private WebBeansContext webBeansContext;
     private AnnotatedField<? super P> producerField;
 
-    public ProducerFieldProducer(Bean<P> owner, AnnotatedField<? super P> producerField, WebBeansContext context)
+    public ProducerFieldProducer(Bean<P> owner,
+                                 AnnotatedField<? super P> producerField,
+                                 AnnotatedMethod<? super P> disposerMethod,
+                                 Set<InjectionPoint> disposalIPs,
+                                 WebBeansContext webBeansContext)
     {
-        super(Collections.<InjectionPoint>emptySet());
+        super(owner, disposerMethod, Collections.<InjectionPoint>emptySet(), disposalIPs, webBeansContext);
         if (owner == null && !producerField.isStatic())
         {
             throw new IllegalArgumentException("owner may not be null");
         }
         Asserts.assertNotNull(producerField, "field may not be null");
-        Asserts.assertNotNull(context, "WebBeansContext may not be null");
-        this.owner = owner;
-        webBeansContext = context;
         this.producerField = producerField;
     }
 
     @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=1623574&r1=1623573&r2=1623574&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 Sep  8 20:59:47 2014
@@ -25,7 +25,6 @@ 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;
@@ -39,14 +38,9 @@ import org.apache.webbeans.util.Asserts;
 /**
  * A {@link javax.enterprise.inject.spi.Producer} for producer-method beans.
  */
-public class ProducerMethodProducer<T, P> extends AbstractProducer<T>
+public class ProducerMethodProducer<T, P> extends BaseProducerProducer<T, P>
 {
-
-    private Bean<P> owner;
-    private WebBeansContext webBeansContext;
     private Method producerMethod;
-    private Method disposalMethod;
-    private Set<InjectionPoint> disposalIPs;
 
     public ProducerMethodProducer(Bean<P> owner,
                                   AnnotatedMethod<? super P> producerMethod,
@@ -55,46 +49,20 @@ public class ProducerMethodProducer<T, P
                                   Set<InjectionPoint> disposalIPs,
                                   WebBeansContext webBeansContext)
     {
-        super(points);
-        if (owner == null && !producerMethod.isStatic())
-        {
-            throw new IllegalArgumentException("owner may not be null");
-        }
+        super(owner, disposerMethod, points, disposalIPs, webBeansContext);
         Asserts.assertNotNull(producerMethod, "method may not be null");
-        Asserts.assertNotNull(webBeansContext, "WebBeansContext may not be null");
         if (!producerMethod.isStatic())
         {
             Asserts.assertNotNull(owner, "owner may not be null for non-static producer method");
         }
-        this.owner = owner;
-        this.webBeansContext = webBeansContext;
-        this.disposalIPs = disposalIPs;
-
         final OpenWebBeansEjbPlugin ejbPlugin = webBeansContext.getPluginLoader().getEjbPlugin();
         if (ejbPlugin != null)
         {
             this.producerMethod = ejbPlugin.resolveViewMethod(owner, producerMethod.getJavaMember());
-            if (disposerMethod != null)
-            {
-                disposalMethod = ejbPlugin.resolveViewMethod(owner, disposerMethod.getJavaMember());
-            }
         }
         else
         {
             this.producerMethod = producerMethod.getJavaMember();
-            if (disposerMethod != null)
-            {
-                disposalMethod = disposerMethod.getJavaMember();
-            }
-        }
-    }
-
-    @Override
-    public void defineInterceptorStack(final Bean<T> bean, final AnnotatedType<T> annotatedType, final WebBeansContext webBeansContext)
-    {
-        if (webBeansContext.getOpenWebBeansConfiguration().supportsInterceptionOnProducers())
-        {
-            super.defineInterceptorStack(bean, annotatedType, webBeansContext);
         }
     }
 
@@ -126,40 +94,4 @@ public class ProducerMethodProducer<T, P
             }
         }
     }
-
-    @Override
-    public void dispose(T instance)
-    {
-        if (disposalMethod != null)
-        {
-            P parentInstance = null;
-            CreationalContext<P> parentCreationalContext = null;
-            InjectableMethod<T> m;
-            try
-            {
-                parentCreationalContext = webBeansContext.getBeanManagerImpl().createCreationalContext(owner);
-
-                if (!Modifier.isStatic(disposalMethod.getModifiers()))
-                {
-                    parentInstance = (P)webBeansContext.getBeanManagerImpl().getReference(owner, owner.getBeanClass(), parentCreationalContext);
-                }
-
-                m = new InjectableMethod<T>(disposalMethod, parentInstance, this, (CreationalContextImpl<T>) parentCreationalContext, disposalIPs);
-                m.setDisposable(true);
-                m.setProducerMethodInstance(instance);
-
-                m.doInjection();
-
-            }
-            finally
-            {
-                parentCreationalContext.release();
-            }
-        }
-    }
-
-    public Set<InjectionPoint> getDisposalIPs()
-    {
-        return disposalIPs;
-    }
 }

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=1623574&r1=1623573&r2=1623574&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 Mon Sep  8 20:59:47 2014
@@ -1382,8 +1382,8 @@ public final class WebBeansUtil
         //Check for Enabled via Alternative
         setInjectionTargetBeanEnableFlag(managedBeanCreator.getBean());
         ManagedBean<T> managedBean = managedBeanCreator.getBean();
-        new ProducerMethodBeansBuilder(managedBean.getWebBeansContext(), managedBean.getAnnotatedType()).defineProducerMethods(managedBean);
-        new ProducerFieldBeansBuilder(managedBean.getWebBeansContext(), managedBean.getAnnotatedType()).defineProducerFields(managedBean);
+        new ProducerMethodBeansBuilder(managedBean.getWebBeansContext(), managedBean.getAnnotatedType()).defineProducerMethods(
+                managedBean, new ProducerFieldBeansBuilder(managedBean.getWebBeansContext(), managedBean.getAnnotatedType()).defineProducerFields(managedBean));
         new ObserverMethodsBuilder<T>(webBeansContext, managedBean.getAnnotatedType()).defineObserverMethods(managedBean);
 
         if (managedBean.getProducer() instanceof AbstractProducer)



Mime
View raw message