users@jsr311.java.net

Re: MessageBodyWriter and annotations

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Mon, 30 Jun 2008 15:48:41 -0400

On Jun 30, 2008, at 3:44 PM, Bill Burke wrote:

> IMO, the same is true with Readers.
>
> @PUT
> public void put(@Compression(0.2) Image image) {...}
>
> @Compression should be passed in as the Reader's Annotation[]
>
That is the case for Readers. Sounds like I'm in the minority on the
expectation for Writers - the main issue is there's no way to annotate
a return type so you'd always get the method designator (@GET or
whatever), an @Path etc.

Marc.

> Stephan Koops wrote:
>> Hi,
>> I agree with you, Bill, that it is good to give the resource method
>> annotations.
>> If they should not be this, the Annotation[] parameter could be
>> removed.
>> best regards
>> Stephan
>> Bill Burke schrieb:
>>> Marc Hadley wrote:
>>>> On Jun 30, 2008, at 11:21 AM, Sergey Beryozkin wrote:
>>>>>
>>>>> Consider this method :
>>>>>
>>>>> @AnnotationA
>>>>> public Response get() {
>>>>> return Response.ok().entity(new Foo()).build();
>>>>> }
>>>>>
>>>>> @AnnotationB
>>>>> public class Foo {}
>>>>>
>>>>> Which annotation should be passed to a given MessageBodyWriter
>>>>> instance capable of serializing Foo ?
>>>>> Is it @AnnotationB ?
>>>>>
>>>> Yes, AnnotationB.
>>>>
>>>
>>> No, I don't agree with this. It should be @AnnotationA. If you
>>> don't pass in the method's annotations, there is no way to do per
>>> method configuration.
>>>
>>> For example:
>>>
>>> @Compression(0.2)
>>> @Path("/myimage")
>>> @GET
>>> public Image get() {}
>>>
>>>
>>> @Compression(1.0)
>>> @Path("/anotherImage")
>>> @GET
>>> public Image getAnother() {}
>>>
>>> The @Compression annotation is my configuration annotation.
>>>
>>> Bill
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
>> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>

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