openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1623059 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/creation/ObserverMethodsBuilder.java component/creation/ProducerMethodBeansBuilder.java config/BeansDeployer.java util/WebBeansUtil.java
Date Sun, 07 Sep 2014 15:42:49 GMT
Author: rmannibucau
Date: Sun Sep  7 15:42:49 2014
New Revision: 1623059

URL: http://svn.apache.org/r1623059
Log:
ensure EventMetadata is not used anywhere else as in observer parameters

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ObserverMethodsBuilder.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/util/WebBeansUtil.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ObserverMethodsBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ObserverMethodsBuilder.java?rev=1623059&r1=1623058&r2=1623059&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ObserverMethodsBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ObserverMethodsBuilder.java
Sun Sep  7 15:42:49 2014
@@ -18,6 +18,7 @@
  */
 package org.apache.webbeans.component.creation;
 
+import java.lang.annotation.Annotation;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -25,16 +26,19 @@ import java.util.Set;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.event.Observes;
 import javax.enterprise.event.Reception;
+import javax.enterprise.inject.Default;
 import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
 import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.DefinitionException;
+import javax.enterprise.inject.spi.EventMetadata;
+import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.inject.Inject;
 
 import org.apache.webbeans.component.AbstractOwbBean;
-import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.util.AnnotationUtil;
@@ -44,7 +48,7 @@ import org.apache.webbeans.util.Asserts;
  *
  * @param <T> bean class type
  */
-public class ObserverMethodsBuilder<T, I extends InjectionTargetBean<T>>
+public class ObserverMethodsBuilder<T>
 {    
     
     protected final WebBeansContext webBeansContext;
@@ -96,6 +100,20 @@ public class ObserverMethodsBuilder<T, I
                 definedObservers.add(definedObserver);
             }
         }
+
+        if (!definedObservers.isEmpty())
+        {
+            for (final InjectionPoint ip : bean.getInjectionPoints())
+            {
+                final Set<Annotation> qualifiers = ip.getQualifiers();
+                if (EventMetadata.class == ip.getType()
+                        && qualifiers != null && ip.getQualifiers().size()
== 1
+                        && Default.class == qualifiers.iterator().next().annotationType())
+                {
+                    throw new DefinitionException(ip + " is not an observer parameter");
+                }
+            }
+        }
         
         return definedObservers;
     }

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=1623059&r1=1623058&r2=1623059&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
Sun Sep  7 15:42:49 2014
@@ -105,6 +105,7 @@ public class ProducerMethodBeansBuilder<
                             producerMethodBean,
                             AnnotationUtil.asArray(annotatedMethod.getAnnotations()));
                     WebBeansUtil.checkProducerGenericType(producerMethodBean, annotatedMethod.getJavaMember());
+
                     producerBeans.add(producerMethodBean);
                 }
             }

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=1623059&r1=1623058&r2=1623059&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
Sun Sep  7 15:42:49 2014
@@ -1318,7 +1318,7 @@ public class BeansDeployer
                 Set<ObserverMethod<?>> observerMethods = new HashSet<ObserverMethod<?>>();
                 if(bean.isEnabled())
                 {
-                    observerMethods = new ObserverMethodsBuilder<T, InjectionTargetBean<T>>(webBeansContext,
bean.getAnnotatedType()).defineObserverMethods(bean);
+                    observerMethods = new ObserverMethodsBuilder<T>(webBeansContext,
bean.getAnnotatedType()).defineObserverMethods(bean);
                 }
                 Set<ProducerMethodBean<?>> producerMethods = new ProducerMethodBeansBuilder(bean.getWebBeansContext(),
bean.getAnnotatedType()).defineProducerMethods(bean);
                 Set<ProducerFieldBean<?>> producerFields = new ProducerFieldBeansBuilder(bean.getWebBeansContext(),
bean.getAnnotatedType()).defineProducerFields(bean);

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=1623059&r1=1623058&r2=1623059&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
Sun Sep  7 15:42:49 2014
@@ -489,7 +489,7 @@ public final class WebBeansUtil
         Asserts.nullCheckForClass(clazz);
         ExtensionBeanBuilder<T> extensionBeanBuilder = new ExtensionBeanBuilder<T>(webBeansContext,
clazz);
         ExtensionBean<T> bean = extensionBeanBuilder.getBean();
-        new ObserverMethodsBuilder<T, InjectionTargetBean<T>>(webBeansContext,
extensionBeanBuilder.getAnnotatedType()).defineObserverMethods(bean);
+        new ObserverMethodsBuilder<T>(webBeansContext, extensionBeanBuilder.getAnnotatedType()).defineObserverMethods(bean);
         return bean;
     }
 
@@ -1380,7 +1380,7 @@ public final class WebBeansUtil
         ManagedBean<T> managedBean = managedBeanCreator.getBean();
         new ProducerMethodBeansBuilder(managedBean.getWebBeansContext(), managedBean.getAnnotatedType()).defineProducerMethods(managedBean);
         new ProducerFieldBeansBuilder(managedBean.getWebBeansContext(), managedBean.getAnnotatedType()).defineProducerFields(managedBean);
-        new ObserverMethodsBuilder<T, InjectionTargetBean<T>>(webBeansContext,
managedBean.getAnnotatedType()).defineObserverMethods(managedBean);
+        new ObserverMethodsBuilder<T>(webBeansContext, managedBean.getAnnotatedType()).defineObserverMethods(managedBean);
 
         if (managedBean.getProducer() instanceof AbstractProducer)
         {



Mime
View raw message