Top Description Methods
javax.ws.rs.ext

public Interface InterceptorContext

Known Direct Subinterfaces
javax.ws.rs.ext.ReaderInterceptorContext, javax.ws.rs.ext.WriterInterceptorContext
Imports
java.lang.annotation.Annotation, java.lang.reflect.Type, java.util.Collection, javax.ws.rs.core.MediaType

Context shared by message body interceptors that can be used to wrap calls to javax.ws.rs.ext.MessageBodyReader#readFrom and javax.ws.rs.ext.MessageBodyWriter#writeTo. The getters and setters in this context class correspond to the parameters in the aforementioned methods.
Authors
Santiago Pericas-Geertsen, Bill Burke
Since
2.0
See Also
ReaderInterceptor, WriterInterceptor, ReaderInterceptorContext, WriterInterceptorContext

Method Summary

Modifier and TypeMethod and Description
public Annotation[]

Returns:

annotations declared on the artifact that initiated the intercepted entity provider invocation.
getAnnotations
()

Get an array of the annotations formally declared on the artifact that initiated the intercepted entity provider invocation.

public Type

Returns:

type of object produced or written
getGenericType
()

Get the type of the object to be produced or written.

public MediaType

Returns:

media type of HTTP entity
getMediaType
()

Get media type of HTTP entity.

public Object

Returns:

an Object containing the value of the property, or null if no property exists matching the given name.
getProperty
(String
a String specifying the name of the property.
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.

public Collection<String>

Returns:

an immutable collection of property names.
getPropertyNames
()

Returns an immutable collection containing the property names available within the context of the current request/response exchange context.

public Class<?>

Returns:

java type supported by provider
getType
()

Get Java type supported by corresponding message body provider.

public void
removeProperty(String
a String specifying the name of the property to be removed.
name
)

Removes a property with the given name from the current request/response exchange context.

public void
setAnnotations(Annotation[]
updated annotations declarataion of the artifact that initiated the intercepted entity provider invocation. Must not be null.
annotations
)

Update annotations on the formal declaration of the artifact that initiated the intercepted entity provider invocation.

public void
setGenericType(Type
new type for object
genericType
)

Update type of the object to be produced or written.

public void
setMediaType(MediaType
new type for HTTP entity
mediaType
)

Update media type of HTTP entity.

public void
setProperty(String
a String specifying the name of the property.
name
,
Object
an Object representing the property to be bound.
object
)

Binds an object to a given property name in the current request/response exchange context.

public void
setType(Class<?>
java type for provider
type
)

Update Java type before calling message body provider.

Method Detail

getAnnotationsback to summary
public Annotation[] getAnnotations()

Get an array of the annotations formally declared on the artifact that initiated the intercepted entity provider invocation. E.g. if the message body is to be converted into a method parameter, this will be the annotations on that parameter returned by 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.

Returns:Annotation[]

annotations declared on the artifact that initiated the intercepted entity provider invocation.

getGenericTypeback to summary
public Type getGenericType()

Get the type of the object to be produced or written.

Returns:Type

type of object produced or written

getMediaTypeback to summary
public MediaType getMediaType()

Get media type of HTTP entity.

Returns:MediaType

media type of HTTP entity

getPropertyback to summary
public Object getProperty(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.

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.

Parameters
name:String

a String specifying the name of the property.

Returns:Object

an Object containing the value of the property, or null if no property exists matching the given name.

See Also
getPropertyNames()
getPropertyNamesback to summary
public Collection<String> getPropertyNames()

Returns an immutable collection containing the property names available within the context of the current request/response exchange context.

Use the getProperty 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.

Returns:Collection<String>

an immutable collection of property names.

See Also
getProperty
getTypeback to summary
public Class<?> getType()

Get Java type supported by corresponding message body provider.

Returns:Class<?>

java type supported by provider

removePropertyback to summary
public void removeProperty(String name)

Removes a property with the given name from the current request/response exchange context. After removal, subsequent calls to getProperty 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.

Parameters
name:String

a String specifying the name of the property to be removed.

setAnnotationsback to summary
public void setAnnotations(Annotation[] annotations)

Update annotations on the formal declaration of the artifact that initiated the intercepted entity provider invocation. Calling this method has no effect in the client API.

Parameters
annotations:Annotation[]

updated annotations declarataion of the artifact that initiated the intercepted entity provider invocation. Must not be null.

Exceptions
NullPointerException:
in case the input parameter is null.
setGenericTypeback to summary
public void setGenericType(Type genericType)

Update type of the object to be produced or written.

Parameters
genericType:Type

new type for object

setMediaTypeback to summary
public void setMediaType(MediaType mediaType)

Update media type of HTTP entity.

Parameters
mediaType:MediaType

new type for HTTP entity

setPropertyback to summary
public void setProperty(String name, Object object)

Binds an object to a given property name in the current request/response exchange context. If the name specified is already used for a property, this method will replace the value of the property with the new value.

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.

Parameters
name:String

a String specifying the name of the property.

object:Object

an Object representing the property to be bound.

setTypeback to summary
public void setType(Class<?> type)

Update Java type before calling message body provider.

Parameters
type:Class<?>

java type for provider