Top Description Methods
javax.ws.rs

public @Interface ConstrainedTo

extends Annotation
Annotations
@Target:TYPE
@Retention:RUNTIME
@Documented
Imports
java.lang.annotation.Documented, .ElementType, .Retention, .RetentionPolicy, .Target

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 javax.ws.rs.ext.MessageBodyReader provider implementation to run only as part of a JAX-RS client run-time:

 @ConstrainedTo(RuntimeType.CLIENT)
 public class MyReader implements MessageBodyReader {
     ...
 }

The following example illustrates restricting a javax.ws.rs.ext.WriterInterceptor provider implementation to run only as part of a JAX-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 javax.ws.rs.client.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 {
     ...
 }
Author
Marek Potociar
Since
2.0

Method Summary

Modifier and TypeMethod and Description
public RuntimeType
value()

Define the constraint type to be placed on a JAX-RS provider.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public RuntimeType value()

Define the constraint type to be placed on a JAX-RS provider.