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

Re: [jax-rs-spec users] Registering the same provider class with Configurable

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Mon, 27 Apr 2015 21:57:25 +0100

Hi Marek

A quick follow-up. The reason I'm looking into this issue is that we
have a bug reported and apparently a test somewhere expects something like

config.register(GzipInterceptor.class); // first registration
config.register(GzipInterceptor.class, 6500); //replaces the first reg

instead of what is documented in the end of Configurable docs:

config.register(GzipInterceptor.class); // first registration
config.register(GzipInterceptor.class, 6500); //rejected by runtime

I think the source of the confusion is the text in the example showing a
registration with a dynamic 6500:

// override the priority of registered GzipInterceptor
// and both of it's provider contracts
config.register(GzipInterceptor.class, 6500);

I believe it says that a default priority associated with
GzipInterceptor is ignored in favor of 6500, but I'm honestly not
surprised that someone can read it that it *replaces* the previous
registration of GzipInterceptor.

IMHO the above text might need to be updated a bit

Cheers, Sergey



On 27/04/15 16:38, Sergey Beryozkin wrote:
> Hi Marek,
>
> I think it does. This is how our code works right now, but I wanted to
> confirm that as far as the same provider class registration is concerned
> it is basically the original provider registration of a given class that
> is 'sticky' with the follow-up registrations of the same class being
> ignored.
>
> Thanks, Sergey
>
> On 27/04/15 16:24, Marek Potociar wrote:
>> Hi Sergey,
>>
>> Seems to me that you’re mixing parts of _two separate examples_ in the
>> API docs into a single code flow…
>>
>> There are separate examples for:
>>
>> - registering a provider (with a default priority or the one set by an
>> annotation)
>> - registering a provider with a specific priority override
>> - rejecting multiple registration of the same provider
>>
>> You should look at the examples in separate context and not as a single
>> code flow.
>>
>> HTH,
>> Marek
>>
>>> On 27 Apr 2015, at 12:10, Sergey Beryozkin <sberyozkin_at_talend.com
>>> <mailto:sberyozkin_at_talend.com>> wrote:
>>>
>>> Hi All,
>>>
>>> The documentation at [1] says/shows the examples:
>>>
>>> (1)
>>>
>>> // register GzipInterceptor as a ReaderInterceptor
>>> // as well as a WriterInterceptor
>>> config.register(GzipInterceptor.class);
>>>
>>> followed by
>>>
>>> // override the priority of registered GzipInterceptor
>>> // and both of it's provider contracts
>>> config.register(GzipInterceptor.class, 6500);
>>>
>>> Meaning that the previous GzipInterceptor registrations for its
>>> contracts with some priority is replaced, with 6500 being a new
>>> priority.
>>>
>>> (2)
>>>
>>> And then "As a general rule, for each JAX-RS component class there can
>>> be at most one registration..." with this example:
>>>
>>> config.register(GzipInterceptor.class, WriterInterceptor.class);
>>> ...
>>> config.register(GzipInterceptor.class, 6500); // Rejected by runtime.
>>>
>>>
>>> So in (1) the second registration of GzipInterceptor is accepted, but
>>> in (2) - no.
>>>
>>> This is a bit confusing. What am I missing, can you please clarify ?
>>>
>>> Thanks, Sergey
>>>
>>>
>>>
>>> [1]
>>> https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/javax/ws/rs/core/Configurable.html
>>>
>>>
>>>
>>
>


-- 
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com