public class ContainerRequest extends org.glassfish.jersey.message.internal.InboundMessageContext implements ContainerRequestContext, Request, HttpHeaders, org.glassfish.jersey.internal.PropertiesDelegate
ApplicationHandler for each incoming client request.ACCEPT, ACCEPT_CHARSET, ACCEPT_ENCODING, ACCEPT_LANGUAGE, ALLOW, AUTHORIZATION, CACHE_CONTROL, CONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_ID, 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_EVENT_ID_HEADER, LAST_MODIFIED, LINK, LOCATION, RETRY_AFTER, SET_COOKIE, USER_AGENT, VARY, WWW_AUTHENTICATE| Constructor and Description |
|---|
ContainerRequest(URI baseUri,
URI requestUri,
String httpMethod,
SecurityContext securityContext,
org.glassfish.jersey.internal.PropertiesDelegate propertiesDelegate)
Create new Jersey container request context.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abortWith(Response response)
Abort the filter chain with a response.
|
Response.ResponseBuilder |
evaluatePreconditions()
Evaluate request preconditions for a resource that does not currently
exist.
|
Response.ResponseBuilder |
evaluatePreconditions(Date lastModified)
Evaluate request preconditions based on the passed in value.
|
Response.ResponseBuilder |
evaluatePreconditions(Date lastModified,
EntityTag eTag)
Evaluate request preconditions based on the passed in value.
|
Response.ResponseBuilder |
evaluatePreconditions(EntityTag eTag)
Evaluate request preconditions based on the passed in value.
|
Response |
getAbortResponse()
Get the request filter chain aborting response if set, or
null otherwise. |
URI |
getAbsolutePath()
Get the absolute path of the request.
|
List<Locale> |
getAcceptableLanguages()
Get a list of languages that are acceptable for the response.
|
List<MediaType> |
getAcceptableMediaTypes()
Get a list of media types that are acceptable for the response.
|
URI |
getBaseUri()
Get base request URI.
|
Map<String,Cookie> |
getCookies()
Get any cookies that accompanied the request.
|
String |
getMethod()
Get the request method.
|
String |
getPath(boolean decode)
Get the path of the current request relative to the application root (base)
URI as a string.
|
org.glassfish.jersey.internal.PropertiesDelegate |
getPropertiesDelegate()
Get the underlying properties delegate.
|
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. |
Collection<String> |
getPropertyNames()
Returns an immutable
collection containing the property
names available within the context of the current request/response exchange context. |
protected Iterable<ReaderInterceptor> |
getReaderInterceptors()
Get all reader interceptors applicable to this request.
|
Request |
getRequest()
Get the injectable request information.
|
List<String> |
getRequestHeader(String name)
Get the values of a HTTP request header.
|
MultivaluedMap<String,String> |
getRequestHeaders()
Get the values of HTTP request headers.
|
RequestScopedInitializer |
getRequestScopedInitializer()
Get a custom container extensions initializer for the current request.
|
URI |
getRequestUri()
Get request URI.
|
ContainerResponseWriter |
getResponseWriter()
Get the container response writer for the current request.
|
SecurityContext |
getSecurityContext()
Get the injectable security context information for the current request.
|
ExtendedUriInfo |
getUriInfo()
Get request URI information.
|
String |
getVaryValue()
Get the value of HTTP Vary response header to be set in the response,
or
null if no value is to be set. |
void |
inResponseProcessing()
Notify this request that the response created from this request is already being
processed.
|
<T> T |
readEntity(Class<T> rawType)
Read entity from a context entity input stream.
|
<T> T |
readEntity(Class<T> rawType,
Annotation[] annotations)
Read entity from a context entity input stream.
|
<T> T |
readEntity(Class<T> rawType,
Type type)
Read entity from a context entity input stream.
|
<T> T |
readEntity(Class<T> rawType,
Type type,
Annotation[] annotations)
Read entity from a context entity input stream.
|
void |
removeProperty(String name)
Removes a property with the given name from the current request/response
exchange context.
|
Variant |
selectVariant(List<Variant> variants)
Select the representation variant that best matches the request.
|
void |
setEntityStream(InputStream input)
Set a new entity input stream.
|
void |
setMethod(String method)
Set the request method.
|
void |
setMethodWithoutException(String method)
Like
setMethod(String) but does not throw IllegalStateException if the method is invoked in other than
pre-matching phase. |
void |
setProperty(String name,
Object object)
Binds an object to a given property name in the current request/response
exchange context.
|
void |
setRequestScopedInitializer(RequestScopedInitializer requestScopedInitializer)
Set a custom container extensions initializer for the current request.
|
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.
|
void |
setRequestUri(URI baseUri,
URI requestUri)
Set a new request URI using a new base URI to resolve the application-specific
request URI part.
|
void |
setSecurityContext(SecurityContext context)
Set a new injectable security context information for the current request.
|
void |
setWriter(ContainerResponseWriter responseWriter)
Set the container response writer for the current request.
|
bufferEntity, close, getAllowedMethods, getDate, getEntityStream, getEntityTag, getHeaders, getHeaderString, getIfMatch, getIfNoneMatch, getLanguage, getLastModified, getLength, getLink, getLinkBuilder, getLinks, getLocation, getMediaType, getQualifiedAcceptableLanguages, getQualifiedAcceptableMediaTypes, getQualifiedAcceptCharset, getQualifiedAcceptEncoding, getRequestCookies, getResponseCookies, getWorkers, hasEntity, hasLink, header, headers, headers, headers, headers, readEntity, readEntity, readEntity, readEntity, remove, setWorkersclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDate, getEntityStream, getHeaders, getHeaderString, getLanguage, getLength, getMediaType, hasEntitygetDate, getHeaderString, getLanguage, getLength, getMediaTypepublic ContainerRequest(URI baseUri, URI requestUri, String httpMethod, SecurityContext securityContext, org.glassfish.jersey.internal.PropertiesDelegate propertiesDelegate)
baseUri - base application URI.requestUri - request URI.httpMethod - request HTTP method name.securityContext - security context of the current request. Must not be null.
The SecurityContext.getUserPrincipal() must return
null if the current request has not been authenticated
by the container.propertiesDelegate - custom properties delegate
to be used by the context.public RequestScopedInitializer getRequestScopedInitializer()
null if not
available.public void setRequestScopedInitializer(RequestScopedInitializer requestScopedInitializer)
requestScopedInitializer - custom container extensions initializer.public ContainerResponseWriter getResponseWriter()
public void setWriter(ContainerResponseWriter responseWriter)
responseWriter - container response writer. Must not be null.public <T> T readEntity(Class<T> rawType)
T - entity Java object type.rawType - raw Java entity type.public <T> T readEntity(Class<T> rawType, Annotation[] annotations)
T - entity Java object type.rawType - raw Java entity type.annotations - entity annotations.public <T> T readEntity(Class<T> rawType, Type type)
T - entity Java object type.rawType - raw Java entity type.type - generic Java entity type.public <T> T readEntity(Class<T> rawType, Type type, Annotation[] annotations)
T - entity Java object type.rawType - raw Java entity type.type - generic Java entity type.annotations - entity annotations.public Object getProperty(String name)
ContainerRequestContextnull 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 ContainerRequestContext.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.
getProperty in interface ContainerRequestContextgetProperty in interface org.glassfish.jersey.internal.PropertiesDelegatename - 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.ContainerRequestContext.getPropertyNames()public Collection<String> getPropertyNames()
ContainerRequestContextcollection containing the property
names available within the context of the current request/response exchange context.
Use the ContainerRequestContext.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.
getPropertyNames in interface ContainerRequestContextgetPropertyNames in interface org.glassfish.jersey.internal.PropertiesDelegatecollection of property names.ContainerRequestContext.getProperty(java.lang.String)public void setProperty(String name, Object object)
ContainerRequestContextA 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 ContainerRequestContext.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
ContainerRequestContext.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.
setProperty in interface ContainerRequestContextsetProperty in interface org.glassfish.jersey.internal.PropertiesDelegatename - a String specifying the name of the property.object - an Object representing the property to be bound.public void removeProperty(String name)
ContainerRequestContextContainerRequestContext.getProperty(java.lang.String)
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.
removeProperty in interface ContainerRequestContextremoveProperty in interface org.glassfish.jersey.internal.PropertiesDelegatename - a String specifying the name of the property to be removed.public org.glassfish.jersey.internal.PropertiesDelegate getPropertiesDelegate()
public ExtendedUriInfo getUriInfo()
ContainerRequestContextsetRequestUri(...) methods will be reflected in the previously
returned UriInfo instance.getUriInfo in interface ContainerRequestContextprotected Iterable<ReaderInterceptor> getReaderInterceptors()
getReaderInterceptors in class org.glassfish.jersey.message.internal.InboundMessageContextpublic URI getBaseUri()
public URI getRequestUri()
public URI getAbsolutePath()
public void setRequestUri(URI requestUri) throws IllegalStateException
ContainerRequestContext
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.
setRequestUri in interface ContainerRequestContextrequestUri - new URI of the request.IllegalStateException - in case the method is not invoked from a pre-matching
request filter.ContainerRequestContext.setRequestUri(java.net.URI, java.net.URI)public void setRequestUri(URI baseUri, URI requestUri) throws IllegalStateException
ContainerRequestContext
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.
setRequestUri in interface ContainerRequestContextbaseUri - base URI that will be used to resolve the application-specific
part of the request URI.requestUri - new URI of the request.IllegalStateException - in case the method is not invoked from a pre-matching
request filter.ContainerRequestContext.setRequestUri(java.net.URI)public String getPath(boolean decode)
decode - controls whether sequences of escaped octets are decoded
(true) or not (false).public String getMethod()
ContainerRequestContextgetMethod in interface ContainerRequestContextgetMethod in interface RequestHttpMethodpublic void setMethod(String method) throws IllegalStateException
ContainerRequestContext
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.
setMethod in interface ContainerRequestContextmethod - new request method.IllegalStateException - in case the method is not invoked from a pre-matching
request filter.HttpMethodpublic void setMethodWithoutException(String method)
setMethod(String) but does not throw IllegalStateException if the method is invoked in other than
pre-matching phase.method - HTTP method.public SecurityContext getSecurityContext()
ContainerRequestContextSecurityContext.getUserPrincipal() must return null
if the current request has not been authenticated.getSecurityContext in interface ContainerRequestContextpublic void setSecurityContext(SecurityContext context)
ContainerRequestContextSecurityContext.getUserPrincipal() must return null
if the current request has not been authenticated.setSecurityContext in interface ContainerRequestContextcontext - new injectable request security context information.public void setEntityStream(InputStream input)
org.glassfish.jersey.message.internal.InboundMessageContextsetEntityStream in interface ContainerRequestContextsetEntityStream in class org.glassfish.jersey.message.internal.InboundMessageContextinput - new entity input stream.public Request getRequest()
ContainerRequestContextgetRequest in interface ContainerRequestContextpublic void abortWith(Response response)
ContainerRequestContextabortWith in interface ContainerRequestContextresponse - response to be sent back to the client.public void inResponseProcessing()
public Response getAbortResponse()
null otherwise.null otherwise.public Map<String,Cookie> getCookies()
ContainerRequestContextgetCookies in interface ContainerRequestContextgetCookies in interface HttpHeadersCookie.public List<MediaType> getAcceptableMediaTypes()
ContainerRequestContextgetAcceptableMediaTypes in interface ContainerRequestContextgetAcceptableMediaTypes in interface HttpHeaderspublic List<Locale> getAcceptableLanguages()
ContainerRequestContextgetAcceptableLanguages in interface ContainerRequestContextgetAcceptableLanguages in interface HttpHeaderspublic Variant selectVariant(List<Variant> variants) throws IllegalArgumentException
Requestnull in case there is no matching variant in the list.
More explicit variants are chosen ahead of less explicit ones. A vary header is computed from the supplied list and automatically added to the response.
selectVariant in interface Requestvariants - a list of Variant that describe all of the available representation
variants.null if there's no match.IllegalArgumentException - if variants is empty or null.Variant.VariantListBuilderpublic String getVaryValue()
null if no value is to be set.null otherwise.public Response.ResponseBuilder evaluatePreconditions(EntityTag eTag)
RequestevaluatePreconditions in interface RequesteTag - an ETag for the current state of the resourcenull if the preconditions are met or a ResponseBuilder set with
the appropriate status if the preconditions are not met. A returned
ResponseBuilder will include an ETag header set with the value of eTag,
provided none of the precondition evaluation has failed, in which case
the ETag header would not be included and the status code of the returned
ResponseBuilder would be set to Response.Status.PRECONDITION_FAILED.public Response.ResponseBuilder evaluatePreconditions(Date lastModified)
RequestevaluatePreconditions in interface RequestlastModified - a date that specifies the modification date of the resourcenull if the preconditions are met or a ResponseBuilder set with
the appropriate status if the preconditions are not met.public Response.ResponseBuilder evaluatePreconditions(Date lastModified, EntityTag eTag)
RequestevaluatePreconditions in interface RequestlastModified - a date that specifies the modification date of the resourceeTag - an ETag for the current state of the resourcenull if the preconditions are met or a ResponseBuilder set with
the appropriate status if the preconditions are not met. A returned
ResponseBuilder will include an ETag header set with the value of eTag,
provided none of the precondition evaluation has failed, in which case
the ETag header would not be included and the status code of the returned
ResponseBuilder would be set to Response.Status.PRECONDITION_FAILED.public Response.ResponseBuilder evaluatePreconditions()
RequestNote that both preconditions If-None-Match: * and
If-None-Match: something will always be considered to
have been met and it is the applications responsibility
to enforce any additional method-specific semantics. E.g. a
PUT on a resource that does not exist might succeed whereas
a GET on a resource that does not exist would likely result
in a 404 response. It would be the responsibility of the application to
generate the 404 response.
evaluatePreconditions in interface Requestnull if the preconditions are met or a ResponseBuilder set with
the appropriate status if the preconditions are not met.public List<String> getRequestHeader(String name)
getRequestHeaders().get(name).getRequestHeader in interface HttpHeadersname - the header name, case insensitive.IllegalStateException - if called outside the scope of a request.public MultivaluedMap<String,String> getRequestHeaders()
null.getRequestHeaders in interface HttpHeadersIllegalStateException - if called outside the scope of a request.Copyright © 2007-2017, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.