commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: [digester] Set attribute in a static class
Date Tue, 27 Jan 2004 21:52:27 GMT
On Wed, 2004-01-28 at 05:09, Samuel Cheung wrote:
> Hi,
> I would like to use Digester to set attribute in my static class.
> So I create my own ObjectCreationFactory (child class of
> AbstractObjectCreationFactory) to return the static object. 
> But when I set the attribute of the Static object by using addCallParam(), I
> got exception:
> Jan 27, 2004 12:32:49 AM org.apache.commons.digester.Digester peekParams
> WARNING: Empty stack (returning null)

Digester needs target *objects* on its object stack in order to set
their attributes. The error message is indicating that when Digester
went to get the top object on the object stack, in order to set its
parameter1 value, it found that the object stack was empty.

Your approach of using a factory would work with *singleton* objects.
However I can't imagine how you would use one with a purely static class
- what are you returning from the CreateObject method? If you are
returning *null* instead of an object, that would explain the symptoms..

Regardless, Roberts suggestion of a custom rule is probably the best
solution provided you don't have too many of these static classes. If
you *do* have a lot of these static classes, you may have more serious
problems anyway :-)

Or you could change to using Singletons instead....



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

View raw message