openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1798674 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: configurator/ObserverMethodConfiguratorImpl.java portable/events/ProcessObserverMethodImpl.java
Date Wed, 14 Jun 2017 12:59:12 GMT
Author: struberg
Date: Wed Jun 14 12:59:12 2017
New Revision: 1798674

URL: http://svn.apache.org/viewvc?rev=1798674&view=rev
Log:
OWB-1186 delegate through to original ObserverMethod for ProcessOM

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/ObserverMethodConfiguratorImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessObserverMethodImpl.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/ObserverMethodConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/ObserverMethodConfiguratorImpl.java?rev=1798674&r1=1798673&r2=1798674&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/ObserverMethodConfiguratorImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/ObserverMethodConfiguratorImpl.java
Wed Jun 14 12:59:12 2017
@@ -42,6 +42,7 @@ import java.util.stream.Collectors;
 
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.event.EventContextImpl;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.WebBeansException;
 
@@ -50,6 +51,8 @@ public class ObserverMethodConfiguratorI
 {
     private final WebBeansContext webBeansContext;
 
+    private ObserverMethod<T> originalObserverMethod;
+
     /**
      * The Extension which added this very ObserverMethod
      */
@@ -66,10 +69,19 @@ public class ObserverMethodConfiguratorI
     private EventConsumer notifyWith;
 
 
+    /**
+     * Used for ProcessObserverMethod and ProcessSyntheticObserverMethod.
+     *
+     * In this case the Configurator just tweaks the Qualifiers, etc, but does _not_
+     * change the Notification.
+     * EXCEPT a {@link #notifyWith(EventConsumer)} is set!
+     */
     public ObserverMethodConfiguratorImpl(WebBeansContext webBeansContext, Extension extension,
ObserverMethod<T> observerMethod)
     {
         this(webBeansContext, extension);
         read(observerMethod);
+
+        this.originalObserverMethod = observerMethod;
     }
 
     public ObserverMethodConfiguratorImpl(WebBeansContext webBeansContext, Extension extension)
@@ -279,6 +291,7 @@ public class ObserverMethodConfiguratorI
             webBeansContext.getBeanManagerImpl().getErrorStack().pushError(e);
             return null;
         }
+
         return new ConfiguredObserverMethod();
     }
 
@@ -322,7 +335,7 @@ public class ObserverMethodConfiguratorI
         @Override
         public void notify(T event)
         {
-
+            notify(new EventContextImpl<>(event, null));
         }
 
         @Override
@@ -330,7 +343,16 @@ public class ObserverMethodConfiguratorI
         {
             try
             {
-                notifyWith.accept(eventContext);
+                if (notifyWith == null && originalObserverMethod != null)
+                {
+                    // In case of ProcessObserverMethod with no switched-out Consumer
+                    // we just deletage through to the original ObserverMethos
+                    originalObserverMethod.notify((EventContext) eventContext);
+                }
+                else
+                {
+                    notifyWith.accept(eventContext);
+                }
             }
             catch (Exception e)
             {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessObserverMethodImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessObserverMethodImpl.java?rev=1798674&r1=1798673&r2=1798674&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessObserverMethodImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessObserverMethodImpl.java
Wed Jun 14 12:59:12 2017
@@ -19,12 +19,14 @@
 package org.apache.webbeans.portable.events;
 
 import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.enterprise.inject.spi.ProcessObserverMethod;
 import javax.enterprise.inject.spi.configurator.ObserverMethodConfigurator;
 
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.configurator.ObserverMethodConfiguratorImpl;
+import org.apache.webbeans.portable.events.discovery.ExtensionAware;
 
 /**
  * Implementation of  {@link ProcessObserverMethod}.
@@ -34,7 +36,7 @@ import org.apache.webbeans.configurator.
  * @param <X> declared bean class
  * @param <T> event type
  */
-public class ProcessObserverMethodImpl<T,X> extends EventBase implements ProcessObserverMethod<T,
X>
+public class ProcessObserverMethodImpl<T,X> extends EventBase implements ProcessObserverMethod<T,
X>, ExtensionAware
 {
     private final WebBeansContext webBeansContext;
 
@@ -46,13 +48,22 @@ public class ProcessObserverMethodImpl<T
     private boolean vetoed = false;
     private ObserverMethodConfiguratorImpl observerMethodConfigurator = null;
 
+    private Extension extension;
+
+
     public ProcessObserverMethodImpl(WebBeansContext webBeansContext, AnnotatedMethod<X>
annotatedMethod,ObserverMethod<T> observerMethod)
     {
         this.webBeansContext = webBeansContext;
         this.annotatedMethod = annotatedMethod;
         this.observerMethod = observerMethod;
     }
-    
+
+    @Override
+    public void setExtension(Extension extension)
+    {
+        this.extension = extension;
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -66,7 +77,7 @@ public class ProcessObserverMethodImpl<T
     @Override
     public ObserverMethodConfigurator<T> configureObserverMethod()
     {
-        this.observerMethodConfigurator = new ObserverMethodConfiguratorImpl(webBeansContext,
null, observerMethod);
+        this.observerMethodConfigurator = new ObserverMethodConfiguratorImpl(webBeansContext,
extension, observerMethod);
         return observerMethodConfigurator;
     }
 



Mime
View raw message