Author: markt Date: Thu Jan 10 09:32:39 2013 New Revision: 1431228 URL: http://svn.apache.org/viewvc?rev=1431228&view=rev Log: Add support for auto-detection and configuration of JARs on the classpath that provide tag plug-in implementations. Based on a patch by Sheldon Shao.
Added: tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestTagPluginManager.java - copied unchanged from r1431221, tomcat/trunk/test/org/apache/jasper/compiler/TestTagPluginManager.java tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TesterTag.java - copied unchanged from r1431221, tomcat/trunk/test/org/apache/jasper/compiler/TesterTag.java tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TesterTagPlugin.java - copied unchanged from r1431221, tomcat/trunk/test/org/apache/jasper/compiler/TesterTagPlugin.java tomcat/tc7.0.x/trunk/test/webapp-3.0/WEB-INF/classes/ - copied from r1431221, tomcat/trunk/test/webapp-3.0/WEB-INF/classes/ Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1431221 Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java?rev=1431228&r1=1431227&r2=1431228&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java Thu Jan 10 09:32:39 2013 @@ -14,10 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.jasper.compiler; +import java.io.IOException; import java.io.InputStream; +import java.net.URL; +import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; @@ -33,9 +35,10 @@ import org.apache.jasper.xmlparser.TreeN * Manages tag plugin optimizations. * @author Kin-man Chung */ - public class TagPluginManager { + private static final String META_INF_JASPER_TAG_PLUGINS_XML = + "META-INF/org.apache.jasper/tagPlugins.xml"; private static final String TAG_PLUGINS_XML = "/WEB-INF/tagPlugins.xml"; private static final String TAG_PLUGINS_ROOT_ELEM = "tag-plugins"; @@ -73,12 +76,62 @@ public class TagPluginManager { if (initialized) return; - InputStream is = ctxt.getResourceAsStream(TAG_PLUGINS_XML); - if (is == null) - return; + tagPlugins = new HashMap<String, TagPlugin>(); + + Enumeration<URL> urls = null; + try { + urls = ctxt.getClassLoader().getResources( + META_INF_JASPER_TAG_PLUGINS_XML); + } catch (IOException ioe) { + throw new JasperException(ioe); + } + + if (urls != null) { + while(urls.hasMoreElements()) { + URL url = urls.nextElement(); + InputStream is = null; + try { + is = url.openStream(); + loadTagPlugins(err, is); + } catch(IOException ioe) { + throw new JasperException(ioe); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException ioe) { + throw new JasperException(ioe); + } + } + } + } + } + + InputStream is = null; + try { + is = ctxt.getResourceAsStream(TAG_PLUGINS_XML); + if (is != null) { + loadTagPlugins(err, is); + } + } finally { + try { + if (is != null) { + is.close(); + } + } catch (IOException ioe) { + throw new JasperException(ioe); + } + } + + initialized = true; + } + + + private void loadTagPlugins(ErrorDispatcher err, InputStream is) + throws JasperException { - TreeNode root = (new ParserUtils()).parseXMLDocument(TAG_PLUGINS_XML, - is); + TreeNode root = + (new ParserUtils()).parseXMLDocument(TAG_PLUGINS_XML, is); if (root == null) { return; } 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=1431228&r1=1431227&r2=1431228&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Thu Jan 10 09:32:39 2013 @@ -154,6 +154,11 @@ </subsection> <subsection name="Jasper"> <changelog> + <add> + <bug>54240</bug>: Add support for auto-detection and configuration of + JARs on the classpath that provide tag plug-in implementations. Based on + a patch by Sheldon Shao. (markt) + </add> <fix> <bug>54241</bug>: Revert the fix for <bug>35410</bug> as it was not compliant with the JSP specification, specifically that --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org