users@jsr311.java.net

Re: MessageBodyWriter and annotations

From: Bill Burke <bburke_at_redhat.com>
Date: Mon, 30 Jun 2008 15:31:25 -0400

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

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com