commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Horn, Lutz" <Lutz.H...@FIZ-Karlsruhe.DE>
Subject Re: Strange behaviour with xmlrules
Date Fri, 20 Jun 2003 07:17:53 GMT
Hi Simon,

* From: Simon Kitching [mailto:simon@ecnetwork.co.nz]
> If I understand your mail, you have got a working solution, 
> but are just
> wondering why you need to put the "setNext" rule *before* the
> "setContent" in order to get the setContent() method called before the
> addBaz() method.

Yes. I should have stated this at the beginning of my mail.

> In most cases it doesn't matter. Only if the method invoked by setNext
> requires a fully initialized object does this behaviour cause 
> a problem;
> I presume that your setBaz method does?

The MyBaz instance is added to a java.util.Map using one of it's
fields as the key. So in fact the setter accessor method for this
field must be called before it is added to the Map. Else the field's
value is null which is no use as a key in a Map :-)

> The root cause of this kind of behaviour is that digester is a
> stack-based system, and rules actually fire in 3 steps:
[...]
> In order to ensure proper stack-based behaviour, when multiple rules
> match a pattern:
> * their begin methods are called in the order the rules were added
> * their body methods are called in the order the rules were added
> * their end methods are called *in reverse order*.
> 
> It is because setNextRule and callMethodRule do their work in their
> "end" methods (for good reasons) that they appear to fire in reverse
> order.

Thank you, that's a very useful description.

Regards
Lutz

Mime
View raw message