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

[jsr339-experts] Re: [jax-rs-spec users] Re: Re: Name Binding Alignment with CDI

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Thu, 24 Jan 2013 22:55:36 +0000

OK, thanks for the confirmations/extra info,

Cheers, Sergey
On 24/01/13 18:46, Santiago Pericas-Geertsen wrote:
>
> On Jan 24, 2013, at 10:33 AM, Sergey Beryozkin<sberyozkin_at_talend.com> wrote:
>
>> On 24/01/13 13:57, Santiago Pericas-Geertsen wrote:
>>>
>>> On Jan 24, 2013, at 4:30 AM, Sergey Beryozkin<sberyozkin_at_talend.com> wrote:
>>>
>>>> Actually, I'm wondering is a good idea at all,
>>>>
>>>> On 23/01/13 15:52, Sergey Beryozkin wrote:
>>>>> On 23/01/13 15:38, Santiago Pericas-Geertsen wrote:
>>>>>> Hello Experts,
>>>>>>
>>>>>> We recently had a discussion with Pete Muir related to name binding in
>>>>>> JAX-RS and CDI (interceptor binding). As a result, I propose making a
>>>>>> small change to our spec in order to align our semantics with CDI's.
>>>>>>
>>>>>> The proposed change relates to the use of multiple binding
>>>>>> annotations. There are two sub-cases: (i) multiple binding annotations
>>>>>> on a resource method or class and (ii) multiple binding annotations on
>>>>>> the filter or interceptor.
>>>>>>
>>>>>> (i)
>>>>>>
>>>>>> @A class MyFilter1 ...
>>>>>> @B class MyFilter2 ...
>>>>>>
>>>>>> // Binds both MyFilter1 and MyFilter2
>>>>>> @A @B public Foo myMethod1() ...
>>>>>>
>>>>>> (ii)
>>>>>>
>>>>>> @A @B class MyFilter ...
>>>>>>
>>>>>> // Binds MyFilter
>>>>>> @A @B public Foo myMethod2() ...
>>>>>>
>>>>>> There are no changes w.r.t. (i), our semantics agreed with CDI's.
>>>>>> Before this change, we could bind MyFilter to myMethod2() using either
>>>>>> '_at_A or @B'. In order to align with CDI, we will now require both '_at_A
>>>>>> and @B' as shown above.
>>>>>
>>>>> So effectively specific method name bindings should contain all ones of
>>>>> the given filter for it to be applicable ?
>>>>
>>>> First, I was not correct above, this update would assume that the name bindings of a specific filter would have to contain all the bindings of a specific method for this filter be bind-able to this filter.
>>>
>>> No, that's why I listed the two cases above. The relationship filters and methods is asymmetric. A method has to list all the annotations on the filter class, but not the other way around. Please check the updated section in the spec.
>>>
>> I think you saying, re (ii), "Before this change, we could bind MyFilter to myMethod2() using either '_at_A or @B'." confused me - that was difficult to interpret for me, I'm assuming you were referring that the following were working before :
>>
>> @A @B class MyFilter {
>> }
>>
>> @A public Foo myMethod2()
>>
>> but now it will only work as per example only as per example in (ii), right; If yes then I understand
>
> Yes, exactly.
>
>>
>>>>
>>>> This may make sense in CDI but CDI is at different level than JAX-RS, for example, replacing @A& @B with something more meaningful:
>>>>
>>>> @GZIP @LOG public Foo myMethod1()
>>>> @LOG public Foo myMethod1()
>>>
>>> It's hard to comment on this example if you don't show the annotations on the filter classes.
>>>
>> Well, I thought of:
>>
>> @GZIP MyFilter1;
>>
>> @LOG MyFilter2;
>>
>> thinking it would prevent myMethod1() from being processed - assuming I got it with the above conclusion - it actually works.
>
> Yes, just like before.
>
>>
>> Still wondering: what exactly is the rationale for aligning with CDI ? CDI is about managing the injection/etc, JAX-RS is about managing HTTP service invocations ?
>
> CDI also defines method interceptors and name binding. It was pointed out to us that the fact that our name binding was not compatible was confusing given that CDI and JAX-RS are often used together and are both part of EE.
>
> -- Santiago
>