clucas 01/03/23 22:49:30
Modified: src/etc modules.xml server.xml
src/share/org/apache/jasper/compiler
JspParseEventListener.java TagBeginGenerator.java
TagCache.java TagEndGenerator.java
TagGeneratorBase.java
Added: src/share/org/apache/jasper/compiler TagPoolGenerator.java
TagPoolManagerGenerator.java
src/share/org/apache/jasper/runtime TagHandlerPool.java
TagHandlerPoolImpl.java TagPoolManager.java
TagPoolManagerImpl.java
src/share/org/apache/tomcat/modules/tagpool
TagPoolManagerInterceptor.java
Log:
Addition of tag handler pooling support. Tag handler pooling is disabled
by default. To enable it, see server.xml.
Revision Changes Path
1.3 +6 -0 jakarta-tomcat/src/etc/modules.xml
Index: modules.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/etc/modules.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- modules.xml 2001/03/21 06:55:40 1.2
+++ modules.xml 2001/03/24 06:49:29 1.3
@@ -507,4 +507,10 @@
</module>
+<module name="TagPoolManagerInterceptor"
javaClass="org.apache.tomcat.modules.tagpool.TagPoolManagerInterceptor">
+<category name="tagpool"/>
+<doc>Not yet</doc>
+</module>
+
+
</modules>
1.72 +27 -0 jakarta-tomcat/src/etc/server.xml
Index: server.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/etc/server.xml,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- server.xml 2001/03/21 06:55:40 1.71
+++ server.xml 2001/03/24 06:49:29 1.72
@@ -121,6 +121,33 @@
<Servlet22Interceptor />
+
+ <!-- Tag pooling support.
+ To enable the reuse of tag handlers as described in
+ the JSP spec, uncomment the following. If your pages
+ use a lot of custom tags, you should see a nice performance
+ gain.
+
+ Note that placing the interceptor here will enable
+ Tag pooling for all of the web applicatitions loaded -
+ this may be a bad thing if all tags are not coded to
+ handle reuse. To enable pooling only for specific web
+ applications i.e. Contexts, place the interceptor inside of
+ the Context's definition.
+
+ To view information about tag usage uncomment the tag
+ LogSetter. Set verbosityLevel to DEBUG to see everytime
+ a tag is obtained and released.
+ -->
+ <!--
+ <LogSetter name="tag_pool_log" timestamps="true"
+ path="logs/tagpool-${yyyyMMdd}.log"
+ verbosityLevel="INFORMATION" />
+
+ <TagPoolManagerInterceptor debug="0"/>
+ -->
+
+
<!-- ==================== Connectors ==================== -->
<!-- new http adapter. Attributes:
1.25 +38 -7
jakarta-tomcat/src/share/org/apache/jasper/compiler/JspParseEventListener.java
Index: JspParseEventListener.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspParseEventListener.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- JspParseEventListener.java 2001/03/09 22:29:23 1.24
+++ JspParseEventListener.java 2001/03/24 06:49:29 1.25
@@ -131,6 +131,10 @@
private Stack tagHandlerStack;
private Hashtable tagVarNumbers;
+ // This variable keeps track of tag pools. We only need
+ // one tag pool per tag reuse scope.
+ private Vector tagPools = new Vector();
+
final void addGenerator(Generator gen) throws JasperException {
gen.init(ctxt);
generators.addElement(gen);
@@ -269,12 +273,17 @@
writer.println("}");
writer.println();
- writer.println("private static boolean _jspx_inited = false;");
+ writer.println("private boolean _jspx_inited = false;");
writer.println();
- writer.println("public final void _jspx_init() throws
org.apache.jasper.JasperException {");
+ writer.println("public final synchronized void _jspx_init() throws
org.apache.jasper.JasperException {");
+ writer.pushIndent();
+ writer.println("if (! _jspx_inited) {");
writer.pushIndent();
generateAll(InitMethodPhase.class);
+ writer.println("_jspx_inited = true;");
+ writer.popIndent();
+ writer.println("}");
writer.popIndent();
writer.println("}");
writer.println();
@@ -304,14 +313,11 @@
writer.println("String _value = null;");
writer.println("try {");
writer.pushIndent();
+ writer.println("try {");
+ writer.pushIndent();
writer.println();
- writer.println("if (_jspx_inited == false) {");
- writer.pushIndent();
writer.println("_jspx_init();");
- writer.println("_jspx_inited = true;");
- writer.popIndent();
- writer.println("}");
writer.println("_jspxFactory = JspFactory.getDefaultFactory();");
if (this.contentTypeDir == true)
@@ -351,6 +357,16 @@
writer.popIndent();
writer.println("if (pageContext != null)
pageContext.handlePageException(ex);");
writer.popIndent();
+ writer.println("} catch (Error error) {");
+ writer.pushIndent();
+ writer.println("throw error;");
+ writer.popIndent();
+ writer.println("} catch (Throwable throwable) {");
+ writer.pushIndent();
+ writer.println("throw new ServletException(throwable);");
+ writer.popIndent();
+ writer.println("}");
+ writer.popIndent();
writer.println("} finally {");
writer.pushIndent();
/* Do stuff here for finally actions... */
@@ -908,6 +924,21 @@
Generator gen = new GeneratorWrapper(tbg, start, stop);
addGenerator(gen);
+
+ // If this is the first tag, then generate code to store reference
+ // to tag pool manager.
+ if (tagPools.size() == 0) {
+ addGenerator(new TagPoolManagerGenerator());
+ }
+
+ // if we haven't added a tag pool generator for this tag, then add one
+ String tagPoolVarName = TagPoolGenerator.getPoolName(tli, ti, attrs);
+ if (! tagPools.contains(tagPoolVarName)) {
+ tagPools.add(tagPoolVarName);
+ TagPoolGenerator tpg = new TagPoolGenerator(prefix, shortTagName,
attrs, tli, ti);
+ gen = new GeneratorWrapper(tpg, start, stop);
+ addGenerator(gen);
+ }
}
public void handleTagEnd(Mark start, Mark stop, String prefix,
1.19 +29 -12
jakarta-tomcat/src/share/org/apache/jasper/compiler/TagBeginGenerator.java
Index: TagBeginGenerator.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagBeginGenerator.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- TagBeginGenerator.java 2001/03/09 22:26:14 1.18
+++ TagBeginGenerator.java 2001/03/24 06:49:29 1.19
@@ -279,23 +279,40 @@
String parent = top == null ? null : top.tagHandlerInstanceName;
String evalVar = "_jspx_eval_"+baseVarName;
- tagBegin(new TagVariableData(thVarName, evalVar));
+ TagVariableData tvd = new TagVariableData(thVarName, evalVar);
+ String exceptionCheckName = tvd.tagExceptionCheckName;
+ tagBegin(tvd);
writer.println("/* ---- "+prefix+":"+shortTagName+" ---- */");
-
- writer.println(ti.getTagClassName()+" "+thVarName+" = new
"+ti.getTagClassName()+"();");
-
- generateSetters(writer, parent);
-
- VariableInfo[] vi = ti.getVariableInfo(tagData);
-
+
+ writer.println(ti.getTagClassName() + " " + thVarName + " = null;");
+ // set the exception check variable to false by default.
+ // it will be set to true if an exception is caught.
+ writer.println("boolean " + exceptionCheckName + " = false;");
+
+ VariableInfo[] vi = ti.getVariableInfo(tagData);
+
// Just declare AT_BEGIN here...
declareVariables(writer, vi, true, false, VariableInfo.AT_BEGIN);
-
- writer.println("try {");
- writer.pushIndent();
+
+ // this first try is for tag cleanup
+ writer.println("try {");
+ writer.pushIndent();
+ writer.println("try {");
+ writer.pushIndent();
+ String poolName = TagPoolGenerator.getPoolVariableName(tli, ti, attrs);
+ writer.println("if (" + poolName + " != null) {");
+ writer.pushIndent();
+ writer.println(thVarName + " = (" + ti.getTagClassName() + ") " + poolName
+ ".getHandler();");
+ writer.popIndent();
+ writer.println("}");
+ writer.println("if (" + thVarName + " == null) {");
+ writer.pushIndent();
+ writer.println(thVarName + " = new " + ti.getTagClassName() + "();");
+ writer.popIndent();
+ writer.println("}");
-
+ generateSetters(writer, parent);
writer.println("int "+evalVar+" = "
+thVarName+".doStartTag();");
1.2 +3 -3
jakarta-tomcat/src/share/org/apache/jasper/compiler/TagCache.java
Index: TagCache.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagCache.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TagCache.java 1999/10/20 11:22:54 1.1
+++ TagCache.java 2001/03/24 06:49:29 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagCache.java,v 1.1
1999/10/20 11:22:54 akv Exp $
- * $Revision: 1.1 $
- * $Date: 1999/10/20 11:22:54 $
+ * $Header:
/home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagCache.java,v 1.2
2001/03/24 06:49:29 clucas Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/03/24 06:49:29 $
*
* ====================================================================
*
1.10 +24 -2
jakarta-tomcat/src/share/org/apache/jasper/compiler/TagEndGenerator.java
Index: TagEndGenerator.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagEndGenerator.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- TagEndGenerator.java 2001/03/09 22:26:14 1.9
+++ TagEndGenerator.java 2001/03/24 06:49:29 1.10
@@ -100,6 +100,7 @@
TagVariableData tvd = tagEnd();
String thVarName = tvd.tagHandlerInstanceName;
String evalVarName = tvd.tagEvalVarName;
+ String exceptionCheckName = tvd.tagExceptionCheckName;
VariableInfo[] vi = ti.getVariableInfo(new TagData(attrs));
@@ -157,9 +158,30 @@
// writer.popIndent();
/** FIXME: REMOVE END */
- writer.println("} finally {");
- writer.pushIndent();
+ writer.println("} catch (Throwable throwable) {");
+ writer.pushIndent();
+ writer.println(exceptionCheckName + " = true;");
+ writer.println("throw throwable;");
+ writer.popIndent();
+ writer.println("}");
+ writer.popIndent();
+ writer.println("} finally {");
+ writer.pushIndent();
+ String poolName = TagPoolGenerator.getPoolVariableName(tli, ti, attrs);
+ writer.println("if (" + poolName + " != null && " + thVarName + " != null)
{");
+ writer.pushIndent();
+ writer.println(poolName + ".releaseHandler(" + thVarName + ", " +
exceptionCheckName + ");");
+ //writer.println(poolName + ".releaseHandler(" + thVarName + ");");
+ writer.popIndent();
+ writer.println("} else {");
+ writer.pushIndent();
+ writer.println("if (" + thVarName + " != null) {");
+ writer.pushIndent();
writer.println(thVarName+".release();");
+ writer.popIndent();
+ writer.println("}");
+ writer.popIndent();
+ writer.println("}");
writer.popIndent();
writer.println("}");
1.6 +2 -0
jakarta-tomcat/src/share/org/apache/jasper/compiler/TagGeneratorBase.java
Index: TagGeneratorBase.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagGeneratorBase.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TagGeneratorBase.java 2001/01/07 19:24:21 1.5
+++ TagGeneratorBase.java 2001/03/24 06:49:29 1.6
@@ -77,9 +77,11 @@
class TagVariableData {
String tagHandlerInstanceName;
String tagEvalVarName;
+ String tagExceptionCheckName;
TagVariableData(String tagHandlerInstanceName, String tagEvalVarName) {
this.tagHandlerInstanceName = tagHandlerInstanceName;
this.tagEvalVarName = tagEvalVarName;
+ this.tagExceptionCheckName = tagHandlerInstanceName + "_exceptionCheck";
}
}
1.1
jakarta-tomcat/src/share/org/apache/jasper/compiler/TagPoolGenerator.java
Index: TagPoolGenerator.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.jasper.compiler;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Vector;
import javax.servlet.jsp.tagext.TagLibraryInfo;
import javax.servlet.jsp.tagext.TagInfo;
/**
* This class generates tag pooling related information. Specifically,
* it generates code to declare tag pools and to obtain tag pools
* during jsp initialization.
*
* @author Casey Lucas <[EMAIL PROTECTED]>
* @see TagPoolManager
*/
public class TagPoolGenerator extends GeneratorBase
implements ClassDeclarationPhase, InitMethodPhase {
// Tag related info.
// Some of them aren't used now, but might be in the future.
private String prefix;
private String shortTagName;
private TagLibraryInfo tli;
private TagInfo ti;
private Hashtable attrs;
// Computed pool name and pool name as a valid variable name
private String poolName;
private String poolVarName;
private final static String POOL_VARIABLE_NAME_PREFIX = "_jspx_tagPool_";
/**
* No default constructor.
*/
private TagPoolGenerator() {
}
/**
* Common constructor with enough information to generate code.
*
* @param prefix
* @param shortTagName
* @param attrs
* @param tli
* @param ti
*/
public TagPoolGenerator(String prefix, String shortTagName,
Hashtable attrs, TagLibraryInfo tli,
TagInfo ti) {
this.prefix = prefix;
this.shortTagName = shortTagName;
this.tli = tli;
this.ti = ti;
this.attrs = attrs;
this.poolName = getPoolName(tli, ti, attrs);
this.poolVarName = getPoolVariableName(poolName);
}
/**
* This method returns a unique pool name based on the given
* TagLibraryInfo, TagInfo, and set of tag attributes. Tag
* attribute order does not affect the returned name.
*
* @param tli
* @param ti
* @param attributes
* @return
*/
public static String getPoolName(TagLibraryInfo tli, TagInfo ti, Hashtable
attributes) {
return getSafeVariableName(tli.getURI() + "_" + ti.getTagName() +
getStringFromAttributes(attributes));
}
/**
* This method returns a unique pool variable name given
* TagLibraryInfo, TagInfo and set of tag attributes.
*
* @param tli
* @param ti
* @param attributes
* @return
* @see getPoolName
*/
public static String getPoolVariableName(TagLibraryInfo tli, TagInfo ti,
Hashtable attributes) {
return getPoolVariableName(getPoolName(tli, ti, attributes));
}
/**
* This method returns a unique pool variable name given
* a unique pool name
*
* @param poolName
* @return
* @see getPoolName
*/
public static String getPoolVariableName(String poolName) {
return getSafeVariableName(POOL_VARIABLE_NAME_PREFIX + poolName);
}
/**
* This method generates code from based on the jsp. During
* class declaration phase, it declares a tag pool for this
* tag. During the initilization phase, it generates code
* to lookup a pool from the tag pool manager.
*
* @param writer
* @param phase
*/
public void generate(ServletWriter writer, Class phase) {
if (ClassDeclarationPhase.class.isAssignableFrom(phase)) {
writer.println("org.apache.jasper.runtime.TagHandlerPool " + poolVarName
+ " = null;");
} else if (InitMethodPhase.class.isAssignableFrom(phase)) {
writer.println("if (" + TagPoolManagerGenerator.MANAGER_VARIABLE + " !=
null) {");
writer.pushIndent();
writer.println(poolVarName + " = ");
writer.pushIndent();
writer.println(TagPoolManagerGenerator.MANAGER_VARIABLE + ".getPool(\""
+ poolName + "\",");
writer.println(ti.getTagClassName() + ".class);");
writer.popIndent();
writer.popIndent();
writer.println("}");
}
}
/**
* This method generates a string based on a set of tag attributes.
* It sorts the attributes by name then concatenates them.
*
* @param attributes
* @return
*/
private static String getStringFromAttributes(Hashtable attributes) {
if (attributes == null || attributes.isEmpty()) {
return "";
} else {
Vector sortedAttributes = new Vector(attributes.size());
Enumeration elements = attributes.keys();
int i;
while (elements.hasMoreElements()) {
String attributeName = (String) elements.nextElement();
for (i=0; i<sortedAttributes.size(); i++) {
if (attributeName.compareTo((String)
sortedAttributes.elementAt(i)) < 0) {
break;
}
}
sortedAttributes.insertElementAt(attributeName, i);
}
// cat the attributes
StringBuffer buffer = new StringBuffer();
for (i=0; i<sortedAttributes.size(); i++) {
buffer.append('_');
buffer.append(sortedAttributes.elementAt(i));
}
return buffer.toString();
}
}
/**
* Constant that holds the characters that can be valid first
* characters of a java variable.
*/
private static final String VALID_FIRST_CHARS =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
/**
* Constant that holds the characters that can be used as in
* a valid java variable name -- non first char case.
*/
private static final String VALID_CHARS = VALID_FIRST_CHARS + "1234567890";
/**
* This method generates a string that can be used as a java
* variable name. Characters that cant be used are replaced
* with an underscore.
*
* @param s
* @return
*/
private static String getSafeVariableName(String s) {
StringBuffer buffer = new StringBuffer();
String compareAgainst = VALID_FIRST_CHARS;
for (int i=0; i<s.length(); i++) {
if (i == 1) {
compareAgainst = VALID_CHARS;
}
if (compareAgainst.indexOf(s.charAt(i)) != -1) {
buffer.append(s.charAt(i));
} else {
buffer.append('_');
}
}
return buffer.toString();
}
}
1.1
jakarta-tomcat/src/share/org/apache/jasper/compiler/TagPoolManagerGenerator.java
Index: TagPoolManagerGenerator.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.jasper.compiler;
import org.apache.jasper.runtime.TagPoolManager;
/**
* This class generates code during the initilization phase that
* declares and attempts to obtain a TagPoolManager.
*
* @author Casey Lucas <[EMAIL PROTECTED]>
* @see TagPoolManager
*/
public class TagPoolManagerGenerator extends GeneratorBase
implements InitMethodPhase {
/**
* variable name generated into java file
*/
public static final String MANAGER_VARIABLE = "tagPoolManager";
/**
* Generate ref to TagPoolManager
*
* @param writer
* @param phase
*/
public void generate(ServletWriter writer, Class phase) {
if (InitMethodPhase.class.isAssignableFrom(phase)) {
writer.println("org.apache.jasper.runtime.TagPoolManager " +
MANAGER_VARIABLE + " =");
writer.pushIndent();
//
writer.println("org.apache.jasper.runtime.TagPoolManager.getDefaultPoolManager();");
writer.println("(org.apache.jasper.runtime.TagPoolManager)
getServletContext().getAttribute(\"" +
TagPoolManager.CONTEXT_ATTRIBUTE_NAME + "\");");
writer.popIndent();
}
}
}
1.1
jakarta-tomcat/src/share/org/apache/jasper/runtime/TagHandlerPool.java
Index: TagHandlerPool.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.jasper.runtime;
import javax.servlet.jsp.tagext.Tag;
/**
* This interface allows pooling of tag handlers.
*
* @author Casey Lucas <[EMAIL PROTECTED]>
* @see TagPoolManager
*/
public interface TagHandlerPool {
/**
* This method is called by JSPs to obtain a tag handler.
*
* @return Tag handler appropriate for this pool
*/
public Tag getHandler();
/**
* This method is called by JSPs when they are finished using a
* tag handler obtained from getHandler
*
* @param usedTag
* @param removeFromPool
* Set to true if this handler should be removed from the pool.
* This might occur if an exception is thrown during tag usage.
*/
public void releaseHandler(Tag usedTag, boolean removeFromPool);
/**
* This method is called to shutdown this pool. It is normally
* called by TagPoolManager.shutdown. It should perform cleanup
* and call Tag.release for any stored tags.
*/
public void shutdown();
}
1.1
jakarta-tomcat/src/share/org/apache/jasper/runtime/TagHandlerPoolImpl.java
Index: TagHandlerPoolImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.jasper.runtime;
import javax.servlet.jsp.tagext.Tag;
import java.util.Stack;
import java.util.EmptyStackException;
import java.util.Enumeration;
import org.apache.tomcat.util.log.Log;
/**
* This class provides a basic implementation of TagHandlerPool.
* Its pooling strategy is to grow the pool so that a caller
* never has to wait for a tag handler. Therefore in the worst
* case, the pool size will be equal to the total number of
* concurently used tags (that are at the same reuse scope.) This
* implementation does not shrink the pool.
*
* @author Casey Lucas <[EMAIL PROTECTED]>
* @see TagPoolManagerImpl
*/
public class TagHandlerPoolImpl implements TagHandlerPool {
/**
* the class of tag handler that we store
*/
Class myHandlerClass = null;
/**
* the collection of available handlers
*/
Stack myHandlers = new Stack();
/**
* Tomcat logging mechanism
*/
Log myLog = null;
/**
* Unique name for this pool
*
* @see TagPoolGenerator
*/
String myPoolName = null;
/**
* Keep this constructor private because we need to know what type
* of handlers to create.
*/
private TagHandlerPoolImpl() {
}
/**
* Create a TagHandlerPoolImpl that will store objects of the given
* class type
*
* @param handlerClass
* tag handler class
*/
public TagHandlerPoolImpl(Class handlerClass, String poolName) {
if (! Tag.class.isAssignableFrom(handlerClass)) {
throw new IllegalArgumentException
("TagHandlerPoolImpl should only be used with Tag objects");
}
myHandlerClass = handlerClass;
myPoolName = poolName;
myLog = Log.getLog(TagPoolManagerImpl.LOG_NAME, this);
if (myLog.getLevel() >= Log.INFORMATION) {
myLog.log("New tag pool named '" + myPoolName + "' created to handle " +
handlerClass.getName(), Log.INFORMATION);
}
}
/**
* Obtain a tag handler. This implementation allocates one if one
* is not available. So the collection will grow with concurent
* tag handler use.
*
* @return tag handler
*/
public Tag getHandler() {
Tag returnValue = null;
try {
synchronized (myHandlers) {
if (myHandlers.empty()) {
if (myLog.getLevel() >= Log.DEBUG) {
myLog.log("Allocating new tag of type " +
myHandlerClass.getName(), Log.DEBUG);
}
returnValue = (Tag) myHandlerClass.newInstance();
} else {
if (myLog.getLevel() >= Log.DEBUG) {
myLog.log("Obtaining cached tag of type " +
myHandlerClass.getName(), Log.DEBUG);
}
returnValue = (Tag) myHandlers.pop();
}
}
}
// Ignore these two errors. The jsp page should get the same error
// if it tries to allocate a tag handler.
catch (InstantiationException exception) {
if (myLog.getLevel() >= Log.WARNING) {
myLog.log("Failed to allocate tag of type " +
myHandlerClass.getName() +
": " + exception.toString(), Log.WARNING);
}
}
catch (IllegalAccessException exception) {
if (myLog.getLevel() >= Log.WARNING) {
myLog.log("Failed to allocate tag of type " +
myHandlerClass.getName() +
": " + exception.toString(), Log.WARNING);
}
}
return returnValue;
}
/**
* This method releases a tag handler obtained from getHandler.
* The JSP shouls always call this method after finished using a
* tag handler.
*
* @param usedTag tag previously obtained from getHandler
* @param removeFromPool
* Set to true to remove handler from pool. One reason for this
* is an exception during tag processing.
*/
public void releaseHandler(Tag usedTag, boolean removeFromPool) {
if (myLog.getLevel() >= Log.DEBUG) {
String message = null;
if (removeFromPool) {
message = "Removing tag of type " + myHandlerClass.getName() + "
from cache";
} else {
message = "Returning tag of type " + myHandlerClass.getName() + " to
cache";
}
myLog.log(message, Log.DEBUG);
}
if (removeFromPool) {
usedTag.release();
} else {
synchronized (myHandlers) {
myHandlers.push(usedTag);
}
}
}
/**
* This method performs pool shutdown. It will call Tag.release
* for all of its tag handlers.
*/
public void shutdown() {
synchronized (myHandlers) {
if (myLog.getLevel() >= Log.INFORMATION) {
myLog.log("Shutting down pool '" + myPoolName + "', pool contained "
+
myHandlers.size() + " tags", Log.INFORMATION);
}
Enumeration handlers = myHandlers.elements();
while (handlers.hasMoreElements()) {
((Tag) handlers.nextElement()).release();
}
myHandlers.removeAllElements();
}
}
}
1.1
jakarta-tomcat/src/share/org/apache/jasper/runtime/TagPoolManager.java
Index: TagPoolManager.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.jasper.runtime;
/**
* This interface provides methods for tag handler pooling.
* It specifies management of pools of tag handlers. Normally,
* one TagPoolManager derivative is stored per application
* context. This allows tag pooling on a per web application
* scope.<br>
*
* TagPoolManagers manage TagHandlerPools. TagHandlerPools
* are uniquely named per reuse scope. The current JSP spec
* allows for tag reuse if all of these conditions are met:
* <ul>
* <li>tag scope doesnt conflict
* <li>tags are of the same type
* <li>tags use the same set of attributes
* </ul>
*
* @author Casey Lucas <[EMAIL PROTECTED]>
* @see TagPoolManagerInterceptor
*/
public interface TagPoolManager {
/**
* This constant is the name of the TagPoolManager attribute
* stored into each ServletContext (if tag pooling is enabled.)
*/
public static final String CONTEXT_ATTRIBUTE_NAME =
"org.apache.jasper.runtime.TagPoolManager";
/**
* Obtain a named pool. Each uniquely named pool holds tag
* handlers.
*
* @param poolName unique name of the tag pool
* @param handlerClass
* the type of tag handler objects stored by the pool
* @return
*/
public TagHandlerPool getPool(String poolName, Class handlerClass);
/**
* This method allows the pool manager to shutdown all of its
* pools. Normally, this involves calling relase for all
* its tag handlers.
*/
public void shutdown();
}
1.1
jakarta-tomcat/src/share/org/apache/jasper/runtime/TagPoolManagerImpl.java
Index: TagPoolManagerImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.jasper.runtime;
import java.util.Hashtable;
import java.util.Enumeration;
import org.apache.tomcat.util.log.Log;
/**
* This class provides a basic implementation for TagPoolManager.
* It simply manages a collection of named pools, including their
* retrieval and cleanup.
*
* @author Casey Lucas <[EMAIL PROTECTED]
* @see TagPoolManagerInterceptor
*/
public class TagPoolManagerImpl implements TagPoolManager {
/**
* the collection of tag pools
*/
Hashtable myPools = new Hashtable();
/**
* logging capabilities
*/
Log myLog = null;
/**
* This constant is the log named that can be used in configuration
* files to enable logging.
*/
public static final String LOG_NAME = "tag_pool_log";
/**
* This constructor just sets up logging.
*/
public TagPoolManagerImpl() {
myLog = Log.getLog(LOG_NAME, this);
}
/**
* Obtain a pool by the given name that provides handlers for
* the given class. If no pool is available for the given name
* then allocate a new one and return it.
*
* @param poolName name of the requested pool
* @param handlerClass
* class of the tag handlers
* @return named pool
*/
public TagHandlerPool getPool(String poolName, Class handlerClass) {
TagHandlerPool returnValue = null;
synchronized (myPools) {
returnValue = (TagHandlerPool) myPools.get(poolName);
if (returnValue == null) {
returnValue = new TagHandlerPoolImpl(handlerClass, poolName);
myPools.put(poolName, returnValue);
}
if (myLog.getLevel() >= Log.INFORMATION) {
myLog.log("Getting pool named '" +
poolName + "' for tag handler class '" +
handlerClass.getName() + "'", Log.INFORMATION);
myLog.log("Number of pools is now " + myPools.size(),
Log.INFORMATION);
}
}
return returnValue;
}
/**
* This method is called when the tag pools should be shutdown. It
* calls shutdown for each of the tag pools.
*/
public void shutdown() {
synchronized (myPools) {
if (myLog.getLevel() >= Log.INFORMATION) {
myLog.log("Shutting down " + myPools.size() + " pools",
Log.INFORMATION);
}
Enumeration pools = myPools.elements();
while (pools.hasMoreElements()) {
((TagHandlerPool) pools.nextElement()).shutdown();
}
}
}
}
1.1
jakarta-tomcat/src/share/org/apache/tomcat/modules/tagpool/TagPoolManagerInterceptor.java
Index: TagPoolManagerInterceptor.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.tomcat.modules.tagpool;
import org.apache.tomcat.core.*;
import org.apache.jasper.runtime.TagPoolManager;
import org.apache.jasper.runtime.TagPoolManagerImpl;
/**
* This interceptor sets up tag pooling if it is enabled, it will
* add a TagPoolManagerImpl to the application context. JSPs will
* then find it and use tag pooling. To disable tag pooling, just
* dont include this interceptor.
*
* @author Casey Lucas <[EMAIL PROTECTED]>
* @see TagPoolManager
*/
public class TagPoolManagerInterceptor extends BaseInterceptor {
/**
* This hook is called when an application context is initialized.
* Here, we add a TagPoolManagerImpl to the application context.
*
* @param ctx
* @exception TomcatException
*/
public synchronized void contextInit(Context ctx) throws TomcatException {
if (debug>0) {
log("Adding TagPoolManagerImpl: " + ctx);
}
TagPoolManager manager = (TagPoolManager)
ctx.getAttribute(TagPoolManager.CONTEXT_ATTRIBUTE_NAME);
if (manager != null) {
if (debug>0) {
log("TagPoolManagerImpl already exists for: " + ctx);
}
} else {
manager = new TagPoolManagerImpl();
ctx.setAttribute(TagPoolManager.CONTEXT_ATTRIBUTE_NAME, manager);
}
}
/**
* This hook is called when an application context is shutdown. Here,
* the TagPoolManagerImpl is removed from the application context.
*
* @param ctx
* @exception TomcatException
*/
public synchronized void contextShutdown(Context ctx) throws TomcatException {
if (debug>0) {
log("Removing TagPoolManagerImpl: " + ctx);
}
TagPoolManager manager = (TagPoolManager)
ctx.getAttribute(TagPoolManager.CONTEXT_ATTRIBUTE_NAME);
if (manager != null) {
ctx.removeAttribute(TagPoolManager.CONTEXT_ATTRIBUTE_NAME);
manager.shutdown();
} else {
if (debug>0) {
log("TagPoolManagerImpl not found for: " + ctx);
}
}
}
}