public interface ClientRequestContext
Modifier and Type | Method and Description |
---|---|
void |
abortWith(Response response)
Abort the filter chain with a response.
|
java.util.List<java.util.Locale> |
getAcceptableLanguages()
Get a list of languages that are acceptable for the response.
|
java.util.List<MediaType> |
getAcceptableMediaTypes()
Get a list of media types that are acceptable for the response.
|
Client |
getClient()
Get the client instance associated with the request.
|
Configuration |
getConfiguration()
Get the immutable configuration of the request.
|
java.util.Map<java.lang.String,Cookie> |
getCookies()
Get any cookies that accompanied the request.
|
java.util.Date |
getDate()
Get message date.
|
java.lang.Object |
getEntity()
Get the message entity Java instance.
|
java.lang.annotation.Annotation[] |
getEntityAnnotations()
Get the annotations attached to the entity instance.
|
java.lang.Class<?> |
getEntityClass()
Get the raw entity type information.
|
java.io.OutputStream |
getEntityStream()
Get the entity output stream.
|
java.lang.reflect.Type |
getEntityType()
Get the generic entity type information.
|
MultivaluedMap<java.lang.String,java.lang.Object> |
getHeaders()
Get the mutable request headers multivalued map.
|
java.lang.String |
getHeaderString(java.lang.String name)
Get a message header as a single string value.
|
java.util.Locale |
getLanguage()
Get the language of the entity.
|
MediaType |
getMediaType()
Get the media type of the entity.
|
java.lang.String |
getMethod()
Get the request method.
|
java.lang.Object |
getProperty(java.lang.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. |
java.util.Collection<java.lang.String> |
getPropertyNames()
Returns an immutable
collection containing the property names available within the context of the
current request/response exchange context. |
MultivaluedMap<java.lang.String,java.lang.String> |
getStringHeaders()
Get a string view of header values associated with the message.
|
java.net.URI |
getUri()
Get the request URI.
|
boolean |
hasEntity()
Check if there is an entity available in the request.
|
default boolean |
hasProperty(java.lang.String name)
Returns
true if the property with the given name is registered in the current request/response exchange
context, or false if there is no property by that name. |
void |
removeProperty(java.lang.String name)
Removes a property with the given name from the current request/response exchange context.
|
void |
setEntity(java.lang.Object entity)
Set a new message entity.
|
void |
setEntity(java.lang.Object entity,
java.lang.annotation.Annotation[] annotations,
MediaType mediaType)
Set a new message entity, including the attached annotations and the media type.
|
void |
setEntityStream(java.io.OutputStream outputStream)
Set a new entity output stream.
|
void |
setMethod(java.lang.String method)
Set the request method.
|
void |
setProperty(java.lang.String name,
java.lang.Object object)
Binds an object to a given property name in the current request/response exchange context.
|
void |
setUri(java.net.URI uri)
Set a new request URI.
|
java.lang.Object getProperty(java.lang.String name)
null
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 getPropertyNames()
. Custom property names should
follow the same convention as package names.
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.getPropertyNames()
java.util.Collection<java.lang.String> getPropertyNames()
collection
containing the property names available within the context of the
current request/response exchange context.
Use the getProperty(java.lang.String)
method with a property name to get the value of a property.
collection
of property names.getProperty(java.lang.String)
default boolean hasProperty(java.lang.String name)
true
if the property with the given name is registered in the current request/response exchange
context, or false
if there is no property by that name.
Use the getProperty(java.lang.String)
method with a property name to get the value of a property.
name
- a String
specifying the name of the property.true
if this property is registered in the context, or false
if no property exists matching
the given name.getPropertyNames()
void setProperty(java.lang.String name, java.lang.Object object)
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 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 removeProperty(String)
method.
name
- a String
specifying the name of the property.object
- an Object
representing the property to be bound.void removeProperty(java.lang.String name)
getProperty(java.lang.String)
to retrieve the property value will return null
.name
- a String
specifying the name of the property to be removed.java.net.URI getUri()
void setUri(java.net.URI uri)
uri
- new request URI.java.lang.String getMethod()
HttpMethod
void setMethod(java.lang.String method)
method
- new request method.HttpMethod
MultivaluedMap<java.lang.String,java.lang.Object> getHeaders()
getStringHeaders()
,
getHeaderString(String)
MultivaluedMap<java.lang.String,java.lang.String> getStringHeaders()
headers map
are reflected in this view.
The method converts the non-string header values to strings using a
RuntimeDelegate.HeaderDelegate
if one is available via
RuntimeDelegate.createHeaderDelegate(java.lang.Class)
for the class of the value or using the
values toString
method if a header delegate is not available.
getHeaders()
,
getHeaderString(String)
java.lang.String getHeaderString(java.lang.String name)
RuntimeDelegate.HeaderDelegate
if one
is available via RuntimeDelegate.createHeaderDelegate(java.lang.Class)
for the header value
class or using its toString
method if a header delegate is not available.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.getHeaders()
,
getStringHeaders()
java.util.Date getDate()
null
if not present.java.util.Locale getLanguage()
null
if not specifiedMediaType getMediaType()
null
if not specified (e.g. there's no request entity).java.util.List<MediaType> getAcceptableMediaTypes()
java.util.List<java.util.Locale> getAcceptableLanguages()
java.util.Map<java.lang.String,Cookie> getCookies()
Cookie
.boolean hasEntity()
true
if the entity is present, returns false
otherwise.true
if there is an entity present in the message, false
otherwise.java.lang.Object getEntity()
null
if the message does not contain an entity.null
if message does not contain an entity body.java.lang.Class<?> getEntityClass()
java.lang.reflect.Type getEntityType()
void setEntity(java.lang.Object entity)
annotations
and media type
are preserved.
It is the callers responsibility to wrap the actual entity with GenericEntity
if
preservation of its generic type is required.
entity
- entity object.setEntity(Object, java.lang.annotation.Annotation[], jakarta.ws.rs.core.MediaType)
,
MessageBodyWriter
void setEntity(java.lang.Object entity, java.lang.annotation.Annotation[] annotations, MediaType mediaType)
It is the callers responsibility to wrap the actual entity with GenericEntity
if
preservation of its generic type is required.
entity
- entity object.annotations
- annotations attached to the entity instance.mediaType
- entity media type.setEntity(Object)
,
MessageBodyWriter
java.lang.annotation.Annotation[] getEntityAnnotations()
Note that the returned annotations array contains only those annotations explicitly attached to entity instance (such
as the ones attached using
Entity.Entity(Object, jakarta.ws.rs.core.MediaType, java.lang.annotation.Annotation[])
method). The entity
instance annotations array does not include annotations declared on the entity implementation class or its ancestors.
java.io.OutputStream getEntityStream()
void setEntityStream(java.io.OutputStream outputStream)
outputStream
- new entity output stream.Client getClient()
Configuration getConfiguration()
void abortWith(Response response)
response
- response to be sent back to the client.