You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Michael Pearce <mi...@studioelectrica.com> on 2003/08/13 00:02:23 UTC

Jasper: TagHandlerPool for each Page and TagHandlerPoolFactory

Hello all.

I was just looking over the code generated by Jasper in Tomcat 4.1.27.  For
my <c:url> tag, the following code is generated for the page:

  public baseLayout_jsp() {
    _jspx_tagPool_c_url_value = new
org.apache.jasper.runtime.TagHandlerPool();
  }

Is there any reason that there is a separate pool created for each page?  It
would seem like it would be more efficient (i.e. less Tag Objects created)
if there was a single pool.

After looking at the latest CVS source, it looks like the Jasper generated
code may have changed to something more like:
  public baseLayout_jsp() {
    _jspx_tagPool_c_url_value =
org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(config);
  }

It appears that the instantiation code has been moved inside of
TagHandlerPool.  Unfortunately, there is still no control over the
TagHandlerPool instantiation by an outside Tag Pool.  I think it would be
better to specify a "tagpoolFactoryClassName" instead of "tagpoolClassName".
Being able to only specify the "tagpoolClassName" does not provide as much
flexibility (since a new TagpoolHandler is always created with a call to
getTagHandlerPool(ServletConfig)).  This way, the TagHandlerPoolFactory
could decide if it wants to always create new TagHandlerPool Objects (as the
current implementation does) or re-use the same TagHandlerPool (which I
would like to implement).

The Factory would be simple:

/*
* Implementions should specify a public no-args constructor.
*/
public interface TagHandlerPoolFactory {
  TagHandlerPool getTagHandlerPool(config);
}

A static instance of TagHandlerPoolFactory could be created in
TagHandlerPool and used for each call to
TagHandlerPool.getTagHandlerPool(ServletConfig).

-mike