Werner, Thanks for pointing out to me the Unmarshaller(Object) constructor. For some reason I have overlooked it, and must not have been aware that it existed. Now I have a clearer pictures on how this can be done with Castor. I see two possible ways Castor can be enhanced to solve this problem of Castor with Spring:
1. First possible solution is to add a new method called Unmarshaller.setObject(Object) or Unmarshaller.setRootObject(Object), so that after I obtain an instance of both the unmarshaller and the dvConfig objects through the Spring factory bean, I can call the setObject() method to set the dvConfig object on the unmarshaller object. For example, in the spring xml file we could have the following DAO bean that would have access to both the unmarshaller object and the dvConfig object: <bean id="dvConfigDAO" class="com.nget.japps.model.dv.DvConfigDAO"> <property name="unmarshaller" ref="unmarshaller" /> <property name="dvConfig" ref="dvConfig" /> </bean> And inside of the dvConfigDAO we would write the following code: // Set the object that we want to unmarshall to unmarshaller.setObject(dvConfig); // Set the castor xml mapping file unmarshaller.setMapping(map); // Create a Reader to the file to unmarshall from Reader reader = new FileReader(xmlFilePath); // Unmarshall the xml into the dv config object dvConfig = (DvConfig) unmarshaller.unmarshal(reader); --- 2. Second possible solution I think is to somehow modify either the CastorResolverFactoryBean or CastorUnmarshallerFactoryBean so that we could pass in an instance of an object that we want to unmarshall to. For example, in the spring xml file we would have something like this: <bean id="unmarshaller" class="org.springframework.xml.castor.CastorUnmarshallerFactoryBean"> <property name="resolver" ref="resolver"/> <property name="object" ref="dvConfig"/> </bean> I think either one of these two solutions would work, and would solve my problem. Let me know if either one of these solutions is doable. Thanks. --- Werner Guttmann <[EMAIL PROTECTED]> wrote: > Well, right now, there's no easy solution. I have > just had a look at > Unmarshaller(Object), that allows you to set an > object instance (rather > than a Class instance) on the Unmarshaller before > unmarshalling takes > place. Let me see whether and how this could be > integrated with the > Spring factory beans for Castor XML. > > Werner > ********************************************************** * Saladin Sharif * e-mail: [EMAIL PROTECTED] * Visit homepage @ http://gaia.ecs.csus.edu/~sharifs ********************************************************** ____________________________________________________________________________________ Don't get soaked. Take a quick peek at the forecast with the Yahoo! Search weather shortcut. http://tools.search.yahoo.com/shortcuts/#loc_weather --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email

