users@jersey.java.net

Re: Configuration of JAXB un/marshalling

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Tue, 23 Nov 2010 12:33:31 +0100

On Nov 22, 2010, at 11:24 PM, DaHoopster wrote:

>
> Hi Paul,
>
> I am trying to customize the XML namespace prefix mapping using
> NamespacePrefixMapper. But since I need to set a property on the
> Marshaller,
> I am thinking about writing a custom ContextResolver<Marshaller> to
> do this.
>
> I am not quite sure, however, on how to get the appropriate
> JAXBContext
> inside the marshaller context resolver I am writing. The resources
> produce
> both JSON and XML, but I want the property set on the marshaller
> created by
> both JSON JAXB context and regular JAXB context.
>
> Could you suggest a way to do this?
>

Create an instance of JSONJAXBContext, which extends JAXBContext:

   http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/json/JSONJAXBContext.html

and return the Marshaller from JSONJAXB.createMarshaller. Then it
should work for XML or JSON.

Paul.


> Thanks,
> Han
> --
> View this message in context: http://jersey.576304.n2.nabble.com/Configuration-of-JAXB-un-marshalling-tp678862p5764653.html
> Sent from the Jersey mailing list archive at Nabble.com.