commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: [Digester] setting properties from the app's runtime
Date Mon, 30 May 2005 02:34:53 GMT
On Wed, 2005-05-25 at 00:50 +0200, Timo Boewing wrote:
> Hello all,
> I am working with Digester since some time now and am very happy with
> it; however, I have one major problem with it: whenever I let Digester
> create objects using addObjectCreate(), i want to set a property on this
> instance before calls of addSetProperties() or so are made. This
> property is not from the XML but from the app's runtime, say, a global
> variable.

Hi Timo,

Sorry I didn't see your email earlier.

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

Or you can write a custom rule, QuestionInitialiserRule, that makes the
necessary call, and add it:
  Rule questionInitialiserRule = new QuestionInitialiserRule(...);

  digester.addRule(..., questionInitialiserRule);
A custom rule like this should be about 20 lines of code.

I would think that using FactoryCreateRule is probably the best option
given your description.



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

View raw message