public class ClientRequestContextImpl extends Object implements ClientRequestContext
Modifier and Type | Field and Description |
---|---|
protected Response |
abortedWithResponse |
protected ClientInvocation |
invocation |
Constructor and Description |
---|
ClientRequestContextImpl(ClientInvocation invocation) |
Modifier and Type | Method and Description |
---|---|
void |
abortWith(Response response)
Abort the filter chain with a response.
|
Response |
getAbortedWithResponse() |
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.
|
Client |
getClient()
Get the client instance associated with the request.
|
Configuration |
getConfiguration()
Get the immutable configuration of the request.
|
Map<String,Cookie> |
getCookies()
Get any cookies that accompanied the request.
|
Date |
getDate()
Get message date.
|
Object |
getEntity()
Get the message entity Java instance.
|
Annotation[] |
getEntityAnnotations()
Get the annotations attached to the entity instance.
|
Class<?> |
getEntityClass()
Get the raw entity type information.
|
OutputStream |
getEntityStream()
Get the entity output stream.
|
Type |
getEntityType()
Get the generic entity type information.
|
MultivaluedMap<String,Object> |
getHeaders()
Get the mutable request headers multivalued map.
|
String |
getHeaderString(String name)
Get a message header as a single string value.
|
ClientInvocation |
getInvocation()
exposes the client invocation for easier integration with other libraries
|
Locale |
getLanguage()
Get the language of the entity.
|
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. |
MultivaluedMap<String,String> |
getStringHeaders()
Get a string view of header values associated with the message.
|
URI |
getUri()
Get the request URI.
|
boolean |
hasEntity()
Check if there is an entity available in the request.
|
void |
removeProperty(String name)
Removes a property with the given name from the current request/response
exchange context.
|
void |
setEntity(Object entity)
Set a new message entity.
|
void |
setEntity(Object entity,
Annotation[] annotations,
MediaType mediaType)
Set a new message entity, including the attached annotations and the media type.
|
void |
setEntityStream(OutputStream entityStream)
Set a new entity output 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 |
setUri(URI uri)
Set a new request URI.
|
protected ClientInvocation invocation
protected Response abortedWithResponse
public ClientRequestContextImpl(ClientInvocation invocation)
public Response getAbortedWithResponse()
public Object getProperty(String name)
ClientRequestContext
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 ClientRequestContext.getPropertyNames()
.
Custom property names should follow the same convention as package names.
getProperty
in interface ClientRequestContext
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.ClientRequestContext.getPropertyNames()
public Collection<String> getPropertyNames()
ClientRequestContext
collection
containing the property names
available within the context of the current request/response exchange context.
Use the ClientRequestContext.getProperty(java.lang.String)
method with a property name to get the value of
a property.
getPropertyNames
in interface ClientRequestContext
collection
of property names.ClientRequestContext.getProperty(java.lang.String)
public void setProperty(String name, Object object)
ClientRequestContext
A property allows a filters and interceptors to exchange additional custom information not already provided by this interface.
A list of supported properties can be retrieved using ClientRequestContext.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
ClientRequestContext.removeProperty(String)
method.
setProperty
in interface ClientRequestContext
name
- a String
specifying the name of the property.object
- an Object
representing the property to be bound.public void removeProperty(String name)
ClientRequestContext
ClientRequestContext.getProperty(java.lang.String)
to retrieve the property value will return null
.removeProperty
in interface ClientRequestContext
name
- a String
specifying the name of the property to be removed.public Class<?> getEntityClass()
ClientRequestContext
getEntityClass
in interface ClientRequestContext
public Type getEntityType()
ClientRequestContext
getEntityType
in interface ClientRequestContext
public void setEntity(Object entity)
ClientRequestContext
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.
setEntity
in interface ClientRequestContext
entity
- entity object.ClientRequestContext.setEntity(Object, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)
,
MessageBodyWriter
public void setEntity(Object entity, Annotation[] annotations, MediaType mediaType)
ClientRequestContext
It is the callers responsibility to wrap the actual entity with
GenericEntity
if preservation of its generic
type is required.
setEntity
in interface ClientRequestContext
entity
- entity object.annotations
- annotations attached to the entity instance.mediaType
- entity media type.ClientRequestContext.setEntity(Object)
,
MessageBodyWriter
public URI getUri()
ClientRequestContext
getUri
in interface ClientRequestContext
public void setUri(URI uri)
ClientRequestContext
setUri
in interface ClientRequestContext
uri
- new request URI.public String getMethod()
ClientRequestContext
getMethod
in interface ClientRequestContext
HttpMethod
public void setMethod(String method)
ClientRequestContext
setMethod
in interface ClientRequestContext
method
- new request method.HttpMethod
public MultivaluedMap<String,Object> getHeaders()
ClientRequestContext
getHeaders
in interface ClientRequestContext
ClientRequestContext.getStringHeaders()
,
ClientRequestContext.getHeaderString(String)
public Date getDate()
ClientRequestContext
getDate
in interface ClientRequestContext
null
if not present.public Locale getLanguage()
ClientRequestContext
getLanguage
in interface ClientRequestContext
null
if not specifiedpublic MediaType getMediaType()
ClientRequestContext
getMediaType
in interface ClientRequestContext
null
if not specified (e.g. there's no
request entity).public List<MediaType> getAcceptableMediaTypes()
ClientRequestContext
getAcceptableMediaTypes
in interface ClientRequestContext
public List<Locale> getAcceptableLanguages()
ClientRequestContext
getAcceptableLanguages
in interface ClientRequestContext
public Map<String,Cookie> getCookies()
ClientRequestContext
getCookies
in interface ClientRequestContext
Cookie
.public boolean hasEntity()
ClientRequestContext
true
if the entity is present, returns
false
otherwise.hasEntity
in interface ClientRequestContext
true
if there is an entity present in the message,
false
otherwise.public OutputStream getEntityStream()
ClientRequestContext
getEntityStream
in interface ClientRequestContext
public void setEntityStream(OutputStream entityStream)
ClientRequestContext
setEntityStream
in interface ClientRequestContext
entityStream
- new entity output stream.public Object getEntity()
ClientRequestContext
null
if the message does not contain an entity.getEntity
in interface ClientRequestContext
null
if message does not contain an
entity body.public Annotation[] getEntityAnnotations()
ClientRequestContext
Note that the returned annotations array contains only those annotations
explicitly attached to entity instance (such as the ones attached using
Entity(Object, javax.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.
getEntityAnnotations
in interface ClientRequestContext
public Client getClient()
ClientRequestContext
getClient
in interface ClientRequestContext
public Configuration getConfiguration()
ClientRequestContext
getConfiguration
in interface ClientRequestContext
public void abortWith(Response response)
ClientRequestContext
abortWith
in interface ClientRequestContext
response
- response to be sent back to the client.public MultivaluedMap<String,String> getStringHeaders()
ClientRequestContext
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.
getStringHeaders
in interface ClientRequestContext
ClientRequestContext.getHeaders()
,
ClientRequestContext.getHeaderString(String)
public String getHeaderString(String name)
ClientRequestContext
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.getHeaderString
in interface ClientRequestContext
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.ClientRequestContext.getHeaders()
,
ClientRequestContext.getStringHeaders()
public ClientInvocation getInvocation()
Copyright © 2021 JBoss by Red Hat. All rights reserved.