Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 65710 invoked from network); 2 Nov 2001 04:35:33 -0000 Received: from unknown (HELO osaka.betaversion.org) (192.18.49.133) by daedalus.apache.org with SMTP; 2 Nov 2001 04:35:33 -0000 Received: (qmail 5830 invoked from network); 2 Nov 2001 04:37:55 -0000 Received: from nagoya.betaversion.org (192.18.49.131) by osaka.betaversion.org with SMTP; 2 Nov 2001 04:37:55 -0000 Received: (qmail 13403 invoked by uid 97); 2 Nov 2001 04:35:41 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 13372 invoked by uid 97); 2 Nov 2001 04:35:40 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 13361 invoked from network); 2 Nov 2001 04:35:40 -0000 X-Server-Uuid: 80b15476-7d0b-11d3-9ede-009027af8f7a Message-ID: <075784FF0BB4F14CA2BA46CE5E92EDA4023B97@HBWELEXGA> From: "*Colin Sharples" To: "Commons Dev list" Subject: Digester FactoryCreate rule Date: Fri, 2 Nov 2001 17:36:56 +1300 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) X-WSS-ID: 17FCFD1811572-01-01 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi, I've been using the digester for a while now, and thought that I'd pretty much got on top of things. However, I've hit on a problem using the FactoryCreate rule. I'm not sure if this is because I'm not using this properly, or because there's a bug somewhere. I've happily been using the digester to create objects like this: digester.addObjectCreateRule("foo/bar", "com.foo.Bar"); digester.addSetProperties("foo/bar"); digester.addSetNext("foo/bar", "addBar", "com.foo.Bar"); which creates an instance of Bar and adds it to the foo object below it on the stack using foo.addBar(). So far so good. Now, I have a situation where I have previously created and cached the Bar objects, so instead of creating new Bar instances, I want to do a lookup using the id specified by the tag. I thought that I could use the FactoryCreate to do this, by creating an ObjectCreationFactory which knows how to locate the Bar objects by id. I changed the digester set-up to: digester.addFactoryCreateRule("foo/bar", "com.foo.BarCreationFactory"); digester.addSetProperties("foo/bar"); digester.addSetNext("foo/bar", "addBar", "com.foo.Bar"); I assumed that this would work the same way, but that just shows you should never assume anything. The parse would fail with a NoSuchMethodError, which stumped me a bit at first. Then I realised that the Bar object was being popped off the stack before the SetNext was happening, so that the digester was trying to call addBar() on the object *below* foo. Setting debug to lots showed that the end() event was indeed being fired to the FactoryCreate rule *before* it was fired to the SetNext rule. This seems like strange behaviour - but is it buggy or am I interpreting things wrong? TIA Colin Sharples IBM Global Services New Zealand. -- To unsubscribe, e-mail: For additional commands, e-mail: