ster GzipInterceptor as a ReaderInterceptor // as well as a WriterInterceptor config.register(GzipInterceptor.class);
There are however situations when the default registration of a JAX-RS component to all the recognized provider contracts is not desirable. In such cases users may use other versions of the {@code register(...)} method to explicitly specify the collection of the provider contractsfor which the JAX-RS component should be registered and/or the binding priority of each registered provider contract.
For example:
@BindingPriority(USER) public class ClientLoggingFilter implements ClientRequestFilter, ClientResponseFilter { ... } @BindingPriority(ENTITY_CODER) public class GzipInterceptor implements ReaderInterceptor, WriterInterceptor { ... } ... // register ClientLoggingFilter as a ClientResponseFilter only config.register(ClientLoggingFilter.class, ClientResponseFilter.class); // override the binding priority of registered GzipInterceptor // and both of it's provider contracts config.register(GzipInterceptor.class, 6500);
As a general rule, for each JAX-RS component class there can be at most one registration — class-based or instance-based — configured at any given moment. Implementations MUST reject any attempts to configure a new registration for a provider class that has been already registered in the given configurable context earlier. Implementations SHOULD also raise a warning to inform the user about the rejected component registration.
For example:
config.register(GzipInterceptor.class, WriterInterceptor.class); config.register(GzipInterceptor.class); // Rejected by runtime. config.register(new GzipInterceptor()); // Rejected by runtime. config.register(GzipInterceptor.class, 6500); // Rejected by runtime. config.register(new ClientLoggingFilter()); config.register(ClientLoggingFilter.class); // rejected by runtime. config.register(ClientLoggingFilter.class, ClientResponseFilter.class); // Rejected by runtime.
@author Marek Potociar
@since 2.0