Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 4923 invoked from network); 25 May 2005 23:40:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 25 May 2005 23:40:09 -0000 Received: (qmail 80946 invoked by uid 500); 25 May 2005 23:40:02 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 80899 invoked by uid 500); 25 May 2005 23:40:02 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 80883 invoked by uid 99); 25 May 2005 23:40:02 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from avmta4-rme.xtra.co.nz (HELO avmta4-rme.xtra.co.nz) (210.86.15.159) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 25 May 2005 16:40:00 -0700 Received: from pop1-rme.xtra.co.nz ([210.86.15.240]) by avmta4-rme.xtra.co.nz with ESMTP id <20050525233957.XJQA2892.avmta4-rme.xtra.co.nz@pop1-rme.xtra.co.nz> for ; Thu, 26 May 2005 11:39:57 +1200 Received: from [10.1.1.9] ([222.152.207.84]) by pop1-rme.xtra.co.nz with ESMTP id <20050525233956.NSMS7985.pop1-rme.xtra.co.nz@[10.1.1.9]> for ; Thu, 26 May 2005 11:39:56 +1200 Subject: Re: [digester] call-method-rule From: Simon Kitching Reply-To: skitching@apache.org To: Jakarta Commons Users List In-Reply-To: <200505251653.28539.xarm@forthnet.gr> References: <200505251653.28539.xarm@forthnet.gr> Content-Type: text/plain Date: Thu, 26 May 2005 11:40:53 +1200 Message-Id: <1117064453.3881.18.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On Wed, 2005-05-25 at 16:53 +0300, Markos Charatzas wrote: > Hi again! :D > > Knowing that "call-method-rule" and "call-param-rule" dont have a strong > association between them, Im facing a problem where although a > "call-method-rule" is specified, doesn't actually get called. > > Using xml rules I have the following... > ------------------------------------------------------- > > > > paramcount="1" /> > > > > > > ------------------------------------------------------- > > I noticed that removing either of them, the remaining one works flawlessly... > > Am I missing smth? I think you've struck the design flaw in CallMethodRule. CallMethodRule uses a single stack to store its parameters on. So when you have two "interlaced" callmethodrules like this then the parameters can get mixed up between the calls. And there's an additional (documented) feature with CallMethodRule which is that a call to a method with exactly one parameter doesn't fire if the parameter is not available. This is meant to handle the case where a class has a default value (for "englishName" for example) and you don't want to override that by calling setEnglishName(null) when there is no xml tag for the parameter. So in your case, I bet that when both name/english are undefined, no call gets made. But when both are defined, I suspect that the parameter associated with one method gets set twice - first to the english name, then overwritten with the greek name. And then that method gets called because the parameter is non-null. But the other method sees its parameter has never been set, and so skips the call. Regarding a solution for your case: I think it is probably easiest for you to just write custom rules for setting the english and greek names. // note: rough code only class SetGreekNameRule { public void body(elementNamespace, elementName, bodyText) { OLIShip ship = (OLIShip) digester.peek(); ship.setGreekName(bodyText); } } digester.addRule( "routes/route/ship/name/greek", new SetGreekNameRule()); // and same for the english name Of course you're using that blasted xmlrules stuff so you'll need to figure out how to access your custom rule classes. There is something called "programmatically defined rules" that I think does the job. Regards, Simon --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org