public interface InterceptorContext
MessageBodyReader.readFrom(java.lang.Class<T>, java.lang.reflect.Type, java.lang.annotation.Annotation[], jakarta.ws.rs.core.MediaType, jakarta.ws.rs.core.MultivaluedMap<java.lang.String, java.lang.String>, java.io.InputStream)
and MessageBodyWriter.writeTo(T, java.lang.Class<?>, java.lang.reflect.Type, java.lang.annotation.Annotation[], jakarta.ws.rs.core.MediaType, jakarta.ws.rs.core.MultivaluedMap<java.lang.String, java.lang.Object>, java.io.OutputStream)
. The getters
and setters in this context class correspond to the parameters in the aforementioned methods.ReaderInterceptor
,
WriterInterceptor
,
ReaderInterceptorContext
,
WriterInterceptorContext
Modifier and Type | Method and Description |
---|---|
java.lang.annotation.Annotation[] |
getAnnotations()
Get an array of the annotations formally declared on the artifact that initiated the intercepted entity provider
invocation.
|
java.lang.reflect.Type |
getGenericType()
Get the type of the object to be produced or written.
|
MediaType |
getMediaType()
Get media type of HTTP entity.
|
java.lang.Object |
getProperty(java.lang.String name)
Returns the property with the given name registered in the current request/response exchange context, or
null
if there is no property by that name. |
java.util.Collection<java.lang.String> |
getPropertyNames()
Returns an immutable
collection containing the property names available within the
context of the current request/response exchange context. |
java.lang.Class<?> |
getType()
Get Java type supported by corresponding message body provider.
|
void |
removeProperty(java.lang.String name)
Removes a property with the given name from the current request/response exchange context.
|
void |
setAnnotations(java.lang.annotation.Annotation[] annotations)
Update annotations on the formal declaration of the artifact that initiated the intercepted entity provider
invocation.
|
void |
setGenericType(java.lang.reflect.Type genericType)
Update type of the object to be produced or written.
|
void |
setMediaType(MediaType mediaType)
Update media type of HTTP entity.
|
void |
setProperty(java.lang.String name,
java.lang.Object object)
Binds an object to a given property name in the current request/response exchange context.
|
void |
setType(java.lang.Class<?> type)
Update Java type before calling message body provider.
|
java.lang.Object getProperty(java.lang.String name)
null
if there is no property by that name.
A property allows a JAX-RS filters and interceptors to exchange additional custom information not already provided by this interface.
A list of supported properties can be retrieved using getPropertyNames()
. Custom property names should
follow the same convention as package names.
In a Servlet container, on the server side, the properties are backed by the ServletRequest
and contain all
the attributes available in the ServletRequest
.
name
- a String
specifying the name of the property.Object
containing the value of the property, or null
if no property exists matching the
given name.getPropertyNames()
java.util.Collection<java.lang.String> getPropertyNames()
collection
containing the property names available within the
context of the current request/response exchange context.
Use the getProperty(java.lang.String)
method with a property name to get the value of a property.
In a Servlet container, the properties are synchronized with the ServletRequest
and expose all the attributes
available in the ServletRequest
. Any modifications of the properties are also reflected in the set of
properties of the associated ServletRequest
.
collection
of property names.getProperty(java.lang.String)
void setProperty(java.lang.String name, java.lang.Object object)
A property allows a JAX-RS filters and interceptors to exchange additional custom information not already provided by this interface.
A list of supported properties can be retrieved using getPropertyNames()
. Custom property names should
follow the same convention as package names.
If a null
value is passed, the effect is the same as calling the removeProperty(String)
method.
In a Servlet container, on the server side, the properties are backed by the ServletRequest
and contain all
the attributes available in the ServletRequest
.
name
- a String
specifying the name of the property.object
- an Object
representing the property to be bound.void removeProperty(java.lang.String name)
getProperty(java.lang.String)
to retrieve the property value will return null
.
In a Servlet container, on the server side, the properties are backed by the ServletRequest
and contain all
the attributes available in the ServletRequest
.
name
- a String
specifying the name of the property to be removed.java.lang.annotation.Annotation[] getAnnotations()
Method.getParameterAnnotations()
; if the
server-side response entity instance is to be converted into an output stream, this will be the annotations on the
matched resource method returned by Method.getAnnotations()
.
This method may return an empty array in case the interceptor is not invoked in a context of any particular resource
method (e.g. as part of the client API), but will never return null
.void setAnnotations(java.lang.annotation.Annotation[] annotations)
annotations
- updated annotations declarataion of the artifact that initiated the intercepted entity provider
invocation. Must not be null
.java.lang.NullPointerException
- in case the input parameter is null
.java.lang.Class<?> getType()
void setType(java.lang.Class<?> type)
type
- java type for providerjava.lang.reflect.Type getGenericType()
void setGenericType(java.lang.reflect.Type genericType)
genericType
- new type for objectMediaType getMediaType()
void setMediaType(MediaType mediaType)
mediaType
- new type for HTTP entity