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 0D30911867 for ; Sat, 28 Jun 2014 15:13:55 +0000 (UTC) Received: (qmail 3020 invoked by uid 500); 28 Jun 2014 15:13:54 -0000 Delivered-To: apmail-openwebbeans-commits-archive@openwebbeans.apache.org Received: (qmail 2995 invoked by uid 500); 28 Jun 2014 15:13:54 -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 2983 invoked by uid 99); 28 Jun 2014 15:13:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Jun 2014 15:13:53 +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; Sat, 28 Jun 2014 15:13:52 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 060FA2388831; Sat, 28 Jun 2014 15:13:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1606370 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java webbeans-tck/testng-dev.xml Date: Sat, 28 Jun 2014 15:13:31 -0000 To: commits@openwebbeans.apache.org From: rmannibucau@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140628151332.060FA2388831@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rmannibucau Date: Sat Jun 28 15:13:31 2014 New Revision: 1606370 URL: http://svn.apache.org/r1606370 Log: OWB-978 @Vetoed Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java openwebbeans/trunk/webbeans-tck/testng-dev.xml Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1606370&r1=1606369&r2=1606370&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java Sat Jun 28 15:13:31 2014 @@ -49,6 +49,7 @@ import org.apache.webbeans.exception.Web import javax.annotation.Priority; import javax.enterprise.inject.Alternative; +import javax.enterprise.inject.Vetoed; import javax.enterprise.inject.spi.BeanAttributes; import javax.enterprise.inject.spi.DefinitionException; import javax.enterprise.inject.spi.DeploymentException; @@ -94,6 +95,7 @@ import javax.enterprise.inject.spi.Inter import javax.enterprise.inject.spi.ObserverMethod; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; +import java.lang.reflect.Method; import java.net.URL; import java.security.PrivilegedActionException; import java.util.ArrayList; @@ -120,6 +122,20 @@ public class BeansDeployer private static final Logger logger = WebBeansLoggerFacade.getLogger(BeansDeployer.class); public static final String JAVAX_ENTERPRISE_PACKAGE = "javax.enterprise."; + private static final Method GET_PACKAGE; + static + { + try + { + GET_PACKAGE = ClassLoader.class.getDeclaredMethod("getPackage", String.class); + GET_PACKAGE.setAccessible(true); + } + catch (final NoSuchMethodException e) + { + throw new IllegalStateException(e); + } + } + /**Deployment is started or not*/ protected boolean deployed = false; @@ -134,6 +150,7 @@ public class BeansDeployer private final DecoratorsManager decoratorsManager; private final InterceptorsManager interceptorsManager; + private final Map packageVetoCache = new HashMap(); /** * Creates a new deployer with given xml configurator. @@ -458,6 +475,8 @@ public class BeansDeployer webBeansContext.getWebBeansUtil().inspectErrorStack( "There are errors that are added by AfterDeploymentValidation event observers. Look at logs for further details"); + + packageVetoCache.clear(); // no more needed, free the memory } /** @@ -663,6 +682,11 @@ public class BeansDeployer for (Class implClass : classIndex) { + if (isVetoed(implClass)) + { + continue; + } + try { //Define annotation type @@ -694,6 +718,68 @@ public class BeansDeployer return annotatedTypes; } + private boolean isVetoed(final Class implClass) + { + if (implClass.getAnnotation(Vetoed.class) != null) + { + return true; + } + + ClassLoader classLoader = implClass.getClassLoader(); + if (classLoader == null) + { + classLoader = BeansDeployer.class.getClassLoader(); + } + + Package pckge = implClass.getPackage(); + do + { + // yes we cache result with potentially different classloader but this is not portable by spec + final String name = pckge.getName(); + { + final Boolean result = packageVetoCache.get(name); + if (result != null && result) + { + return result; + } + } + if (pckge.getAnnotation(Vetoed.class) != null) + { + packageVetoCache.put(pckge.getName(), true); + return true; + } + else + { + packageVetoCache.put(pckge.getName(), false); + } + + final int idx = name.lastIndexOf('.'); + if (idx > 0) + { + final String previousPackage = name.substring(0, idx); + final Boolean result = packageVetoCache.get(previousPackage); + if (result != null && result) + { + return result; + } + try // this is related to classloader and not to Package actually :( so we need reflection + { + pckge = Package.class.cast(GET_PACKAGE.invoke(classLoader, previousPackage)); + } + catch (final Exception e) + { + throw new IllegalStateException(e); + } + } + else + { + pckge = null; + } + } while (pckge != null); + + return false; + } + /** * Process any AnnotatedTypes which got added by BeforeBeanDiscovery#addAnnotatedType * @param annotatedTypes Modified: openwebbeans/trunk/webbeans-tck/testng-dev.xml URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/testng-dev.xml?rev=1606370&r1=1606369&r2=1606370&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-tck/testng-dev.xml (original) +++ openwebbeans/trunk/webbeans-tck/testng-dev.xml Sat Jun 28 15:13:31 2014 @@ -40,7 +40,7 @@ + name="org.jboss.cdi.tck.tests.lookup.clientProxy.unproxyable.finalMethod.StaticFinalMethodTest" />