cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java
luehe 2005/02/14 11:54:53 Modified:jasper2/src/share/org/apache/jasper Constants.java jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java Log: Use configuration from alt-dd if specified. (Setter for alt-dd had been added to StandardContext, but this info was never used.) Revision ChangesPath 1.17 +3 -0 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/Constants.java Index: Constants.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/Constants.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- Constants.java17 Mar 2004 19:23:03 - 1.16 +++ Constants.java14 Feb 2005 19:54:52 - 1.17 @@ -121,6 +121,9 @@ public static final String TMP_DIR = javax.servlet.context.tempdir; public static final String FORWARD_SEEN = javax.servlet.forward.seen; +// Must be kept in sync with org/apache/catalina/Globals.java +public static final String ALT_DD_ATTR = org.apache.catalina.deploy.alt_dd; + /** * Public Id and the Resource path (of the cached copy) * of the DTDs for tag library descriptors. 1.28 +28 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- TldLocationsCache.java16 Jun 2004 18:05:12 - 1.27 +++ TldLocationsCache.java14 Feb 2005 19:54:52 - 1.28 @@ -17,6 +17,8 @@ package org.apache.jasper.compiler; import java.io.InputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.net.JarURLConnection; import java.net.URL; import java.net.URLClassLoader; @@ -34,6 +36,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.jasper.Constants; import org.apache.jasper.JasperException; import org.apache.jasper.xmlparser.ParserUtils; import org.apache.jasper.xmlparser.TreeNode; @@ -260,18 +263,39 @@ try { // Acquire input stream to web application deployment descriptor -is = ctxt.getResourceAsStream(WEB_XML); -if (is == null) { -if (log.isWarnEnabled()) { +String altDDName = (String)ctxt.getAttribute( +Constants.ALT_DD_ATTR); +if (altDDName != null) { +try { +is = new FileInputStream(altDDName); +} catch (FileNotFoundException e) { +if (log.isWarnEnabled()) { +log.warn(Localizer.getMessage( + jsp.error.internal.filenotfound, +altDDName)); +} +} +} else { +is = ctxt.getResourceAsStream(WEB_XML); +if (is == null log.isWarnEnabled()) { log.warn(Localizer.getMessage( jsp.error.internal.filenotfound, WEB_XML)); } +} + +if (is == null) { return; } // Parse the web application deployment descriptor -TreeNode webtld = new ParserUtils().parseXMLDocument(WEB_XML, is); +TreeNode webtld = null; +// altDDName is the absolute path of the DD +if (altDDName != null) { +webtld = new ParserUtils().parseXMLDocument(altDDName, is); +} else { +webtld = new ParserUtils().parseXMLDocument(WEB_XML, is); +} // Allow taglib to be an element of the root or jsp-config (JSP2.0) TreeNode jspConfig = webtld.findChild(jsp-config); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java
yoavs 2004/06/16 11:05:12 Modified:jasper2 build.xml jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java Log: Bugzilla 29368 done: replaced references to xmlParserAPIs.jar with xmls-apis.jar. Revision ChangesPath 1.26 +2 -2 jakarta-tomcat-jasper/jasper2/build.xml Index: build.xml === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/build.xml,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- build.xml 21 Jul 2003 21:14:06 - 1.25 +++ build.xml 16 Jun 2004 18:05:12 - 1.26 @@ -31,7 +31,7 @@ pathelement location=${tools.jar}/ pathelement location=${xerces.jar}/ pathelement location=${xercesImpl.jar}/ -pathelement location=${xmlParserAPIs.jar}/ +pathelement location=${xml-apis.jar}/ pathelement location=${commons-el.jar}/ pathelement location=${commons-collections.jar}/ pathelement location=${commons-logging.jar}/ @@ -48,7 +48,7 @@ pathelement location=${tools.jar}/ pathelement location=${xerces.jar}/ pathelement location=${xercesImpl.jar}/ -pathelement location=${xmlParserAPIs.jar}/ +pathelement location=${xml-apis.jar}/ pathelement location=${commons-collections.jar}/ pathelement location=${commons-launcher.jar}/ pathelement location=${jasper.build}/shared/classes/ 1.27 +1 -0 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- TldLocationsCache.java17 Mar 2004 19:23:03 - 1.26 +++ TldLocationsCache.java16 Jun 2004 18:05:12 - 1.27 @@ -154,6 +154,7 @@ noTldJars.add(tomcat-coyote.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); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java JspConfig.java
luehe 2004/02/26 17:03:56 Modified:jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java JspConfig.java Log: Close input stream Revision ChangesPath 1.24 +47 -37 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- TldLocationsCache.java4 Feb 2004 20:01:13 - 1.23 +++ TldLocationsCache.java27 Feb 2004 01:03:55 - 1.24 @@ -293,49 +293,59 @@ */ private void processWebDotXml() throws Exception { -// Acquire an input stream to the web application deployment descriptor -InputStream is = ctxt.getResourceAsStream(WEB_XML); -if (is == null) { -if (log.isWarnEnabled()) { -log.warn(Localizer.getMessage(jsp.error.internal.filenotfound, - WEB_XML)); +InputStream is = null; + +try { +// Acquire input stream to web application deployment descriptor +is = ctxt.getResourceAsStream(WEB_XML); +if (is == null) { +if (log.isWarnEnabled()) { +log.warn(Localizer.getMessage(jsp.error.internal.filenotfound, + WEB_XML)); +} +return; } -return; -} -// Parse the web application deployment descriptor -TreeNode webtld = new ParserUtils().parseXMLDocument(WEB_XML, is); +// Parse the web application deployment descriptor +TreeNode webtld = new ParserUtils().parseXMLDocument(WEB_XML, is); -// Allow taglib to be an element of the root or jsp-config (JSP2.0) -TreeNode jspConfig = webtld.findChild(jsp-config); -if (jspConfig != null) { -webtld = jspConfig; -} -Iterator taglibs = webtld.findChildren(taglib); -while (taglibs.hasNext()) { +// Allow taglib to be an element of the root or jsp-config (JSP2.0) +TreeNode jspConfig = webtld.findChild(jsp-config); +if (jspConfig != null) { +webtld = jspConfig; +} +Iterator taglibs = webtld.findChildren(taglib); +while (taglibs.hasNext()) { -// Parse the next taglib element -TreeNode taglib = (TreeNode) taglibs.next(); -String tagUri = null; -String tagLoc = null; -TreeNode child = taglib.findChild(taglib-uri); -if (child != null) -tagUri = child.getBody(); -child = taglib.findChild(taglib-location); -if (child != null) -tagLoc = child.getBody(); +// Parse the next taglib element +TreeNode taglib = (TreeNode) taglibs.next(); +String tagUri = null; +String tagLoc = null; +TreeNode child = taglib.findChild(taglib-uri); +if (child != null) +tagUri = child.getBody(); +child = taglib.findChild(taglib-location); +if (child != null) +tagLoc = child.getBody(); -// Save this location if appropriate -if (tagLoc == null) -continue; -if (uriType(tagLoc) == NOROOT_REL_URI) -tagLoc = /WEB-INF/ + tagLoc; -String tagLoc2 = null; -if (tagLoc.endsWith(JAR_FILE_SUFFIX)) { -tagLoc = ctxt.getResource(tagLoc).toString(); -tagLoc2 = META-INF/taglib.tld; +// Save this location if appropriate +if (tagLoc == null) +continue; +if (uriType(tagLoc) == NOROOT_REL_URI) +tagLoc = /WEB-INF/ + tagLoc; +String tagLoc2 = null; +if (tagLoc.endsWith(JAR_FILE_SUFFIX)) { +tagLoc = ctxt.getResource(tagLoc).toString(); +tagLoc2 = META-INF/taglib.tld; +} +mappings.put(tagUri, new String[] { tagLoc, tagLoc2 }); +} +} finally { +if (is != null) { +try { +is.close(); +} catch (Throwable t) {} } -mappings.put(tagUri, new String[] { tagLoc, tagLoc2 }); } } 1.15 +121 -109
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java
luehe 2004/02/26 17:30:39 Modified:jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java Log: 80 char limit Revision ChangesPath 1.25 +3 -2 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- TldLocationsCache.java27 Feb 2004 01:03:55 - 1.24 +++ TldLocationsCache.java27 Feb 2004 01:30:39 - 1.25 @@ -300,8 +300,9 @@ is = ctxt.getResourceAsStream(WEB_XML); if (is == null) { if (log.isWarnEnabled()) { -log.warn(Localizer.getMessage(jsp.error.internal.filenotfound, - WEB_XML)); +log.warn(Localizer.getMessage( +jsp.error.internal.filenotfound, +WEB_XML)); } return; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java
luehe 2004/02/04 12:01:13 Modified:jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java Log: Ported (from org.apache.catalina.startup.TldConfig) ability to ignore (for TLD scanning purposes) JARs (in the classloader delegation chain) that are known not to contain any TLDs. Revision ChangesPath 1.23 +120 -5 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- TldLocationsCache.java2 Jan 2004 18:43:49 - 1.22 +++ TldLocationsCache.java4 Feb 2004 20:01:13 - 1.23 @@ -61,8 +61,10 @@ import java.net.URLConnection; import java.util.Enumeration; import java.util.Hashtable; +import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import java.util.StringTokenizer; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -123,6 +125,9 @@ private static final String FILE_PROTOCOL = file:; private static final String JAR_FILE_SUFFIX = .jar; +// Names of JARs that are known not to contain any TLDs +private static HashSet noTldJars; + /** * The mapping of the 'global' tag library URI to the location (resource * path) of the TLD associated with that tag library. The location is @@ -138,6 +143,61 @@ //* // Constructor and Initilizations + +/* + * Initializes the set of JARs that are known not to contain any TLDs + */ +static { +noTldJars = new HashSet(); +noTldJars.add(ant.jar); +noTldJars.add(catalina.jar); +noTldJars.add(catalina-ant.jar); +noTldJars.add(catalina-cluster.jar); +noTldJars.add(catalina-optional.jar); +noTldJars.add(catalina-i18n-fr.jar); +noTldJars.add(catalina-i18n-ja.jar); +noTldJars.add(catalina-i18n-es.jar); +noTldJars.add(commons-dbcp.jar); +noTldJars.add(commons-modeler.jar); +noTldJars.add(commons-logging-api.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(commons-el.jar); +noTldJars.add(jakarta-regexp-1.2.jar); +noTldJars.add(jasper-compiler.jar); +noTldJars.add(jasper-runtime.jar); +noTldJars.add(jmx.jar); +noTldJars.add(jmx-tools.jar); +noTldJars.add(jsp-api.jar); +noTldJars.add(jkshm.jar); +noTldJars.add(jkconfig.jar); +noTldJars.add(naming-common.jar); +noTldJars.add(naming-resources.jar); +noTldJars.add(naming-factory.jar); +noTldJars.add(naming-java.jar); +noTldJars.add(servlet-api.jar); +noTldJars.add(servlets-default.jar); +noTldJars.add(servlets-invoker.jar); +noTldJars.add(servlets-common.jar); +noTldJars.add(servlets-webdav.jar); +noTldJars.add(tomcat-util.jar); +noTldJars.add(tomcat-http11.jar); +noTldJars.add(tomcat-jni.jar); +noTldJars.add(tomcat-jk.jar); +noTldJars.add(tomcat-jk2.jar); +noTldJars.add(tomcat-coyote.jar); +noTldJars.add(xercesImpl.jar); +noTldJars.add(xmlParserAPIs.jar); +// JARs from J2SE runtime +noTldJars.add(sunjce_provider.jar); +noTldJars.add(ldapsec.jar); +noTldJars.add(localedata.jar); +noTldJars.add(dnsns.jar); +} public TldLocationsCache(ServletContext ctxt) { this(ctxt, true); @@ -161,6 +221,22 @@ } /** + * 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.clear(); +StringTokenizer tokenizer = new StringTokenizer(jarNames, ,); +while (tokenizer.hasMoreElements()) { +noTldJars.add(tokenizer.nextToken()); +} +} +} + +/** * Gets the 'location' of the TLD associated with the given taglib 'uri'. * * Returns null if the uri is not associated with any tag library 'exposed' @@ -277,7
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java
markt 2004/01/02 10:43:49 Modified:jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java Log: - Tab police on patrol :) Revision ChangesPath 1.22 +69 -69 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- TldLocationsCache.java23 Sep 2003 01:19:52 - 1.21 +++ TldLocationsCache.java2 Jan 2004 18:43:49 - 1.22 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999,2004 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -178,8 +178,8 @@ */ public String[] getLocation(String uri) throws JasperException { if (!initialized) { - init(); - } +init(); +} return (String[]) mappings.get(uri); } @@ -204,11 +204,11 @@ try { processWebDotXml(); scanJars(); - processTldsInFileSystem(/WEB-INF/); +processTldsInFileSystem(/WEB-INF/); initialized = true; } catch (Exception ex) { -throw new JasperException(Localizer.getMessage(jsp.error.internal.tldinit, -ex.getMessage())); +throw new JasperException(Localizer.getMessage( +jsp.error.internal.tldinit, ex.getMessage())); } } @@ -221,20 +221,20 @@ InputStream is = ctxt.getResourceAsStream(WEB_XML); if (is == null) { if (log.isWarnEnabled()) { - log.warn(Localizer.getMessage(jsp.error.internal.filenotfound, - WEB_XML)); - } +log.warn(Localizer.getMessage(jsp.error.internal.filenotfound, + WEB_XML)); +} return; } // Parse the web application deployment descriptor TreeNode webtld = new ParserUtils().parseXMLDocument(WEB_XML, is); - // Allow taglib to be an element of the root or jsp-config (JSP2.0) - TreeNode jspConfig = webtld.findChild(jsp-config); - if (jspConfig != null) { - webtld = jspConfig; - } +// Allow taglib to be an element of the root or jsp-config (JSP2.0) +TreeNode jspConfig = webtld.findChild(jsp-config); +if (jspConfig != null) { +webtld = jspConfig; +} Iterator taglibs = webtld.findChildren(taglib); while (taglibs.hasNext()) { @@ -256,9 +256,9 @@ tagLoc = /WEB-INF/ + tagLoc; String tagLoc2 = null; if (tagLoc.endsWith(JAR_FILE_SUFFIX)) { - tagLoc = ctxt.getResource(tagLoc).toString(); +tagLoc = ctxt.getResource(tagLoc).toString(); tagLoc2 = META-INF/taglib.tld; - } +} mappings.put(tagUri, new String[] { tagLoc, tagLoc2 }); } } @@ -273,13 +273,13 @@ * JAR should be ignored, false otherwise */ private void scanJar(JarURLConnection conn, boolean ignore) - throws JasperException { +throws JasperException { JarFile jarFile = null; - String resourcePath = conn.getJarFileURL().toString(); +String resourcePath = conn.getJarFileURL().toString(); try { - if (redeployMode) { +if (redeployMode) { conn.setUseCaches(false); } jarFile = conn.getJarFile(); @@ -292,8 +292,8 @@ InputStream stream = jarFile.getInputStream(entry); try { String uri = getUriFromTld(resourcePath, stream); - // Add implicit map entry only if its uri is not already - // present in the map +// Add implicit map entry only if its uri is not already +// present in the map if (uri != null mappings.get(uri) == null) { mappings.put(uri, new String[]{ resourcePath, name }); } @@ -302,8 +302,8 @@ try { stream.close(); } catch (Throwable t) { - // do nothing -
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java
luehe 2003/09/22 18:19:53 Modified:jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java Log: Avoid scanning the JARs under WEB-INF/lib twice Revision ChangesPath 1.21 +18 -39 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- TldLocationsCache.java2 Sep 2003 21:39:59 - 1.20 +++ TldLocationsCache.java23 Sep 2003 01:19:52 - 1.21 @@ -203,9 +203,8 @@ if (initialized) return; try { processWebDotXml(); -processJars(); +scanJars(); processTldsInFileSystem(/WEB-INF/); - processTldsInGlobalJars(); initialized = true; } catch (Exception ex) { throw new JasperException(Localizer.getMessage(jsp.error.internal.tldinit, @@ -265,39 +264,15 @@ } /** - * Processes any JAR files contained in this web application's - * WEB-INF/lib directory. - */ -private void processJars() throws Exception { - -Set libSet = ctxt.getResourcePaths(/WEB-INF/lib); -if (libSet != null) { -Iterator it = libSet.iterator(); -while (it.hasNext()) { -String resourcePath = (String) it.next(); -if (resourcePath.endsWith(JAR_FILE_SUFFIX)) { - URL url = ctxt.getResource(resourcePath); - if (url == null) - return; - URL jarURL = new URL(jar: + url.toString() + !/); - processTldsInJar((JarURLConnection) jarURL.openConnection(), - false); - } -} -} -} - -/** - * Parses any TLD files located in the META-INF directory (or any - * subdirectory of it) of the JAR file at the given resource path, and adds - * an implicit map entry to the taglib map for any TLD that has a uri - * element. + * Scans the given JarURLConnection for TLD files located in META-INF + * (or a subdirectory of it), adding an implicit map entry to the taglib + * map for any TLD that has a uri element. * - * @param conn The JarURLConnection to the JAR file containing the TLDs + * @param conn The JarURLConnection to the JAR file to scan * @param ignore true if any exceptions raised when processing the given * JAR should be ignored, false otherwise */ -private void processTldsInJar(JarURLConnection conn, boolean ignore) +private void scanJar(JarURLConnection conn, boolean ignore) throws JasperException { JarFile jarFile = null; @@ -421,16 +396,20 @@ } /* - * Processes any TLDs in all JAR files accessible to all parent - * classloaders of the web application's classloader. + * Scans all JARs accessible to the webapp's classloader and its + * parent classloaders for TLDs. + * + * The list of JARs always includes the JARs under WEB-INF/lib, as well as + * all shared JARs in the classloader delegation chain of the webapp's + * classloader. * - * This is a Tomcat-specific extension to the TLD search order defined in - * the JSP spec, which will allow tag libraries packaged as JAR + * The latter constitutes a Tomcat-specific extension to the TLD search + * order defined in the JSP spec. It allows tag libraries packaged as JAR * files to be shared by web applications by simply dropping them in a * location that all web applications have access to (e.g., * CATALINA_HOME/common/lib). */ -private void processTldsInGlobalJars() throws Exception { +private void scanJars() throws Exception { ClassLoader loader = Thread.currentThread().getContextClassLoader(); while (loader != null) { @@ -439,14 +418,14 @@ for (int i=0; iurls.length; i++) { URLConnection conn = urls[i].openConnection(); if (conn instanceof JarURLConnection) { - processTldsInJar((JarURLConnection) conn, true); + scanJar((JarURLConnection) conn, true); } else { String urlStr = urls[i].toString(); if (urlStr.startsWith(FILE_PROTOCOL) urlStr.endsWith(JAR_FILE_SUFFIX)) { URL jarURL = new URL(jar: + urlStr + !/); -
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java
remm2003/06/13 09:50:41 Modified:jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java Log: - Default to setting caches to false (rather than not), so that JAR locking does not occur. IMO it is a far more sensible default value for TC 5. Revision ChangesPath 1.19 +1 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- TldLocationsCache.java14 Apr 2003 18:18:43 - 1.18 +++ TldLocationsCache.java13 Jun 2003 16:50:41 - 1.19 @@ -147,7 +147,7 @@ // Constructor and Initilizations public TldLocationsCache(ServletContext ctxt) { -this(ctxt, false); +this(ctxt, true); } /** Constructor. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java
luehe 2003/03/05 10:05:19 Modified:jasper2/src/share/org/apache/jasper/compiler Tag: tomcat_4_branch TldLocationsCache.java Log: Applied patch provided by Ryan Lubke to also consider any of the subdirectories of /WEB-INF (and not just the /WEB-INF directory itself) when looking for TLDs Revision ChangesPath No revision No revision 1.4.2.2 +8 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -u -r1.4.2.1 -r1.4.2.2 --- TldLocationsCache.java16 Dec 2002 21:23:25 - 1.4.2.1 +++ TldLocationsCache.java5 Mar 2003 18:05:19 - 1.4.2.2 @@ -156,7 +156,7 @@ try { processWebDotXml(); processJars(); - processTldsInFileSystem(); + processTldsInFileSystem(/WEB-INF/); initialized = true; } catch (JasperException ex) { Constants.message(jsp.error.internal.tldinit, @@ -279,12 +279,17 @@ * an implicit map entry to the taglib map for any TLD that has a uri * element. */ -private void processTldsInFileSystem() throws JasperException { - Set dirList = ctxt.getResourcePaths(/WEB-INF/); +private void processTldsInFileSystem(String startPath) + throws JasperException { + + Set dirList = ctxt.getResourcePaths(startPath); if (dirList != null) { Iterator it = dirList.iterator(); while (it.hasNext()) { String path = (String) it.next(); +if (path.endsWith(/)) { +processTldsInFileSystem(path); +} if (!path.endsWith(.tld)) { continue; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java
luehe 2002/12/16 13:23:25 Modified:jasper2/src/share/org/apache/jasper/compiler Tag: tomcat_4_branch TldLocationsCache.java Log: Fixed 14200: TLDs under WEB-INF are not scanned for URI mappings Revision ChangesPath No revision No revision 1.4.2.1 +101 -73 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -r1.4 -r1.4.2.1 --- TldLocationsCache.java20 Jun 2002 23:00:43 - 1.4 +++ TldLocationsCache.java16 Dec 2002 21:23:25 - 1.4.2.1 @@ -107,6 +107,7 @@ * the TLD of this tag library. * * @author Pierre Delisle + * @author Jan Luehe */ public class TldLocationsCache { @@ -118,45 +119,56 @@ public static final int ROOT_REL_URI = 1; public static final int NOROOT_REL_URI = 2; -static private final String WEB_XML = /WEB-INF/web.xml; +private static final String WEB_XML = /WEB-INF/web.xml; /** - * 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: + * 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. + *[1] If the location is a jar file, this is the location of the tld. */ -private Hashtable mappings = new Hashtable(); +private Hashtable mappings; -private Hashtable tlds = new Hashtable(); +private Hashtable tlds; + +private boolean initialized; +private ServletContext ctxt; -private boolean initialized=false; -ServletContext ctxt; //* // Constructor and Initilizations +/** + * Constructor. + * + * @param ctxt the servlet context of the web application in which Jasper + * is running + */ public TldLocationsCache(ServletContext ctxt) { -this.ctxt=ctxt; +this.ctxt = ctxt; +mappings = new Hashtable(); +tlds = new Hashtable(); +initialized = false; } private void init() { if( initialized ) return; try { -processWebDotXml(ctxt); -processJars(ctxt); -initialized=true; +processWebDotXml(); +processJars(); + processTldsInFileSystem(); +initialized = true; } catch (JasperException ex) { Constants.message(jsp.error.internal.tldinit, new Object[] { ex.getMessage() }, Logger.ERROR); } } - -private void processWebDotXml(ServletContext ctxt) -throws JasperException -{ + +/* + * Populates taglib map described in web.xml. + */ +private void processWebDotXml() throws JasperException { // Acquire an input stream to the web application deployment descriptor InputStream is = ctxt.getResourceAsStream(WEB_XML); @@ -168,11 +180,8 @@ } // Parse the web application deployment descriptor -ClassLoader cl = -// (ClassLoader) ctxt.getAttribute(Constants.SERVLET_CLASS_LOADER); -this.getClass().getClassLoader(); -ParserUtils pu = ParserUtils.createParserUtils(cl); -TreeNode webtld = pu.parseXMLDocument(WEB_XML, is); +TreeNode webtld = new ParserUtils().parseXMLDocument(WEB_XML, is); + Iterator taglibs = webtld.findChildren(taglib); while (taglibs.hasNext()) { @@ -196,44 +205,38 @@ if (tagLoc.endsWith(.jar)) tagLoc2 = META-INF/taglib.tld; mappings.put(tagUri, new String[] {tagLoc, tagLoc2}); - } - } /** - * Process all the jar files contained in this web application + * Processes any JAR files contained in this web application's * WEB-INF/lib directory. */ -private void processJars(ServletContext ctxt) -throws JasperException -{ - +private void processJars() throws JasperException { Set libSet = ctxt.getResourcePaths(/WEB-INF/lib); if (libSet != null) {
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java
luehe 2002/12/13 11:09:52 Modified:jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java Log: - Added support for implicit taglib map entries from TLDs in the filesystem. - Add implicit entry to taglib map only if its uri is not already present in the map Revision ChangesPath 1.10 +90 -51 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- TldLocationsCache.java2 Dec 2002 22:26:23 - 1.9 +++ TldLocationsCache.java13 Dec 2002 19:09:52 - 1.10 @@ -107,6 +107,7 @@ * the TLD of this tag library. * * @author Pierre Delisle + * @author Jan Luehe */ public class TldLocationsCache { @@ -121,12 +122,11 @@ private static final String WEB_XML = /WEB-INF/web.xml; /** - * 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: + * 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. + *[1] If the location is a jar file, this is the location of the tld. */ private Hashtable mappings; @@ -163,19 +163,21 @@ private void init() { if( initialized ) return; try { -processWebDotXml(ctxt); -processJars(ctxt); -initialized=true; +processWebDotXml(); +processJars(); + processTldsInFileSystem(); +initialized = true; } catch (JasperException ex) { Constants.message(jsp.error.internal.tldinit, new Object[] { ex.getMessage() }, Logger.ERROR); } } - -private void processWebDotXml(ServletContext ctxt) -throws JasperException -{ + +/* + * Populates taglib map described in web.xml. + */ +private void processWebDotXml() throws JasperException { // Acquire an input stream to the web application deployment descriptor InputStream is = ctxt.getResourceAsStream(WEB_XML); @@ -187,8 +189,7 @@ } // Parse the web application deployment descriptor -ParserUtils pu = new ParserUtils(); -TreeNode webtld = pu.parseXMLDocument(WEB_XML, is); +TreeNode webtld = new ParserUtils().parseXMLDocument(WEB_XML, is); // Allow taglib be an element of the root or jsp-config (JSP2.0) TreeNode jspConfig = webtld.findChild(jsp-config); @@ -218,44 +219,38 @@ if (tagLoc.endsWith(.jar)) tagLoc2 = META-INF/taglib.tld; mappings.put(tagUri, new String[] {tagLoc, tagLoc2}); - } - } /** - * Process all the jar files contained in this web application + * Processes any JAR files contained in this web application's * WEB-INF/lib directory. */ -private void processJars(ServletContext ctxt) -throws JasperException -{ - +private void processJars() throws JasperException { Set libSet = ctxt.getResourcePaths(/WEB-INF/lib); if (libSet != null) { Iterator it = libSet.iterator(); while (it.hasNext()) { String resourcePath = (String) it.next(); if (resourcePath.endsWith(.jar)) -tldConfigJar(ctxt, resourcePath); +processTldsInJar(resourcePath); } } - } /** - * Process a TLD in the JAR file at the specified resource path - * (if there is one). Will update the URI mappings for all - * the .tld files found in the META-INF directory tree, if - * a uri element is defined in the TLD. + * Parses any TLD files located in the META-INF directory (or any + * subdirectory of it) of the JAR file at the given resource path, and adds + * an implicit map entry to the taglib map for any TLD that has a uri + * element. * * @param resourcePath Context-relative resource path */ -private void tldConfigJar(ServletContext ctxt, String resourcePath) -throws JasperException -{ +private void
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java
kinman 2002/12/02 14:26:23 Modified:jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java Log: - Patch by [EMAIL PROTECTED] (Petr Jiricka) Fix 14854: Allow redeploying tag libraries from the same jar, do not lock the jar files on Windows Revision ChangesPath 1.9 +50 -24 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- TldLocationsCache.java9 Oct 2002 18:25:39 - 1.8 +++ TldLocationsCache.java2 Dec 2002 22:26:23 - 1.9 @@ -134,15 +134,30 @@ private boolean initialized; private ServletContext ctxt; +private boolean redeployMode; //* // Constructor and Initilizations public TldLocationsCache(ServletContext ctxt) { +this(ctxt, false); +} + +/** Constructs a new instance of TldLocationsCache. + * @param ctxt the servlet context of the web application in which Jasper + * is running + * @param redeployMode if true, then the compiler will allow redeploying + * a tag library from the same jar, at the expense of slowing down the server + * a bit. Note that this may only work on JDK 1.3.1_01a and later, because + * of JDK bug 4211817 fixed in this release. + * If redeployMode is false, a faster but less capable mode will be used. + */ +public TldLocationsCache(ServletContext ctxt, boolean redeployMode) { this.ctxt = ctxt; - mappings = new Hashtable(); - tlds = new Hashtable(); - initialized = false; +this.redeployMode = redeployMode; +mappings = new Hashtable(); +tlds = new Hashtable(); +initialized = false; } private void init() { @@ -247,6 +262,9 @@ url = new URL(jar: + url.toString() + !/); JarURLConnection conn = (JarURLConnection) url.openConnection(); +if (redeployMode) { +conn.setUseCaches(false); +} jarFile = conn.getJarFile(); Enumeration entries = jarFile.entries(); while (entries.hasMoreElements()) { @@ -255,32 +273,40 @@ if (!name.startsWith(META-INF/)) continue; if (!name.endsWith(.tld)) continue; stream = jarFile.getInputStream(entry); -String uri = parseTldForUri(resourcePath, stream); -if (uri != null) { -mappings.put(uri, new String[]{ resourcePath, name }); +try { +String uri = parseTldForUri(resourcePath, stream); +if (uri != null) { +mappings.put(uri, new String[]{ resourcePath, name }); +} +} +finally { +if (stream != null) { +try { +stream.close(); +} catch (Throwable t) {} +} } } -// FIXME @@@ -// -- it seems that the JarURLConnection class caches JarFile -// objects for particular URLs, and there is no way to get -// it to release the cached entry, so -// there's no way to redeploy from the same JAR file. Wierd. } catch (Exception ex) { -if (stream != null) { -try { -stream.close(); -} catch (Throwable t) { - // ignore - } -} -if (jarFile != null) { -try { -jarFile.close(); -} catch (Throwable t) { - // ignore - } +if (!redeployMode) { +// if not in redeploy mode, close the jar in case of an error +if (jarFile != null) { +try { +jarFile.close(); +} catch (Throwable t) { /* ignore */ } +} } throw new JasperException(ex); +} +finally { +if (redeployMode) { +// if in redeploy mode, always close the jar +if (jarFile != null) { +try { +jarFile.close(); +} catch (Throwable t) { /* ignore */ } +
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java
costin 2002/06/20 16:00:43 Modified:jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java Log: Added some code to allow the caching of the TldLibraryInfo. On apps with many pages and many taglibs it is a waste of time to read/parse the same tld on every page. Revision ChangesPath 1.4 +25 -2 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TldLocationsCache.java5 Jun 2002 23:18:33 - 1.3 +++ TldLocationsCache.java20 Jun 2002 23:00:43 - 1.4 @@ -130,20 +130,30 @@ */ private Hashtable mappings = new Hashtable(); +private Hashtable tlds = new Hashtable(); + +private boolean initialized=false; +ServletContext ctxt; //* // Constructor and Initilizations - + public TldLocationsCache(ServletContext ctxt) { +this.ctxt=ctxt; +} + +private void init() { +if( initialized ) return; try { processWebDotXml(ctxt); processJars(ctxt); +initialized=true; } catch (JasperException ex) { Constants.message(jsp.error.internal.tldinit, new Object[] { ex.getMessage() }, Logger.ERROR); } } - + private void processWebDotXml(ServletContext ctxt) throws JasperException { @@ -305,6 +315,7 @@ public String[] getLocation(String uri) throws JasperException { +if( ! initialized ) init(); return (String[])mappings.get(uri); } @@ -327,6 +338,18 @@ } } +public TagLibraryInfo getTagLibraryInfo( String uri ) { +if( ! initialized ) init(); +Object o=tlds.get( uri ); +if( o==null ) return null; +return (TagLibraryInfo)o; +} + +public void addTagLibraryInfo( String uri, TagLibraryInfo tld ) { +if( ! initialized ) init(); +tlds.put( uri, tld); +} + private void p(String s) { System.out.println([TldLocationsCache] + s); } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java
remm2002/06/05 16:18:33 Modified:jasper2/src/share/org/apache/jasper/compiler TldLocationsCache.java Log: - getResourcePaths now returns null if the path does not exist. Revision ChangesPath 1.3 +7 -5 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TldLocationsCache.java24 Apr 2002 02:21:05 - 1.2 +++ TldLocationsCache.java5 Jun 2002 23:18:33 - 1.3 @@ -200,11 +200,13 @@ { Set libSet = ctxt.getResourcePaths(/WEB-INF/lib); -Iterator it = libSet.iterator(); -while (it.hasNext()) { -String resourcePath = (String) it.next(); -if (resourcePath.endsWith(.jar)) -tldConfigJar(ctxt, resourcePath); +if (libSet != null) { +Iterator it = libSet.iterator(); +while (it.hasNext()) { +String resourcePath = (String) it.next(); +if (resourcePath.endsWith(.jar)) +tldConfigJar(ctxt, resourcePath); +} } } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]