openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1607453 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/creation/ObserverMethodsBuilder.java event/ContainerEventObserverMethodImpl.java event/NotificationManager.java event/ObserverMethodImpl.java
Date Wed, 02 Jul 2014 19:17:22 GMT
Author: struberg
Date: Wed Jul  2 19:17:21 2014
New Revision: 1607453

URL: http://svn.apache.org/r1607453
Log:
fix observer method qualifier and injection point detection

The code was basically ok, but it didn't work with
custom AnnotatedType which 
a.) do not properly point to their 'parent' -> add the annotatedMethod as parameter
b.) create new wrapper objects each time they get called. This breaks == comparison

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/event/ContainerEventObserverMethodImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.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=1607453&r1=1607452&r2=1607453&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
Wed Jul  2 19:17:21 2014
@@ -91,7 +91,8 @@ public class ObserverMethodsBuilder<T, I
                 checkObserverMethodConditions(bean, observesParameter);
                 
                 //Looking for ObserverMethod
-                ObserverMethod<?> definedObserver = webBeansContext.getBeanManagerImpl().getNotificationManager().getObservableMethodForAnnotatedMethod(observesParameter,
bean);
+                ObserverMethod<?> definedObserver = webBeansContext.getBeanManagerImpl().getNotificationManager().
+                        getObservableMethodForAnnotatedMethod(annotatedMethod, observesParameter,
bean);
                 definedObservers.add(definedObserver);
             }
         }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ContainerEventObserverMethodImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ContainerEventObserverMethodImpl.java?rev=1607453&r1=1607452&r2=1607453&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ContainerEventObserverMethodImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ContainerEventObserverMethodImpl.java
Wed Jul  2 19:17:21 2014
@@ -21,14 +21,16 @@ package org.apache.webbeans.event;
 import org.apache.webbeans.component.AbstractOwbBean;
 import org.apache.webbeans.portable.events.discovery.ExtensionAware;
 
+import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
 import java.lang.reflect.InvocationTargetException;
 
 public class ContainerEventObserverMethodImpl<T> extends ObserverMethodImpl<T>
 {
-    public ContainerEventObserverMethodImpl(final AbstractOwbBean<?> bean, final AnnotatedParameter<T>
annotatedObservesParameter)
+    public ContainerEventObserverMethodImpl(final AbstractOwbBean<?> bean, final AnnotatedMethod<T>
annotatedObserverMethod,
+                                            final AnnotatedParameter<T> annotatedObservesParameter)
     {
-        super(bean, annotatedObservesParameter);
+        super(bean, annotatedObserverMethod, annotatedObservesParameter);
     }
 
     @Override

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=1607453&r1=1607452&r2=1607453&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 Jul  2 19:17:21 2014
@@ -496,14 +496,14 @@ public final class NotificationManager
      * @param bean bean instance 
      * @return ObserverMethod
      */
-    public <T> ObserverMethod<?> getObservableMethodForAnnotatedMethod(AnnotatedParameter<?>
annotatedParameter, AbstractOwbBean<T> bean)
+    public <T> ObserverMethod<?> getObservableMethodForAnnotatedMethod(AnnotatedMethod<?>
annotatedMethod, AnnotatedParameter<?> annotatedParameter, AbstractOwbBean<T>
bean)
     {
         Asserts.assertNotNull(annotatedParameter, "annotatedParameter can not be null");
         
         //Observer creation from annotated method
         ObserverMethodImpl<T> observer = isContainerEvent(annotatedParameter)?
-                new ContainerEventObserverMethodImpl(bean, annotatedParameter) :
-                new ObserverMethodImpl(bean, annotatedParameter);
+                new ContainerEventObserverMethodImpl(bean, annotatedMethod, annotatedParameter)
:
+                new ObserverMethodImpl(bean, annotatedMethod, annotatedParameter);
         
         //Adds this observer
         addObserver(observer, annotatedParameter.getBaseType());

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java?rev=1607453&r1=1607452&r2=1607453&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
Wed Jul  2 19:17:21 2014
@@ -125,15 +125,12 @@ public class ObserverMethodImpl<T> imple
      * used if the qualifiers and event type are already known, e.g. from the XML.
      * @param bean
      * @param annotatedObserverMethod
-     * @param ifExist
-     * @param qualifiers
-     * @param observedEventType
      */
-    public ObserverMethodImpl(AbstractOwbBean<?> bean, AnnotatedParameter<T>
annotatedObservesParameter)
+    public ObserverMethodImpl(AbstractOwbBean<?> bean, AnnotatedMethod<T> annotatedObserverMethod,
AnnotatedParameter<T> annotatedObservesParameter)
     {
         this.bean = bean;
         this.annotatedObservesParameter = annotatedObservesParameter;
-        annotatedObserverMethod = (AnnotatedMethod<T>)annotatedObservesParameter.getDeclaringCallable();
+        this.annotatedObserverMethod = annotatedObserverMethod;
         observedEventType = annotatedObservesParameter.getBaseType();
         Observes observes = annotatedObservesParameter.getAnnotation(Observes.class);
         ifExist = observes.notifyObserver() == Reception.IF_EXISTS;
@@ -160,7 +157,7 @@ public class ObserverMethodImpl<T> imple
         injectionPoints = new LinkedHashSet<InjectionPoint>();
         for (AnnotatedParameter<?> parameter: annotatedObserverMethod.getParameters())
         {
-            if (parameter != annotatedObservesParameter)
+            if (!parameter.isAnnotationPresent(Observes.class))
             {
                 Collection<Annotation> qualifierAnnots = getWebBeansContext().getAnnotationManager().getQualifierAnnotations(parameter.getAnnotations());
 



Mime
View raw message