openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1798909 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptionFactoryBean.java webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java webbeans-tck/testng-dev.xml
Date Fri, 16 Jun 2017 11:08:52 GMT
Author: rmannibucau
Date: Fri Jun 16 11:08:52 2017
New Revision: 1798909

URL: http://svn.apache.org/viewvc?rev=1798909&view=rev
Log:
moving InterceptionFactory validation at startup

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptionFactoryBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-tck/testng-dev.xml

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptionFactoryBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptionFactoryBean.java?rev=1798909&r1=1798908&r2=1798909&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptionFactoryBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptionFactoryBean.java
Fri Jun 16 11:08:52 2017
@@ -73,23 +73,9 @@ public class InterceptionFactoryBean ext
                                                  final CreationalContextImpl<InterceptionFactory<?>>
creationalContext)
         {
             final InjectionPoint ip = creationalContext.getInjectionPoint();
-            if (!ParameterizedType.class.isInstance(ip.getType()))
-            {
-                throw new IllegalArgumentException(
-                        "No type specified for the interception factory, ensure to paramterize
it");
-            }
-            final ParameterizedType pt = ParameterizedType.class.cast(ip.getType());
-            if (pt.getActualTypeArguments() == null || pt.getActualTypeArguments().length
!= 1)
-            {
-                throw new IllegalArgumentException("No explicit type specified for the interception
factory");
-            }
-            final Type type = pt.getActualTypeArguments()[0];
-            if (!Class.class.isInstance(type))
-            {
-                throw new IllegalArgumentException("InterceptionFactory only works with Class,
no generics");
-            }
-
-            final AnnotatedType<?> at = context.getBeanManagerImpl().createAnnotatedType(Class.class.cast(type));
+            final AnnotatedType<?> at = context.getBeanManagerImpl().createAnnotatedType(
+                    // already validated at startup so let's be brutal at runtime
+                    Class.class.cast(ParameterizedType.class.cast(ip.getType()).getActualTypeArguments()[0]));
             return new InterceptionFactoryImpl(context, at, ip.getQualifiers(), creationalContext);
         }
     }

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=1798909&r1=1798908&r2=1798909&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
Fri Jun 16 11:08:52 2017
@@ -111,6 +111,7 @@ import javax.enterprise.inject.spi.Befor
 import javax.enterprise.inject.spi.DeploymentException;
 import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InterceptionFactory;
 import javax.enterprise.inject.spi.Interceptor;
 import javax.enterprise.inject.spi.PassivationCapable;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
@@ -1677,6 +1678,24 @@ public final class WebBeansUtil
                         throw new WebBeansConfigurationException("injected bean parameter
must be " + rawType);
                     }
                 }
+                else if (InterceptionFactory.class == rawType)
+                {
+                    if (!ParameterizedType.class.isInstance(injectionPoint.getType()))
+                    {
+                        throw new WebBeansConfigurationException(
+                                "No type specified for the interception factory, ensure to
paramterize it");
+                    }
+                    final ParameterizedType pt = ParameterizedType.class.cast(injectionPoint.getType());
+                    if (pt.getActualTypeArguments() == null || pt.getActualTypeArguments().length
!= 1)
+                    {
+                        throw new WebBeansConfigurationException("No explicit type specified
for the interception factory");
+                    }
+                    final Type type = pt.getActualTypeArguments()[0];
+                    if (!Class.class.isInstance(type))
+                    {
+                        throw new WebBeansConfigurationException("InterceptionFactory only
works with Class, no generics");
+                    }
+                }
 
                 if (isDecorator)
                 {

Modified: openwebbeans/trunk/webbeans-tck/testng-dev.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/testng-dev.xml?rev=1798909&r1=1798908&r2=1798909&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tck/testng-dev.xml (original)
+++ openwebbeans/trunk/webbeans-tck/testng-dev.xml Fri Jun 16 11:08:52 2017
@@ -18,7 +18,7 @@
 <suite name="JSR-346-TCK" verbose="2" configfailurepolicy="continue">
   <test name="JSR-346 TCK">
     <classes>
-          <class name="org.jboss.cdi.tck.tests.extensions.interceptionFactory.InterceptionFactoryTest"
/>
+          <class name="org.jboss.cdi.tck.tests.extensions.interceptionFactory.broken.InvalidInterceptionFactoryInjectionPointTest"
/>
       <!--
       <class name="org.jboss.cdi.tck.tests.event.parameterized.ParameterizedEventTest"
/>
       <class name="org.jboss.cdi.tck.tests.event.fires.FireEventTest" />



Mime
View raw message