commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Justin Ashworth" <justin-comm...@ashworth.org>
Subject Re: [Digester] Passing arguments to constructors
Date Wed, 15 Jan 2003 15:36:29 GMT
Thanks Craig, this worked great!

----- Original Message -----
From: "Craig R. McClanahan" <craigmcc@apache.org>
To: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
Sent: Tuesday, January 14, 2003 12:15 PM
Subject: Re: [Digester] Passing arguments to constructors


>
>
> On Tue, 14 Jan 2003, Justin Ashworth wrote:
>
> > Date: Tue, 14 Jan 2003 08:50:14 -0500
> > From: Justin Ashworth <justin-commons@ashworth.org>
> > Reply-To: Jakarta Commons Users List <commons-user@jakarta.apache.org>
> > To: commons-user@jakarta.apache.org
> > Subject: [Digester] Passing arguments to constructors
> >
> > Hi,
> >
> > I just started using Digester yesterday and it has already saved me a
lot of
> > time.  However, there is one thing which I haven't been able to figure
out
> > how to do that is making up for the time I saved.  I have a condition
under
> > which a certain object should not be created from the XML.  I am reading
in
> > menu contents from an XML file and I want to make the menu dynamic based
on
> > the user's permissions, known only at runtime.  I could easily do this
if I
> > could just pass the permissions into the constructor when a new object
is
> > created or, alternatively, when setNext is called.  That way I can
determine
> > at runtime whether or not the object should be saved or ignored, based
on
> > whether or not the user has appropriate permissions.  Right now what I
have
> > to do is create the entire object then parse through it and prune the
> > branches that shouldn't exist, which as you could imagine takes a lot of
> > time.  Are there any provisions for doing what I'm trying to do with
> > Digester?  If not, does anybody else think this would be worthwhile
enough
> > that I could implement the feature in Digester?
> >
>
> Check out the ObjectCreationFactory rule.  Instead of specifying the class
> of the object you're trying to create, you specify the class of a Factory
> object -- which can do anything necessary to create the instance of the
> actual object (including calling a constructor with parameters, or calling
> some other object factory, or ...).
>
> > Thanks much,
> >
> > Justin
>
> Craig
>
>
> --
> To unsubscribe, e-mail:
<mailto:commons-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:commons-user-help@jakarta.apache.org>
>


Mime
View raw message