users@jersey.java.net

Re: [Jersey] Configuring xml formatting

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 17 Nov 2008 11:59:34 +0100

On Nov 15, 2008, at 2:05 AM, Miroslav Šulc wrote:

> Hi,
>
> is there a way to configure xml formatting in jersey? I need to set
> "jaxb.formatted.output" to true as otherwise new lines and spaces,
> which
> are in my app significant, are not preserved.
>

Create a class like the following:

@Provider
public MyResolver implements ContextResolver<Marshaller> {
   Marshaller getContext(Class<?> type) {
   }
}


For this you need to create your own JAXBContext and then a Marshaller
for the types you require formatting (return null otherwise). It is
recommend you create JAXBContext just once because they are expensive.

Paul.

> Thank you for advice.
>
> Miroslav
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>