Class PreMatchContainerRequestContext
- All Implemented Interfaces:
ContainerRequestContext,SuspendableContainerRequestContext
- Direct Known Subclasses:
PostMatchContainerRequestContext,ResponseContainerRequestContext
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.PreMatchContainerRequestContext(HttpRequest request, ContainerRequestFilter[] requestFilters, Supplier<BuiltResponse> continuation) -
Method Summary
Modifier and TypeMethodDescriptionvoidAbort the filter chain with a response.filter()Get a list of languages that are acceptable for the response.Get a list of media types that are acceptable for the response.Get any cookies that accompanied the request.getDate()Get message date.Get the entity input stream.Get the mutable request headers multivalued map.getHeaderString(String name) Get a message header as a single string value.Get the language of the entity.intGet Content-Length value.Get the media type of the entity.Get the request method.getProperty(String name) Returns the property with the given name registered in the current request/response exchange context, ornullif there is no property by that name.Returns an immutablecollectioncontaining the property names available within the context of the current request/response exchange context.Get the injectable request information.Get the injectable security context information for the current request.Get request URI information.booleanCheck if there is a non-empty entity input stream available in the request message.voidremoveProperty(String name) Removes a property with the given name from the current request/response exchange context.voidresume()Resumes the current request, and proceeds to the next request filter, if any, or to the resource method.voidAborts the current request with the given exception.voidsetEntityStream(InputStream entityStream) Set a new entity input stream.voidSet the request method.voidsetProperty(String name, Object object) Binds an object to a given property name in the current request/response exchange context.voidsetRequestUri(URI requestUri) Set a new request URI using the current base URI of the application to resolve the application-specific request URI part.voidsetRequestUri(URI baseUri, URI requestUri) Set a new request URI using a new base URI to resolve the application-specific request URI part.voidsetSecurityContext(SecurityContext context) Set a new injectable security context information for the current request.booleanvoidsuspend()Suspends the current request.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.ws.rs.container.ContainerRequestContext
hasProperty
-
Field Details
-
httpRequest
-
response
-
-
Constructor Details
-
PreMatchContainerRequestContext
Deprecated. -
PreMatchContainerRequestContext
public PreMatchContainerRequestContext(HttpRequest request, ContainerRequestFilter[] requestFilters, Supplier<BuiltResponse> continuation)
-
-
Method Details
-
getHttpRequest
-
getResponseAbortedWith
-
getProperty
Description copied from interface:ContainerRequestContextReturns the property with the given name registered in the current request/response exchange context, ornullif 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
ServletRequestand expose all the attributes available in theServletRequest. Any modifications of the properties are also reflected in the set of properties of the associatedServletRequest.- Specified by:
getPropertyin interfaceContainerRequestContext- Parameters:
name- aStringspecifying the name of the property.- Returns:
- an
Objectcontaining the value of the property, ornullif no property exists matching the given name. - See Also:
-
getPropertyNames
Description copied from interface:ContainerRequestContextReturns an immutablecollectioncontaining 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
ServletRequestand expose all the attributes available in theServletRequest. Any modifications of the properties are also reflected in the set of properties of the associatedServletRequest.- Specified by:
getPropertyNamesin interfaceContainerRequestContext- Returns:
- an immutable
collectionof property names. - See Also:
-
setProperty
Description copied from interface:ContainerRequestContextBinds an object to a given property name in the current request/response exchange context. If the name specified is already used for a property, this method will replace the value of the property with the new value.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.If a
nullvalue is passed, the effect is the same as calling theContainerRequestContext.removeProperty(String)method.In a Servlet container, the properties are synchronized with the
ServletRequestand expose all the attributes available in theServletRequest. Any modifications of the properties are also reflected in the set of properties of the associatedServletRequest.- Specified by:
setPropertyin interfaceContainerRequestContext- Parameters:
name- aStringspecifying the name of the property.object- anObjectrepresenting the property to be bound.
-
removeProperty
Description copied from interface:ContainerRequestContextRemoves a property with the given name from the current request/response exchange context. After removal, subsequent calls toContainerRequestContext.getProperty(java.lang.String)to retrieve the property value will returnnull.In a Servlet container, the properties are synchronized with the
ServletRequestand expose all the attributes available in theServletRequest. Any modifications of the properties are also reflected in the set of properties of the associatedServletRequest.- Specified by:
removePropertyin interfaceContainerRequestContext- Parameters:
name- aStringspecifying the name of the property to be removed.
-
getUriInfo
Description copied from interface:ContainerRequestContextGet request URI information. The returned object contains "live" view of the request URI information in a sense that any changes made to the request URI using one of thesetRequestUri(...)methods will be reflected in the previously returnedUriInfoinstance.- Specified by:
getUriInfoin interfaceContainerRequestContext- Returns:
- request URI information.
-
setRequestUri
Description copied from interface:ContainerRequestContextSet a new request URI using the current base URI of the application to resolve the application-specific request URI part.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
IllegalStateExceptionbeing thrown.- Specified by:
setRequestUriin interfaceContainerRequestContext- Parameters:
requestUri- new URI of the request.- Throws:
IllegalStateException- in case the method is not invoked from apre-matchingrequest filter.- See Also:
-
setRequestUri
Description copied from interface:ContainerRequestContextSet a new request URI using a new base URI to resolve the application-specific request URI part.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
IllegalStateExceptionbeing thrown.- Specified by:
setRequestUriin interfaceContainerRequestContext- Parameters:
baseUri- base URI that will be used to resolve the application-specific part of the request URI.requestUri- new URI of the request.- Throws:
IllegalStateException- in case the method is not invoked from apre-matchingrequest filter.- See Also:
-
getMethod
Description copied from interface:ContainerRequestContextGet the request method.- Specified by:
getMethodin interfaceContainerRequestContext- Returns:
- the request method.
- See Also:
-
setMethod
Description copied from interface:ContainerRequestContextSet the request method.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
IllegalStateExceptionbeing thrown.- Specified by:
setMethodin interfaceContainerRequestContext- Parameters:
method- new request method.- See Also:
-
getHeaders
Description copied from interface:ContainerRequestContextGet the mutable request headers multivalued map.- Specified by:
getHeadersin interfaceContainerRequestContext- Returns:
- mutable multivalued map of request headers.
- See Also:
-
getDate
Description copied from interface:ContainerRequestContextGet message date.- Specified by:
getDatein interfaceContainerRequestContext- Returns:
- the message date, otherwise
nullif not present.
-
getLanguage
Description copied from interface:ContainerRequestContextGet the language of the entity.- Specified by:
getLanguagein interfaceContainerRequestContext- Returns:
- the language of the entity or
nullif not specified
-
getLength
public int getLength()Description copied from interface:ContainerRequestContextGet Content-Length value.- Specified by:
getLengthin interfaceContainerRequestContext- Returns:
- Content-Length as integer if present and valid number. In other cases returns
-1.
-
getMediaType
Description copied from interface:ContainerRequestContextGet the media type of the entity.- Specified by:
getMediaTypein interfaceContainerRequestContext- Returns:
- the media type or
nullif not specified (e.g. there's no request entity).
-
getAcceptableMediaTypes
Description copied from interface:ContainerRequestContextGet a list of media types that are acceptable for the response.- Specified by:
getAcceptableMediaTypesin interfaceContainerRequestContext- Returns:
- a read-only list of requested response media types sorted according to their q-value, with highest preference first.
-
getAcceptableLanguages
Description copied from interface:ContainerRequestContextGet a list of languages that are acceptable for the response.- Specified by:
getAcceptableLanguagesin interfaceContainerRequestContext- Returns:
- a read-only list of acceptable languages sorted according to their q-value, with highest preference first.
-
getCookies
Description copied from interface:ContainerRequestContextGet any cookies that accompanied the request.- Specified by:
getCookiesin interfaceContainerRequestContext- Returns:
- a read-only map of cookie name (String) to
Cookie.
-
hasEntity
public boolean hasEntity()Description copied from interface:ContainerRequestContextCheck if there is a non-empty entity input stream available in the request message. The method returnstrueif the entity is present, returnsfalseotherwise.- Specified by:
hasEntityin interfaceContainerRequestContext- Returns:
trueif there is an entity present in the message,falseotherwise.
-
getEntityStream
Description copied from interface:ContainerRequestContextGet the entity input stream. The JAX-RS runtime is responsible for closing the input stream.- Specified by:
getEntityStreamin interfaceContainerRequestContext- Returns:
- entity input stream.
-
setEntityStream
Description copied from interface:ContainerRequestContextSet a new entity input stream. The JAX-RS runtime is responsible for closing the input stream.- Specified by:
setEntityStreamin interfaceContainerRequestContext- Parameters:
entityStream- new entity input stream.
-
getSecurityContext
Description copied from interface:ContainerRequestContextGet the injectable security context information for the current request. TheSecurityContext.getUserPrincipal()must returnnullif the current request has not been authenticated.- Specified by:
getSecurityContextin interfaceContainerRequestContext- Returns:
- injectable request security context information.
-
setSecurityContext
Description copied from interface:ContainerRequestContextSet a new injectable security context information for the current request. TheSecurityContext.getUserPrincipal()must returnnullif the current request has not been authenticated.- Specified by:
setSecurityContextin interfaceContainerRequestContext- Parameters:
context- new injectable request security context information.
-
getRequest
Description copied from interface:ContainerRequestContextGet the injectable request information.- Specified by:
getRequestin interfaceContainerRequestContext- Returns:
- injectable request information.
-
getHeaderString
Description copied from interface:ContainerRequestContextGet a message header as a single string value.- Specified by:
getHeaderStringin interfaceContainerRequestContext- Parameters:
name- the message header.- Returns:
- the message header value. If the message header is not present then
nullis 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. - See Also:
-
suspend
public void suspend()Description copied from interface:SuspendableContainerRequestContextSuspends the current request. This makes the current request asynchronous. No further request filter is executed until this request is resumed. No reply is going to be sent to the client until this request is resumed either withSuspendableContainerRequestContext.resume()or aborted withSuspendableContainerRequestContext.resume(Throwable)orContainerRequestContext.abortWith(jakarta.ws.rs.core.Response).- Specified by:
suspendin interfaceSuspendableContainerRequestContext
-
abortWith
Description copied from interface:ContainerRequestContextAbort the filter chain with a response. This method breaks the filter chain processing and returns the provided response back to the client. The provided response goes through the chain of applicable response filters.- Specified by:
abortWithin interfaceContainerRequestContext- Parameters:
response- response to be sent back to the client.
-
resume
public void resume()Description copied from interface:SuspendableContainerRequestContextResumes the current request, and proceeds to the next request filter, if any, or to the resource method.- Specified by:
resumein interfaceSuspendableContainerRequestContext
-
resume
Description copied from interface:SuspendableContainerRequestContextAborts the current request with the given exception. This behaves as if the request filter threw this exception synchronously, which means exceptions may be mapped via exception mappers, response filters will run and async response callbacks will be called with this exception.- Specified by:
resumein interfaceSuspendableContainerRequestContext- Parameters:
t- the exception to send back to the client, as mapped by the application.
-
filter
-
startedContinuation
public boolean startedContinuation()
-