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

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

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Mon, 27 Apr 2015 17:24:05 +0200

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