commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: [digester] Can rules be re-used?
Date Thu, 20 Jan 2005 01:16:02 GMT
On Thu, 2005-01-20 at 09:58 +0900, Bill Keese wrote:
> I see. Although an XML file containing rules is clearly read-only (thus
> corresponding to the traditional english-language meaning of "rule"), I
> guess the "Rule" class is more like a "tag processor", or something like
> that. Well, it would be easy to write Rule classes if Digester
> instantiated a new Rule object for each element it processed. But since
> the Rule objects are reused, it gets tricky.

Yep. Log4J has a configuration-parsing module that is "inspired" by
digester, and which uses the term "Action" rather than "Rule", which I
quite like. 

> Simon Kitching wrote:
> >>If there is only one Rule to process <foo> elements (matching pattern
> >>*/foo), won't bodyText get mangled?
> >>    
> >>
> >
> >For those which have a Stack member: no. This will work fine
> >"recursively", but will fail in multi-threaded environments.
> >  
> >
> Hmm, if you go so far as to use a stack, you might as well store the
> stack in the calling Digester object rather than in the Rule object.
> That would make the Rule object stateless and thus thread safe.

Yep. Note that storing rule-related data on the Digester instance wasn't
possible until release 1.6, which first provided the "named stacks"

> Of course, you would also need to get rid of the Digester back-reference.

In order to have a single rule instance associated with multiple
Digester objects, yes.

I would like to see Digester2 achieve this by passing the Digester as a
parameter to the begin/body/end methods.



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message