From graffito-dev-return-1304-apmail-incubator-graffito-dev-archive=www.apache.org@incubator.apache.org Wed Sep 13 00:57:49 2006 Return-Path: Delivered-To: apmail-incubator-graffito-dev-archive@www.apache.org Received: (qmail 26408 invoked from network); 13 Sep 2006 00:57:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Sep 2006 00:57:49 -0000 Received: (qmail 29386 invoked by uid 500); 13 Sep 2006 00:57:49 -0000 Mailing-List: contact graffito-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: graffito-dev@incubator.apache.org Delivered-To: mailing list graffito-dev@incubator.apache.org Received: (qmail 29375 invoked by uid 99); 13 Sep 2006 00:57:49 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Sep 2006 17:57:49 -0700 Authentication-Results: idunn.apache.osuosl.org smtp.mail=dsconnelly@adelphia.net; spf=pass X-ASF-Spam-Status: No, hits=1.8 required=5.0 tests=DNS_FROM_RFC_ABUSE,DNS_FROM_RFC_POST Received-SPF: pass (idunn.apache.osuosl.org: domain adelphia.net designates 68.168.78.199 as permitted sender) Received: from ([68.168.78.199:46340] helo=mta9.adelphia.net) by idunn.apache.osuosl.org (ecelerity 2.1 r(10620)) with ESMTP id 10/31-06304-89757054 for ; Tue, 12 Sep 2006 17:58:01 -0700 Received: from [192.168.0.8] (really [69.162.180.18]) by mta9.adelphia.net (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id <20060913005742.UIKP10083.mta9.adelphia.net@[192.168.0.8]> for ; Tue, 12 Sep 2006 20:57:42 -0400 Message-ID: <450757A6.3020907@adelphia.net> Date: Tue, 12 Sep 2006 20:58:14 -0400 From: Dan Connelly User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: graffito-dev@incubator.apache.org Subject: Re: Why doesn't OjbectConverter getObject call this.newInstance method ? References: <450713E4.7080504@adelphia.net> In-Reply-To: <450713E4.7080504@adelphia.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N All: I implemented a simple change in ObjectConverterImpl. It solves the problem I reported. I added the following method: protected Object newInstance(String className) { return ReflectionUtils.newInstance(className); } Elsewhere in ObjectConverterImpl, it will now invoke this.newInstance(classDescriptor.getClassName()); where previously the invocation had been ReflectionUtils.newInstance(classDescriptor.getClassName()); Now I can over-ride the newInstance in MyObjectConverterImpl (which subclasses ObjectConverterImpl). This allows me to construct objects for my model using its factory class. I will submit an enhancement Jira tomorrow to get this change into ObjectConvertImpl. -- Dan Dan Connelly wrote: > All: > > I do a pm.save on the root of my model objects. Then I want to fetch > the object model back using some code like: > > RootClass root = (RootClass) pm.getObject("/test.root"); > > This fails because my model uses a factory class, not constructors, to > instantiate model objects, including instances of the RootClass. > > This pm is constructed using my custom MyObjectConverterImpl, which is > a subclass of ObjectConverterImpl. I expected that this would give > me a way to control object creation. It seems that I was wrong > (unless I copy major portions of ObjectConverterImpl). > > ObjectConverterImpl, if I delegate getObject to it, attempts to get a > root object using this code: > > Object root = > ReflectionUtils.newInstance(classDescriptor.getClassName()); > > That causes the failure. ReflectionUtils is out of my control. > ObjectConverterImpl does not invoke *this.newInstance* so that > MyObjectConverterImpl can get control back for the construction in my > objects (using my factory class). > > What are the plans, if any, are there to accommodate object models > which use a factory class for construction of its objects? > > -- Dan > > > >