For performance reasons, I am attempting to
1. construct a digester
2. configure it with a lot of rules
3. parse a document
4. parse another document
I am not trying to utilize a single parser instance from multiple threads at the same
time. The
most expensive part of parsing our documents with the digester is setting up the
rules, so I'd
like to only have to do that once.
Unfortunately this does not work because the implementations of Rule.finish() in all
of the
various rules set the rule's member variables to null. For example from
ObjectCreateRule:
public void finish() throws Exception {
attributeName = null;
className = null;
}
I realize I can fix this by subclassing each of the rules or alternately by
subclassing Digester
and changing this behavior. But this behavior seems not only inconvenient in my case
but
meaningless in the general case. The only purpose accomplished by setting the members
to null is
to prevent reuse. It's not a meaningful cleanup step otherwise because the members
don't maintain
any state except that necessary to define the rule. This doesn't clean up memory in
Java unless
you want the members to be garbage collected but not the rule itself, which seems
useless because
it doesn't allow the Rule object to be used to define a different rule since there is
no way to
re-set these members except through the constructor. So why is the code this way?
I'm hoping someone will either explain or change this behavior.
Thanks for the help.
Matt Cleveland
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/