users@jersey.java.net

Re: [Jersey] Modifying JAXB Behavior for Returned Objects

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 20 Oct 2009 10:23:57 +0200

On Oct 19, 2009, at 8:03 PM, Tatu Saloranta wrote:

> On Fri, Oct 16, 2009 at 3:27 PM, Tim McNerney <java_at_oneofus.org>
> wrote:
>> I'm using JAXB notation on a simple bean as a return value for some
>> @GET
>> methods, converted to either JSON or XML. In one case, I am return
>> a single
>> instance, but in another, I return a list of items. For the single
>> object,
>> I'd like to convert to the complete value, but when returning a
>> list, I'd
>> like an abbreviated representation. Is there any declarative way to
>> do this?
>
> You could use different objects for separate cases; with a common
> abstract base class?

Yes, such support is not possible with JAXB unless you do the above or
develop some form of customer marshaling i.e. this is something that
could potentially be developed and supported by a JAXB-style extension
supplied by Jersey but it is not something we have right now.

Paul.


> I don't know if it's otherwise cleanly possible -- sounds like you are
> trying to create a union type of sorts, which is not something you
> typically do in Java.
>

> -+ Tatu +-
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>