users@jersey.java.net

Re: [Jersey] JaxB collections, GenericEntity & top element name & namespace in Jersey ?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 01 Jun 2010 12:24:04 +0200

On May 31, 2010, at 5:07 PM, Morten wrote:

> Using GenericEntity it appears that Jersey will allow me to use JaxB
> collections in Jersey for both return values and input?
>

For response entities only, if you are adding an entity to a Response
builder. You do not need to use it if you can declare the type in the
method declaration, as such type information is not erased.


> The problem is how do I define the name and namespace of the top
> element in the XML that Jersey reads/writes ? I need this to make
> sure the output conforms to a XSD schema.
>

It is not currently possible. So you will need to use wrapper classes.

We need to add a feature to support such a mechanism. Either an
annotation or a special return type e.g. JAXBCollection<T>:

   return new JAXBCollection<List<Foo>>(new QName(...), foo);

Paul.