Return-Path: X-Original-To: apmail-openwebbeans-commits-archive@www.apache.org Delivered-To: apmail-openwebbeans-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0FC8917ACE for ; Mon, 29 Sep 2014 11:36:52 +0000 (UTC) Received: (qmail 75140 invoked by uid 500); 29 Sep 2014 11:36:52 -0000 Delivered-To: apmail-openwebbeans-commits-archive@openwebbeans.apache.org Received: (qmail 75118 invoked by uid 500); 29 Sep 2014 11:36:51 -0000 Mailing-List: contact commits-help@openwebbeans.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openwebbeans.apache.org Delivered-To: mailing list commits@openwebbeans.apache.org Received: (qmail 75107 invoked by uid 99); 29 Sep 2014 11:36:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Sep 2014 11:36:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Sep 2014 11:36:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id BA43023889B9; Mon, 29 Sep 2014 11:36:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@openwebbeans.apache.org From: rsandtner@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140929113627.BA43023889B9@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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> cdiConstructorInterceptors = new ArrayList>(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 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,