tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <>
Subject Re: tag handler pooling ideas
Date Thu, 08 Mar 2001 03:05:42 GMT
Casey Lucas wrote:
> I am planning on implementing tag handler pooling and would like
> to throw out a few ideas for feedback:
> assumptions:
> - Tag handlers can only be reused if the same set of attributes
> are used for the tag.
> - Tag.relese is called only once -- at some point before the
> handler is garbage collected.

I believe you must add one more restriction on reuse: you can only
reuse tag handlers that are on the same nesting level. For instance,
this case requires two tag handler instances even though they have
the same set of attributes:

  <x:tag1 attr1="a" attr2="b">
    <x:tag1 attr1="xyz" attr2="123"/>

> basic idea:
> My general idea was to have a collection of named pools.  Jasper
> could then render code to use the named pool to obtain handler
> instances instead of newing them each time.
> more info:
> Each tag handler pool would have a name that would include
> the tag's short name and the set of attributes that were used
> on the tag.  

If by "short name", you mean something that identifies both the
tag library and the tag, I'm with you. The prefix is not enough.
The prefix is assigned per page, and you can actually use different 
prefixes for the same library in different pages, so you need 
another unique name for the tag library as such. The same problem
exists with the taglib uri attribute value. Maybe you can use the 
context-relative path to the TLD; no matter how the TLD is identified 
by the taglib directive's uri attribute, it must always be resolved 
to a path to the TLD, and that must be unique within one app.

> This would give us the correct reuse level.  So
> for the following tags there would be two named pools (after
> taking into account attributes):
> <x:tag1 attr1="a" attr2="b"/>
> <x:tag1 attr1="xyz" attr2="123"/>
> <x:tag1 attr1="a"/>
> To eliminate the need to lookup the pool by name each time a
> tag was needed, pool references could be rendered and initialized
> (looked up) when the jsp is initialized.  Inside the main jsp
> method (_jspService), the pool references would be used directly.

I'm not sure I follow.

> When the pools are removed (shutdown, reload, etc.) Tag.release
> will be called for each of the handlers.  I assume that pools need
> to be per web application, but haven't given it a lot of thought.


Hans Bergsten
Gefion Software
Author of JavaServer Pages (O'Reilly),

View raw message