users@jsr311.java.net

Re: declared return-type ignored for selection of MessageBodyWriter?

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Mon, 29 Sep 2008 13:59:01 -0400

On Sep 29, 2008, at 11:54 AM, Reto Bachmann-Gmür wrote:
>>>
>> Hmm, not sure if I understand you. You need to call the isWritable
>> method at least once for each distinct combination of type, generic
>> type, annotations and supported media type to determine if the
>> writer is able to serialize the entity.
> If we call isWritable with the declared type (and not with the type
> of the object actually returned) we can identify all possible method-
> writer pairs that would generate an acceptable response.

The type argument of the isWritable method is the class of the
instance, not of the method return type. If a method returns Response
you don't statically know what you'll get for an entity. It would be
weird if you got different writers for the same depending on the
resource method return type.


> Based on information of the relative quality of both the method and
> the writer we can determine the best pair. On the other hand, if the
> writer is selected basing on the actually returned object we have to
> select the method without knowing which provider will be used and
> thus without considering its quality.
>
Yup.

Marc.

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.