Class ClientRequest
- All Implemented Interfaces:
javax.ws.rs.client.ClientRequestContext, org.glassfish.jersey.internal.inject.InjectionManagerSupplier
- Author:
- Marek Potociar (marek.potociar at oracle.com)
-
Nested Class Summary
Nested classes/interfaces inherited from class OutboundMessageContext
OutboundMessageContext.StreamProvider -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedClientRequest(URI requestUri, ClientConfig clientConfig, PropertiesDelegate propertiesDelegate) Create new Jersey client request context.ClientRequest(ClientRequest original) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidabortWith(javax.ws.rs.core.Response response) voidAdd new accepted types to the message headers.voidaccept(javax.ws.rs.core.MediaType... types) Add new accepted types to the message headers.voidacceptLanguage(String... locales) Add new accepted languages to the message headers.voidacceptLanguage(Locale... locales) Add new accepted languages to the message headers.voidcacheControl(javax.ws.rs.core.CacheControl cacheControl) Add new cache control entry to the message headers.voidcookie(javax.ws.rs.core.Cookie cookie) Add new cookie to the message headers.voidEnable a buffering of serialized entity.voidSet message encoding.javax.ws.rs.core.ResponseGet the request filter chain aborting response if set, ornullotherwise.javax.ws.rs.core.Configurationorg.glassfish.jersey.internal.inject.InjectionManagerGet injection manager.getProperty(String name) Iterable<javax.ws.rs.ext.ReaderInterceptor> Get reader interceptors of this request.getUri()Get the message body workers associated with the request.Iterable<javax.ws.rs.ext.WriterInterceptor> Get writer interceptors of this request.booleanIndicates whether the User-Agent header should be omitted if not directly set to the map of headers.voidignoreUserAgent(boolean ignore) Indicates whether the User-Agent header should be omitted if not directly set to the map of headers.booleanReturns true if the request is called asynchronously usingAsyncInvokervoidSet message language.voidSet message language.voidremoveProperty(String name) <T> TresolveProperty(String name, Class<T> type) Resolve a property value for the specified propertyname.<T> TresolveProperty(String name, T defaultValue) Resolve a property value for the specified propertyname.voidvoidsetProperty(String name, Object object) voidvoidsetWorkers(MessageBodyWorkers workers) Set the message body workers associated with the request.voidSet message content type.voidtype(javax.ws.rs.core.MediaType type) Set message content type.voidvariant(javax.ws.rs.core.Variant variant) Set message content variant (type, language and encoding).voidWrite (serialize) the entity set in this request into theentity stream.Methods inherited from class OutboundMessageContext
close, commitStream, enableBuffering, getAcceptableLanguages, getAcceptableMediaTypes, getAllowedMethods, getDate, getEntity, getEntityAnnotations, getEntityClass, getEntityStream, getEntityTag, getEntityType, getHeaders, getHeaderString, getLanguage, getLastModified, getLength, getLengthLong, getLink, getLinkBuilder, getLinks, getLocation, getMediaType, getRequestCookies, getResponseCookies, getStringHeaders, hasEntity, hasLink, isCommitted, replaceHeaders, setEntity, setEntity, setEntity, setEntity, setEntityAnnotations, setEntityStream, setEntityType, setMediaType, setStreamProviderMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.ws.rs.client.ClientRequestContext
getAcceptableLanguages, getAcceptableMediaTypes, getDate, getEntity, getEntityAnnotations, getEntityClass, getEntityStream, getEntityType, getHeaders, getHeaderString, getLanguage, getMediaType, getStringHeaders, hasEntity, setEntity, setEntity, setEntityStream
-
Constructor Details
-
ClientRequest
protected ClientRequest(URI requestUri, ClientConfig clientConfig, PropertiesDelegate propertiesDelegate) Create new Jersey client request context.- Parameters:
requestUri- request Uri.clientConfig- request configuration.propertiesDelegate- properties delegate.
-
ClientRequest
Copy constructor.- Parameters:
original- original instance.
-
-
Method Details
-
resolveProperty
Resolve a property value for the specified propertyname.The method returns the value of the property registered in the request-specific property bag, if available. If no property for the given property name is found in the request-specific property bag, the method looks at the properties stored in the
global client-runtime configurationthis request belongs to. If there is a value defined in the client-runtime configuration, it is returned, otherwise the method returnsnullif no such property is registered neither in the client runtime nor in the request-specific property bag.- Type Parameters:
T- property Java type.- Parameters:
name- property name.type- expected property class type.- Returns:
- resolved property value or
nullif no such property is registered.
-
resolveProperty
Resolve a property value for the specified propertyname.The method returns the value of the property registered in the request-specific property bag, if available. If no property for the given property name is found in the request-specific property bag, the method looks at the properties stored in the
global client-runtime configurationthis request belongs to. If there is a value defined in the client-runtime configuration, it is returned, otherwise the method returnsdefaultValueif no such property is registered neither in the client runtime nor in the request-specific property bag.- Type Parameters:
T- property Java type.- Parameters:
name- property name.defaultValue- default value to return if the property is not registered.- Returns:
- resolved property value or
defaultValueif no such property is registered.
-
getProperty
-
getPropertyNames
- Specified by:
getPropertyNamesin interfacejavax.ws.rs.client.ClientRequestContext
-
setProperty
-
removeProperty
- Specified by:
removePropertyin interfacejavax.ws.rs.client.ClientRequestContext
-
getUri
- Specified by:
getUriin interfacejavax.ws.rs.client.ClientRequestContext
-
setUri
- Specified by:
setUriin interfacejavax.ws.rs.client.ClientRequestContext
-
getMethod
- Specified by:
getMethodin interfacejavax.ws.rs.client.ClientRequestContext
-
setMethod
- Specified by:
setMethodin interfacejavax.ws.rs.client.ClientRequestContext
-
getClient
- Specified by:
getClientin interfacejavax.ws.rs.client.ClientRequestContext
-
abortWith
public void abortWith(javax.ws.rs.core.Response response) - Specified by:
abortWithin interfacejavax.ws.rs.client.ClientRequestContext
-
getAbortResponse
public javax.ws.rs.core.Response getAbortResponse()Get the request filter chain aborting response if set, ornullotherwise.- Returns:
- request filter chain aborting response if set, or
nullotherwise.
-
getConfiguration
public javax.ws.rs.core.Configuration getConfiguration()- Specified by:
getConfigurationin interfacejavax.ws.rs.client.ClientRequestContext
-
getCookies
-
getWorkers
Get the message body workers associated with the request.- Returns:
- message body workers.
-
setWorkers
Set the message body workers associated with the request.- Parameters:
workers- message body workers.
-
accept
public void accept(javax.ws.rs.core.MediaType... types) Add new accepted types to the message headers.- Parameters:
types- accepted types to be added.
-
accept
Add new accepted types to the message headers.- Parameters:
types- accepted types to be added.
-
acceptLanguage
Add new accepted languages to the message headers.- Parameters:
locales- accepted languages to be added.
-
acceptLanguage
Add new accepted languages to the message headers.- Parameters:
locales- accepted languages to be added.
-
cookie
public void cookie(javax.ws.rs.core.Cookie cookie) Add new cookie to the message headers.- Parameters:
cookie- cookie to be added.
-
cacheControl
public void cacheControl(javax.ws.rs.core.CacheControl cacheControl) Add new cache control entry to the message headers.- Parameters:
cacheControl- cache control entry to be added.
-
encoding
Set message encoding.- Parameters:
encoding- message encoding to be set.
-
language
Set message language.- Parameters:
language- message language to be set.
-
language
Set message language.- Parameters:
language- message language to be set.
-
type
public void type(javax.ws.rs.core.MediaType type) Set message content type.- Parameters:
type- message content type to be set.
-
type
Set message content type.- Parameters:
type- message content type to be set.
-
variant
public void variant(javax.ws.rs.core.Variant variant) Set message content variant (type, language and encoding).- Parameters:
variant- message content content variant (type, language and encoding) to be set.
-
isAsynchronous
public boolean isAsynchronous()Returns true if the request is called asynchronously usingAsyncInvoker- Returns:
- True if the request is asynchronous; false otherwise.
-
enableBuffering
public void enableBuffering()Enable a buffering of serialized entity. The buffering will be configured from runtime configuration associated with this request. The property determining the size of the buffer isCommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER. The buffering functionality is by default disabled and could be enabled by calling this method. In this case this method must be called before first bytes are written to theentity stream. -
writeEntity
Write (serialize) the entity set in this request into theentity stream. The method usewriter interceptorsandmessage body writer. This method modifies the state of this request and therefore it can be called only once per request life cycle otherwise IllegalStateException is thrown. Note thatOutboundMessageContext.setStreamProvider(org.glassfish.jersey.message.internal.OutboundMessageContext.StreamProvider)and optionallyenableBuffering()must be called before calling this method.- Throws:
IOException- In the case of IO error.
-
getWriterInterceptors
Get writer interceptors of this request.- Returns:
- Writer interceptors in the interceptor execution order.
-
getReaderInterceptors
Get reader interceptors of this request.- Returns:
- Reader interceptors in the interceptor execution order.
-
getInjectionManager
public org.glassfish.jersey.internal.inject.InjectionManager getInjectionManager()Description copied from interface:org.glassfish.jersey.internal.inject.InjectionManagerSupplierGet injection manager.- Specified by:
getInjectionManagerin interfaceorg.glassfish.jersey.internal.inject.InjectionManagerSupplier- Returns:
- injection manager.
-
ignoreUserAgent
public boolean ignoreUserAgent()Indicates whether the User-Agent header should be omitted if not directly set to the map of headers.- Returns:
trueif the header should be omitted,falseotherwise.
-
ignoreUserAgent
public void ignoreUserAgent(boolean ignore) Indicates whether the User-Agent header should be omitted if not directly set to the map of headers.- Parameters:
ignore-trueif the header should be omitted,falseotherwise.
-