public class UriConnegFilter extends java.lang.Object implements ContainerRequestFilter
Accept
header
or a language that is the value of the Accept-Language
header.
This filter may be used when the accetable media type and acceptable language need to be declared in the URI.
This class may be extended to declare the mappings and the extending class,
foo.MyUriConnegFilter
say, can be registered as a container request
filter. When an application is deployed as a Servlet or Filter such a filter
can be registered using the following initialization parameters:
<init-param> <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name> <param-value>foo.MyUriConnegFilter</param-value> </init-param>
If a suffix of "atom" is regstered with a media type of "application/atom+xml" then a GET request of:
GET /resource.atom
is transformed to:
GET /resource Accept: application/atom+xmlAny existing "Accept" header value will be replaced.
If a suffix of "english: is regstered with a language of "en" then a GET request of:
GET /resource.english
is transformed to:
GET /resource Accept-Language: enAny existing "Accept-Language"header value will be replaced.
The media type mappings are processed before the language type mappings.
com.sun.jersey.api.container.filter
Constructor and Description |
---|
UriConnegFilter(java.util.Map<java.lang.String,MediaType> mediaExtentions)
Create a filter with suffix to media type mappings.
|
UriConnegFilter(java.util.Map<java.lang.String,MediaType> mediaExtentions,
java.util.Map<java.lang.String,java.lang.String> languageExtentions)
Create a filter with suffix to media type mappings and suffix to
langauge mappings.
|
Modifier and Type | Method and Description |
---|---|
ContainerRequest |
filter(ContainerRequest request)
Filter the request.
|
public UriConnegFilter(java.util.Map<java.lang.String,MediaType> mediaExtentions)
mediaExtentions
- the suffix to media type mappings.public UriConnegFilter(java.util.Map<java.lang.String,MediaType> mediaExtentions, java.util.Map<java.lang.String,java.lang.String> languageExtentions)
mediaExtentions
- the suffix to media type mappings.languageExtentions
- the syffix to language mappings.public ContainerRequest filter(ContainerRequest request)
ContainerRequestFilter
An implementation may modify the state of the request or create a new instance.
filter
in interface ContainerRequestFilter
request
- the request.Copyright © 2016 Oracle Corporation. All Rights Reserved.