openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1628898 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: container/BeanManagerImpl.java util/GenericsUtil.java
Date Thu, 02 Oct 2014 07:27:44 GMT
Author: rmannibucau
Date: Thu Oct  2 07:27:44 2014
New Revision: 1628898

URL: http://svn.apache.org/r1628898
Log:
supporting raw producer for any parameterized injection point

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=1628898&r1=1628897&r2=1628898&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
Thu Oct  2 07:27:44 2014
@@ -694,8 +694,9 @@ public class BeanManagerImpl implements 
         //Check type if bean type is given
         if(beanType != null && beanType != Object.class)
         {
-            if(!isBeanTypeAssignableToGivenType(bean.getTypes(), beanType, bean instanceof
NewBean) &&
-               !GenericsUtil.satisfiesDependency(false, AbstractProducerBean.class.isInstance(bean),
beanType, bean.getBeanClass()))
+            final boolean isProducer = AbstractProducerBean.class.isInstance(bean);
+            if(!isBeanTypeAssignableToGivenType(bean.getTypes(), beanType, bean instanceof
NewBean, isProducer) &&
+               !GenericsUtil.satisfiesDependency(false, isProducer, beanType, bean.getBeanClass()))
             {
                 throw new IllegalArgumentException("Given bean type : " + beanType + " is
not applicable for the bean instance : " + bean);
             }
@@ -866,24 +867,21 @@ public class BeanManagerImpl implements 
     }
 
 
-    private boolean isBeanTypeAssignableToGivenType(Set<Type> beanTypes, Type givenType,
boolean newBean)
+    private boolean isBeanTypeAssignableToGivenType(Set<Type> beanTypes, Type givenType,
boolean newBean, boolean producer)
     {
-        Iterator<Type> itBeanApiTypes = beanTypes.iterator();
-        while (itBeanApiTypes.hasNext())
+        for (final Type beanApiType : beanTypes)
         {
-            Type beanApiType = itBeanApiTypes.next();
-
-            if(GenericsUtil.satisfiesDependency(false, false, givenType, beanApiType))
+            if (GenericsUtil.satisfiesDependency(false, producer, givenType, beanApiType))
             {
                 return true;
             }
             else
             {
                 //Check for @New
-                if(newBean && ClassUtil.isParametrizedType(givenType))
+                if (newBean && ClassUtil.isParametrizedType(givenType))
                 {
                     Class<?> requiredType = ClassUtil.getClass(givenType);
-                    if(ClassUtil.isClassAssignable(requiredType, ClassUtil.getClass(beanApiType)))
+                    if (ClassUtil.isClassAssignable(requiredType, ClassUtil.getClass(beanApiType)))
                     {
                         return true;
                     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java?rev=1628898&r1=1628897&r2=1628898&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java
Thu Oct  2 07:27:44 2014
@@ -316,7 +316,10 @@ public final class GenericsUtil
             }
             else if (!isAssignableFrom(isDelegateOrEvent, false, injectionPointTypeArgument,
beanTypeArgument))
             {
-                return false;
+                if (!isProducer || beanTypeArgument != Object.class) // if unbound that's
ok for producers (5.2.3 IIRC)
+                {
+                    return false;
+                }
             }
         }
         return true;



Mime
View raw message