openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1591636 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: container/BeanManagerImpl.java event/EventImpl.java event/EventMetadataImpl.java util/GenericsUtil.java
Date Thu, 01 May 2014 12:29:17 GMT
Author: arne
Date: Thu May  1 12:29:16 2014
New Revision: 1591636

URL: http://svn.apache.org/r1591636
Log:
OWB-815: Fixed EventMetadata#getType() for special cases

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadataImpl.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=1591636&r1=1591635&r2=1591636&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 May  1 12:29:16 2014
@@ -69,7 +69,6 @@ import org.apache.webbeans.component.New
 import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.component.third.PassivationCapableThirdpartyBeanImpl;
 import org.apache.webbeans.component.third.ThirdpartyBeanImpl;
-import org.apache.webbeans.config.OwbParametrizedTypeImpl;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.decorator.DecoratorComparator;
@@ -413,9 +412,9 @@ public class BeanManagerImpl extends Abs
     public void fireEvent(Object event, Annotation... bindings)
     {       
         Type type = event.getClass();
-        if (event.getClass().getTypeParameters().length > 0)
+        if (GenericsUtil.hasTypeParameters(type))
         {
-            type = new OwbParametrizedTypeImpl(event.getClass().getDeclaringClass(), event.getClass(),
event.getClass().getTypeParameters());
+            type = GenericsUtil.getParameterizedType(type);
         }
         fireEvent(event, new EventMetadataImpl(type, null, bindings, webBeansContext), false);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java?rev=1591636&r1=1591635&r2=1591636&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java
Thu May  1 12:29:16 2014
@@ -21,6 +21,7 @@ package org.apache.webbeans.event;
 import java.io.IOException;
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
 import java.util.Set;
 
 import javax.enterprise.event.Event;
@@ -29,6 +30,7 @@ import javax.enterprise.util.TypeLiteral
 
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.util.Asserts;
+import org.apache.webbeans.util.GenericsUtil;
 
 /**
  * Event implementation.
@@ -77,7 +79,12 @@ public class EventImpl<T> implements Eve
     @Override
     public void fire(T event)
     {
-        webBeansContext.getBeanManagerImpl().fireEvent(event, metadata, false);
+        Type eventType = event.getClass();
+        if (GenericsUtil.hasTypeParameters(eventType))
+        {
+            eventType = GenericsUtil.resolveType(GenericsUtil.getParameterizedType(eventType),
metadata.getType());
+        }
+        webBeansContext.getBeanManagerImpl().fireEvent(event, metadata.select(eventType),
false);
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadataImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadataImpl.java?rev=1591636&r1=1591635&r2=1591636&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadataImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadataImpl.java
Thu May  1 12:29:16 2014
@@ -33,7 +33,6 @@ import javax.enterprise.util.TypeLiteral
 
 import org.apache.webbeans.annotation.AnyLiteral;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.ArrayUtil;
 import org.apache.webbeans.util.GenericsUtil;
 
@@ -59,7 +58,7 @@ public class EventMetadataImpl implement
         Set<Annotation> completeQualifiers;
         if (qualifiers.length == 0)
         {
-            completeQualifiers = AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION;
+            completeQualifiers = Collections.<Annotation>singleton(AnyLiteral.INSTANCE);
         }
         else
         {

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=1591636&r1=1591635&r2=1591636&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 May  1 12:29:16 2014
@@ -548,7 +548,6 @@ public final class GenericsUtil
      * 
      * @param type the type to get the closure for
      * @param actualType the context to bind type variables
-     * @param declaringClass the class declaring the type
      * @return the type closure
      */
     public static Set<Type> getTypeClosure(Type type, Type actualType)
@@ -559,14 +558,9 @@ public final class GenericsUtil
         {
             return getTypeClosure(actualType, type);
         }
-        if (type instanceof Class)
+        if (hasTypeParameters(type))
         {
-            Class<?> classType = (Class<?>)type;
-            TypeVariable<?>[] typeParameters = classType.getTypeParameters();
-            if (typeParameters.length > 0)
-            {
-                type = new OwbParametrizedTypeImpl(classType.getDeclaringClass(), classType,
typeParameters);
-            }
+            type = getParameterizedType(type);
         }
         Set<Type> typeClosure = new HashSet<Type>();
         typeClosure.add(Object.class);
@@ -593,7 +587,17 @@ public final class GenericsUtil
         }
     }
 
-    static ParameterizedType getParameterizedType(Type type)
+    public static boolean hasTypeParameters(Type type)
+    {
+        if (type instanceof Class)
+        {
+            Class<?> classType = (Class<?>)type;
+            return classType.getTypeParameters().length > 0;
+        }
+        return false;
+    }
+
+    public static ParameterizedType getParameterizedType(Type type)
     {
         if (type instanceof ParameterizedType)
         {



Mime
View raw message