openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1818673 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/ main/java/org/apache/webbeans/component/creation/ main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/corespi/se/ main/java/org/ap...
Date Tue, 19 Dec 2017 14:37:36 GMT
Author: struberg
Date: Tue Dec 19 14:37:36 2017
New Revision: 1818673

URL: http://svn.apache.org/viewvc?rev=1818673&view=rev
Log:
OWB-1215 completely rework all the producer method specialization logic


Removed:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SortedListHelper.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.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/corespi/se/DefaultContextsService.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/specialized/SpecializeDeactivationTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/ProducerMethodSpecialisationTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java?rev=1818673&r1=1818672&r2=1818673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
Tue Dec 19 14:37:36 2017
@@ -113,14 +113,4 @@ public class AbstractProducerBean<T> ext
         return true;
     }
 
-    /**
-     * For producer beans we add the info about the owner component
-     */
-    @Override
-    protected void addToStringInfo(StringBuilder builder)
-    {
-        Class<?> returnType = ownerComponent.getBeanClass();
-        builder.append(", OwnerBean Class: ")
-            .append(returnType != null ? returnType.getName() : "null");
-    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java?rev=1818673&r1=1818672&r2=1818673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
Tue Dec 19 14:37:36 2017
@@ -99,4 +99,14 @@ public class ProducerFieldBean<T> extend
         }
         return passivatingId;
     }
+
+    /**
+     * For producer beans we add the info about the owner component
+     */
+    @Override
+    protected void addToStringInfo(StringBuilder builder)
+    {
+        builder.append(", Producer Field: " + producerField);
+    }
+
 }

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=1818673&r1=1818672&r2=1818673&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
Tue Dec 19 14:37:36 2017
@@ -106,4 +106,14 @@ public class ProducerMethodBean<T> exten
     {
         return isPassivationCapable(creatorMethod.getReturnType(), creatorMethod.getModifiers());
     }
+
+    /**
+     * For producer beans we add the info about the owner component
+     */
+    @Override
+    protected void addToStringInfo(StringBuilder builder)
+    {
+        builder.append(", Producer Method: " + creatorMethod);
+    }
+
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java?rev=1818673&r1=1818672&r2=1818673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
Tue Dec 19 14:37:36 2017
@@ -18,12 +18,8 @@
  */
 package org.apache.webbeans.component.creation;
 
-import java.lang.reflect.Method;
 import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
 
-import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
 import javax.enterprise.inject.spi.Bean;
@@ -33,7 +29,6 @@ import javax.enterprise.inject.spi.Defin
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.ProducerMethodBean;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.ClassUtil;
 
 public class ProducerMethodBeanBuilder<T> extends AbstractProducerBeanBuilder<T,
AnnotatedMethod<?>, ProducerMethodBean<T>>
@@ -44,35 +39,6 @@ public class ProducerMethodBeanBuilder<T
         super(parent, annotatedMethod, beanAttributes);
     }
 
-    public void configureProducerSpecialization(ProducerMethodBean<T> bean, AnnotatedMethod<T>
annotatedMethod)
-    {
-        List<AnnotatedParameter<T>> annotatedParameters = annotatedMethod.getParameters();
-        List<Class<?>> parameters = new ArrayList<>();
-        for(AnnotatedParameter<T> annotatedParam : annotatedParameters)
-        {
-            parameters.add(ClassUtil.getClass(annotatedParam.getBaseType()));
-        }
-
-        Method superMethod = bean.getWebBeansContext().getSecurityService().doPrivilegedGetDeclaredMethod(annotatedMethod.getDeclaringType().getJavaClass().getSuperclass(),
-                annotatedMethod.getJavaMember().getName(), parameters.toArray(new Class[parameters.size()]));
-
-        if (superMethod == null)
-        {
-            throw new WebBeansConfigurationException("Annotated producer method specialization
failed : " + annotatedMethod.getJavaMember().getName()
-                                                     + " not found in super class : " + annotatedMethod.getDeclaringType().getJavaClass().getSuperclass().getName()
-                                                     + " for annotated method : " + annotatedMethod);
-        }
-        
-        if (!AnnotationUtil.hasAnnotation(superMethod.getAnnotations(), Produces.class))
-        {
-            throw new WebBeansConfigurationException("Annotated producer method specialization
failed : " + annotatedMethod.getJavaMember().getName()
-                                                     + " found in super class : " + annotatedMethod.getDeclaringType().getJavaClass().getSuperclass().getName()
-                                                     + " is not annotated with @Produces"
+ " for annotated method : " + annotatedMethod);
-        }
-        
-        bean.setSpecializedBean(true);        
-    }
-
     @Override
     protected <P> ProducerMethodBean<T> createBean(InjectionTargetBean<P>
parent, Class<T> beanClass)
     {

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=1818673&r1=1818672&r2=1818673&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
Tue Dec 19 14:37:36 2017
@@ -107,9 +107,9 @@ public class ProducerMethodBeansBuilder<
                     }
                     producerMethodBeanCreator.validate();
 
-                    if(specialize)
+                    if (specialize)
                     {
-                        producerMethodBeanCreator.configureProducerSpecialization(producerMethodBean,
(AnnotatedMethod<T>) annotatedMethod);
+                        producerMethodBean.setSpecializedBean(true);
                     }
                     producerMethodBean.setCreatorMethod(annotatedMethod.getJavaMember());
 

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=1818673&r1=1818672&r2=1818673&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
Tue Dec 19 14:37:36 2017
@@ -127,6 +127,7 @@ import java.util.Set;
 import java.util.Stack;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import java.util.stream.Collectors;
 
 import static java.util.Arrays.asList;
 import static org.apache.webbeans.spi.BeanArchiveService.BeanDiscoveryMode;
@@ -311,7 +312,7 @@ public class BeansDeployer
                 // create beans from the discovered AnnotatedTypes
                 deployFromBeanAttributes(beanAttributesPerBda);
 
-                webBeansContext.getWebBeansUtil().configureProducerMethodSpecializations();
+                configureProducerMethodSpecializations();
 
                 // all beans which got 'overridden' by a Specialized version can be removed
now
                 removeDisabledBeans();
@@ -958,6 +959,126 @@ public class BeansDeployer
         return false;
     }
 
+    /**
+     * Configure direct/indirect specialized producer method beans.
+     * Also disable 'overwritten' producer method beans.
+     * But only if they got overwritten in an enabled alternative.
+     */
+    public void configureProducerMethodSpecializations()
+    {
+        Set<Bean<?>> beans = webBeansContext.getBeanManagerImpl().getBeans();
+
+        // Collect all producer method beans
+        // and sort them with subclasses first
+        // This is important as we can later go top-down and
+        // disable all 'overwritten' producer methods which must be
+        // further down in the list
+        List<ProducerMethodBean> producerMethodBeans = beans.stream()
+            .filter(ProducerMethodBean.class::isInstance)
+            .map(ProducerMethodBean.class::cast)
+            .sorted((e1, e2) ->
+                {
+                    if (e1.getBeanClass().isAssignableFrom(e2.getBeanClass()))
+                    {
+                        return 1;
+                    }
+                    else if (e1.equals(e2))
+                    {
+                        return 0;
+                    }
+                    return -1;
+                })
+            .collect(Collectors.toList());
+
+        checkSpecializedProducerMethodConditions(producerMethodBeans);
+
+        for (int i = 0; i < producerMethodBeans.size(); i++)
+        {
+            ProducerMethodBean<?> producerMethodBean = producerMethodBeans.get(i);
+            if (!producerMethodBean.isEnabled())
+            {
+                continue;
+            }
+
+            for (int j = i+1; j < producerMethodBeans.size(); j++)
+            {
+                ProducerMethodBean<?> otherProducerMethodBean = producerMethodBeans.get(j);
+
+                if (!otherProducerMethodBean.isEnabled())
+                {
+                    // already disabled
+                    continue;
+                }
+
+                if (producerMethodBean.getBeanClass().equals(otherProducerMethodBean.getBeanClass()))
+                {
+                    // must be another producerMethod from the same class. Probably different
qualifier?
+                    continue;
+                }
+
+                if (otherProducerMethodBean.getBeanClass().isAssignableFrom(producerMethodBean.getBeanClass()))
+                {
+                    // yikes we did hit a superclass!
+
+                    if (producerMethodBean.getCreatorMethod().getName().equals(otherProducerMethodBean.getCreatorMethod().getName()))
+                    {
+                        // disable the other bean as it got 'specialized' with the current
bean.
+                        otherProducerMethodBean.setEnabled(false);
+                    }
+                }
+                else
+                {
+                    // since all the producermethods are sorted we can stop
+                    // once we leave the 'block' of superclasses for a bean
+                    break;
+                }
+
+            }
+        }
+    }
+
+    /**
+     * Verify that all conditions for Specialized producer methdods are met.
+     * See spec section 3.3.3. Specializing a producer method
+     */
+    private void checkSpecializedProducerMethodConditions(List<ProducerMethodBean>
producerBeans)
+    {
+        Set<String> methodsDisabledDueToSpecialization = new HashSet<>();
+        for (ProducerMethodBean producerBean : producerBeans)
+        {
+            if (producerBean.isSpecializedBean())
+            {
+                Method creatorMethod = producerBean.getCreatorMethod();
+
+                Method overloadedMethod = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethod(
+                        creatorMethod.getDeclaringClass().getSuperclass(),
+                        creatorMethod.getName(),
+                        creatorMethod.getParameterTypes());
+                if (overloadedMethod == null)
+                {
+                    throw new WebBeansConfigurationException("Annotated producer method specialization
failed : " + creatorMethod.getName()
+                        + " not found in super class : " + creatorMethod.getDeclaringClass().getSuperclass().getName()
+                        + " for annotated method : " + creatorMethod);
+                }
+
+                if (!AnnotationUtil.hasAnnotation(creatorMethod.getAnnotations(), Produces.class))
+                {
+                    throw new WebBeansConfigurationException("Annotated producer method specialization
failed : " + creatorMethod.getName()
+                        + " found in super class : " + creatorMethod.getDeclaringClass().getSuperclass().getName()
+                        + " is not annotated with @Produces" + " for annotated method : "
+ creatorMethod);
+                }
+
+                String superMethod = overloadedMethod.toString();
+                if (methodsDisabledDueToSpecialization.contains(superMethod))
+                {
+                    throw new WebBeansDeploymentException("Multiple specializations for the
same producer method got detected for type"
+                        + producerBean);
+                }
+                methodsDisabledDueToSpecialization.add(superMethod);
+            }
+        }
+    }
+
 
     /**
      * Validate all injection points.

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java?rev=1818673&r1=1818672&r2=1818673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java
Tue Dec 19 14:37:36 2017
@@ -62,7 +62,6 @@ public class DefaultContextsService exte
     private static ThreadLocal<DependentContext> dependentContext;
 
 
-    private final boolean supportsConversation;
 
     static
     {
@@ -76,7 +75,6 @@ public class DefaultContextsService exte
     public DefaultContextsService(WebBeansContext webBeansContext)
     {
         super(webBeansContext);
-        this.supportsConversation = webBeansContext.getOpenWebBeansConfiguration().supportsConversation();
     }
 
     /**

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=1818673&r1=1818672&r2=1818673&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
Tue Dec 19 14:37:36 2017
@@ -146,7 +146,6 @@ import java.lang.reflect.ParameterizedTy
 import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
 import java.lang.reflect.WildcardType;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -593,255 +592,12 @@ public final class WebBeansUtil
         return new InjectionPointBean(webBeansContext);
     }
 
-    /**
-     * Configure a list of producer method beans, which override the same method
-     * and the bean classes are directly extended each other.
-     *
-     * @param sortedProducerBeans
-     */
-    private void configSpecializedProducerMethodBeans(List<ProducerMethodBean> sortedProducerBeans)
-    {
-        if (sortedProducerBeans.isEmpty())
-        {
-            return;
-        }
-
-        AlternativesManager altManager = webBeansContext.getAlternativesManager();
-        Method superMethod = sortedProducerBeans.get(0).getCreatorMethod();
-
-        for(int i=1; i<sortedProducerBeans.size(); i++)
-        {
-            ProducerMethodBean bean = sortedProducerBeans.get(i);
-            ProducerMethodBean superBean = sortedProducerBeans.get(i - 1);
-
-            // inherit name is super class has name
-            boolean isSuperHasName = isSuperMethodNamed(bean, bean.getCreatorMethod(), superMethod);
-
-            // disable super bean if needed
-            if (bean.getCreatorMethod().getAnnotation(Alternative.class) == null)
-            {
-                //disable superbean if the current bean is not an alternative
-                superBean.setEnabled(false);
-            }
-            else if(altManager.isAlternative(bean))
-            {
-                //disable superbean if the current bean is an enabled alternative
-                superBean.setEnabled(false);
-            }
-
-            //if no name defined, set superMethod to this bean since this
-            //bean's method might have name defined.
-            if (!isSuperHasName)
-            {
-                superMethod = bean.getCreatorMethod();
-            }
-        }
-    }
-
-    /**
-     * Configure direct/indirect specialized producer method beans.
-     */
-    public void configureProducerMethodSpecializations()
-    {
-        Method method;
-        ProducerMethodBean pbean;
-        ProducerMethodBean pLeft;
-        ProducerMethodBean pRight;
-
-        // collect all producer method beans
-        Set<Bean<?>> beans = webBeansContext.getBeanManagerImpl().getBeans();
-        List<ProducerMethodBean> producerBeans = new ArrayList<>();
-        Set<String> methodsDisabledDueToSpecialization = new HashSet<>();
-
-        for(Bean b : beans)
-        {
-            if (b instanceof ProducerMethodBean)
-            {
-                producerBeans.add((ProducerMethodBean)b);
-
-                if (((ProducerMethodBean) b).isSpecializedBean())
-                {
-                    Method creatorMethod = ((ProducerMethodBean) b).getCreatorMethod();
-                    Method overloadedMethod = getParentClassMethod(creatorMethod.getDeclaringClass(),
creatorMethod.getName(), creatorMethod.getParameterTypes());
-                    if (overloadedMethod == null)
-                    {
-                        throw new WebBeansDeploymentException("Specialized producer method
doesn't override method from a parent class"
-                            + b.toString());
-                    }
-
-                    String superMethod = overloadedMethod.toString();
-                    if (methodsDisabledDueToSpecialization.contains(superMethod))
-                    {
-                        throw new WebBeansDeploymentException("Multiple specializations for
the same producer method got detected for type"
-                                + b.toString());
-                    }
-                    methodsDisabledDueToSpecialization.add(superMethod);
-                }
-            }
-        }
-        methodsDisabledDueToSpecialization.clear(); // not needed any longer
-
-        // create sorted bean helper.
-        SortedListHelper<ProducerMethodBean> producerBeanListHelper = new
-            SortedListHelper<>(new ArrayList<>(),
-            (e1, e2) ->
-            {
-                if (e1.getBeanClass().isAssignableFrom(e2.getBeanClass()))
-                {
-                    return -1;
-                }
-                else if (e1.equals(e2))
-                {
-                    return 0;
-                }
-                return 1;
-            });
-
-        Set<Method> disabledProducerMethods = new HashSet<>();
-
-        while(true)
-        {
-            pbean = null;
-            method = null;
-            producerBeanListHelper.clear();
-
-            //locate the first specialized bean
-            for(ProducerMethodBean pb : producerBeans)
-            {
-                if (pb.isSpecializedBean())
-                {
-                    pbean = pb;
-                    method = pb.getCreatorMethod();
-                    producerBeanListHelper.add(pb);
-                    break;
-                }
-            }
-            if (pbean == null)
-            {
-                break;
-            }
-
-            pRight = pbean;
-            pLeft = pRight;
-            boolean pLeftContinue = true;
-            boolean pRightContinue = true;
-
-            // find all pbean's super beans and sub sub beans
-            while(pLeftContinue || pRightContinue)
-            {
-                pRightContinue = false;
-                pLeftContinue = false;
-                for(ProducerMethodBean pb : producerBeans)
-                {
-                    //left
-                    if (pLeft!= null &&
-                        pLeft.getBeanClass().getSuperclass().equals(pb.getBeanClass()))
-                    {
-                        Method superMethod = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethod(pb.getBeanClass(),
method.getName(), method.getParameterTypes());
-
-                        //Added by GE, method check is necessary otherwise getting wrong
method qualifier annotations
-                        if (superMethod != null && superMethod.equals(pb.getCreatorMethod()))
-                        {
-                            if (disabledProducerMethods.contains(superMethod))
-                            {
-                                throw new WebBeansConfigurationException("Multiple specializations
for the same producer method got detected for type"
-                                        + pbean.toString());
-                            }
-                            disabledProducerMethods.add(superMethod);
-                            producerBeanListHelper.add(pb);
-                            pLeft = (pb.isSpecializedBean()) ? pb : null;
-                        }
-                        else
-                        {
-                            pLeft = null;
-                        }
-                        if (pLeft != null)
-                        {
-                            pLeftContinue = true;
-                        }
-                    }
-                    //right
-                    if (pRight != null &&
-                        pb.getBeanClass().getSuperclass().equals(pRight.getBeanClass()))
-                    {
-                        if (!pb.isSpecializedBean())
-                        {
-                            pRight = null;
-                        }
-                        else
-                        {
-                            Method superMethod = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethod(pb.getBeanClass(),
-                                                                                        
                           method.getName(), method.getParameterTypes());
-                            //Added by GE, method check is necessary otherwise getting wrong
method qualifier annotations
-                            if (superMethod != null && superMethod.equals(pb.getCreatorMethod()))
-                            {
-                                producerBeanListHelper.add(pb);
-                                pRight = pb;
-                            }
-                            else
-                            {
-                                pRight = null;
-                            }
-                        }
-                        if (pRight != null)
-                        {
-                            pRightContinue = true;
-                        }
-                    }
-                } // for
-            } // while
-
-            //remove the group from producer bean list
-            for(ProducerMethodBean pb : producerBeanListHelper.getList())
-            {
-                producerBeans.remove(pb);
-            }
-            //configure the directly extended producer beans
-            configSpecializedProducerMethodBeans(producerBeanListHelper.getList());
-        }
-    }
-
-    /**
-     * Get the overloaded method with the exact signature as the given method from the parent
class.
-     */
-    private Method getParentClassMethod(Class<?> clazz, String methodName, Class[]
paramTypes)
-    {
-        Class<?> superClass = clazz.getSuperclass();
-        if (superClass != null && !superClass.equals(Object.class))
-        {
-            try
-            {
-                return superClass.getDeclaredMethod(methodName, paramTypes);
-            }
-            catch (NoSuchMethodException e)
-            {
-                // recurse further to the superclass
-                return getParentClassMethod(superClass, methodName, paramTypes);
-            }
-        }
-
-        return null;
-    }
-
-
     public <T> Constructor<T> getNoArgConstructor(Class<T> clazz)
     {
         return webBeansContext.getSecurityService().doPrivilegedGetDeclaredConstructor(clazz);
     }
 
     /**
-     * Configures the name of the producer method for specializing the parent.
-     *
-     * @param component producer method component
-     * @param method specialized producer method
-     * @param superMethod overriden super producer method
-     */
-    public boolean isSuperMethodNamed(AbstractOwbBean<?> component, Method method,
Method superMethod)
-    {
-        return webBeansContext.getAnnotationManager().isSuperMethodNamed(component, method,
superMethod);
-    }
-
-    /**
      * Returns true if instance injection point false otherwise.
      *
      * @param injectionPoint injection point definition

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/managed/specialized/SpecializeDeactivationTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/managed/specialized/SpecializeDeactivationTest.java?rev=1818673&r1=1818672&r2=1818673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/managed/specialized/SpecializeDeactivationTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/managed/specialized/SpecializeDeactivationTest.java
Tue Dec 19 14:37:36 2017
@@ -78,7 +78,7 @@ public class SpecializeDeactivationTest
         assertTrue(Impl2.called);
     }
 
-    public static interface API
+    public interface API
     {
         void init();
     }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/ProducerMethodSpecialisationTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/ProducerMethodSpecialisationTest.java?rev=1818673&r1=1818672&r2=1818673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/ProducerMethodSpecialisationTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/specalization/ProducerMethodSpecialisationTest.java
Tue Dec 19 14:37:36 2017
@@ -18,6 +18,7 @@
  */
 package org.apache.webbeans.test.specalization;
 
+import javax.enterprise.inject.Alternative;
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.Specializes;
 import javax.enterprise.util.AnnotationLiteral;
@@ -46,8 +47,14 @@ public class ProducerMethodSpecialisatio
         assertEquals("A-three", getInstance(String.class, new AnnotationLiteral<ThreeProducesMethod>(){}));
     }
 
+    @Test
+    public void testProducerMethodSpecialisation_NotEnabledAlternative()
+    {
+        startContainer(A.class, C.class);
+        assertEquals("A-one", getInstance(String.class, new AnnotationLiteral<OneProducesMethod>(){}));
+    }
 
-    public static class A 
+    public static class A
     {
         @Produces
         @OneProducesMethod
@@ -91,6 +98,18 @@ public class ProducerMethodSpecialisatio
     }
 
 
+    public static class C extends A
+    {
+        @Produces
+        @Specializes
+        @OneProducesMethod
+        @Alternative // not enabled!
+        public String getX()
+        {
+            return "C-one";
+        }
+    }
+
     @Retention(RetentionPolicy.RUNTIME)
     @Target({ElementType.METHOD, ElementType.TYPE})
     @Qualifier



Mime
View raw message