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

[jsr339-experts] Re: [jax-rs-spec users] Re: Question about DynamicFeature

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Wed, 26 Sep 2012 09:09:15 -0700

On Sep 26, 2012, at 2:51 AM, Sergey Beryozkin <sberyozkin_at_talend.com> wrote:

> On 25/09/12 17:12, Marek Potociar wrote:
>> It just means that any name-bound filters bound via dynamic features will be bound to that method regardless of whether the method contains the proper name bindings or not.
> OK, I understand. It would probably be clearer if the original text was rephrased a bit, up to you really...
>
> What I'd like to ask is this: what is the use case of getting the feature introduced. I'm sure there's one, I'm just not quite seeing why
> I'd recommend users to use DynamicFeature to register the filters as an alternative to say using Application that can offer post-match global (will apply to all methods) or name-bound (linked to specific methods) filters, as well as interceptors.
>
> Where does DynamicFeature add the extra dimension ?

To answer in one word: aspects. E.g.

- you want to make sure all GET methods use a certain set of filters / interceptors.
- you want to make sure that all methods annotated with a special annotation use a certain set of filters / interceptors. The instances of these providers can be pre-configured at deploy time from the value of the annotation(s) or method signature as well as more tightly bound together etc.

Some concrete examples:
- filter that supports @RolesAllowed
- JSONP interceptor that let's you define callback name via method-level annotation

It's true that you could do some of these things via regular global filters. But at the expense of decreased run-time performance.

Marek


>
> Thanks, Sergey
>
>>
>> Marek
>>
>> On Sep 24, 2012, at 10:25 AM, Sergey Beryozkin<sberyozkin_at_talend.com> wrote:
>>
>>> Hi
>>>
>>> I'd like to ask for a clarification re DynamicFeature, the docs say:
>>>
>>> "Dynamic feature provider is used by JAX-RS runtime to register providers that shall be applied to a particular resource class and method and overrides any annotation-based binding definitions defined on the returned resource filter or interceptor instance."
>>>
>>> I'm confused by "...overrides any annotation-based binding definitions defined on the returned resource filter or interceptor instance."
>>>
>>> The feature dynamically adds providers (filters, interceptors). What exactly the 'overrides' refers to ?
>>>
>>> Thanks, Sergey
>>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com