Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 67942 invoked from network); 5 Jan 2009 19:20:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Jan 2009 19:20:42 -0000 Received: (qmail 28605 invoked by uid 500); 5 Jan 2009 19:20:33 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 28542 invoked by uid 500); 5 Jan 2009 19:20:33 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 28531 invoked by uid 99); 5 Jan 2009 19:20:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Jan 2009 11:20:33 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Jan 2009 19:20:32 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A5F2B238899B; Mon, 5 Jan 2009 11:20:12 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r731651 - in /tomcat/trunk/java/org/apache/jasper/compiler: ImplicitTagLibraryInfo.java JspUtil.java ParserController.java TagFileProcessor.java TagLibraryInfoImpl.java Date: Mon, 05 Jan 2009 19:20:11 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090105192012.A5F2B238899B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Mon Jan 5 11:20:11 2009 New Revision: 731651 URL: http://svn.apache.org/viewvc?rev=731651&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=46471 Use the URL of the JAR as well as the path within the JAR to identify a tag file to keep tag file definitions unique. Modified: tomcat/trunk/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java tomcat/trunk/java/org/apache/jasper/compiler/ParserController.java tomcat/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java Modified: tomcat/trunk/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java?rev=731651&r1=731650&r2=731651&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java Mon Jan 5 11:20:11 2009 @@ -194,6 +194,7 @@ tagInfo = TagFileProcessor.parseTagFileDirectives(pc, shortName, path, + pc.getJspCompilationContext().getTagFileJarUrl(path), this); } catch (JasperException je) { throw new RuntimeException(je.toString(), je); Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java?rev=731651&r1=731650&r2=731651&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java Mon Jan 5 11:20:11 2009 @@ -26,7 +26,6 @@ import java.util.jar.JarFile; import java.util.zip.ZipEntry; -import org.apache.jasper.Constants; import org.apache.jasper.JasperException; import org.apache.jasper.JspCompilationContext; import org.xml.sax.Attributes; @@ -818,9 +817,31 @@ * * @return Fully-qualified class name of the tag handler corresponding to * the given tag file path + * + * @deprecated Use {@link #getTagHandlerClassName(String, String, + * ErrorDispatcher) + * See https://issues.apache.org/bugzilla/show_bug.cgi?id=46471 */ public static String getTagHandlerClassName(String path, ErrorDispatcher err) throws JasperException { + return getTagHandlerClassName(path, null, err); + } + + /** + * Gets the fully-qualified class name of the tag handler corresponding to + * the given tag file path. + * + * @param path + * Tag file path + * @param err + * Error dispatcher + * + * @return Fully-qualified class name of the tag handler corresponding to + * the given tag file path + */ + public static String getTagHandlerClassName(String path, String urn, + ErrorDispatcher err) throws JasperException { + String className = null; int begin = 0; @@ -848,7 +869,7 @@ } else { index = path.indexOf(META_INF_TAGS); if (index != -1) { - className = "org.apache.jsp.tag.meta."; + className = getClassNameBase(urn); begin = index + META_INF_TAGS.length(); } else { err.jspError("jsp.error.tagfile.illegalPath", path); @@ -860,6 +881,15 @@ return className; } + private static String getClassNameBase(String urn) { + StringBuffer base = new StringBuffer("org.apache.jsp.tag.meta."); + if (urn != null) { + base.append(makeJavaPackage(urn)); + base.append('.'); + } + return base.toString(); + } + /** * Converts the given path to a Java package or fully-qualified class name * Modified: tomcat/trunk/java/org/apache/jasper/compiler/ParserController.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/ParserController.java?rev=731651&r1=731650&r2=731651&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/ParserController.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/ParserController.java Mon Jan 5 11:20:11 2009 @@ -144,15 +144,31 @@ * This is invoked by the compiler * * @param inFileName The name of the tag file to be parsed. + * @deprecated Use {@link #parseTagFileDirectives(String, URL)} + * See https://issues.apache.org/bugzilla/show_bug.cgi?id=46471 */ public Node.Nodes parseTagFileDirectives(String inFileName) throws FileNotFoundException, JasperException, IOException { + return parseTagFileDirectives( + inFileName, ctxt.getTagFileJarUrl(inFileName)); + } + + /** + * Extracts tag file directive information from the given tag file. + * + * This is invoked by the compiler + * + * @param inFileName The name of the tag file to be parsed. + * @param tagFileJarUrl The location of the tag file. + */ + public Node.Nodes parseTagFileDirectives(String inFileName, + URL tagFileJarUrl) + throws FileNotFoundException, JasperException, IOException { boolean isTagFileSave = isTagFile; boolean directiveOnlySave = directiveOnly; isTagFile = true; directiveOnly = true; - Node.Nodes page = doParse(inFileName, null, - ctxt.getTagFileJarUrl(inFileName)); + Node.Nodes page = doParse(inFileName, null, tagFileJarUrl); directiveOnly = directiveOnlySave; isTagFile = isTagFileSave; return page; Modified: tomcat/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java?rev=731651&r1=731650&r2=731651&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java Mon Jan 5 11:20:11 2009 @@ -19,6 +19,8 @@ import java.io.FileNotFoundException; import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; import java.net.URLClassLoader; import java.util.Iterator; import java.util.Vector; @@ -380,7 +382,8 @@ bodycontent = TagInfo.BODY_CONTENT_SCRIPTLESS; } - String tagClassName = JspUtil.getTagHandlerClassName(path, err); + String tagClassName = JspUtil.getTagHandlerClassName( + path, tagLibInfo.getReliableURN(), err); TagVariableInfo[] tagVariableInfos = new TagVariableInfo[variableVector .size()]; @@ -502,16 +505,46 @@ * @param tagLibInfo * the TagLibraryInfo object associated with this TagInfo * @return a TagInfo object assembled from the directives in the tag file. + * @deprecated Use {@link TagFileProcessor#parseTagFileDirectives( + * ParserController, String, String, URL, TagLibraryInfo)} + * See https://issues.apache.org/bugzilla/show_bug.cgi?id=46471 */ public static TagInfo parseTagFileDirectives(ParserController pc, String name, String path, TagLibraryInfo tagLibInfo) throws JasperException { + return parseTagFileDirectives(pc, name, path, + pc.getJspCompilationContext().getTagFileJarUrl(path), + tagLibInfo); + } + + /** + * Parses the tag file, and collects information on the directives included + * in it. The method is used to obtain the info on the tag file, when the + * handler that it represents is referenced. The tag file is not compiled + * here. + * + * @param pc + * the current ParserController used in this compilation + * @param name + * the tag name as specified in the TLD + * @param tagfile + * the path for the tagfile + * @param tagFileJarUrl + * the url for the Jar containign the tag file + * @param tagLibInfo + * the TagLibraryInfo object associated with this TagInfo + * @return a TagInfo object assembled from the directives in the tag file. + */ + public static TagInfo parseTagFileDirectives(ParserController pc, + String name, String path, URL tagFileJarUrl, TagLibraryInfo tagLibInfo) + throws JasperException { + ErrorDispatcher err = pc.getCompiler().getErrorDispatcher(); Node.Nodes page = null; try { - page = pc.parseTagFileDirectives(path); + page = pc.parseTagFileDirectives(path, tagFileJarUrl); } catch (FileNotFoundException e) { err.jspError("jsp.error.file.not.found", path); } catch (IOException e) { @@ -532,16 +565,33 @@ private Class loadTagFile(Compiler compiler, String tagFilePath, TagInfo tagInfo, PageInfo parentPageInfo) throws JasperException { + URL tagFileJarUrl = null; + if (tagFilePath.startsWith("/META-INF/")) { + try { + tagFileJarUrl = new URL("jar:" + + compiler.getCompilationContext().getTldLocation( + tagInfo.getTagLibrary().getURI())[0] + "!/"); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } + String tagFileJarPath; + if (tagFileJarUrl == null) { + tagFileJarPath = ""; + } else { + tagFileJarPath = tagFileJarUrl.toString(); + } + JspCompilationContext ctxt = compiler.getCompilationContext(); JspRuntimeContext rctxt = ctxt.getRuntimeContext(); - JspServletWrapper wrapper = rctxt.getWrapper(tagFilePath); + JspServletWrapper wrapper = rctxt.getWrapper(tagFileJarPath + tagFilePath); synchronized (rctxt) { if (wrapper == null) { wrapper = new JspServletWrapper(ctxt.getServletContext(), ctxt .getOptions(), tagFilePath, tagInfo, ctxt - .getRuntimeContext(), ctxt.getTagFileJarUrl(tagFilePath)); - rctxt.addWrapper(tagFilePath, wrapper); + .getRuntimeContext(), tagFileJarUrl); + rctxt.addWrapper(tagFileJarPath + tagFilePath, wrapper); // Use same classloader and classpath for compiling tag files wrapper.getJspEngineContext().setClassLoader( Modified: tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java?rev=731651&r1=731650&r2=731651&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java Mon Jan 5 11:20:11 2009 @@ -478,13 +478,16 @@ if (path.startsWith("/META-INF/tags")) { // Tag file packaged in JAR + // See https://issues.apache.org/bugzilla/show_bug.cgi?id=46471 + // This needs to be removed once all the broken code that depends on + // it has been removed ctxt.setTagFileJarUrl(path, jarFileUrl); } else if (!path.startsWith("/WEB-INF/tags")) { err.jspError("jsp.error.tagfile.illegalPath", path); } TagInfo tagInfo = TagFileProcessor.parseTagFileDirectives( - parserController, name, path, this); + parserController, name, path, jarFileUrl, this); return new TagFileInfo(name, path, tagInfo); } @@ -686,7 +689,7 @@ } else if ("param-value".equals(tname)) { initParam[1] = element.getBody(); } else if ("description".equals(tname)) { - ; // Do nothing + // Do nothing } else { if (log.isWarnEnabled()) { log.warn(Localizer.getMessage( --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org