Interface ClientRequestContext
public interface ClientRequestContext
- Since:
- 2.0
- Author:
- Marek Potociar
- 
Method SummaryModifier and Type Method Description voidabortWith(Response response)Abort the filter chain with a response.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.ClientgetClient()Get the client instance associated with the request.ConfigurationgetConfiguration()Get the immutable configuration of the request.Map<String,Cookie>getCookies()Get any cookies that accompanied the request.DategetDate()Get message date.ObjectgetEntity()Get the message entity Java instance.Annotation[]getEntityAnnotations()Get the annotations attached to the entity instance.Class<?>getEntityClass()Get the raw entity type information.OutputStreamgetEntityStream()Get the entity output stream.TypegetEntityType()Get the generic entity type information.MultivaluedMap<String,Object>getHeaders()Get the mutable request headers multivalued map.StringgetHeaderString(String name)Get a message header as a single string value.LocalegetLanguage()Get the language of the entity.MediaTypegetMediaType()Get the media type of the entity.StringgetMethod()Get the request method.ObjectgetProperty(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.Collection<String>getPropertyNames()Returns an immutablecollectioncontaining 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.URIgetUri()Get the request URI.booleanhasEntity()Check if there is an entity available in the request.voidremoveProperty(String name)Removes a property with the given name from the current request/response exchange context.voidsetEntity(Object entity)Set a new message entity.voidsetEntity(Object entity, Annotation[] annotations, MediaType mediaType)Set a new message entity, including the attached annotations and the media type.voidsetEntityStream(OutputStream outputStream)Set a new entity output stream.voidsetMethod(String method)Set the request method.voidsetProperty(String name, Object object)Binds an object to a given property name in the current request/response exchange context.voidsetUri(URI uri)Set a new request URI.
- 
Method Details- 
getPropertyReturns 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 getPropertyNames(). Custom property names should follow the same convention as package names.- Parameters:
- name- a- Stringspecifying the name of the property.
- Returns:
- an Objectcontaining the value of the property, ornullif no property exists matching the given name.
- See Also:
- getPropertyNames()
 
- 
getPropertyNamesCollection<String> getPropertyNames()Returns an immutablecollectioncontaining 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.- Returns:
- an immutable collectionof property names.
- See Also:
- getProperty(java.lang.String)
 
- 
setPropertyBinds 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 getPropertyNames(). Custom property names should follow the same convention as package names.If a nullvalue is passed, the effect is the same as calling theremoveProperty(String)method.- Parameters:
- name- a- Stringspecifying the name of the property.
- object- an- Objectrepresenting the property to be bound.
 
- 
removePropertyRemoves a property with the given name from the current request/response exchange context. After removal, subsequent calls togetProperty(java.lang.String)to retrieve the property value will returnnull.- Parameters:
- name- a- Stringspecifying the name of the property to be removed.
 
- 
getUriURI getUri()Get the request URI.- Returns:
- request URI.
 
- 
setUriSet a new request URI.- Parameters:
- uri- new request URI.
 
- 
getMethodString getMethod()Get the request method.- Returns:
- the request method.
- See Also:
- HttpMethod
 
- 
setMethodSet the request method.- Parameters:
- method- new request method.
- See Also:
- HttpMethod
 
- 
getHeadersMultivaluedMap<String,Object> getHeaders()Get the mutable request headers multivalued map.- Returns:
- mutable multivalued map of request headers.
- See Also:
- getStringHeaders(),- getHeaderString(String)
 
- 
getStringHeadersMultivaluedMap<String,String> getStringHeaders()Get a string view of header values associated with the message. Changes in the underlyingheaders mapare reflected in this view.The method converts the non-string header values to strings using a RuntimeDelegate.HeaderDelegateif one is available viaRuntimeDelegate.createHeaderDelegate(java.lang.Class)for the class of the value or using the valuestoStringmethod if a header delegate is not available.- Returns:
- response headers as a string view of header values.
- See Also:
- getHeaders(),- getHeaderString(String)
 
- 
getHeaderStringGet a message header as a single string value. Each single header value is converted to String using aRuntimeDelegate.HeaderDelegateif one is available viaRuntimeDelegate.createHeaderDelegate(java.lang.Class)for the header value class or using itstoStringmethod if a header delegate is not available.- 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:
- getHeaders(),- getStringHeaders()
 
- 
getDateDate getDate()Get message date.- Returns:
- the message date, otherwise nullif not present.
 
- 
getLanguageLocale getLanguage()Get the language of the entity.- Returns:
- the language of the entity or nullif not specified
 
- 
getMediaTypeMediaType getMediaType()Get the media type of the entity.- Returns:
- the media type or nullif not specified (e.g. there's no request entity).
 
- 
getAcceptableMediaTypesGet a list of media types that are acceptable for the response.- Returns:
- a read-only list of requested response media types sorted according to their q-value, with highest preference first.
 
- 
getAcceptableLanguagesGet a list of languages that are acceptable for the response.- Returns:
- a read-only list of acceptable languages sorted according to their q-value, with highest preference first.
 
- 
getCookiesGet any cookies that accompanied the request.- Returns:
- a read-only map of cookie name (String) to Cookie.
 
- 
hasEntityboolean hasEntity()Check if there is an entity available in the request. The method returnstrueif the entity is present, returnsfalseotherwise.- Returns:
- trueif there is an entity present in the message,- falseotherwise.
 
- 
getEntityObject getEntity()Get the message entity Java instance. Returnsnullif the message does not contain an entity.- Returns:
- the message entity or nullif message does not contain an entity body.
 
- 
getEntityClassClass<?> getEntityClass()Get the raw entity type information.- Returns:
- raw entity type.
 
- 
getEntityTypeType getEntityType()Get the generic entity type information.- Returns:
- generic entity type.
 
- 
setEntitySet a new message entity. The existing entityannotationsandmedia typeare preserved.It is the callers responsibility to wrap the actual entity with GenericEntityif preservation of its generic type is required.- Parameters:
- entity- entity object.
- See Also:
- setEntity(Object, java.lang.annotation.Annotation[], jakarta.ws.rs.core.MediaType),- MessageBodyWriter
 
- 
setEntitySet a new message entity, including the attached annotations and the media type.It is the callers responsibility to wrap the actual entity with GenericEntityif preservation of its generic type is required.- Parameters:
- entity- entity object.
- annotations- annotations attached to the entity instance.
- mediaType- entity media type.
- See Also:
- setEntity(Object),- MessageBodyWriter
 
- 
getEntityAnnotationsAnnotation[] getEntityAnnotations()Get the annotations attached to the entity instance.Note that the returned annotations array contains only those annotations explicitly attached to entity instance (such as the ones attached using 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.- Returns:
- annotations attached to the entity instance.
 
- 
getEntityStreamOutputStream getEntityStream()Get the entity output stream. The JAX-RS runtime is responsible for closing the output stream.- Returns:
- entity output stream.
 
- 
setEntityStreamSet a new entity output stream. The JAX-RS runtime is responsible for closing the output stream.- Parameters:
- outputStream- new entity output stream.
 
- 
getClientClient getClient()Get the client instance associated with the request.- Returns:
- client instance associated with the request.
 
- 
getConfigurationConfiguration getConfiguration()Get the immutable configuration of the request.- Returns:
- immutable request configuration.
 
- 
abortWithAbort 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.- Parameters:
- response- response to be sent back to the client.
 
 
-