openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1803385 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/event/ test/java/org/apache/webbeans/test/events/injectiontarget/
Date Sat, 29 Jul 2017 18:27:06 GMT
Author: struberg
Date: Sat Jul 29 18:27:06 2017
New Revision: 1803385

URL: http://svn.apache.org/viewvc?rev=1803385&view=rev
Log:
OWB-1205 omit sending ProcessInjectionPoint when parsing Extension lifecycle observer methods

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ContainerEventObserverMethodImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionPointTest.java

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=1803385&r1=1803384&r2=1803385&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
Sat Jul 29 18:27:06 2017
@@ -38,7 +38,9 @@ public class ContainerEventObserverMetho
     public ContainerEventObserverMethodImpl(AbstractOwbBean<?> bean, AnnotatedMethod<T>
annotatedObserverMethod,
                                             AnnotatedParameter<T> annotatedObservesParameter)
     {
-        super(bean, annotatedObserverMethod, annotatedObservesParameter);
+        // we do NOT fire any further events while building this ObserverMethod, e.g for
ProcessInjectionPoint...
+        super(bean, annotatedObserverMethod, annotatedObservesParameter, false);
+
         WithAnnotations withAnnotationsAnn = annotatedObservesParameter.getAnnotation(WithAnnotations.class);
         if (withAnnotationsAnn != null)
         {

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=1803385&r1=1803384&r2=1803385&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
Sat Jul 29 18:27:06 2017
@@ -134,6 +134,11 @@ public class ObserverMethodImpl<T> imple
      */
     public ObserverMethodImpl(AbstractOwbBean<?> ownerBean, AnnotatedMethod<T>
annotatedObserverMethod, AnnotatedParameter<T> annotatedObservesParameter)
     {
+        this(ownerBean, annotatedObserverMethod, annotatedObservesParameter, true);
+    }
+
+    protected ObserverMethodImpl(AbstractOwbBean<?> ownerBean, AnnotatedMethod<T>
annotatedObserverMethod, AnnotatedParameter<T> annotatedObservesParameter, boolean fireEvent)
+    {
         this.ownerBean = ownerBean;
         this.annotatedObservesParameter = annotatedObservesParameter;
         this.annotatedObserverMethod = annotatedObserverMethod;
@@ -189,7 +194,7 @@ public class ObserverMethodImpl<T> imple
         {
             if (!parameter.isAnnotationPresent(observerAnnotation))
             {
-                injectionPoints.add(getWebBeansContext().getInjectionPointFactory().buildInjectionPoint(ownerBean,
parameter, true));
+                injectionPoints.add(getWebBeansContext().getInjectionPointFactory().buildInjectionPoint(ownerBean,
parameter, fireEvent));
             }
         }
 

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionPointTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionPointTest.java?rev=1803385&r1=1803384&r2=1803385&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionPointTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionPointTest.java
Sat Jul 29 18:27:06 2017
@@ -20,6 +20,8 @@ import javax.enterprise.context.Dependen
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.Typed;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
 import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.ProcessInjectionPoint;
 import javax.inject.Inject;
@@ -30,6 +32,15 @@ import org.junit.Test;
 
 public class ProcessInjectionPointTest extends AbstractUnitTest
 {
+    @Test
+    public void testBeforeBeanDiscoveryMustNotTriggerProcessInjectionPoint()
+    {
+        addExtension(new TestExtension2());
+        startContainer(X.class);
+
+        TestExtension2 extensionBeanInstance = getInstance(TestExtension2.class);
+        Assert.assertNotNull(extensionBeanInstance);
+    }
 
     @Test
     public void testConsumerAScanning()
@@ -43,6 +54,9 @@ public class ProcessInjectionPointTest e
 
         Assert.assertFalse(extension.isBInjectionPointParsed());
         Assert.assertFalse(extension.isOtherInjectionPointParsed());
+
+        TestExtension extensionBeanInstance = getInstance(TestExtension.class);
+        Assert.assertNotNull(extensionBeanInstance);
     }
 
     @Test
@@ -110,11 +124,13 @@ public class ProcessInjectionPointTest e
         Assert.assertTrue(extension.isRawInstanceInjectionPointParsed());
     }
 
-    public interface SomeInterface {
+    public interface SomeInterface
+    {
         void doSomething();
     }
 
-    public static class SomeImpl implements SomeInterface {
+    public static class SomeImpl implements SomeInterface
+    {
         @Override
         public void doSomething()
         {
@@ -276,4 +292,21 @@ public class ProcessInjectionPointTest e
             return explicitInstanceInjectionPointParsed;
         }
     }
-}
+
+    public static class TestExtension2 implements Extension
+    {
+        void TestWeirdBeforeBeanDiscovery(@Observes BeforeBeanDiscovery bbd, BeanManager
unusedBeanManager)
+        {
+            // all fine, this is just to test an old problem with firing
+            // ProcessInjectionPoint for Extension observers as well.
+            // Which created a problem because the Extensions are not yet ready.
+        }
+
+        void testExplicitInstance(@Observes ProcessInjectionPoint<?, ?> pip, BeanManager
unusedBeanManager)
+        {
+            // nothing to do
+        }
+
+
+    }
+}
\ No newline at end of file



Mime
View raw message