public class PreMatchContainerRequestContext extends Object implements SuspendableContainerRequestContext
Modifier and Type | Field and Description |
---|---|
protected HttpRequest |
httpRequest |
protected Response |
response |
Constructor and Description |
---|
PreMatchContainerRequestContext(HttpRequest request)
Deprecated.
|
PreMatchContainerRequestContext(HttpRequest request,
ContainerRequestFilter[] requestFilters,
Supplier<BuiltResponse> continuation) |
Modifier and Type | Method and Description |
---|---|
void |
abortWith(Response response)
Abort the filter chain with a response.
|
BuiltResponse |
filter() |
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.
|
Map<String,Cookie> |
getCookies()
Get any cookies that accompanied the request.
|
Date |
getDate()
Get message date.
|
InputStream |
getEntityStream()
Get the entity input stream.
|
MultivaluedMap<String,String> |
getHeaders()
Get the mutable request headers multivalued map.
|
String |
getHeaderString(String name)
Get a message header as a single string value.
|
HttpRequest |
getHttpRequest() |
Locale |
getLanguage()
Get the language of the entity.
|
int |
getLength()
Get Content-Length value.
|
MediaType |
getMediaType()
Get the media type of the entity.
|
String |
getMethod()
Get the request method.
|
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. |
Request |
getRequest()
Get the injectable request information.
|
Response |
getResponseAbortedWith() |
SecurityContext |
getSecurityContext()
Get the injectable security context information for the current request.
|
UriInfo |
getUriInfo()
Get request URI information.
|
boolean |
hasEntity()
Check if there is a non-empty entity input stream available in the request
message.
|
void |
removeProperty(String name)
Removes a property with the given name from the current request/response
exchange context.
|
void |
resume()
Resumes the current request, and proceeds to the next request filter, if any,
or to the resource method.
|
void |
resume(Throwable t)
Aborts the current request with the given exception.
|
void |
setEntityStream(InputStream entityStream)
Set a new entity input stream.
|
void |
setMethod(String method)
Set the request method.
|
void |
setProperty(String name,
Object object)
Binds an object to a given property name in the current request/response
exchange context.
|
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.
|
boolean |
startedContinuation() |
void |
suspend()
Suspends the current request.
|
protected final HttpRequest httpRequest
protected Response response
@Deprecated public PreMatchContainerRequestContext(HttpRequest request)
public PreMatchContainerRequestContext(HttpRequest request, ContainerRequestFilter[] requestFilters, Supplier<BuiltResponse> continuation)
public HttpRequest getHttpRequest()
public Response getResponseAbortedWith()
public Object getProperty(String name)
ContainerRequestContext
null
if there is no property by that name.
A property allows 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 ContainerRequestContext
name
- 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()
ContainerRequestContext
collection
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 ContainerRequestContext
collection
of property names.ContainerRequestContext.getProperty(java.lang.String)
public void setProperty(String name, Object object)
ContainerRequestContext
A property allows 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 ContainerRequestContext
name
- a String
specifying the name of the property.object
- an Object
representing the property to be bound.public void removeProperty(String name)
ContainerRequestContext
ContainerRequestContext.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 ContainerRequestContext
name
- a String
specifying the name of the property to be removed.public UriInfo getUriInfo()
ContainerRequestContext
setRequestUri(...)
methods will be reflected in the previously
returned UriInfo
instance.getUriInfo
in interface ContainerRequestContext
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 ContainerRequestContext
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, 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 ContainerRequestContext
baseUri
- 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 getMethod()
ContainerRequestContext
getMethod
in interface ContainerRequestContext
HttpMethod
public void setMethod(String method)
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 ContainerRequestContext
method
- new request method.HttpMethod
public MultivaluedMap<String,String> getHeaders()
ContainerRequestContext
getHeaders
in interface ContainerRequestContext
ContainerRequestContext.getHeaderString(String)
public Date getDate()
ContainerRequestContext
getDate
in interface ContainerRequestContext
null
if not present.public Locale getLanguage()
ContainerRequestContext
getLanguage
in interface ContainerRequestContext
null
if not specifiedpublic int getLength()
ContainerRequestContext
getLength
in interface ContainerRequestContext
-1
.public MediaType getMediaType()
ContainerRequestContext
getMediaType
in interface ContainerRequestContext
null
if not specified (e.g. there's no
request entity).public List<MediaType> getAcceptableMediaTypes()
ContainerRequestContext
getAcceptableMediaTypes
in interface ContainerRequestContext
public List<Locale> getAcceptableLanguages()
ContainerRequestContext
getAcceptableLanguages
in interface ContainerRequestContext
public Map<String,Cookie> getCookies()
ContainerRequestContext
getCookies
in interface ContainerRequestContext
Cookie
.public boolean hasEntity()
ContainerRequestContext
true
if the entity is present, returns
false
otherwise.hasEntity
in interface ContainerRequestContext
true
if there is an entity present in the message,
false
otherwise.public InputStream getEntityStream()
ContainerRequestContext
getEntityStream
in interface ContainerRequestContext
public void setEntityStream(InputStream entityStream)
ContainerRequestContext
setEntityStream
in interface ContainerRequestContext
entityStream
- new entity input stream.public SecurityContext getSecurityContext()
ContainerRequestContext
SecurityContext.getUserPrincipal()
must return null
if the current request has not been authenticated.getSecurityContext
in interface ContainerRequestContext
public void setSecurityContext(SecurityContext context)
ContainerRequestContext
SecurityContext.getUserPrincipal()
must return null
if the current request has not been authenticated.setSecurityContext
in interface ContainerRequestContext
context
- new injectable request security context information.public Request getRequest()
ContainerRequestContext
getRequest
in interface ContainerRequestContext
public String getHeaderString(String name)
ContainerRequestContext
getHeaderString
in interface ContainerRequestContext
name
- the message header.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.ContainerRequestContext.getHeaders()
public void suspend()
SuspendableContainerRequestContext
SuspendableContainerRequestContext.resume()
or aborted with SuspendableContainerRequestContext.resume(Throwable)
or
ContainerRequestContext.abortWith(javax.ws.rs.core.Response)
.suspend
in interface SuspendableContainerRequestContext
public void abortWith(Response response)
ContainerRequestContext
abortWith
in interface ContainerRequestContext
response
- response to be sent back to the client.public void resume()
SuspendableContainerRequestContext
resume
in interface SuspendableContainerRequestContext
public void resume(Throwable t)
SuspendableContainerRequestContext
resume
in interface SuspendableContainerRequestContext
t
- the exception to send back to the client, as mapped by the application.public BuiltResponse filter()
public boolean startedContinuation()
Copyright © 2019 JBoss by Red Hat. All rights reserved.