openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1802363 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/util/WebBeansUtil.java test/java/org/apache/webbeans/test/events/container/ test/java/org/apache/webbeans/test/events/container/SpecificContainerEventTest.java
Date Wed, 19 Jul 2017 07:42:46 GMT
Author: rmannibucau
Date: Wed Jul 19 07:42:46 2017
New Revision: 1802363

URL: http://svn.apache.org/viewvc?rev=1802363&view=rev
Log:
OWB-1203 ensure ProcessSyntheticBean event is handled correctly in extensions

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/container/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/container/SpecificContainerEventTest.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java

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=1802363&r1=1802362&r2=1802363&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
Wed Jul 19 07:42:46 2017
@@ -80,6 +80,7 @@ import org.apache.webbeans.portable.even
 import org.apache.webbeans.portable.events.generics.GProcessProducerMethod;
 import org.apache.webbeans.portable.events.generics.GProcessSessionBean;
 import org.apache.webbeans.portable.events.generics.GProcessSyntheticAnnotatedType;
+import org.apache.webbeans.portable.events.generics.GProcessSyntheticBean;
 import org.apache.webbeans.portable.events.generics.GProcessSyntheticObserverMethod;
 import org.apache.webbeans.spi.plugins.OpenWebBeansEjbPlugin;
 import org.apache.webbeans.spi.plugins.OpenWebBeansPlugin;
@@ -126,6 +127,7 @@ import javax.enterprise.inject.spi.Proce
 import javax.enterprise.inject.spi.ProcessProducerMethod;
 import javax.enterprise.inject.spi.ProcessSessionBean;
 import javax.enterprise.inject.spi.ProcessSyntheticAnnotatedType;
+import javax.enterprise.inject.spi.ProcessSyntheticBean;
 import javax.enterprise.inject.spi.ProcessSyntheticObserverMethod;
 import javax.enterprise.inject.spi.Producer;
 import javax.enterprise.util.TypeLiteral;
@@ -1208,7 +1210,8 @@ public final class WebBeansUtil
             GProcessBeanAttributes.class,
             GProcessManagedBean.class,
             GProcessSessionBean.class,
-            GProcessBean.class}));
+            GProcessBean.class,
+            GProcessSyntheticBean.class}));
     public static boolean isExtensionBeanEventType(Type type)
     {
         return EXTENSION_BEAN_EVENT_TYPES.contains(type);
@@ -1223,7 +1226,8 @@ public final class WebBeansUtil
             ProcessBeanAttributes.class,
             ProcessManagedBean.class,
             ProcessBean.class,
-            ProcessSessionBean.class}));
+            ProcessSessionBean.class,
+            ProcessSyntheticBean.class}));
     public static boolean isDefaultExtensionBeanEventType(Class<?> clazz)
     {
         return DEFAULT_EXTENSION_BEAN_EVENT_TYPE.contains(clazz);

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/container/SpecificContainerEventTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/container/SpecificContainerEventTest.java?rev=1802363&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/container/SpecificContainerEventTest.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/container/SpecificContainerEventTest.java
Wed Jul 19 07:42:46 2017
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.webbeans.test.events.container;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessBean;
+
+import org.apache.webbeans.annotation.DefaultLiteral;
+import org.apache.webbeans.test.AbstractUnitTest;
+import org.junit.Test;
+
+public class SpecificContainerEventTest extends AbstractUnitTest
+{
+    @Test
+    public void captureSpecific()
+    {
+        final AtomicInteger counter = new AtomicInteger(0);
+        addExtension(new Extension()
+        {
+            void onProcessBean(@Observes final ProcessBean<Foo> foo)
+            {
+                counter.incrementAndGet();
+            }
+
+            void onAfterBeanDiscovery(@Observes final AfterBeanDiscovery afterBeanDiscovery)
+            {
+                afterBeanDiscovery.addBean()
+                        .addType(Bar.class)
+                        .addQualifier(DefaultLiteral.INSTANCE)
+                        .createWith(c -> new Bar());
+            }
+        });
+        startContainer(Foo.class);
+        assertEquals(1, counter.get());
+    }
+
+    @ApplicationScoped
+    public static class Foo
+    {
+    }
+
+    public static class Bar
+    {
+    }
+}



Mime
View raw message