Top Description Methods
javax.ws.rs.container

public Interface ContainerRequestContext

Imports
java.io.InputStream, java.net.URI, java.util.Collection, .Date, .List, .Locale, .Map, javax.ws.rs.core.Cookie, .MediaType, .MultivaluedMap, .Request, .Response, .SecurityContext, .UriInfo

Container request filter context. A mutable class that provides request-specific information for the filter, such as request URI, message headers, message entity or request-scoped properties. The exposed setters allow modification of the exposed request-specific information.
Author
Marek Potociar
Since
2.0

Method Summary

Modifier and TypeMethod and Description
public void
abortWith(Response
response to be sent back to the client.
response
)

Abort the filter chain with a response.

public List<Locale>

Returns:

a read-only list of acceptable languages sorted according to their q-value, with highest preference first.
getAcceptableLanguages
()

Get a list of languages that are acceptable for the response.

public List<MediaType>

Returns:

a read-only list of requested response media types sorted according to their q-value, with highest preference first.
getAcceptableMediaTypes
()

Get a list of media types that are acceptable for the response.

public Map<String, Cookie>

Returns:

a read-only map of cookie name (String) to Cookie.
getCookies
()

Get any cookies that accompanied the request.

public Date

Returns:

the message date, otherwise null if not present.
getDate
()

Get message date.

public InputStream

Returns:

entity input stream.
getEntityStream
()

Get the entity input stream.

public MultivaluedMap<String, String>

Returns:

mutable multivalued map of request headers.
getHeaders
()

Get the mutable request headers multivalued map.

public String

Returns:

the message header value. If the message header is not present then null is returned. If the message header is present but has no value then the empty string is returned. If the message header is present more than once then the values of joined together and separated by a ',' character.
getHeaderString
(String
the message header.
name
)

Get a message header as a single string value.

public Locale

Returns:

the language of the entity or null if not specified
getLanguage
()

Get the language of the entity.

public int

Returns:

Content-Length as integer if present and valid number. In other cases returns -1.
getLength
()

Get Content-Length value.

public MediaType

Returns:

the media type or null if not specified (e.g. there's no request entity).
getMediaType
()

Get the media type of the entity.

public String

Returns:

the request method.
getMethod
()

Get the request method.

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 Request

Returns:

injectable request information.
getRequest
()

Get the injectable request information.

public SecurityContext

Returns:

injectable request security context information.
getSecurityContext
()

Get the injectable security context information for the current request.

public UriInfo

Returns:

request URI information.
getUriInfo
()

Get request URI information.

public boolean

Returns:

true if there is an entity present in the message, false otherwise.
hasEntity
()

Check if there is a non-empty entity input stream available in the request message.

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
setEntityStream(InputStream
new entity input stream.
input
)

Set a new entity input stream.

public void
setMethod(String
new request method.
method
)

Set the request method.

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
setRequestUri(URI
new URI of the request.
requestUri
)

Set a new request URI using the current base URI of the application to resolve the application-specific request URI part.

public void
setRequestUri(URI
base URI that will be used to resolve the application-specific part of the request URI.
baseUri
,
URI
new URI of the request.
requestUri
)

Set a new request URI using a new base URI to resolve the application-specific request URI part.

public void
setSecurityContext(SecurityContext
new injectable request security context information.
context
)

Set a new injectable security context information for the current request.

Method Detail

abortWithback to summary
public void abortWith(Response response)

Abort the filter chain with a response. This method breaks the filter chain processing and returns the provided response back to the client. The provided response goes through the chain of applicable response filters.

Parameters
response:Response

response to be sent back to the client.

Exceptions
IllegalStateException:
in case the method is invoked from a response filter.
getAcceptableLanguagesback to summary
public List<Locale> getAcceptableLanguages()

Get a list of languages that are acceptable for the response.

Returns:List<Locale>

a read-only list of acceptable languages sorted according to their q-value, with highest preference first.

getAcceptableMediaTypesback to summary
public List<MediaType> getAcceptableMediaTypes()

Get a list of media types that are acceptable for the response.

Returns:List<MediaType>

a read-only list of requested response media types sorted according to their q-value, with highest preference first.

getCookiesback to summary
public Map<String, Cookie> getCookies()

Get any cookies that accompanied the request.

Returns:Map<String, Cookie>

a read-only map of cookie name (String) to Cookie.

getDateback to summary
public Date getDate()

Get message date.

Returns:Date

the message date, otherwise null if not present.

getEntityStreamback to summary
public InputStream getEntityStream()

Get the entity input stream. The JAX-RS runtime is responsible for closing the input stream.

Returns:InputStream

entity input stream.

getHeadersback to summary
public MultivaluedMap<String, String> getHeaders()

Get the mutable request headers multivalued map.

Returns:MultivaluedMap<String, String>

mutable multivalued map of request headers.

See Also
getHeaderString(String)
getHeaderStringback to summary
public String getHeaderString(String name)

Get a message header as a single string value.

Parameters
name:String

the message header.

Returns:String

the message header value. If the message header is not present then null is returned. If the message header is present but has no value then the empty string is returned. If the message header is present more than once then the values of joined together and separated by a ',' character.

See Also
getHeaders()
getLanguageback to summary
public Locale getLanguage()

Get the language of the entity.

Returns:Locale

the language of the entity or null if not specified

getLengthback to summary
public int getLength()

Get Content-Length value.

Returns:int

Content-Length as integer if present and valid number. In other cases returns -1.

getMediaTypeback to summary
public MediaType getMediaType()

Get the media type of the entity.

Returns:MediaType

the media type or null if not specified (e.g. there's no request entity).

getMethodback to summary
public String getMethod()

Get the request method.

Returns:String

the request method.

See Also
javax.ws.rs.HttpMethod
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, 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.

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
getRequestback to summary
public Request getRequest()

Get the injectable request information.

Returns:Request

injectable request information.

getSecurityContextback to summary
public SecurityContext getSecurityContext()

Get the injectable security context information for the current request. The SecurityContext#getUserPrincipal() must return null if the current request has not been authenticated.

Returns:SecurityContext

injectable request security context information.

getUriInfoback to summary
public UriInfo getUriInfo()

Get request URI information. The returned object contains "live" view of the request URI information in a sense that any changes made to the request URI using one of the setRequestUri(...) methods will be reflected in the previously returned UriInfo instance.

Returns:UriInfo

request URI information.

hasEntityback to summary
public boolean hasEntity()

Check if there is a non-empty entity input stream available in the request message. The method returns true if the entity is present, returns false otherwise.

Returns:boolean

true if there is an entity present in the message, false otherwise.

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, 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.

Parameters
name:String

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

setEntityStreamback to summary
public void setEntityStream(InputStream input)

Set a new entity input stream. The JAX-RS runtime is responsible for closing the input stream.

Parameters
input:InputStream

new entity input stream.

Exceptions
IllegalStateException:
in case the method is invoked from a response filter.
setMethodback to summary
public void setMethod(String method)

Set the request method.

Note that the method is usable only in pre-matching filters, prior to the resource matching occurs. Trying to invoke the method in a filter bound to a resource method results in an IllegalStateException being thrown.

Parameters
method:String

new request method.

Exceptions
IllegalStateException:
in case the method is not invoked from a pre-matching request filter.
See Also
javax.ws.rs.HttpMethod
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, 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.

Parameters
name:String

a String specifying the name of the property.

object:Object

an Object representing the property to be bound.

setRequestUriback to summary
public void setRequestUri(URI requestUri)

Set a new request URI using the current base URI of the application to resolve the application-specific request URI part.

Note that the method is usable only in pre-matching filters, prior to the resource matching occurs. Trying to invoke the method in a filter bound to a resource method results in an IllegalStateException being thrown.

Parameters
requestUri:URI

new URI of the request.

Exceptions
IllegalStateException:
in case the method is not invoked from a pre-matching request filter.
See Also
setRequestUri(java.net.URI, java.net.URI)
setRequestUriback to summary
public void setRequestUri(URI baseUri, URI requestUri)

Set a new request URI using a new base URI to resolve the application-specific request URI part.

Note that the method is usable only in pre-matching filters, prior to the resource matching occurs. Trying to invoke the method in a filter bound to a resource method results in an IllegalStateException being thrown.

Parameters
baseUri:URI

base URI that will be used to resolve the application-specific part of the request URI.

requestUri:URI

new URI of the request.

Exceptions
IllegalStateException:
in case the method is not invoked from a pre-matching request filter.
See Also
setRequestUri(java.net.URI)
setSecurityContextback to summary
public void setSecurityContext(SecurityContext context)

Set a new injectable security context information for the current request. The SecurityContext#getUserPrincipal() must return null if the current request has not been authenticated.

Parameters
context:SecurityContext

new injectable request security context information.

Exceptions
IllegalStateException:
in case the method is invoked from a response filter.