commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Bare <>
Subject Re: [digester] help with multi-argument constructor
Date Mon, 26 May 2003 19:12:02 GMT
Thanks Simon and Robert for the insight into how these
rules work. I understand now why my idea is somewhat
at odds with the way digester is designed.

You are correct that I want to use a setNext rule
after creating the User 0bject to add each user to an
aggregate object. Sorta like this:

    digester.addObjectCreate( "users", Users.class );

    digester.addCallConstructor( "users/user",
User.class, 2 );
    digester.addCallParam( "users/user/id", 0 );
    digester.addCallParam( "users/user/name", 1 );

    digester.addSetNext( "users/user", "addUser" );

If I understand correctly, the CallParam pushes values
onto the stack and the CallMethod rule pops them off
and finally invokes the method in the
end(java.lang.String namespace, java.lang.String name)
method of the rule. I was thinking that the
CallConstructor rule could work the same way, and that
the newly created object could be pushed onto the
stack in the end(...) method. Then the SetNext rule
could come along and pop do its thing.

The issue with this, I guess, is that you need to
insure that the the constructor is called and the
object pushed onto the stack before SetNext's end(...)
is invoked. Or, is there more to it than that? If the
Constructor was invoked in the body(...) of my
hypothetical CallConstructorRule, that would
definitely push the new object first. Would body(...)
definitely be called -after- the params were pushed
onto the stack?

Maybe I'll grab some sack and code up a rule. In the
meantime, Simon's work-around is working well enough.

Thanks again. The jakarta project is a like a toy
store. There are so many nifty things tucked away in
various corners.


Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.

View raw message