openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1728235 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/OpenWebBeansConfiguration.java corespi/scanner/AbstractMetaDataDiscovery.java
Date Tue, 02 Feb 2016 22:59:53 GMT
Author: struberg
Date: Tue Feb  2 22:59:53 2016
New Revision: 1728235

URL: http://svn.apache.org/viewvc?rev=1728235&view=rev
Log:
OWB-1106 add a openwebbeans.properties flag to only pick up jars with META-INF/beans.xml again.

activated via:
org.apache.webbeans.scanBeansXmlOnly=true
in some META-INF/openwebbeans/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

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=1728235&r1=1728234&r2=1728235&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
Tue Feb  2 22:59:53 2016
@@ -135,6 +135,11 @@ public class OpenWebBeansConfiguration
     public static final String SCAN_EXCLUSION_PATHS = "org.apache.webbeans.scanExclusionPaths";
 
     /**
+     * Flag which indicates that only jars with an explicit META-INF/beans.xml marker file
shall get paresed.
+     * Default is {@code false}
+     */
+    public static final String SCAN_ONLY_BEANS_XML_JARS = "org.apache.webbeans.scanBeansXmlOnly";
+    /**
      * 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
      * weaving or bytecode modification.
@@ -167,6 +172,9 @@ public class OpenWebBeansConfiguration
     /**Default configuration files*/
     private static final String DEFAULT_CONFIG_PROPERTIES_NAME = "META-INF/openwebbeans/openwebbeans.properties";
 
+    /**
+     * A value which indicates an 'automatic' behaviour.
+     */
     private static final String AUTO_CONFIG = "auto";
 
     /**Property of application*/
@@ -356,6 +364,16 @@ public class OpenWebBeansConfiguration
         return Boolean.valueOf(value);
     }
 
+    /**
+     * Flag which indicates that only jars with an explicit META-INF/beans.xml marker file
shall get paresed.
+     * Default is {@code false}
+     */
+    public boolean scanOnlyBeansXmlJars()
+    {
+        String value = getProperty(SCAN_ONLY_BEANS_XML_JARS);
+        return "true".equalsIgnoreCase(value);
+    }
+
     public synchronized Set<String> getIgnoredInterfaces()
     {
         if (ignoredInterfaces == null)

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=1728235&r1=1728234&r2=1728235&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
Tue Feb  2 22:59:53 2016
@@ -204,16 +204,20 @@ public abstract class AbstractMetaDataDi
                 }
             }
 
-            // third step: remove all jars we know they do not contain any CDI beans
-            filterExcludedJars(classPathUrls);
-
-            // forth step: add all 'implicit bean archives'
-            for (URL url : classPathUrls)
+            boolean onlyBeansXmlJars = webBeansContext.getOpenWebBeansConfiguration().scanOnlyBeansXmlJars();
+            if (!onlyBeansXmlJars)
             {
-                if (isBdaUrlEnabled(url))
+                // third step: remove all jars we know they do not contain any CDI beans
+                filterExcludedJars(classPathUrls);
+
+                // forth step: add all 'implicit bean archives'
+                for (URL url : classPathUrls)
                 {
-                    addWebBeansXmlLocation(url);
-                    addDeploymentUrl(url.toExternalForm(), url);
+                    if (isBdaUrlEnabled(url))
+                    {
+                        addWebBeansXmlLocation(url);
+                        addDeploymentUrl(url.toExternalForm(), url);
+                    }
                 }
             }
         }
@@ -247,7 +251,7 @@ public abstract class AbstractMetaDataDi
             final String path = url.toExternalForm();
             // TODO: should extract file path and test file.getName(), not the whole path
             // + should be configurable
-            final int knownJarIdx = isKnownJar(path);
+            final int knownJarIdx = isExcludedJar(path);
             // -Prun-its openwebbeans-tomcat7 in path but WEB-INF/classes
             if (knownJarIdx > 0 && knownJarIdx < path.indexOf(".jar"))
             {
@@ -258,7 +262,7 @@ public abstract class AbstractMetaDataDi
         }
     }
 
-    private int isKnownJar(final String path)
+    private int isExcludedJar(final String path)
     {
         // lazy init - required when using DS CdiTestRunner
         initScanningExcludes();



Mime
View raw message