com.sun.jersey.spi.container
Class ContainerRequest

java.lang.Object
  extended by com.sun.jersey.spi.container.ContainerRequest
All Implemented Interfaces:
HttpRequestContext, javax.ws.rs.core.HttpHeaders, javax.ws.rs.core.Request, javax.ws.rs.core.SecurityContext

public class ContainerRequest
extends java.lang.Object
implements HttpRequestContext

An in-bound HTTP request to be processed by the web application.

Containers instantiate, or inherit, and provide an instance to the WebApplication.

Author:
Paul.Sandoz@Sun.Com

Field Summary
 
Fields inherited from interface javax.ws.rs.core.HttpHeaders
ACCEPT, ACCEPT_CHARSET, ACCEPT_ENCODING, ACCEPT_LANGUAGE, AUTHORIZATION, CACHE_CONTROL, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_TYPE, COOKIE, DATE, ETAG, EXPIRES, HOST, IF_MATCH, IF_MODIFIED_SINCE, IF_NONE_MATCH, IF_UNMODIFIED_SINCE, LAST_MODIFIED, LOCATION, SET_COOKIE, USER_AGENT, VARY, WWW_AUTHENTICATE
 
Fields inherited from interface javax.ws.rs.core.SecurityContext
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
ContainerRequest(WebApplication wa, java.lang.String method, java.net.URI baseUri, java.net.URI requestUri, InBoundHeaders headers, java.io.InputStream entity)
          Create a new container request.
 
Method Summary
 javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(java.util.Date lastModified)
           
 javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(java.util.Date lastModified, javax.ws.rs.core.EntityTag eTag)
           
 javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(javax.ws.rs.core.EntityTag eTag)
           
 java.net.URI getAbsolutePath()
          Get the absolute path of the request.
 javax.ws.rs.core.UriBuilder getAbsolutePathBuilder()
          Get the absolute path of the request in the form of a UriBuilder.
 java.util.List<java.util.Locale> getAcceptableLanguages()
           
 javax.ws.rs.core.MediaType getAcceptableMediaType(java.util.List<javax.ws.rs.core.MediaType> mediaTypes)
          Select the first media type, from a list of media types, that is most acceptable according to the requested acceptable media types.
 java.util.List<javax.ws.rs.core.MediaType> getAcceptableMediaTypes()
           
 java.lang.String getAuthenticationScheme()
           
 java.net.URI getBaseUri()
          Get the base URI of the application.
 javax.ws.rs.core.UriBuilder getBaseUriBuilder()
          Get the base URI of the application in the form of a UriBuilder.
 javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getCookieNameValueMap()
          Get the cookie name value map.
 java.util.Map<java.lang.String,javax.ws.rs.core.Cookie> getCookies()
           
<T> T
getEntity(java.lang.Class<T> type)
          Get the request entity, returns null if the request does not contain an entity body.
<T> T
getEntity(java.lang.Class<T> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] as)
          Get the request entity, returns null if the request does not contain an entity body.
 java.io.InputStream getEntityInputStream()
          Get the input stream of the entity.
 java.lang.String getHeaderValue(java.lang.String name)
          Get a HTTP header value.
 java.util.Locale getLanguage()
           
 javax.ws.rs.core.MediaType getMediaType()
           
 java.lang.String getMethod()
           
 java.lang.String getPath()
          Get the path of the current request relative to the base URI as a string.
 java.lang.String getPath(boolean decode)
          Get the path of the current request relative to the base URI as a string.
 java.util.List<javax.ws.rs.core.PathSegment> getPathSegments()
          Get the path of the current request relative to the base URI as a list of PathSegment.
 java.util.List<javax.ws.rs.core.PathSegment> getPathSegments(boolean decode)
          Get the path of the current request relative to the base URI as a list of PathSegment.
 javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getQueryParameters()
          Get the URI query parameters of the current request.
 javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getQueryParameters(boolean decode)
          Get the URI query parameters of the current request.
 java.util.List<java.lang.String> getRequestHeader(java.lang.String name)
           
 javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getRequestHeaders()
           
 java.net.URI getRequestUri()
          Get the absolute request URI.
 javax.ws.rs.core.UriBuilder getRequestUriBuilder()
          Get the absolute request URI in the form of a UriBuilder.
 java.security.Principal getUserPrincipal()
           
 boolean isSecure()
           
 boolean isUserInRole(java.lang.String role)
           
 javax.ws.rs.core.Variant selectVariant(java.util.List<javax.ws.rs.core.Variant> variants)
           
 void setEntityInputStream(java.io.InputStream entity)
          Set the input stream of the entity.
 void setHeaders(InBoundHeaders headers)
          Set the request headers.
 void setMethod(java.lang.String method)
          Set the HTTP method.
 void setUris(java.net.URI baseUri, java.net.URI requestUri)
          Set the base and request URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContainerRequest

public ContainerRequest(WebApplication wa,
                        java.lang.String method,
                        java.net.URI baseUri,
                        java.net.URI requestUri,
                        InBoundHeaders headers,
                        java.io.InputStream entity)
Create a new container request.

The base URI and the request URI must contain the same scheme, user info, host and port components. The base URI must not contain the query and fragment components. The encoded path component of the request URI must start with the encoded path component of the base URI. The encoded path component of the base URI must end in a '/' character.

Parameters:
wa - the web application
method - the HTTP method
baseUri - the base URI of the request
requestUri - the request URI
headers - the request headers
entity - the InputStream of the request entity
Method Detail

setMethod

public void setMethod(java.lang.String method)
Set the HTTP method.

Parameters:
method - the method.

setUris

public void setUris(java.net.URI baseUri,
                    java.net.URI requestUri)
Set the base and request URI.

Parameters:
baseUri - the base URI.
requestUri - the (complete) request URI.

getEntityInputStream

public java.io.InputStream getEntityInputStream()
Get the input stream of the entity.

Returns:
the input stream of the entity.

setEntityInputStream

public void setEntityInputStream(java.io.InputStream entity)
Set the input stream of the entity.

Parameters:
entity - the input stream of the entity.

setHeaders

public void setHeaders(InBoundHeaders headers)
Set the request headers.

Parameters:
headers - the request headers.

getBaseUri

public java.net.URI getBaseUri()
Description copied from interface: HttpRequestContext
Get the base URI of the application. URIs of root resource classes are all relative to this base URI.

Specified by:
getBaseUri in interface HttpRequestContext
Returns:
the base URI of the application

getBaseUriBuilder

public javax.ws.rs.core.UriBuilder getBaseUriBuilder()
Description copied from interface: HttpRequestContext
Get the base URI of the application in the form of a UriBuilder.

Specified by:
getBaseUriBuilder in interface HttpRequestContext
Returns:
a UriBuilder initialized with the base URI of the application.

getRequestUri

public java.net.URI getRequestUri()
Description copied from interface: HttpRequestContext
Get the absolute request URI. This includes query parameters and any supplied fragment.

Specified by:
getRequestUri in interface HttpRequestContext
Returns:
the absolute request URI

getRequestUriBuilder

public javax.ws.rs.core.UriBuilder getRequestUriBuilder()
Description copied from interface: HttpRequestContext
Get the absolute request URI in the form of a UriBuilder.

Specified by:
getRequestUriBuilder in interface HttpRequestContext
Returns:
a UriBuilder initialized with the absolute request URI

getAbsolutePath

public java.net.URI getAbsolutePath()
Description copied from interface: HttpRequestContext
Get the absolute path of the request. This includes everything preceding the path (host, port etc) but excludes query parameters and fragment. This is a shortcut for uriInfo.getBase().resolve(uriInfo.getPath()).

Specified by:
getAbsolutePath in interface HttpRequestContext
Returns:
the absolute path of the request

getAbsolutePathBuilder

public javax.ws.rs.core.UriBuilder getAbsolutePathBuilder()
Description copied from interface: HttpRequestContext
Get the absolute path of the request in the form of a UriBuilder. This includes everything preceding the path (host, port etc) but excludes query parameters and fragment.

Specified by:
getAbsolutePathBuilder in interface HttpRequestContext
Returns:
a UriBuilder initialized with the absolute path of the request

getPath

public java.lang.String getPath()
Description copied from interface: HttpRequestContext
Get the path of the current request relative to the base URI as a string. All sequences of escaped octets are decoded, equivalent to getPath(true).

Specified by:
getPath in interface HttpRequestContext
Returns:
the relative URI path

getPath

public java.lang.String getPath(boolean decode)
Description copied from interface: HttpRequestContext
Get the path of the current request relative to the base URI as a string.

Specified by:
getPath in interface HttpRequestContext
Parameters:
decode - controls whether sequences of escaped octets are decoded (true) or not (false).
Returns:
the relative URI path

getPathSegments

public java.util.List<javax.ws.rs.core.PathSegment> getPathSegments()
Description copied from interface: HttpRequestContext
Get the path of the current request relative to the base URI as a list of PathSegment. This method is useful when the path needs to be parsed, particularly when matrix parameters may be present in the path. All sequences of escaped octets in path segments and matrix parmeter names and values are decoded, equivalent to getPathSegments(true).

Specified by:
getPathSegments in interface HttpRequestContext
Returns:
an unmodifiable list of PathSegment. The matrix parameter map of each path segment is also unmodifiable.
See Also:
PathSegment, Matrix URIs

getPathSegments

public java.util.List<javax.ws.rs.core.PathSegment> getPathSegments(boolean decode)
Description copied from interface: HttpRequestContext
Get the path of the current request relative to the base URI as a list of PathSegment. This method is useful when the path needs to be parsed, particularly when matrix parameters may be present in the path.

Specified by:
getPathSegments in interface HttpRequestContext
Parameters:
decode - controls whether sequences of escaped octets in path segments and matrix parameter names and values are decoded (true) or not (false).
Returns:
an unmodifiable list of PathSegment. The matrix parameter map of each path segment is also unmodifiable.
See Also:
PathSegment, Matrix URIs

getQueryParameters

public javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getQueryParameters()
Description copied from interface: HttpRequestContext
Get the URI query parameters of the current request. All sequences of escaped octets in parameter names and values are decoded, equivalent to getQueryParameters(true).

Specified by:
getQueryParameters in interface HttpRequestContext
Returns:
an unmodifiable map of query parameter names and values

getQueryParameters

public javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getQueryParameters(boolean decode)
Description copied from interface: HttpRequestContext
Get the URI query parameters of the current request.

Specified by:
getQueryParameters in interface HttpRequestContext
Parameters:
decode - controls whether sequences of escaped octets in parameter names and values are decoded (true) or not (false).
Returns:
an unmodifiable map of query parameter names and values

getHeaderValue

public java.lang.String getHeaderValue(java.lang.String name)
Description copied from interface: HttpRequestContext
Get a HTTP header value.

Specified by:
getHeaderValue in interface HttpRequestContext
Parameters:
name - the HTTP header
Returns:
the HTTP header value. If the HTTP header is not present then null is returned. If the HTTP header is present but has no value then the empty string is returned. If the HTTP header is present more than once then the values of joined together and separated by a ',' character.

getEntity

public <T> T getEntity(java.lang.Class<T> type,
                       java.lang.reflect.Type genericType,
                       java.lang.annotation.Annotation[] as)
Description copied from interface: HttpRequestContext
Get the request entity, returns null if the request does not contain an entity body.

Specified by:
getEntity in interface HttpRequestContext
Parameters:
type - the type of entity
genericType - type the generic type of entity, it is the responsibility of the callee to ensure that the type and generic type are consistent otherwise the behvaiour of this method is undefned.
as - the annoations associated with the type
Returns:
the request entity or null

getEntity

public <T> T getEntity(java.lang.Class<T> type)
Description copied from interface: HttpRequestContext
Get the request entity, returns null if the request does not contain an entity body.

Specified by:
getEntity in interface HttpRequestContext
Parameters:
type - the type of entity
Returns:
the request entity or null

getAcceptableMediaType

public javax.ws.rs.core.MediaType getAcceptableMediaType(java.util.List<javax.ws.rs.core.MediaType> mediaTypes)
Description copied from interface: HttpRequestContext
Select the first media type, from a list of media types, that is most acceptable according to the requested acceptable media types.

Specified by:
getAcceptableMediaType in interface HttpRequestContext
Parameters:
mediaTypes - the list of media types
Returns:
the most acceptable media type, or null if no media type was found to be acceptable.

getCookieNameValueMap

public javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getCookieNameValueMap()
Description copied from interface: HttpRequestContext
Get the cookie name value map.

Specified by:
getCookieNameValueMap in interface HttpRequestContext
Returns:
the cookie bame value map.

getRequestHeaders

public javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getRequestHeaders()
Specified by:
getRequestHeaders in interface javax.ws.rs.core.HttpHeaders

getRequestHeader

public java.util.List<java.lang.String> getRequestHeader(java.lang.String name)
Specified by:
getRequestHeader in interface javax.ws.rs.core.HttpHeaders

getAcceptableMediaTypes

public java.util.List<javax.ws.rs.core.MediaType> getAcceptableMediaTypes()
Specified by:
getAcceptableMediaTypes in interface javax.ws.rs.core.HttpHeaders

getAcceptableLanguages

public java.util.List<java.util.Locale> getAcceptableLanguages()
Specified by:
getAcceptableLanguages in interface javax.ws.rs.core.HttpHeaders

getMediaType

public javax.ws.rs.core.MediaType getMediaType()
Specified by:
getMediaType in interface javax.ws.rs.core.HttpHeaders

getLanguage

public java.util.Locale getLanguage()
Specified by:
getLanguage in interface javax.ws.rs.core.HttpHeaders

getCookies

public java.util.Map<java.lang.String,javax.ws.rs.core.Cookie> getCookies()
Specified by:
getCookies in interface javax.ws.rs.core.HttpHeaders

getMethod

public java.lang.String getMethod()
Specified by:
getMethod in interface javax.ws.rs.core.Request

selectVariant

public javax.ws.rs.core.Variant selectVariant(java.util.List<javax.ws.rs.core.Variant> variants)
Specified by:
selectVariant in interface javax.ws.rs.core.Request

evaluatePreconditions

public javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(javax.ws.rs.core.EntityTag eTag)
Specified by:
evaluatePreconditions in interface javax.ws.rs.core.Request

evaluatePreconditions

public javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(java.util.Date lastModified)
Specified by:
evaluatePreconditions in interface javax.ws.rs.core.Request

evaluatePreconditions

public javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(java.util.Date lastModified,
                                                                       javax.ws.rs.core.EntityTag eTag)
Specified by:
evaluatePreconditions in interface javax.ws.rs.core.Request

getUserPrincipal

public java.security.Principal getUserPrincipal()
Specified by:
getUserPrincipal in interface javax.ws.rs.core.SecurityContext

isUserInRole

public boolean isUserInRole(java.lang.String role)
Specified by:
isUserInRole in interface javax.ws.rs.core.SecurityContext

isSecure

public boolean isSecure()
Specified by:
isSecure in interface javax.ws.rs.core.SecurityContext

getAuthenticationScheme

public java.lang.String getAuthenticationScheme()
Specified by:
getAuthenticationScheme in interface javax.ws.rs.core.SecurityContext


Copyright © 2008 Sun Microsystems, Inc. All Rights Reserved.