Bruce, Sorry I think I found the answer. I was looking at the ClassDescriptorResolver interface and could not find a method but I think the method I need is on ClassDescriptorResolverImpl:
associate(Class type, XMLClassDescriptor classDesc) Thanks very much for your help. Stuart -----Original Message----- From: Stuart [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 10, 2005 11:17 AM To: 'Bruce Snyder'; [email protected] Subject: RE: [castor-user] MappingTool Bruce, No the other project is not open source and I only had part of it so it did not make much sense to me. >>The default implementation of the ClassDescriptorResolver >>(ClassDescriptorResolverImpl) will help the unmarshaller resolve a class >>name to its compiled descriptor. This will allow you to load up all the >>compiled mapping descriptors and let the unmarshaller locate the correct >>one according to the class being unmarshalled. In addition, there are >>defnite speed benefits to using the ClassDescriptorResolver, too. I tried what you suggest: Unmarshaller unm = new Unmarshaller(); ClassDescriptorResolver cdr = new ClassDescriptorResolverImpl(); unm.setResolver(cdr); unm.setValidation(false); Object o = unm.unmarshal(inReader); It fails with: [junit] The class for the root element 'ActReq' could not be found. How do I load up all the compiled mapping descriptors into the resolver? (if I do not use a resolver but specify the class when creating the unmarshaller it works). Thanks, Stuart -----Original Message----- From: Bruce Snyder [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 10, 2005 12:19 AM To: S B Subject: Re: [castor-user] MappingTool On 5/9/05, S B <[EMAIL PROTECTED]> wrote: > Bruce/All, > Thanks for your response - I think generating the mapping xml from the > source generator would be a nice addition. > > I guess I am still a little confused about one thing: My server needs to > process multiple different xml 'chunks (not sure if thats the formal > word!)'. At run time I do not know which top-level class this XML will be > for so when creating the Unmarshaller I cannot specify the class. This is > why I started looking into creating the mapping.xml. So my question is - > Can I instead use the compiled mapping descriptors for this? Somehow load > all the compiled mapping discriptors into the Unmarshaller? I definately do > not need to dynamically change the mappings for this project. I suggest using the ClassDescriptorResolver as outlined here: http://castor.codehaus.org/xml-faq.html#How-can-I-speed-up-marshalling/unmar shalling-performance? The default implementation of the ClassDescriptorResolver (ClassDescriptorResolverImpl) will help the unmarshaller resolve a class name to its compiled descriptor. This will allow you to load up all the compiled mapping descriptors and let the unmarshaller locate the correct one according to the class being unmarshalled. In addition, there are defnite speed benefits to using the ClassDescriptorResolver, too. > If the answer is I must use a mapping.xml then I will generate this by > supplying each top level class to the MappingTool (all 100+ of them!). I > must admit that I came across a very similar project to mine using castor in > which they had a mappiing.xml with all their classes (also quite alot) but > in it was only the class information (not fields etc...) and it had a > comment seeming to indicate it had been automatically created....I wish I > knew how they created it and why! The mapping.xml that I created (using the > MappingTool) for each class also has each field detail which I'm not sure I > need (since I do have the compiled descriptors). The only reason I want > this is for the Unmarshaller when it recieves an 'unknown' xml chunk... Is this project open source so that we can have a look at what it is doing? Bruce -- perl -e 'print unpack("u30","D0G)[EMAIL PROTECTED]&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*" );' The Castor Project http://www.castor.org/ Apache Geronimo http://geronimo.apache.org/

