remm 2005/08/30 15:39:36 Modified: jasper2/src/share/org/apache/jasper/compiler TagLibraryInfoImpl.java Parser.java JspDocumentParser.java jasper2/src/share/org/apache/jasper EmbeddedServletOptions.java Options.java JspC.java webapps/docs changelog.xml Log: - JSP compilation speed improvement using tag library information caching. - Submitted by Xingbo Gao. Revision Changes Path 1.60 +1 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java Index: TagLibraryInfoImpl.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- TagLibraryInfoImpl.java 23 Mar 2005 15:48:37 -0000 1.59 +++ TagLibraryInfoImpl.java 30 Aug 2005 22:39:34 -0000 1.60 @@ -86,7 +86,7 @@ print("urn", urn, out); print("info", info, out); print("uri", uri, out); - print("tagLibraryValidator", tagLibraryValidator.toString(), out); + print("tagLibraryValidator", "" + tagLibraryValidator, out); for(int i = 0; i < tags.length; i++) out.println(tags[i].toString()); 1.91 +17 -8 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java Index: Parser.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v retrieving revision 1.90 retrieving revision 1.91 diff -u -r1.90 -r1.91 --- Parser.java 9 Mar 2005 19:13:20 -0000 1.90 +++ Parser.java 30 Aug 2005 22:39:34 -0000 1.91 @@ -414,14 +414,23 @@ prefix, uri, uriPrev); } if (pageInfo.getTaglib(uri) == null) { - String[] location = ctxt.getTldLocation(uri); - pageInfo.addTaglib(uri, - new TagLibraryInfoImpl(ctxt, - parserController, - prefix, - uri, - location, - err)); + TagLibraryInfoImpl impl = null; + if (ctxt.getOptions().isCaching()) { + impl = (TagLibraryInfoImpl) ctxt.getOptions().getCache().get(uri); + } + if (impl == null) { + String[] location = ctxt.getTldLocation(uri); + impl = new TagLibraryInfoImpl(ctxt, + parserController, + prefix, + uri, + location, + err); + if (ctxt.getOptions().isCaching()) { + ctxt.getOptions().getCache().put(uri, impl); + } + } + pageInfo.addTaglib(uri, impl); } pageInfo.addPrefixMapping(prefix, uri); } else { 1.86 +22 -14 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.85 retrieving revision 1.86 diff -u -r1.85 -r1.86 --- JspDocumentParser.java 11 Aug 2005 12:00:32 -0000 1.85 +++ JspDocumentParser.java 30 Aug 2005 22:39:35 -0000 1.86 @@ -1233,20 +1233,28 @@ String[] location = ctxt.getTldLocation(uri); if (location != null || !isPlainUri) { - /* - * If the uri value is a plain uri, a translation error must - * not be generated if the uri is not found in the taglib map. - * Instead, any actions in the namespace defined by the uri - * value must be treated as uninterpreted. - */ - result = - new TagLibraryInfoImpl( - ctxt, - parserController, - prefix, - uri, - location, - err); + if (ctxt.getOptions().isCaching()) { + result = (TagLibraryInfoImpl) ctxt.getOptions().getCache().get(uri); + } + if (result == null) { + /* + * If the uri value is a plain uri, a translation error must + * not be generated if the uri is not found in the taglib map. + * Instead, any actions in the namespace defined by the uri + * value must be treated as uninterpreted. + */ + result = + new TagLibraryInfoImpl( + ctxt, + parserController, + prefix, + uri, + location, + err); + if (ctxt.getOptions().isCaching()) { + ctxt.getOptions().getCache().put(uri, result); + } + } } } 1.24 +8 -0 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/EmbeddedServletOptions.java Index: EmbeddedServletOptions.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/EmbeddedServletOptions.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- EmbeddedServletOptions.java 5 Apr 2005 23:14:43 -0000 1.23 +++ EmbeddedServletOptions.java 30 Aug 2005 22:39:35 -0000 1.24 @@ -347,6 +347,14 @@ return tagPluginManager; } + public boolean isCaching() { + return false; + } + + public Map getCache() { + return null; + } + /** * Create an EmbeddedServletOptions object using data available from * ServletConfig and ServletContext. 1.28 +15 -0 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/Options.java Index: Options.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/Options.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- Options.java 22 Oct 2004 17:13:27 -0000 1.27 +++ Options.java 30 Aug 2005 22:39:35 -0000 1.28 @@ -17,6 +17,7 @@ package org.apache.jasper; import java.io.File; +import java.util.Map; import org.apache.jasper.compiler.JspConfig; import org.apache.jasper.compiler.TagPluginManager; @@ -170,4 +171,18 @@ */ public int getModificationTestInterval(); + /** + * Is caching enabled (used for precompilation). + */ + public boolean isCaching(); + + /** + * The web-application wide cache for the returned TreeNode + * by parseXMLDocument in TagLibraryInfoImpl.parseTLD, + * if isCaching returns true. + * + * @return the Map(String uri, TreeNode tld) instance. + */ + public Map getCache(); + } 1.100 +33 -0 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java Index: JspC.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java,v retrieving revision 1.99 retrieving revision 1.100 diff -u -r1.99 -r1.100 --- JspC.java 27 Jul 2005 15:12:03 -0000 1.99 +++ JspC.java 30 Aug 2005 22:39:35 -0000 1.100 @@ -33,6 +33,8 @@ import java.util.ArrayList; import java.util.Enumeration; import java.util.List; +import java.util.Map; +import java.util.HashMap; import java.util.Stack; import java.util.StringTokenizer; import java.util.Vector; @@ -100,6 +102,7 @@ private static final String SWITCH_OUTPUT_DIR = "-d"; private static final String SWITCH_IE_CLASS_ID = "-ieplugin"; private static final String SWITCH_PACKAGE_NAME = "-p"; + private static final String SWITCH_CACHE = "-cache"; private static final String SWITCH_CLASS_NAME = "-c"; private static final String SWITCH_FULL_STOP = "--"; private static final String SWITCH_COMPILE = "-compile"; @@ -155,6 +158,8 @@ private boolean compile = false; private boolean smapSuppressed = true; private boolean smapDumped = false; + private boolean caching = true; + private Map cache = new HashMap(); private String compiler = null; @@ -282,6 +287,13 @@ xpoweredBy = true; } else if (tok.equals(SWITCH_TRIM_SPACES)) { setTrimSpaces(true); + } else if (tok.equals(SWITCH_CACHE)) { + tok = nextArg(); + if ("false".equals(tok)) { + caching = false; + } else { + caching = true; + } } else if (tok.equals(SWITCH_CLASSPATH)) { setClassPath(nextArg()); } else if (tok.startsWith(SWITCH_DIE)) { @@ -399,6 +411,27 @@ return classDebugInfo; } + /** + * @see Options#isCaching() + */ + public boolean isCaching() { + return caching; + } + + /** + * @see Options#isCaching() + */ + public void setCaching(boolean caching) { + this.caching = caching; + } + + /** + * @see Options#getCache() + */ + public Map getCache() { + return cache; + } + /** * Background compilation check intervals in seconds */ 1.365 +8 -0 jakarta-tomcat-catalina/webapps/docs/changelog.xml Index: changelog.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/webapps/docs/changelog.xml,v retrieving revision 1.364 retrieving revision 1.365 diff -u -r1.364 -r1.365 --- changelog.xml 29 Aug 2005 01:14:45 -0000 1.364 +++ changelog.xml 30 Aug 2005 22:39:36 -0000 1.365 @@ -56,6 +56,14 @@ <fix> Fix NPE with an error message when no Java compiler is available (remm) </fix> + <fix> + Restrict System err stream capture to the Ant compiler, as the Eclipse compiler + does not need it (remm) + </fix> + <update> + JSP compilation speed improvement using tag library information caching, + submitted by Xingbo Gao (remm) + </update> </changelog> </subsection>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]