openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1589348 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: event/NotificationManager.java util/GenericsUtil.java
Date Wed, 23 Apr 2014 06:30:12 GMT
Author: arne
Date: Wed Apr 23 06:30:11 2014
New Revision: 1589348

URL: http://svn.apache.org/r1589348
Log:
OWB-946: Fixed handling of parameterized injection point and raw bean/event type (org.jboss.cdi.tck.tests.event.parameterized.ParameterizedEventTest.testEventObjectTypeUsed)


Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.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/event/NotificationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java?rev=1589348&r1=1589347&r2=1589348&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
Wed Apr 23 06:30:11 2014
@@ -152,21 +152,24 @@ public final class NotificationManager
         
         Set<ObserverMethod<? super T>> matching = new HashSet<ObserverMethod<?
super T>>();
 
-        Type eventType = GenericsUtil.resolveType(declaredEventType, eventClass); 
+        Set<Type> eventTypes = GenericsUtil.getTypeClosure(declaredEventType, eventClass);

 
         Set<Type> observedTypes = observers.keySet();
 
         for (Type observedType : observedTypes)
         {
-            if (GenericsUtil.isAssignableFrom(false, observedType, eventType))
+            for (Type eventType : eventTypes)
             {
-                Set<ObserverMethod<?>> observerMethods = observers.get(observedType);
-
-                for (ObserverMethod<?> observerMethod : observerMethods)
+                if (GenericsUtil.isAssignableFrom(false, observedType, eventType))
                 {
-                    matching.add((ObserverMethod<T>) observerMethod);
+                    Set<ObserverMethod<?>> observerMethods = observers.get(observedType);
+
+                    for (ObserverMethod<?> observerMethod : observerMethods)
+                    {
+                        matching.add((ObserverMethod<T>) observerMethod);
+                    }
+                    break;
                 }
-                break;
             }
         }
         return matching;

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=1589348&r1=1589347&r2=1589348&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
Wed Apr 23 06:30:11 2014
@@ -224,13 +224,33 @@ public final class GenericsUtil
         }
         else
         {
-            throw new IllegalArgumentException("Unsupported type " + injectionPointType.getClass());
+            throw new IllegalArgumentException("Unsupported type " + beanType.getClass());
         }
     }
 
     private static boolean isAssignableFrom(boolean isDelegate, ParameterizedType injectionPointType,
Class<?> beanType)
     {
-        return isAssignableFrom(isDelegate, injectionPointType.getRawType(), beanType);
+        Class<?> rawInjectionPointType = getRawType(injectionPointType);
+        if (rawInjectionPointType.equals(beanType))
+        {
+            return true;
+        }
+        if (!rawInjectionPointType.isAssignableFrom(beanType))
+        {
+            return false;
+        }
+        if (beanType.getSuperclass() != null && isAssignableFrom(isDelegate, injectionPointType,
beanType.getGenericSuperclass()))
+        {
+            return true;
+        }
+        for (Type genericInterface: beanType.getGenericInterfaces())
+        {
+            if (isAssignableFrom(isDelegate, injectionPointType, genericInterface))
+            {
+                return true;
+            }
+        }
+        return false;
     }
 
     private static boolean isAssignableFrom(boolean isDelegate, ParameterizedType injectionPointType,
TypeVariable<?> beanType)



Mime
View raw message