public class ContainerRequest extends InboundMessageContext implements jakarta.ws.rs.container.ContainerRequestContext, jakarta.ws.rs.core.Request, jakarta.ws.rs.core.HttpHeaders, PropertiesDelegate, PropertiesResolver
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,
jakarta.ws.rs.core.SecurityContext securityContext,
PropertiesDelegate propertiesDelegate)
Deprecated.
|
ContainerRequest(URI baseUri,
URI requestUri,
String httpMethod,
jakarta.ws.rs.core.SecurityContext securityContext,
PropertiesDelegate propertiesDelegate,
jakarta.ws.rs.core.Configuration configuration)
Create new Jersey container request context.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abortWith(jakarta.ws.rs.core.Response response) |
jakarta.ws.rs.core.Response.ResponseBuilder |
evaluatePreconditions() |
jakarta.ws.rs.core.Response.ResponseBuilder |
evaluatePreconditions(Date lastModified) |
jakarta.ws.rs.core.Response.ResponseBuilder |
evaluatePreconditions(Date lastModified,
jakarta.ws.rs.core.EntityTag eTag) |
jakarta.ws.rs.core.Response.ResponseBuilder |
evaluatePreconditions(jakarta.ws.rs.core.EntityTag eTag) |
jakarta.ws.rs.core.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() |
List<jakarta.ws.rs.core.MediaType> |
getAcceptableMediaTypes() |
URI |
getBaseUri()
Get base request URI.
|
Map<String,jakarta.ws.rs.core.Cookie> |
getCookies() |
String |
getMethod() |
String |
getPath(boolean decode)
Get the path of the current request relative to the application root (base)
URI as a string.
|
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<jakarta.ws.rs.ext.ReaderInterceptor> |
getReaderInterceptors()
Get all reader interceptors applicable to this request.
|
jakarta.ws.rs.core.Request |
getRequest() |
List<String> |
getRequestHeader(String name)
Get the values of a HTTP request header.
|
jakarta.ws.rs.core.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.
|
jakarta.ws.rs.core.SecurityContext |
getSecurityContext() |
ExtendedUriInfo |
getUriInfo() |
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.
|
<T> T |
resolveProperty(String name,
Class<T> type)
Resolve a property value for the specified property
name. |
<T> T |
resolveProperty(String name,
T defaultValue)
Resolve a property value for the specified property
name. |
jakarta.ws.rs.core.Variant |
selectVariant(List<jakarta.ws.rs.core.Variant> variants) |
void |
setEntityStream(InputStream input)
Set a new entity input stream.
|
void |
setMethod(String 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) |
void |
setRequestUri(URI baseUri,
URI requestUri) |
void |
setSecurityContext(jakarta.ws.rs.core.SecurityContext context) |
void |
setWriter(ContainerResponseWriter responseWriter)
Set the container response writer for the current request.
|
bufferEntity, close, getAllowedMethods, getConfiguration, 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, getMediaTypecreatepublic ContainerRequest(URI baseUri, URI requestUri, String httpMethod, jakarta.ws.rs.core.SecurityContext securityContext, PropertiesDelegate propertiesDelegate, jakarta.ws.rs.core.Configuration configuration)
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.configuration - the server Configuration. If null, the default behaviour is expected.@Deprecated public ContainerRequest(URI baseUri, URI requestUri, String httpMethod, jakarta.ws.rs.core.SecurityContext securityContext, 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.ContainerRequest(URI, URI, String, SecurityContext, PropertiesDelegate, Configuration)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 <T> T resolveProperty(String name, Class<T> type)
PropertiesResolvername.
The method returns the value of the property registered in the request-specific
property bag, if available. If no property for the given property name is found
in the request-specific property bag, the method looks at the properties stored
in the global runtime configuration this request
belongs to. If there is a value defined in the runtime configuration,
it is returned, otherwise the method returns null if no such property is
registered neither in the runtime nor in the request-specific property bag.
resolveProperty in interface PropertiesResolverT - property Java type.name - property name.type - expected property class type.null if no such property is registered.public <T> T resolveProperty(String name, T defaultValue)
PropertiesResolvername.
The method returns the value of the property registered in the request-specific
property bag, if available. If no property for the given property name is found
in the request-specific property bag, the method looks at the properties stored
in the global runtime configuration this request
belongs to. If there is a value defined in the runtime configuration,
it is returned, otherwise the method returns defaultValue if no such property is
registered neither in the runtime nor in the request-specific property bag.
resolveProperty in interface PropertiesResolverT - property Java type.name - property name.defaultValue - default value to return if the property is not registered.defaultValue if no such property is registered.public Object getProperty(String name)
PropertiesDelegatenull 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 PropertiesDelegate.getPropertyNames().
Custom property names should follow the same convention as package names.
getProperty in interface jakarta.ws.rs.container.ContainerRequestContextgetProperty in interface 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.PropertiesDelegate.getPropertyNames()public Collection<String> getPropertyNames()
PropertiesDelegatecollection containing the property
names available within the context of the current request/response exchange context.
Use the PropertiesDelegate.getProperty(java.lang.String) method with a property name to get the value of
a property.
getPropertyNames in interface jakarta.ws.rs.container.ContainerRequestContextgetPropertyNames in interface PropertiesDelegatecollection of property names.PropertiesDelegate.getProperty(java.lang.String)public void setProperty(String name, Object object)
PropertiesDelegateA 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 PropertiesDelegate.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
PropertiesDelegate.removeProperty(String) method.
setProperty in interface jakarta.ws.rs.container.ContainerRequestContextsetProperty in interface PropertiesDelegatename - a String specifying the name of the property.object - an Object representing the property to be bound.public void removeProperty(String name)
PropertiesDelegatePropertiesDelegate.getProperty(java.lang.String)
to retrieve the property value will return null.removeProperty in interface jakarta.ws.rs.container.ContainerRequestContextremoveProperty in interface PropertiesDelegatename - a String specifying the name of the property to be removed.public PropertiesDelegate getPropertiesDelegate()
public ExtendedUriInfo getUriInfo()
getUriInfo in interface jakarta.ws.rs.container.ContainerRequestContextprotected Iterable<jakarta.ws.rs.ext.ReaderInterceptor> getReaderInterceptors()
getReaderInterceptors in class InboundMessageContextpublic URI getBaseUri()
public URI getRequestUri()
public URI getAbsolutePath()
public void setRequestUri(URI requestUri) throws IllegalStateException
setRequestUri in interface jakarta.ws.rs.container.ContainerRequestContextIllegalStateExceptionpublic void setRequestUri(URI baseUri, URI requestUri) throws IllegalStateException
setRequestUri in interface jakarta.ws.rs.container.ContainerRequestContextIllegalStateExceptionpublic String getPath(boolean decode)
decode - controls whether sequences of escaped octets are decoded
(true) or not (false).public String getMethod()
getMethod in interface jakarta.ws.rs.container.ContainerRequestContextgetMethod in interface jakarta.ws.rs.core.Requestpublic void setMethod(String method) throws IllegalStateException
setMethod in interface jakarta.ws.rs.container.ContainerRequestContextIllegalStateExceptionpublic 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 jakarta.ws.rs.core.SecurityContext getSecurityContext()
getSecurityContext in interface jakarta.ws.rs.container.ContainerRequestContextpublic void setSecurityContext(jakarta.ws.rs.core.SecurityContext context)
setSecurityContext in interface jakarta.ws.rs.container.ContainerRequestContextpublic void setEntityStream(InputStream input)
InboundMessageContextsetEntityStream in interface jakarta.ws.rs.container.ContainerRequestContextsetEntityStream in class InboundMessageContextinput - new entity input stream.public jakarta.ws.rs.core.Request getRequest()
getRequest in interface jakarta.ws.rs.container.ContainerRequestContextpublic void abortWith(jakarta.ws.rs.core.Response response)
abortWith in interface jakarta.ws.rs.container.ContainerRequestContextpublic void inResponseProcessing()
public jakarta.ws.rs.core.Response getAbortResponse()
null otherwise.null otherwise.public Map<String,jakarta.ws.rs.core.Cookie> getCookies()
getCookies in interface jakarta.ws.rs.container.ContainerRequestContextgetCookies in interface jakarta.ws.rs.core.HttpHeaderspublic List<jakarta.ws.rs.core.MediaType> getAcceptableMediaTypes()
getAcceptableMediaTypes in interface jakarta.ws.rs.container.ContainerRequestContextgetAcceptableMediaTypes in interface jakarta.ws.rs.core.HttpHeaderspublic List<Locale> getAcceptableLanguages()
getAcceptableLanguages in interface jakarta.ws.rs.container.ContainerRequestContextgetAcceptableLanguages in interface jakarta.ws.rs.core.HttpHeaderspublic jakarta.ws.rs.core.Variant selectVariant(List<jakarta.ws.rs.core.Variant> variants) throws IllegalArgumentException
selectVariant in interface jakarta.ws.rs.core.RequestIllegalArgumentExceptionpublic String getVaryValue()
null if no value is to be set.null otherwise.public jakarta.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(jakarta.ws.rs.core.EntityTag eTag)
evaluatePreconditions in interface jakarta.ws.rs.core.Requestpublic jakarta.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(Date lastModified)
evaluatePreconditions in interface jakarta.ws.rs.core.Requestpublic jakarta.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(Date lastModified, jakarta.ws.rs.core.EntityTag eTag)
evaluatePreconditions in interface jakarta.ws.rs.core.Requestpublic jakarta.ws.rs.core.Response.ResponseBuilder evaluatePreconditions()
evaluatePreconditions in interface jakarta.ws.rs.core.Requestpublic List<String> getRequestHeader(String name)
getRequestHeaders().get(name).getRequestHeader in interface jakarta.ws.rs.core.HttpHeadersname - the header name, case insensitive.IllegalStateException - if called outside the scope of a request.public jakarta.ws.rs.core.MultivaluedMap<String,String> getRequestHeaders()
null.getRequestHeaders in interface jakarta.ws.rs.core.HttpHeadersIllegalStateException - if called outside the scope of a request.Copyright © 2007-2021, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.