Methods Summary |
---|
public javax.servlet.jsp.tagext.Tag | get(java.lang.Class handlerClass)Gets the next available tag handler from this tag handler pool,
instantiating one if this tag handler pool is empty.
PerThreadData ptd = (PerThreadData)perThread.get();
if(ptd.current >=0 ) {
return ptd.handlers[ptd.current--];
} else {
try {
return (Tag) handlerClass.newInstance();
} catch (Exception e) {
throw new JspException(e.getMessage(), e);
}
}
|
protected void | init(javax.servlet.ServletConfig config)
maxSize = Constants.MAX_POOL_SIZE;
String maxSizeS = getOption(config, OPTION_MAXSIZE, null);
if (maxSizeS != null) {
maxSize = Integer.parseInt(maxSizeS);
if (maxSize < 0) {
maxSize = Constants.MAX_POOL_SIZE;
}
}
perThread = new ThreadLocal() {
protected Object initialValue() {
PerThreadData ptd = new PerThreadData();
ptd.handlers = new Tag[maxSize];
ptd.current = -1;
perThreadDataVector.addElement(ptd);
return ptd;
}
};
|
public void | release()Calls the release() method of all tag handlers in this tag handler pool.
Enumeration enumeration = perThreadDataVector.elements();
while (enumeration.hasMoreElements()) {
PerThreadData ptd = (PerThreadData)enumeration.nextElement();
if (ptd.handlers != null) {
for (int i=ptd.current; i>=0; i--) {
if (ptd.handlers[i] != null) {
ptd.handlers[i].release();
}
}
}
}
|
public void | reuse(javax.servlet.jsp.tagext.Tag handler)Adds the given tag handler to this tag handler pool, unless this tag
handler pool has already reached its capacity, in which case the tag
handler's release() method is called.
PerThreadData ptd=(PerThreadData)perThread.get();
if (ptd.current < (ptd.handlers.length - 1)) {
ptd.handlers[++ptd.current] = handler;
} else {
handler.release();
}
|