openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rsandt...@apache.org
Subject svn commit: r1628162 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
Date Mon, 29 Sep 2014 11:36:27 GMT
Author: rsandtner
Date: Mon Sep 29 11:36:27 2014
New Revision: 1628162

URL: http://svn.apache.org/r1628162
Log:
OWB-1011 intercepted beans must be proxyable, added validation

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java?rev=1628162&r1=1628161&r2=1628162&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
Mon Sep 29 11:36:27 2014
@@ -41,8 +41,10 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.inject.spi.DeploymentException;
 import javax.enterprise.inject.spi.InterceptionType;
 import javax.enterprise.inject.spi.Interceptor;
+import javax.inject.Inject;
 import javax.interceptor.ExcludeClassInterceptors;
 import javax.interceptor.Interceptors;
 import javax.interceptor.InvocationContext;
@@ -184,16 +186,36 @@ public class InterceptorResolutionServic
         List<Interceptor<?>> cdiConstructorInterceptors = new ArrayList<Interceptor<?>>(allUsedConstructorCdiInterceptors);
         Collections.sort(cdiConstructorInterceptors, new InterceptorComparator(webBeansContext));
 
-        if (Modifier.isFinal(annotatedType.getJavaClass().getModifiers()) &&
-            (allUsedEjbInterceptors.size() > 0 || 
-             allUsedCdiInterceptors.size() > 0 || 
-             lifecycleMethodInterceptorInfos.size() > 0 ||
-             (decorators != null && decorators.size() > 0)))
+        boolean interceptedBean = allUsedEjbInterceptors.size() > 0 ||
+                                  allUsedCdiInterceptors.size() > 0 ||
+                                  lifecycleMethodInterceptorInfos.size() > 0;
+
+        if ((interceptedBean || decorators.size() > 0) && Modifier.isFinal(annotatedType.getJavaClass().getModifiers()))
         {
-            throw new WebBeansConfigurationException("Cannot apply Decorators or Interceptors
on a final class: " 
+            throw new WebBeansConfigurationException("Cannot apply Decorators or Interceptors
on a final class: "
                                                      + annotatedType.getJavaClass().getName());
         }
-        
+
+        // if we have an interceptedBean, the bean must be proxyable in any case (also @Dependent)
+        if (interceptedBean)
+        {
+            boolean proxyable = false;
+            for (AnnotatedConstructor<T> constructor : annotatedType.getConstructors())
+            {
+                if ((constructor.getParameters().isEmpty() && !isUnproxyable(constructor))
||
+                     constructor.isAnnotationPresent(Inject.class))
+                {
+                    proxyable = true;
+                    break;
+                }
+            }
+
+            if (!proxyable)
+            {
+                throw new DeploymentException("Intercepted Bean " + annotatedType.getBaseType()
+ " must be proxyable");
+            }
+        }
+
         return new BeanInterceptorInfo(decorators, allUsedEjbInterceptors,
                                        cdiInterceptors, cdiConstructorInterceptors,
                                        selfInterceptorBean,



Mime
View raw message