On Fri, May 16, 2014 at 12:06 PM, Jörg Schaible
<joerg.schai...@swisspost.com> wrote:
>
> Hi Lethal,
>
> Lethal Possum wrote:
>
> > Hello Jörg,
> >
> > Thank you for your quick and clear answer.
> >
> > I am trying to migrate an existing code base from JAXB to XStream, to
> > compare the unmarshalling speed and the ease of use of both frameworks.
>
> Well, I guess JAXB will process the XML faster, just because it uses
> generated stubs to read/write the predefined XML. However, biggest drawback
> is, that you will have to generate different stubs for different versions of
> your schema and it gets even more difficult, if you have to process multiple
> XML versions of your schema without knowing which one in advance. Here you
> can provide custom converters in XStream that can read old and new format at
> the same time.
>
Indeed I have been burnt by this issue with JAXB many times in the
past in projects where the XSD where provided to me by whatever
protocol I was implementing. The service provider would rewrite their
XSD completely (to use substitution groups or whatever) and even
though the resulting XML structure would remain basically the same,
the classes generated by xjc would be completely different forcing me
to rewrite a bunch of my code. And I gave up on supporting several
versions of the XSD at the same time.

But this time it is a bit different, I am in control of the XSD and I
use the JAXB annotations on my own POJOs directly, I do not use xjc
generated code. However you are right, it doesn't mean that at some
point I won't need to use converters to fix errors in my initial
design, and that will be a convenient solution.

>
> > Currently our JAXB annotations use the accessors. I wanted to do the same
> > in XStream in case some of the accessors have some extra logic in it and
> > also to make the benchmark as fair as possible.
> >
> > I will review our accessors and if none of them do anything special, I
> > guess accessing the fields directly is not a big issue.
>
> One general advice: Instantiating an XStream instance and setting it up is a
> very expensive operation. Therefore you should do this only once and then
> reuse the prepared instance every time. You may use this instance even
> concurrently since marshalling/unmarshalling is threadsafe.
>
Yes I have learned that from JAXB too which has a costly JAXBContext.
I do use a static final XStream object.
>
> If you have to optimize extremely for speed, you should create custom
> converters for your objects instead of using the default ones based on
> reflection. This will have a similar effect compared to the JAXB stubs.
>
Thanks I'll keep that in mind.
>
> Cheers,
> Jörg
>
>
> ---------------------------------------------------------------------
> 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