jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: Not a big fan of _at_NameBinding, remove it?

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Wed, 20 Feb 2013 10:17:43 +0000

On 19/02/13 23:03, Bill Burke wrote:
> If your annotation has a qualifier, then @NameBinding really isn't a
> very efficient pattern to implement a filter or interceptor. For
> example, let's say you had a @MaxAge annotation that triggered adding a
> Cache-Control header with a qualified max-age:
>
> @MaxAge(100)
> @GET
> public String get() {...}
>
> The @NameBinding filter would have to inject ResourceInfo and look up
> the @MaxAge annotation each and ever request to set the value. It is
> much better to implement a DynamicFeature in this case so you can
> pre-initialize the filter with the annotation's value.
>
DynamicFeature is limited in that it can not be applied to subresource
methods (in my understanding at least), and @NameBinding is very
efficient when a filter has to be bound to specific method or group of
methods, which have some specific pre or post processing requirements.

Cheers, Sergey