tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r893741 - in /tomcat/trunk: conf/ java/org/apache/catalina/startup/ java/org/apache/jasper/compiler/ java/org/apache/tomcat/util/scan/
Date Thu, 24 Dec 2009 12:35:27 GMT
Author: markt
Date: Thu Dec 24 12:35:27 2009
New Revision: 893741

URL: http://svn.apache.org/viewvc?rev=893741&view=rev
Log:
Have one list of JARs to ignore when scanning for config and make it configurable

Modified:
    tomcat/trunk/conf/catalina.properties
    tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
    tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java
    tomcat/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java
    tomcat/trunk/java/org/apache/tomcat/util/scan/DefaultJarScanner.java

Modified: tomcat/trunk/conf/catalina.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/conf/catalina.properties?rev=893741&r1=893740&r2=893741&view=diff
==============================================================================
--- tomcat/trunk/conf/catalina.properties (original)
+++ tomcat/trunk/conf/catalina.properties Thu Dec 24 12:35:27 2009
@@ -73,6 +73,35 @@
 # starting with file:.
 shared.loader=
 
+# List of JAR files that should not be scanned for configuration information
+# such as web fragments, TLD files etc. It must be a comma separated list of
+# JAR file names.
+# The JARs listed below include:
+# - Tomcat Bootstrap JARs
+# - Tomcat API JARs
+# - Catalina JARs
+# - Jasper JARs
+# - Tomcat JARs
+# - Common non-Tomcat JARs
+# - Sun JDK JARs
+# - Apple JDK JARs
+tomcat.util.scan.DefaultJarScanner.jarsToSkip=\
+bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,\
+annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,\
+catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-tribes.jar,\
+jasper.jar,jasper-el.jar,jasper-jdt.jar,\
+tomcat-api.jar,tomcat-util.jar,tomcat-coyote.jar,tomcat-dbcp.jar,\
+tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,\
+commons-beanutils.jar,commons-collections.jar,commons-dbcp.jar,\
+commons-digester.jar,commons-fileupload-1.0.jar,commons-logging.jar,\
+commons-pool.jar,\
+ant.jar,jmx.jar,jmx-tools.jar,\
+xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,\
+dnsns.jar,ldapsec.jar,localedata.jar,sunjce_provider.jar,sunpkcs11.jar,tools.jar,\
+apple_provider.jar,AppleScriptEngine.jar,CoreAudio.jar,dns_sd.jar,\
+j3daudio.jar,j3dcore.jar,j3dutils.jar,jai_core.jar,jai_codec.jar,\
+mlibwrapper_jai.jar,MRJToolkit.jar,vecmath.jar
+
 #
 # String cache configuration.
 tomcat.util.buf.StringCache.byte.enabled=true

Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=893741&r1=893740&r2=893741&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Thu Dec 24 12:35:27 2009
@@ -200,76 +200,6 @@
                                 new LoginConfig("NONE", null, null, null);
 
 
-    // Names of JARs that are known not to contain web-fragment.xml
-    private static HashSet<String> noFragmentJars;
-    
-    /*
-     * Initializes the set of JARs that are known not to contain any web-fragments
-     */
-    static {
-        // TODO - set this list via configuration (also TLDs in Jasper) 
-        noFragmentJars = new HashSet<String>();
-        // Bootstrap JARs
-        noFragmentJars.add("bootstrap.jar");
-        noFragmentJars.add("commons-daemon.jar");
-        noFragmentJars.add("tomcat-juli.jar");
-        // Main JARs
-        noFragmentJars.add("annotations-api.jar");
-        noFragmentJars.add("catalina.jar");
-        noFragmentJars.add("catalina-ant.jar");
-        noFragmentJars.add("catalina-ha.jar");
-        noFragmentJars.add("catalina-tribes.jar");
-        noFragmentJars.add("el-api.jar");
-        noFragmentJars.add("jasper.jar");
-        noFragmentJars.add("jasper-el.jar");
-        noFragmentJars.add("jasper-jdt.jar");
-        noFragmentJars.add("jsp-api.jar");
-        noFragmentJars.add("servlet-api.jar");
-        noFragmentJars.add("tomcat-api.jar");
-        noFragmentJars.add("tomcat-coyote.jar");
-        noFragmentJars.add("tomcat-dbcp.jar");
-        // i18n JARs
-        noFragmentJars.add("tomcat-i18n-en.jar");
-        noFragmentJars.add("tomcat-i18n-es.jar");
-        noFragmentJars.add("tomcat-i18n-fr.jar");
-        noFragmentJars.add("tomcat-i18n-ja.jar");
-        // Misc JARs not included with Tomcat
-        noFragmentJars.add("ant.jar");
-        noFragmentJars.add("commons-dbcp.jar");
-        noFragmentJars.add("commons-beanutils.jar");
-        noFragmentJars.add("commons-fileupload-1.0.jar");
-        noFragmentJars.add("commons-pool.jar");
-        noFragmentJars.add("commons-digester.jar");
-        noFragmentJars.add("commons-logging.jar");
-        noFragmentJars.add("commons-collections.jar");
-        noFragmentJars.add("jmx.jar");
-        noFragmentJars.add("jmx-tools.jar");
-        noFragmentJars.add("xercesImpl.jar");
-        noFragmentJars.add("xmlParserAPIs.jar");
-        noFragmentJars.add("xml-apis.jar");
-        // JARs from J2SE runtime
-        noFragmentJars.add("sunjce_provider.jar");
-        noFragmentJars.add("ldapsec.jar");
-        noFragmentJars.add("localedata.jar");
-        noFragmentJars.add("dnsns.jar");
-        noFragmentJars.add("tools.jar");
-        noFragmentJars.add("sunpkcs11.jar");
-        noFragmentJars.add("sunec.jar");
-        // Apple J2SE runtime
-        noFragmentJars.add("apple_provider.jar");
-        noFragmentJars.add("AppleScriptEngine.jar");
-        noFragmentJars.add("CoreAudio.jar");
-        noFragmentJars.add("dns_sd.jar");
-        noFragmentJars.add("j3daudio.jar");
-        noFragmentJars.add("j3dcore.jar");
-        noFragmentJars.add("j3dutils.jar");
-        noFragmentJars.add("jai_core.jar");
-        noFragmentJars.add("jai_codec.jar");
-        noFragmentJars.add("mlibwrapper_jai.jar");
-        noFragmentJars.add("MRJToolkit.jar");
-        noFragmentJars.add("vecmath.jar");
-    }
-
     // ------------------------------------------------------------- Properties
 
 
@@ -1500,7 +1430,7 @@
         FragmentJarScannerCallback callback = new FragmentJarScannerCallback();
         
         jarScanner.scan(context.getServletContext(),
-                context.getLoader().getClassLoader(), callback, noFragmentJars);
+                context.getLoader().getClassLoader(), callback, null);
         
         return callback.getFragments();
     }

Modified: tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java?rev=893741&r1=893740&r2=893741&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java Thu Dec 24 12:35:27 2009
@@ -64,7 +64,7 @@
     private static final String WEB_INF_LIB = "/WEB-INF/lib/";
     
     // Names of JARs that are known not to contain any TLDs
-    private static HashSet<String> noTldJars;
+    private static Set<String> noTldJars = null;
 
     private static final org.apache.juli.logging.Log log=
         org.apache.juli.logging.LogFactory.getLog( TldConfig.class );
@@ -80,58 +80,6 @@
      */
     private static Digester[] tldDigesters = new Digester[4];
 
-    /*
-     * Initializes the set of JARs that are known not to contain any TLDs
-     */
-    static {
-        noTldJars = new HashSet<String>();
-        // Bootstrap JARs
-        noTldJars.add("bootstrap.jar");
-        noTldJars.add("commons-daemon.jar");
-        noTldJars.add("tomcat-juli.jar");
-        // Main JARs
-        noTldJars.add("annotations-api.jar");
-        noTldJars.add("catalina.jar");
-        noTldJars.add("catalina-ant.jar");
-        noTldJars.add("catalina-ha.jar");
-        noTldJars.add("catalina-tribes.jar");
-        noTldJars.add("el-api.jar");
-        noTldJars.add("jasper.jar");
-        noTldJars.add("jasper-el.jar");
-        noTldJars.add("jasper-jdt.jar");
-        noTldJars.add("jsp-api.jar");
-        noTldJars.add("servlet-api.jar");
-        noTldJars.add("tomcat-api.jar");
-        noTldJars.add("tomcat-coyote.jar");
-        noTldJars.add("tomcat-dbcp.jar");
-        // i18n JARs
-        noTldJars.add("tomcat-i18n-en.jar");
-        noTldJars.add("tomcat-i18n-es.jar");
-        noTldJars.add("tomcat-i18n-fr.jar");
-        noTldJars.add("tomcat-i18n-ja.jar");
-        // Misc JARs not included with Tomcat
-        noTldJars.add("ant.jar");
-        noTldJars.add("commons-dbcp.jar");
-        noTldJars.add("commons-beanutils.jar");
-        noTldJars.add("commons-fileupload-1.0.jar");
-        noTldJars.add("commons-pool.jar");
-        noTldJars.add("commons-digester.jar");
-        noTldJars.add("commons-logging.jar");
-        noTldJars.add("commons-collections.jar");
-        noTldJars.add("jmx.jar");
-        noTldJars.add("jmx-tools.jar");
-        noTldJars.add("xercesImpl.jar");
-        noTldJars.add("xmlParserAPIs.jar");
-        noTldJars.add("xml-apis.jar");
-        // JARs from J2SE runtime
-        noTldJars.add("sunjce_provider.jar");
-        noTldJars.add("ldapsec.jar");
-        noTldJars.add("localedata.jar");
-        noTldJars.add("dnsns.jar");
-        noTldJars.add("tools.jar");
-        noTldJars.add("sunpkcs11.jar");
-    }
-
     /**
      * Create (if necessary) and return a Digester configured to process the
      * tld.
@@ -226,11 +174,17 @@
      * Sets the list of JARs that are known not to contain any TLDs.
      *
      * @param jarNames List of comma-separated names of JAR files that are 
-     * known not to contain any TLDs 
+     * known not to contain any TLDs.
      */
     public static void setNoTldJars(String jarNames) {
-        if (jarNames != null) {
-            noTldJars.clear();
+        if (jarNames == null) {
+            noTldJars = null;
+        } else {
+            if (noTldJars == null) {
+                noTldJars = new HashSet<String>();
+            } else {
+                noTldJars.clear();
+            }
             StringTokenizer tokenizer = new StringTokenizer(jarNames, ",");
             while (tokenizer.hasMoreElements()) {
                 noTldJars.add(tokenizer.nextToken());

Modified: tomcat/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java?rev=893741&r1=893740&r2=893741&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java Thu Dec 24 12:35:27
2009
@@ -98,7 +98,7 @@
     private static final String TLD_EXT = ".tld";
 
     // Names of JARs that are known not to contain any TLDs
-    private static HashSet<String> noTldJars;
+    private static Set<String> noTldJars = null;
 
     /**
      * The mapping of the 'global' tag library URI to the location (resource
@@ -112,76 +112,6 @@
     private boolean initialized;
     private ServletContext ctxt;
 
-    //*********************************************************************
-    // Constructor and Initializations
-
-    /*
-     * Initializes the set of JARs that are known not to contain any TLDs
-     */
-    static {
-        // TODO - set this list via configuration (also web-fragments) 
-        noTldJars = new HashSet<String>();
-        // Bootstrap JARs
-        noTldJars.add("bootstrap.jar");
-        noTldJars.add("commons-daemon.jar");
-        noTldJars.add("tomcat-juli.jar");
-        // Main JARs
-        noTldJars.add("annotations-api.jar");
-        noTldJars.add("catalina.jar");
-        noTldJars.add("catalina-ant.jar");
-        noTldJars.add("catalina-ha.jar");
-        noTldJars.add("catalina-tribes.jar");
-        noTldJars.add("el-api.jar");
-        noTldJars.add("jasper.jar");
-        noTldJars.add("jasper-el.jar");
-        noTldJars.add("jasper-jdt.jar");
-        noTldJars.add("jsp-api.jar");
-        noTldJars.add("servlet-api.jar");
-        noTldJars.add("tomcat-api.jar");
-        noTldJars.add("tomcat-coyote.jar");
-        noTldJars.add("tomcat-dbcp.jar");
-        // i18n JARs
-        noTldJars.add("tomcat-i18n-en.jar");
-        noTldJars.add("tomcat-i18n-es.jar");
-        noTldJars.add("tomcat-i18n-fr.jar");
-        noTldJars.add("tomcat-i18n-ja.jar");
-        // Misc JARs not included with Tomcat
-        noTldJars.add("ant.jar");
-        noTldJars.add("commons-dbcp.jar");
-        noTldJars.add("commons-beanutils.jar");
-        noTldJars.add("commons-fileupload-1.0.jar");
-        noTldJars.add("commons-pool.jar");
-        noTldJars.add("commons-digester.jar");
-        noTldJars.add("commons-logging.jar");
-        noTldJars.add("commons-collections.jar");
-        noTldJars.add("jmx.jar");
-        noTldJars.add("jmx-tools.jar");
-        noTldJars.add("xercesImpl.jar");
-        noTldJars.add("xmlParserAPIs.jar");
-        noTldJars.add("xml-apis.jar");
-        // JARs from J2SE runtime
-        noTldJars.add("sunjce_provider.jar");
-        noTldJars.add("ldapsec.jar");
-        noTldJars.add("localedata.jar");
-        noTldJars.add("dnsns.jar");
-        noTldJars.add("tools.jar");
-        noTldJars.add("sunpkcs11.jar");
-        noTldJars.add("sunec.jar");
-        // Apple J2SE runtime
-        noTldJars.add("apple_provider.jar");
-        noTldJars.add("AppleScriptEngine.jar");
-        noTldJars.add("CoreAudio.jar");
-        noTldJars.add("dns_sd.jar");
-        noTldJars.add("j3daudio.jar");
-        noTldJars.add("j3dcore.jar");
-        noTldJars.add("j3dutils.jar");
-        noTldJars.add("jai_core.jar");
-        noTldJars.add("jai_codec.jar");
-        noTldJars.add("mlibwrapper_jai.jar");
-        noTldJars.add("MRJToolkit.jar");
-        noTldJars.add("vecmath.jar");
-    }
-    
     /** Constructor. 
      *
      * @param ctxt the servlet context of the web application in which Jasper 
@@ -200,8 +130,14 @@
      * known not to contain any TLDs 
      */
     public static void setNoTldJars(String jarNames) {
-        if (jarNames != null) {
-            noTldJars.clear();
+        if (jarNames == null) {
+            noTldJars = null;
+        } else {
+            if (noTldJars == null) {
+                noTldJars = new HashSet<String>();
+            } else {
+                noTldJars.clear();
+            }
             StringTokenizer tokenizer = new StringTokenizer(jarNames, ",");
             while (tokenizer.hasMoreElements()) {
                 noTldJars.add(tokenizer.nextToken());

Modified: tomcat/trunk/java/org/apache/tomcat/util/scan/DefaultJarScanner.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/scan/DefaultJarScanner.java?rev=893741&r1=893740&r2=893741&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/scan/DefaultJarScanner.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/scan/DefaultJarScanner.java Thu Dec 24 12:35:27
2009
@@ -24,8 +24,10 @@
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.net.URLConnection;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
+import java.util.StringTokenizer;
 
 import javax.servlet.ServletContext;
 
@@ -52,17 +54,31 @@
  */
 public class DefaultJarScanner implements JarScanner {
 
+    public static final String SKIP_JARS_PROPERTY =
+        "tomcat.util.scan.DefaultJarScanner.jarsToSkip";
+
     private static final String JAR_EXT = ".jar";
     private static final String WEB_INF_LIB = "/WEB-INF/lib/";
 
     private static final Log log = LogFactory.getLog(DefaultJarScanner.class);
 
+    private static final Set<String> defaultJarsToSkip = new HashSet<String>();
+    
     /**
      * The string resources for this package.
      */
     private static final StringManager sm =
         StringManager.getManager(Constants.Package);
 
+    static {
+        String jarList = System.getProperty(SKIP_JARS_PROPERTY);
+        if (jarList != null) {
+            StringTokenizer tokenizer = new StringTokenizer(jarList, ",");
+            while (tokenizer.hasMoreElements()) {
+                defaultJarsToSkip.add(tokenizer.nextToken());
+            }
+        }
+    }
 
     /**
      * Controls the classpath scanning extension.
@@ -99,7 +115,17 @@
     }
 
     /**
-     * {@inheritDoc}
+     * Scan the provided ServletContext and classloader for JAR files. Each JAR
+     * file found will be passed to the callback handler to be processed.
+     *  
+     * @param context       The ServletContext - used to locate and access
+     *                      WEB-INF/lib
+     * @param classloader   The classloader - used to access JARs not in
+     *                      WEB-INF/lib
+     * @param callback      The handler to process any JARs found
+     * @param jarsToSkip    List of JARs to ignore. If this list is null, a
+     *                      default list will be read from the system property
+     *                      defined by {@link #SKIP_JARS_PROPERTY} 
      */
     @Override
     public void scan(ServletContext context, ClassLoader classloader,
@@ -109,6 +135,13 @@
             log.trace(sm.getString("jarScan.webinflibStart"));
         }
 
+        Set<String> ignoredJars;
+        if (jarsToSkip == null) {
+            ignoredJars = defaultJarsToSkip;
+        } else {
+            ignoredJars = jarsToSkip;
+        }
+
         // Scan WEB-INF/lib
         Set<String> dirList = context.getResourcePaths(WEB_INF_LIB);
         if (dirList != null) {
@@ -116,8 +149,8 @@
             while (it.hasNext()) {
                 String path = it.next();
                 if (path.endsWith(JAR_EXT) &&
-                        !jarsToSkip.contains(
-                                path.substring(path.lastIndexOf('/')))) {
+                        !ignoredJars.contains(
+                                path.substring(path.lastIndexOf('/')+1))) {
                     // Need to scan this JAR
                     URL url = null;
                     try {
@@ -148,7 +181,7 @@
                         
                         // Skip JARs with known not to be interesting and JARs
                         // in WEB-INF/lib we have already scanned
-                        if (!(jarsToSkip.contains(jarName) ||
+                        if (!(ignoredJars.contains(jarName) ||
                                 urls[i].toString().contains(
                                         WEB_INF_LIB + jarName))) {
                             try {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message