You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2012/08/24 22:05:42 UTC
svn commit: r1377078 - in /tomcat/trunk: conf/
java/org/apache/catalina/startup/ java/org/apache/jasper/
java/org/apache/jasper/compiler/ java/org/apache/jasper/resources/
webapps/docs/config/
Author: markt
Date: Fri Aug 24 20:05:41 2012
New Revision: 1377078
URL: http://svn.apache.org/viewvc?rev=1377078&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/trunk/conf/catalina.properties
tomcat/trunk/java/org/apache/catalina/startup/Constants.java
tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java
tomcat/trunk/java/org/apache/jasper/Constants.java
tomcat/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java
tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties
tomcat/trunk/webapps/docs/config/systemprops.xml
Modified: tomcat/trunk/conf/catalina.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/conf/catalina.properties?rev=1377078&r1=1377077&r2=1377078&view=diff
==============================================================================
--- tomcat/trunk/conf/catalina.properties (original)
+++ tomcat/trunk/conf/catalina.properties Fri Aug 24 20:05:41 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/trunk/java/org/apache/catalina/startup/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/Constants.java?rev=1377078&r1=1377077&r2=1377078&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/Constants.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/Constants.java Fri Aug 24 20:05:41 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/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1377078&r1=1377077&r2=1377078&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Fri Aug 24 20:05:41 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;
@@ -134,6 +135,13 @@ 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<>();
+
static {
// Load our mapping properties for the standard authenticators
InputStream is =
@@ -149,8 +157,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.
@@ -1793,7 +1815,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/trunk/java/org/apache/catalina/startup/TldConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java?rev=1377078&r1=1377077&r2=1377078&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java Fri Aug 24 20:05:41 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<>();
+ } else {
+ noTldJars.clear();
+ }
+ StringTokenizer tokenizer = new StringTokenizer(jarNames, ",");
+ while (tokenizer.hasMoreElements()) {
+ noTldJars.add(tokenizer.nextToken());
+ }
+ }
+ }
+
+
// ----------------------------------------------------- Instance Variables
/**
@@ -168,29 +209,6 @@ public final class TldConfig implements
return webxmlTaglibUris.contains(uri);
}
- /**
- * 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<>();
- } else {
- noTldJars.clear();
- }
- StringTokenizer tokenizer = new StringTokenizer(jarNames, ",");
- while (tokenizer.hasMoreElements()) {
- noTldJars.add(tokenizer.nextToken());
- }
- }
- }
-
-
public void addApplicationListener( String s ) {
if(log.isDebugEnabled())
log.debug( "Add tld listener " + s);
Modified: tomcat/trunk/java/org/apache/jasper/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/Constants.java?rev=1377078&r1=1377077&r2=1377078&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/Constants.java (original)
+++ tomcat/trunk/java/org/apache/jasper/Constants.java Fri Aug 24 20:05:41 2012
@@ -222,6 +222,20 @@ public class Constants {
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";
+
+ /**
* Retain reference to default character set so we don't have to look it up.
*/
public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
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=1377078&r1=1377077&r2=1377078&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java Fri Aug 24 20:05:41 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,27 +101,23 @@ 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());
+ }
}
/**
@@ -129,12 +126,12 @@ public class TldLocationsCache {
* @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 {
if (noTldJars == null) {
- noTldJars = new HashSet<String>();
+ noTldJars = new HashSet<>();
} else {
noTldJars.clear();
}
@@ -147,6 +144,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/trunk/java/org/apache/jasper/resources/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties?rev=1377078&r1=1377077&r2=1377078&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties Fri Aug 24 20:05:41 2012
@@ -384,5 +384,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/trunk/webapps/docs/config/systemprops.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/systemprops.xml?rev=1377078&r1=1377077&r2=1377078&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/systemprops.xml (original)
+++ tomcat/trunk/webapps/docs/config/systemprops.xml Fri Aug 24 20:05:41 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