tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1377085 - in /tomcat/tc7.0.x/trunk: ./ conf/ java/org/apache/catalina/startup/ java/org/apache/jasper/ java/org/apache/jasper/compiler/ java/org/apache/jasper/resources/ webapps/docs/ webapps/docs/config/
Date Fri, 24 Aug 2012 20:21:08 GMT
Author: markt
Date: Fri Aug 24 20:21:07 2012
New Revision: 1377085

URL: http://svn.apache.org/viewvc?rev=1377085&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53714
Provide a means of excluding JARs from pluggability scans, TLD scans or all scans.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/conf/catalina.properties
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/Constants.java
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/TldConfig.java
    tomcat/tc7.0.x/trunk/java/org/apache/jasper/Constants.java
    tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java
    tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
    tomcat/tc7.0.x/trunk/webapps/docs/config/systemprops.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1377078

Modified: tomcat/tc7.0.x/trunk/conf/catalina.properties
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/conf/catalina.properties?rev=1377085&r1=1377084&r2=1377085&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/conf/catalina.properties (original)
+++ tomcat/tc7.0.x/trunk/conf/catalina.properties Fri Aug 24 20:21:07 2012
@@ -73,8 +73,12 @@ server.loader=
 # 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
+# List of JAR files that should not be scanned using the JarScanner
+# functionality. This is typically used to scan JARs for configuration
+# information. JARs that do not contain such information may be excluded from
+# the scan to speed up the scanning process. This is the default list. JARs on
+# this list are excluded from all scans. Scan specific lists (to exclude JARs
+# from individual scans) follow this. The list must be a comma separated list of
 # JAR file names.
 # The JARs listed below include:
 # - Tomcat Bootstrap JARs
@@ -104,14 +108,24 @@ geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,\
 ant.jar,ant-junit*.jar,aspectj*.jar,jmx.jar,h2*.jar,hibernate*.jar,httpclient*.jar,\
 jmx-tools.jar,jta*.jar,log4j*.jar,mail*.jar,slf4j*.jar,\
 xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,\
-dnsns.jar,ldapsec.jar,localedata.jar,sunjce_provider.jar,sunmscapi.jar,\
-sunpkcs11.jar,jhall.jar,tools.jar,\
+access-bridge-64.jar,dnsns.jar,jaccess.jar,ldapsec.jar,localedata.jar,\
+sunjce_provider.jar,sunmscapi.jar,sunpkcs11.jar,jhall.jar,tools.jar,\
 sunec.jar,zipfs.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,\
 junit.jar,junit-*.jar,ant-launcher.jar
 
+# Additional JARs (over and above the default JARs listed above) to skip when
+# scanning for Servlet 3.0 pluggability features. These features include web
+# fragments, annotations, SCIs and classes that match @HandlesTypes. The list
+# must be a comma separated list of JAR file names.
+org.apache.catalina.startup.ContextConfig.jarsToSkip=
+
+# Additional JARs (over and above the default JARs listed above) to skip when
+# scanning for TLDs. The list must be a comma separated list of JAR file names.
+org.apache.catalina.startup.TldConfig.jarsToSkip=
+
 #
 # String cache configuration.
 tomcat.util.buf.StringCache.byte.enabled=true

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/Constants.java?rev=1377085&r1=1377084&r2=1377085&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/Constants.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/Constants.java Fri Aug 24 20:21:07
2012
@@ -38,6 +38,13 @@ public final class Constants {
     public static final String HostContextXml = "context.xml.default";
     public static final String HostWebXml = "web.xml.default";
 
+    public static final String DEFAULT_JARS_TO_SKIP =
+            "tomcat.util.scan.DefaultJarScanner.jarsToSkip";
+    public static final String PLUGGABILITY_JARS_TO_SKIP =
+            "org.apache.catalina.startup.ContextConfig.jarsToSkip";
+    public static final String TLD_JARS_TO_SKIP =
+            "org.apache.catalina.startup.TldConfig.jarsToSkip";
+
     /**
      * A dummy value used to suppress loading the default web.xml file.
      *

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1377085&r1=1377084&r2=1377085&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java Fri Aug 24 20:21:07
2012
@@ -41,6 +41,7 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
+import java.util.StringTokenizer;
 import java.util.concurrent.ConcurrentHashMap;
 
 import javax.naming.Binding;
@@ -137,6 +138,14 @@ public class ContextConfig implements Li
      */
     protected static final Properties authenticators;
 
+    /**
+     * The list of JARs that will be skipped when scanning a web application
+     * for JARs. This means the JAR will not be scanned for web fragments, SCIs,
+     * annotations or classes that match @HandlesTypes.
+     */
+    private static final Set<String> pluggabilityJarsToSkip =
+            new HashSet<String>();
+
     static {
         // Load our mapping properties for the standard authenticators
         InputStream is =
@@ -152,8 +161,22 @@ public class ContextConfig implements Li
             }
         }
         authenticators = props;
+
+        // Load the list of JARS to skip
+        addJarsToSkip(Constants.DEFAULT_JARS_TO_SKIP);
+        addJarsToSkip(Constants.PLUGGABILITY_JARS_TO_SKIP);
     }
 
+    private static void addJarsToSkip(String systemPropertyName) {
+        String jarList = System.getProperty(systemPropertyName);
+        if (jarList != null) {
+            StringTokenizer tokenizer = new StringTokenizer(jarList, ",");
+            while (tokenizer.hasMoreElements()) {
+                pluggabilityJarsToSkip.add(tokenizer.nextToken());
+            }
+        }
+
+    }
 
     /**
      * Deployment count.
@@ -1882,7 +1905,8 @@ public class ContextConfig implements Li
         FragmentJarScannerCallback callback = new FragmentJarScannerCallback();
         
         jarScanner.scan(context.getServletContext(),
-                context.getLoader().getClassLoader(), callback, null);
+                context.getLoader().getClassLoader(), callback,
+                pluggabilityJarsToSkip);
         
         return callback.getFragments();
     }

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/TldConfig.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/TldConfig.java?rev=1377085&r1=1377084&r2=1377085&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/TldConfig.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/TldConfig.java Fri Aug 24 20:21:07
2012
@@ -119,6 +119,47 @@ public final class TldConfig  implements
     }
 
 
+    static {
+        // Set the default list of JARs to skip for TLDs
+        StringBuilder jarList = new StringBuilder(System.getProperty(
+                Constants.DEFAULT_JARS_TO_SKIP, ""));
+
+        String tldJars = System.getProperty(Constants.TLD_JARS_TO_SKIP, "");
+        if (tldJars.length() > 0) {
+            if (jarList.length() > 0) {
+                jarList.append(',');
+            }
+            jarList.append(tldJars);
+        }
+
+        if (jarList.length() > 0) {
+            setNoTldJars(jarList.toString());
+        }
+    }
+
+    /**
+     * 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.
+     */
+    public static synchronized void setNoTldJars(String jarNames) {
+        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());
+            }
+        }
+    }
+
+
     // ----------------------------------------------------- Instance Variables
 
     /**
@@ -169,28 +210,6 @@ public final class TldConfig  implements
     }
 
     /**
-     * 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.
-     */
-    public static void setNoTldJars(String jarNames) {
-        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());
-            }
-        }
-    }
-
-    /**
      * @deprecated  Unused - will be removed in 8.0.x
      */
     @Deprecated

Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/Constants.java?rev=1377085&r1=1377084&r2=1377085&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/jasper/Constants.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/Constants.java Fri Aug 24 20:21:07 2012
@@ -219,4 +219,18 @@ public class Constants {
      * the tomcat instance installation path
      */
     public static final String CATALINA_BASE_PROP = "catalina.base";
+
+    /**
+     * Name of system property containing default list of JARs to skip when
+     * scanning JARs for configuration elements such as TLDs.
+     */
+    public static final String DEFAULT_JAR_SKIP_PROP=
+            "tomcat.util.scan.DefaultJarScanner.jarsToSkip";
+
+    /**
+     * Name of system property containing additional list of JARs to skip when
+     * scanning for TLDs.
+     */
+    public static final String TLD_JAR_SKIP_PROP=
+            "org.apache.catalina.startup.TldConfig.jarsToSkip";
 }

Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java?rev=1377085&r1=1377084&r2=1377085&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java Fri Aug 24
20:21:07 2012
@@ -30,6 +30,7 @@ import java.util.StringTokenizer;
 
 import javax.servlet.ServletContext;
 
+import org.apache.jasper.Constants;
 import org.apache.jasper.JasperException;
 import org.apache.jasper.util.ExceptionUtils;
 import org.apache.jasper.xmlparser.ParserUtils;
@@ -100,36 +101,33 @@ public class TldLocationsCache {
     // there are JARs that could be skipped
     private static volatile boolean showTldScanWarning = true;
 
-    /**
-     * The mapping of the 'global' tag library URI to the location (resource
-     * path) of the TLD associated with that tag library. The location is
-     * returned as a String array:
-     *    [0] The location
-     *    [1] If the location is a jar file, this is the location of the tld.
-     */
-    private Hashtable<String, TldLocation> mappings;
-
-    private volatile boolean initialized;
-    private ServletContext ctxt;
+    static {
+        // Set the default list of JARs to skip for TLDs
+        // Set the default list of JARs to skip for TLDs
+        StringBuilder jarList = new StringBuilder(System.getProperty(
+                Constants.DEFAULT_JAR_SKIP_PROP, ""));
+
+        String tldJars = System.getProperty(Constants.TLD_JAR_SKIP_PROP, "");
+        if (tldJars.length() > 0) {
+            if (jarList.length() > 0) {
+                jarList.append(',');
+            }
+            jarList.append(tldJars);
+        }
 
-    /** Constructor. 
-     *
-     * @param ctxt the servlet context of the web application in which Jasper 
-     * is running
-     */
-    public TldLocationsCache(ServletContext ctxt) {
-        this.ctxt = ctxt;
-        mappings = new Hashtable<String, TldLocation>();
-        initialized = false;
+        if (jarList.length() > 0) {
+            setNoTldJars(jarList.toString());
+        }
     }
 
+
     /**
      * 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 
      */
-    public static void setNoTldJars(String jarNames) {
+    public static synchronized void setNoTldJars(String jarNames) {
         if (jarNames == null) {
             noTldJars = null;
         } else {
@@ -147,6 +145,29 @@ public class TldLocationsCache {
 
 
     /**
+     * The mapping of the 'global' tag library URI to the location (resource
+     * path) of the TLD associated with that tag library. The location is
+     * returned as a String array:
+     *    [0] The location
+     *    [1] If the location is a jar file, this is the location of the tld.
+     */
+    private Hashtable<String, TldLocation> mappings;
+
+    private volatile boolean initialized;
+    private ServletContext ctxt;
+
+    /** Constructor.
+     *
+     * @param ctxt the servlet context of the web application in which Jasper
+     * is running
+     */
+    public TldLocationsCache(ServletContext ctxt) {
+        this.ctxt = ctxt;
+        mappings = new Hashtable<String, TldLocation>();
+        initialized = false;
+    }
+
+    /**
      * Obtains the TLD location cache for the given {@link ServletContext} and
      * creates one if one does not currently exist.
      */

Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties?rev=1377085&r1=1377084&r2=1377085&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties Fri Aug
24 20:21:07 2012
@@ -490,5 +490,5 @@ jsp.message.jsp_unload_check=Checking JS
 
 xmlParser.skipBomFail=Failed to skip BOM when parsing XML input stream
 
-jsp.tldCache.noTldInJar=No TLD files were found in [{0}]. Consider adding the JAR to the
tomcat.util.scan.DefaultJarScanner.jarsToSkip property in CATALINA_BASE/conf/catalina.properties
file.
+jsp.tldCache.noTldInJar=No TLD files were found in [{0}]. Consider adding the JAR to the
tomcat.util.scan.DefaultJarScanner.jarsToSkip or org.apache.catalina.startup.TldConfig.jarsToSkip
property in CATALINA_BASE/conf/catalina.properties file.
 jsp.tldCache.noTldSummary=At least one JAR was scanned for TLDs yet contained no TLDs. Enable
debug logging for this logger for a complete list of JARs that were scanned but no TLDs were
found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation
time.

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1377085&r1=1377084&r2=1377085&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Fri Aug 24 20:21:07 2012
@@ -148,6 +148,12 @@
         Always make the resulting web.xml available even if metadata-complete is
         true. (markt)
       </add>
+      <fix>
+        <bug>53714</bug>: Provide separate system properties to control which
+        JARs are excluded from which scans when using the JarScanner. This
+        allows JARs to be excluded from TLD scanning and/or Servlet 3.0
+        pluggability scanning. (markt)
+      </fix>      
     </changelog>
   </subsection>
   <subsection name="Coyote">

Modified: tomcat/tc7.0.x/trunk/webapps/docs/config/systemprops.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/config/systemprops.xml?rev=1377085&r1=1377084&r2=1377085&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/config/systemprops.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/config/systemprops.xml Fri Aug 24 20:21:07 2012
@@ -610,6 +610,32 @@
       <p>If not specified, the default value of <code>false</code> will
be used.</p>
     </property>
 
+    <property name="tomcat.util.scan. DefaultJarScanner.jarsToSkip">
+      <p>The comma-separated list of filenames of JARs that Tomcat will not scan
+         for configuration information when using the
+         <a href="jar-scanner.html">JarScanner</a> functionality. Note that
+         there are additional system properties that enable JARs to be excluded
+         from specific scans rather than all scans.</p>
+      <p>The coded default is that no JARs are skipped however the system
+         property is set in a default Tomcat installation via the
+         <code>$CATALINA_BASE/catalina.properties</code> file.</p>
+    </property>
+
+    <property name="org.apache.catalina.startup. ContextConfig.jarsToSkip">
+      <p>The comma-separated list of additional filenames of JARs that Tomcat
+         will not scan for Servlet 3.0 pluggability features.</p>
+      <p>The coded default is that no JARs are skipped however the system
+         property is set in a default Tomcat installation via the
+         <code>$CATALINA_BASE/catalina.properties</code> file.</p>
+    </property>
+
+    <property name="org.apache.catalina.startup. TldConfig.jarsToSkip">
+      <p>The comma-separated list of additional filenames of JARs that Tomcat
+         will not scan for TLDs.</p>
+      <p>The coded default is that no JARs are skipped however the system
+         property is set in a default Tomcat installation via the
+         <code>$CATALINA_BASE/catalina.properties</code> file.</p>
+    </property>
 
   </properties>
 



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


Mime
View raw message