You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Emmanuel Bourg <sm...@lfjr.net> on 2002/08/12 19:12:28 UTC

[digester] Alternate call method rule proposal

Hello,

I wrote a new rule for the digester based on the CallMethodRule rule, i
think it to could useful to integrate it in the digester code.

With the standard CallMethodRule the method invocation is delayed until
the closing tag is reached, in some cases it's needed to invoke the
method after parsing the opening tag (provided element's attributes are
the only parameters and the body is not used as a parameter), especially
if rules matching sub-elements require data set previously on the parent
objet.

The principle is to invoke the method from the last CallParamRule called
instead of the end() method of the CallMethodRule. To achieve this the
CallParamRule needs a reference to the CallMethodRule object, this is
done by pushing the rule object on the digester's stack in the begin()
method. The last CallParamRule pops the CallMethodRule and calls a
doMethodCall() method on it.

I'm not sure the CallMethodRule and CallParamRule classes can be changed
to allow this without breaking current uses of the Digester (especially
for calls using both element's attributes and element's body as
parameters). In doubt I wrote 2 rules derivated from the digester's
ones, EarlyCallMethodRule and EarlyCallParamRule, i'm attaching them to
this mail. If it's found worth for addition to the digester i'll be glad
to polish this up and submit an extensive patch.

Emmanuel Bourg


Re: [digester] Alternate call method rule proposal

Posted by robert burrell donkin <ro...@mac.com>.
hi Emmanuel

i can see that you probably have a need for this functionality. i also 
think that additional classes is the right way to do it. what does worry 
me is that they duplicate a lot of the standard code. we've discovered 
some subtle bugs in this code and so i'd prefer it if we could re-use as 
much of the standard code as possible (by inheritance).

we've got a release coming up (hopefully) very soon. i'd prefer to leave 
these changes until after the release since this will require a bit of 
tweaking in callmethodrule etc.

a good test case would also be very useful.

- robert

On Monday, August 12, 2002, at 06:12 PM, Emmanuel Bourg wrote:

> Hello,
>
> I wrote a new rule for the digester based on the CallMethodRule rule, i
> think it to could useful to integrate it in the digester code.
>
> With the standard CallMethodRule the method invocation is delayed until
> the closing tag is reached, in some cases it's needed to invoke the
> method after parsing the opening tag (provided element's attributes are
> the only parameters and the body is not used as a parameter), especially
> if rules matching sub-elements require data set previously on the parent
> objet.
>
> The principle is to invoke the method from the last CallParamRule called
> instead of the end() method of the CallMethodRule. To achieve this the
> CallParamRule needs a reference to the CallMethodRule object, this is
> done by pushing the rule object on the digester's stack in the begin()
> method. The last CallParamRule pops the CallMethodRule and calls a
> doMethodCall() method on it.
>
> I'm not sure the CallMethodRule and CallParamRule classes can be changed
> to allow this without breaking current uses of the Digester (especially
> for calls using both element's attributes and element's body as
> parameters). In doubt I wrote 2 rules derivated from the digester's
> ones, EarlyCallMethodRule and EarlyCallParamRule, i'm attaching them to
> this mail. If it's found worth for addition to the digester i'll be glad
> to polish this up and submit an extensive patch.
>
> Emmanuel Bourg
>
>   --
> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.
> org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>