Package javax.ws.rs
Annotation Type ConstrainedTo
-
@Target(TYPE) @Retention(RUNTIME) @Documented public @interface ConstrainedTo
Indicates the run-time context in which an annotated provider is applicable. If a@ConstrainedToannotation is not present on a provider type declaration, the declared provider may be used in any run-time context. If such a annotation is present, the runtime will enforce the specified usage restriction.The following example illustrates restricting a
MessageBodyReaderprovider implementation to run only as part of aClient run-time:@ConstrainedTo(RuntimeType.CLIENT) public class MyReader implements MessageBodyReader { ... }The following example illustrates restricting a
WriterInterceptorprovider implementation to run only as part of aServer run-time:@ConstrainedTo(RuntimeType.SERVER) public class MyWriterInterceptor implements WriterInterceptor { ... }It is a configuration error to constraint a provider implementation to a run-time context in which the provider cannot be applied. In such case, the runtime SHOULD inform a user about the issue and ignore the provider implementation in further processing.
For example, the following restriction of a
ClientRequestFilterto run only as part of the server run-time would be considered invalid:// reported as invalid and ignored by the 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 Description RuntimeTypevalueDefine theconstraint typeto be placed on a provider.
-
-
-
Element Detail
-
value
RuntimeType value
Define theconstraint typeto be placed on a provider.
-
-