users@jsr311.java.net

Re: MessageBodyWriter and annotations

From: Stephan Koops <Stephan.Koops_at_web.de>
Date: Mon, 30 Jun 2008 21:32:15 +0200

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