users@jax-rs-spec.java.net

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

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Mon, 27 Apr 2015 16:38:18 +0100

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
>>
>>
>