You are welcome. Please do not forget the raise the Jira issue (if you
have not done so yet).

Werner 

> -----Original Message-----
> From: Carey, Tom [mailto:[EMAIL PROTECTED] 
> Sent: Dienstag, 24. Oktober 2006 14:59
> To: '[email protected]'
> Subject: RE: [castor-user] Improving Performance with XML 
> (Marshalling and UnMarshalling)
> 
> Thanks Werner.  That code snippet helped to point out that the
> Un/Marshaller.setResolver(.) has to take a 
> XMLClassDescriptorResolver instead of ClassDescriptorResolver. 
> 
> Tom
> -----Original Message-----
> From: Werner Guttmann [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, October 24, 2006 7:25 AM
> To: [email protected]
> Subject: RE: [castor-user] Improving Performance with XML 
> (Marshalling and
> UnMarshalling)
> 
> Once again ... I just had a look at codd from the Spring XMl 
> factory beans for Castor XML, and found this code fragment in the
> CastorResolverFactoryBean:
> 
> XMLClassDescriptorResolver resolver = (XMLClassDescriptorResolver) 
>  
> ClassDescriptorResolverFactory.createClassDescriptorResolver(B
> indingType
> .XML);
> Mapping mapping = new Mapping();
> mapping.loadMapping(new InputSource(...)); 
> MappingUnmarshaller mappingUnmarshaller = new 
> MappingUnmarshaller(); MappingLoader loader = 
> mappingUnmarshaller.getMappingLoader(mapping,
> BindingType.XML);
> resolver.setMappingLoader(loader);
> 
> And subsequently 
> 
> Unmarshaller unmarshaller = new Unmarshaller(); 
> Unmarshaller.setResolver(resolver);
> ... = unmarshaller.unmarshal(..);
> 
> And if you do not use mapping files at all, just simple not 
> set a MappingLoader on the ClassDescriptorResolver .. :-(.
> 
> I hope this helps.
> Werner
> 
> > -----Original Message-----
> > From: Werner Guttmann [mailto:[EMAIL PROTECTED]
> > Sent: Dienstag, 24. Oktober 2006 13:18
> > To: [email protected]
> > Subject: RE: [castor-user] Improving Performance with XML 
> (Marshalling 
> > and UnMarshalling)
> > 
> > Tom,
> >  
> > a couple of things have changed in that area since 1.0.1 
> (even since 
> > 1.0.3). It looks like we will have to update the best practice 
> > document with regards to these changes. Can you please open a Jira 
> > issue asking for this to happen so that we will be able to 
> track this 
> > (for 1.0.5).
> >  
> > Werner
> >  
> > PS Wrt your 'minor' issue .... Especially MappingLoader and 
> > ClassDescriptorResolver have been undergoing major refactorings. As 
> > aresult of this, some methods might not be as clean as one would 
> > expect.
> > But rather than postponing the inclusion of these refactorings ad 
> > infinitum, we have decided to release them as we go and
> > *unfortunately* cause some minor inconsistencies (now and then).
> > 
> > 
> > ________________________________
> > 
> >     From: Carey, Tom [mailto:[EMAIL PROTECTED] 
> >     Sent: Dienstag, 24. Oktober 2006 08:33
> >     To: '[email protected]'
> >     Subject: [castor-user] Improving Performance with XML 
> (Marshalling 
> > and UnMarshalling)
> >     
> >     
> >     I was browsing through the site and noticed the 
> following link under 
> > Best Practices (http://www.castor.org/xml-best-practice.html).  It 
> > mentions that if you reuse a ClassDescriptorResolver, it'll help 
> > improve performance.  I followed the sample code and came 
> up with the 
> > following
> > method:
> >      
> >         private static ClassDescriptorResolver 
> > getClassDescriptorResolver(String mapFileName, Mapping
> > mapping) throws MappingException
> >         {
> >             ClassDescriptorResolver classDescriptorResolver = 
> > 
> (ClassDescriptorResolver)s_classDescriptorResolvers.get(mapFileName);
> >             if (classDescriptorResolver == null)
> >             {
> >                 classDescriptorResolver = 
> > ClassDescriptorResolverFactory.createClassDescriptorResolver(B
> > indingType
> > .XML);
> >                 MappingUnmarshaller mappingUnmarshaller = new 
> > MappingUnmarshaller();
> >                 XMLMappingLoader mappingLoader = 
> > (XMLMappingLoader)mappingUnmarshaller.getMappingLoader(mapping,
> > BindingType.XML);
> >     
> > classDescriptorResolver.setMappingLoader(mappingLoader);
> >             }
> >             return classDescriptorResolver;
> >         }
> >     
> >     Something to note first on the code.  This is minor.  I 
> had to cast 
> > the instance returned from
> > mappingUnmarshaller.getMappingLoader(..)
> > because classDescriptorResolver.setMappingLoader(.) expects a
> > XMLMappingLoader.   Wondering why the set method isn't using the
> > MappingLoader interface.  Then I wouldn't have to cast 
> after calling 
> > mappingUnmarshaller.getMappingLoader().
> >      
> >     Now to the errors I encountered.  Under v1.0.1, I get 
> the following 
> > compiler errors:
> >        cannot access class org.castor.mapping.BindingType, file ...
> > not found
> >        cannot access class org.castor.mapping.MappingUnmarshaller,
> > file ... not found
> >        cannot access class
> > org.exolab.castor.xml.ClassDescriptorResolverFactory, file ... not 
> > found
> >      
> >     When I attempted to upgrade to v1.0.4, I received the following 
> > compiler errors:
> >       (Source code):  Marshaller
> > marshaller.setResolver(getClassDescriptorResolver(mapFileName,
> > mapping)); 
> >       Error(70,28): method
> > setResolver(org.exolab.castor.xml.ClassDescriptorResolver)
> > not found in class org.exolab.castor.xml.Marshaller
> >      
> >       (Source code):  Unmarshaller
> > unmarshaller.setResolver(getClassDescriptorResolver(mapFileName,
> > mapping)); 
> >       Error(114,26): method
> > setResolver(org.exolab.castor.xml.ClassDescriptorResolver)
> > not found in class org.exolab.castor.xml.Unmarshaller
> >      
> >     Would like to use this bit of code to improve 
> performance.  Do you 
> > have any suggestions?
> >      
> >     Also, if I didn't have a mapping file, would creating an empty 
> > mapping instance work?  Something like:
> >       XMLMappingLoader mappingLoader =
> > (XMLMappingLoader)mappingUnmarshaller.getMappingLoader(new
> > Mapping(), BindingType.XML);
> >     
> >     Thanks,
> >     Tom
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> > 
> >     http://xircles.codehaus.org/manage_email
> > 
> > 
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to