users@jaxb.java.net

Re: Using javax.xml.bind.Marshaller manually, will it read a "@XmlSchema" annotation automatically?

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Tue, 22 Dec 2009 10:16:37 +0100

The answer depends on how the annotated classes came about
and how they are to be maintained. The namespace URI has to
be somewhere; putting it into @XmlSchema is one choice.

What xjc does is to generate a class ObjectFactory for each package.
Factory methods take care of creating JAXBElements, using
static QName objects. Of course, that's an additional class.

Accessing one additional annotation once per marshalling can't be
that slow, so caching might be overengineering it.

-W



On Mon, Dec 21, 2009 at 10:41 PM, KARR, DAVID (ATTCINW) <dk068x_at_att.com>wrote:

> I'm looking at some sample Soap client code that's using JAXB for
> serialization.
>
> It's using the JAXB @Xml annotations, to set the schema among other
> things. It's calling javax.xml.bind.Marshaller.marshal() manually, but
> when it constructs the JAXBElement it's reading the "@XmlSchema"
> annotation from the package to get the namespace. In order to do this
> efficiently, it has to cache the class-namespace mapping in a map
> protected by a synchronized block. Are there any reasonable
> alternatives to this strategy?
>
> I guess this is a good reason to use CXF, which hides this cruft.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>