commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Grant Ingersoll" <>
Subject Re: [Digester] Initializing statics
Date Fri, 20 May 2005 12:04:58 GMT
I have a static method that needs to load a rather large file once (this
method is in a third party library, so refactoring is not an option):

public class Foo
   * Call once before using Foo to load
   public static void init(String filename);

My config xmlrules file looks like:
<pattern value="example/foo">
        <!-- static initializer, somewhat-->
        <object-create-rule classname="Foo"/>
        <call-method-rule methodname="init"
	                paramcount="1" />
        <call-param-rule paramnumber='0' attrname='file'/>

And my configuration file looks like:
     <foo file=""/>

The object-create-rule is superflous to some extent, b/c the init call
is on a static.  However, from my limited understanding of Digester, I
need to have an object
on the stack of type Foo in order to call a method on it (even if it is

The above works, it's just that the object created is just thrown away,
as it is not needed, since the other method that I use on Foo is also
static.  I was just wondering if there was another way to do this, I can
envision something like:

<call-static-method-rule methodname="init" paramcount="1"
<call-param-rule paramnumber='0' attrname='file'/>


>>> 5/19/2005 7:35:24 PM >>>
On Thu, 2005-05-19 at 14:22 -0400, Grant Ingersoll wrote:
> Hi,
> I have a class that has a static initializer the loads a rather
> file (this is in a library class) and I would like to initialize it
> the file via Digester.  Right now, I create a dummy object of that
> and then apply a CallMethodRule invoking the init method with the
> attribute containing the file name.  While this works, seems like a
> waste to construct the dummy object.  Is there a preferred way to
> configurable arguments to a static method on a class?

Sorry, Grant, but I don't understand. Perhaps you could provide some
code demonstrating what you're trying to achieve?



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

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

View raw message