really a detail but can we name it jarExclusions or something like that? beanScanningExcludes sounds close to what we have in beans.xml for me since CDI 1.1 - ie exclude classes and not jars. Is it only me? is it relevant?
Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber <http://www.tomitribe.com> ---------- Forwarded message ---------- From: <[email protected]> Date: 2015-09-23 9:06 GMT-07:00 Subject: svn commit: r1704889 - in /openwebbeans/trunk/webbeans-impl/src/main: java/org/apache/webbeans/config/ java/org/apache/webbeans/corespi/scanner/ resources/META-INF/openwebbeans/ To: [email protected] Author: tandraschko Date: Wed Sep 23 16:06:29 2015 New Revision: 1704889 URL: http://svn.apache.org/viewvc?rev=1704889&view=rev Log: OWB-1094 Move bean scanning excludes to openwebbeans.properties Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java?rev=1704889&r1=1704888&r2=1704889&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java Wed Sep 23 16:06:29 2015 @@ -33,7 +33,7 @@ import org.apache.webbeans.logger.WebBea /** * Defines configuration for OpenWebBeans. - * + * * The algorithm is easy: * <ul> * <li>Load all properties you can find with the name (META-INF/openwebbeans/openwebbeans.properties),</li> @@ -51,7 +51,7 @@ public class OpenWebBeansConfiguration /**Conversation periodic delay in ms.*/ public static final String CONVERSATION_PERIODIC_DELAY = "org.apache.webbeans.conversation.Conversation.periodicDelay"; - + /**Timeout interval in ms*/ public static final String CONVERSATION_TIMEOUT_INTERVAL = "org.apache.webbeans.conversation.Conversation.timeoutInterval"; @@ -65,34 +65,34 @@ public class OpenWebBeansConfiguration /**Use EJB Discovery or not*/ public static final String USE_EJB_DISCOVERY = "org.apache.webbeans.spi.deployer.useEjbMetaDataDiscoveryService"; - + /**Container lifecycle*/ public static final String CONTAINER_LIFECYCLE = "org.apache.webbeans.spi.ContainerLifecycle"; - + /**JNDI Service SPI*/ - public static final String JNDI_SERVICE = "org.apache.webbeans.spi.JNDIService"; - + public static final String JNDI_SERVICE = "org.apache.webbeans.spi.JNDIService"; + /**Scanner Service*/ public static final String SCANNER_SERVICE = "org.apache.webbeans.spi.ScannerService"; /**Contexts Service*/ public static final String CONTEXTS_SERVICE = "org.apache.webbeans.spi.ContextsService"; - + /**Conversation Service*/ public static final String CONVERSATION_SERVICE = "org.apache.webbeans.spi.ConversationService"; - + /**Resource Injection Service*/ public static final String RESOURCE_INJECTION_SERVICE = "org.apache.webbeans.spi.ResourceInjectionService"; - + /**Security Service*/ public static final String SECURITY_SERVICE = "org.apache.webbeans.spi.SecurityService"; - + /**Validator Service*/ public static final String VALIDATOR_SERVICE = "org.apache.webbeans.spi.ValidatorService"; - + /**Transaction Service*/ public static final String TRANSACTION_SERVICE = "org.apache.webbeans.spi.TransactionService"; - + /**Application is core JSP*/ public static final String APPLICATION_IS_JSP = "org.apache.webbeans.application.jsp"; @@ -117,6 +117,9 @@ public class OpenWebBeansConfiguration **/ public static final String USE_BDA_BEANSXML_SCANNER = "org.apache.webbeans.useBDABeansXMLScanner"; + /** A list of known JARs/pathes which should not be scanned for beans */ + public static final String BEAN_SCANNING_EXCLUDES = "org.apache.webbeans.beanScanningExcludes"; + /** * a comma-separated list of fully qualified class names that should be ignored * when determining if a decorator matches its delegate. These are typically added by @@ -254,7 +257,7 @@ public class OpenWebBeansConfiguration { return configProperties.getProperty(key); } - + /** * Gets property value. * @param key @@ -265,8 +268,8 @@ public class OpenWebBeansConfiguration { return configProperties.getProperty(key, defaultValue); } - - + + /** * Sets given property. * @param key property name @@ -276,7 +279,7 @@ public class OpenWebBeansConfiguration { configProperties.put(key, value); } - + /** * Gets jsp property. @@ -285,10 +288,10 @@ public class OpenWebBeansConfiguration public boolean isJspApplication() { String value = getProperty(APPLICATION_IS_JSP); - + return Boolean.valueOf(value); } - + /** * Gets conversation supports property. * @return true if supports @@ -296,7 +299,7 @@ public class OpenWebBeansConfiguration public boolean supportsConversation() { String value = getProperty(APPLICATION_SUPPORTS_CONVERSATION); - + return Boolean.valueOf(value); } Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java?rev=1704889&r1=1704888&r2=1704889&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java Wed Sep 23 16:06:29 2015 @@ -39,6 +39,7 @@ import org.apache.xbean.finder.ClassLoad import java.io.IOException; import java.lang.annotation.Annotation; import java.net.URL; +import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; @@ -49,7 +50,6 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; -import static java.util.Arrays.asList; public abstract class AbstractMetaDataDiscovery implements ScannerService @@ -78,6 +78,8 @@ public abstract class AbstractMetaDataDi */ private final Map<String, URL> beanDeploymentUrls = new HashMap<String, URL>(); + protected String[] scanningExcludes; + protected ClassLoader loader; protected CdiArchive archive; protected OwbAnnotationFinder finder; @@ -251,47 +253,7 @@ public abstract class AbstractMetaDataDi private int isKnownJar(final String path) { - for (final String p : asList( - "/jre/lib", - "/Contents/Home/", - "/dt.jar", - "/tools.jar", - "/asm", - "/javassist", - "/xbean-", - "/jconsole.jar", - "/geronimo-", - "/commons-", - "/arquillian-", - "/bsh-", - "/shrinkwrap-", - "/junit-", - "/testng-", - "/openjpa-", - "/bcel", - "/hamcrest", - "/mysql-connector", - "/testng", - "/idea_rt", - "/eclipse", - "/jcommander", - "/tomcat", - "/catalina", - "/jasper", - "/jsp-api", - "/myfaces-", - "/servlet-api", - "/javax", - "/annotation-api", - "/el-api", - "/mojarra", - "/sisu-guice-", - "/sisu-inject-", - "/aether-", - "/plexus-", - "/maven-", - "/guava-", - "/openwebbeans-")) + for (final String p : scanningExcludes) { final int i = path.indexOf(p); if (i > 0) @@ -342,6 +304,21 @@ public abstract class AbstractMetaDataDi // properties are loaded. String usage = WebBeansContext.currentInstance().getOpenWebBeansConfiguration().getProperty(OpenWebBeansConfiguration.USE_BDA_BEANSXML_SCANNER); isBDAScannerEnabled = Boolean.parseBoolean(usage); + + String scanningExcludesProperty = WebBeansContext.currentInstance().getOpenWebBeansConfiguration().getProperty(OpenWebBeansConfiguration.BEAN_SCANNING_EXCLUDES); + ArrayList<String> scanningExcludesList = new ArrayList<String>(); + if (scanningExcludesProperty != null) + { + for (String scanningExclude : scanningExcludesProperty.split(",")) + { + scanningExclude = scanningExclude.trim(); + if (!scanningExclude.isEmpty()) + { + scanningExcludesList.add(scanningExclude); + } + } + } + scanningExcludes = scanningExcludesList.toArray(new String[scanningExcludesList.size()]); } /** Modified: openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1704889&r1=1704888&r2=1704889&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties (original) +++ openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties Wed Sep 23 16:06:29 2015 @@ -19,13 +19,13 @@ # # The default configuration is intended for a JDK and a simple ServletContainer # like jetty, resin or tomcat. -# +# #--------------------------------------------------------------- ################################################################################################ ################################### DEFAULT SPI CONFIGURATION SECTION ########################## -################################################################################################ +################################################################################################ # this is the basic configuration, thus it has a very low ordinal of 10 configuration.ordinal=10 @@ -75,7 +75,7 @@ org.apache.webbeans.spi.SecurityService= # Service which encapsulates the Service-Loader of Java 1.6+ to allow custom implementations to support Java 1.5 org.apache.webbeans.spi.LoaderService=org.apache.webbeans.service.DefaultLoaderService -################################################################################################ +################################################################################################ #################################### SEVERAL CONFIGURATION PARAMETERS ########################## ################################################################################################ @@ -95,7 +95,7 @@ org.apache.webbeans.spi.deployer.useEjbM ################################## OWB Specific Injection ###################################### #If false, uses spec. defined injection with @Inject. Not recommended use as true. -#It will be removed in future development. +#It will be removed in future development. org.apache.webbeans.fieldInjection.useOwbSpecificInjection=false ################################################################################################ @@ -149,3 +149,72 @@ org.apache.webbeans.web.eagerSessionInit org.apache.webbeans.generator.javaVersion=1.6 ################################################################################################ + +######################### Bean Scanning ######################################################## +# A list of known JARs/pathes which should not be scanned for beans +org.apache.webbeans.beanScanningExcludes=/jre/lib, \ + /Contents/Home/, \ + /dt.jar, \ + /tools.jar, \ + /asm, \ + /javassist, \ + /xbean-, \ + /jconsole.jar, \ + /geronimo-, \ + /commons-, \ + /arquillian-, \ + /bsh-, \ + /shrinkwrap-, \ + /junit-, \ + /testng-, \ + /openjpa-, \ + /bcel, \ + /hamcrest, \ + /mysql-connector, \ + /testng, \ + /idea_rt, \ + /eclipse, \ + /jcommander, \ + /tomcat, \ + /catalina, \ + /jasper, \ + /jsp-api, \ + /myfaces-api, \ + /myfaces-impl, \ + /servlet-api, \ + /javax, \ + /annotation-api, \ + /el-api, \ + /mojarra, \ + /sisu-guice-, \ + /sisu-inject-, \ + /aether-, \ + /plexus-, \ + /maven-, \ + /guava-, \ + /openwebbeans-, \ + /bcprov-jdk14-, \ + /bcmail-jdk14-, \ + /bctsp-jdk14-, \ + /bcmail-jdk14-, \ + /ss_css2-, \ + /itext-, \ + /pd4ml-, \ + /xmlpull-, \ + /log4j-, \ + /slf4j-, \ + /logkit, \ + /gson-, \ + /xstream-, \ + /httpclient-, \ + /httpcore-, \ + /backport-util-concurrent-, \ + /xml-apis, \ + /xpp3_min-, \ + /bval-core, \ + /bval-jsr, \ + /hsqldb, \ + /quartz-2, \ + /jetty-, \ + /plexus- +################################################################################################
