commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timo Boewing <bla...@neveprise.net>
Subject Re: [Digester] setting properties from the app's runtime
Date Wed, 01 Jun 2005 21:57:23 GMT
On Mon, 2005-05-30 at 14:34 +1200, Simon Kitching wrote:

> Hi Timo,

Hello Simon,
> 
> Sorry I didn't see your email earlier.

Hey, better than no answer at all :-)

> 
> You can use ObjectParamRule to pass arbitrary objects as part of a
> CallMethodRule. However CallMethodRule rules actually invoke the target
> method when the xml end tag is reached, which might not be what you want
> if you *must* have the call made before addSetProperties.
> 
> An alternative is to use FactoryCreateRule rather than ObjectCreateRule
> to create your object. You can then provide a custom
> ObjectCreationFactory which configures your new instance however it
> wants.

Yes, that is pretty fine; I found a sample of this posted by your around
this time using Google in an mail archive; thank you!

> 
> Or you can write a custom rule, QuestionInitialiserRule, that makes the
> necessary call, and add it:
>   Rule questionInitialiserRule = new QuestionInitialiserRule(...);
> 
>   digester.addObjectCreate(...);
>   digester.addRule(..., questionInitialiserRule);
>   digester.addSetProperties(...);
>   ....
> A custom rule like this should be about 20 lines of code.

The bad news is that I "missed that train" by now, because I completely
settled over to a DigesterLoader XML config in favour of lean Java code,
so
that all my rules are now defined in cfg files rather than in my code,
thus this option is now obsolete for me :-)


However, I am using this opportunity to ask two more questions to you
and the list:

1) I need to set the "classname" attribute of the object-create-rule
dynamically. I did this before when my rules were set in my app's Java
code, so that e.g. the "type" param was read from my XML definitions:

<page id="pg1" type="x.y.QuestionPage">
	[...]
</page>

... so that the type attrib is placed into the classname of the
object-create rule. Is this still possible when using the Digester XML
config?


2) I really am stupid enough not to find a reference documentation for
the DigesterLoader; i.e. what control tags are there and what attribts
are valid for them. Does anyone know where to find it?


> 
> Regards,
> 
> Simon
> 
> 

Thank you for your reply, Simon!

-- 
greetings,                   |  /"\ 
                             |  \ /  ASCII-Ribbon-Campaign
Timo                         |   X     Against HTML Mail
                             |  / \ 
----------------------------------------------------------------------
PUBLIC KEY:
52F3311A     Timo Boewing  <blazko@neveprise.net> 2003/10/30
Fingerprint = F743 E0AA A2F0 1B33 F6FA 417B 72BE 740D 52F3 311A


Mime
View raw message