-
@Target(value=TYPE) @Retention(value=RUNTIME) @Documented public @interface ConstrainedTo
Indicates the run-time context in which an annotated JAX-RS provider is applicable. If a@ConstrainedTo
annotation is not present on a JAX-RS provider type declaration, the declared provider may be used in any run-time context. If such a annotation is present, the JAX-RS runtime will enforce the specified usage restriction.The following example illustrates restricting a
MessageBodyReader
provider implementation to run only as part of aJAX-RS client run-time
:@ConstrainedTo(RuntimeType.CLIENT) public class MyReader implements MessageBodyReader { ... }
The following example illustrates restricting a
WriterInterceptor
provider implementation to run only as part of aJAX-RS server run-time
:@ConstrainedTo(RuntimeType.SERVER) public class MyWriterInterceptor implements WriterInterceptor { ... }
It is a configuration error to constraint a JAX-RS provider implementation to a run-time context in which the provider cannot be applied. In such case a JAX-RS runtime SHOULD inform a user about the issue and ignore the provider implementation in further processing.
For example, the following restriction of a
ClientRequestFilter
to run only as part of a JAX-RS server run-time would be considered invalid:// reported as invalid and ignored by JAX-RS runtime @ConstrainedTo(RuntimeType.SERVER) public class MyFilter implements ClientRequestFilter { ... }
- Since:
- 2.0
- Author:
- Marek Potociar
-
-
Required Element Summary
Required Elements Modifier and Type Required Element and Description RuntimeType
value
Define theconstraint type
to be placed on a JAX-RS provider.
-
-
-
Element Detail
-
value
public abstract RuntimeType value
Define theconstraint type
to be placed on a JAX-RS provider.
-
-
Document created the 11/06/2005, last modified the 18/08/2025
Source of the printed document:https://www.gaudry.be/en/java-api-javaee-rf-javax/ws/rs/ConstrainedTo.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author of this site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.