Class ClientInvocationBuilder
- java.lang.Object
-
- org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder
-
- All Implemented Interfaces:
Invocation.Builder,SyncInvoker
public class ClientInvocationBuilder extends Object implements Invocation.Builder
- Version:
- $Revision: 1 $
- Author:
- Bill Burke, Alessio Soldano
-
-
Field Summary
Fields Modifier and Type Field Description protected ClientInvocationinvocation
-
Constructor Summary
Constructors Constructor Description ClientInvocationBuilder(ResteasyClient client, URI uri, ClientConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Invocation.Builderaccept(MediaType... mediaTypes)Add the accepted response media types.Invocation.Builderaccept(String... mediaTypes)Add the accepted response media types.Invocation.BuilderacceptEncoding(String... encodings)Add acceptable encodings.Invocation.BuilderacceptLanguage(String... locales)Add acceptable languages.Invocation.BuilderacceptLanguage(Locale... locales)Add acceptable languages.AsyncInvokerasync()Access the asynchronous uniform request invocation interface to asynchronously invoke the built request.Invocationbuild(String method)Build a request invocation using an arbitrary request method name.Invocationbuild(String method, Entity<?> entity)Build a request invocation using an arbitrary request method name and request entity.InvocationbuildDelete()Build a DELETE request invocation.InvocationbuildGet()Build a GET request invocation.InvocationbuildPost(Entity<?> entity)Build a POST request invocation.InvocationbuildPut(Entity<?> entity)Build a PUT request invocation.Invocation.BuildercacheControl(CacheControl cacheControl)Set the cache control data of the message.Invocation.Buildercookie(Cookie cookie)Add a cookie to be set.Invocation.Buildercookie(String name, String value)Add a cookie to be set.protected ClientInvocationcreateClientInvocation(ClientInvocation invocation)protected ClientInvocationcreateClientInvocation(ResteasyClient client, URI uri, ClientRequestHeaders headers, ClientConfiguration parent)Responsedelete()Invoke HTTP DELETE method for the current request synchronously.<T> Tdelete(GenericType<T> responseType)Invoke HTTP DELETE method for the current request synchronously.<T> Tdelete(Class<T> responseType)Invoke HTTP DELETE method for the current request synchronously.Responseget()Invoke HTTP GET method for the current request synchronously.<T> Tget(GenericType<T> responseType)Invoke HTTP GET method for the current request synchronously.<T> Tget(Class<T> responseType)Invoke HTTP GET method for the current request synchronously.ClientInvocationgetClientInvocation()exposes the client invocation for easier integration with other librariesClientRequestHeadersgetHeaders()WebTargetgetTarget()URIgetURI()Responsehead()Invoke HTTP HEAD method for the current request synchronously.Invocation.Builderheader(String name, Object value)Add an arbitrary header.Invocation.Builderheaders(MultivaluedMap<String,Object> headers)Replaces all existing headers with the newly supplied headers.booleanisChunked()Responsemethod(String name)Invoke an arbitrary method for the current request synchronously.Responsemethod(String name, Entity<?> entity)Invoke an arbitrary method for the current request synchronously.<T> Tmethod(String name, Entity<?> entity, GenericType<T> responseType)Invoke an arbitrary method for the current request synchronously.<T> Tmethod(String name, Entity<?> entity, Class<T> responseType)Invoke an arbitrary method for the current request synchronously.<T> Tmethod(String name, GenericType<T> responseType)Invoke an arbitrary method for the current request synchronously.<T> Tmethod(String name, Class<T> responseType)Invoke an arbitrary method for the current request synchronously.Responseoptions()Invoke HTTP OPTIONS method for the current request synchronously.<T> Toptions(GenericType<T> responseType)Invoke HTTP OPTIONS method for the current request synchronously.<T> Toptions(Class<T> responseType)Invoke HTTP OPTIONS method for the current request synchronously.Responsepatch(Entity<?> entity)<T> Tpatch(Entity<?> entity, GenericType<T> responseType)<T> Tpatch(Entity<?> entity, Class<T> responseType)Responsepost(Entity<?> entity)Invoke HTTP POST method for the current request synchronously.<T> Tpost(Entity<?> entity, GenericType<T> responseType)Invoke HTTP POST method for the current request synchronously.<T> Tpost(Entity<?> entity, Class<T> responseType)Invoke HTTP POST method for the current request synchronously.Invocation.Builderproperty(String name, Object value)Set a new property in the context of a request represented by this invocation builder.Responseput(Entity<?> entity)Invoke HTTP PUT method for the current request synchronously.<T> Tput(Entity<?> entity, GenericType<T> responseType)Invoke HTTP PUT method for the current request synchronously.<T> Tput(Entity<?> entity, Class<T> responseType)Invoke HTTP PUT method for the current request synchronously.CompletionStageRxInvokerrx()Access the default reactive invoker based onCompletionStage.<T extends RxInvoker>
Trx(Class<T> clazz)Access a reactive invoker based on aRxInvokersubclass provider.voidsetChunked(boolean chunked)voidsetClientInvocation(ClientInvocation invocation)voidsetTarget(WebTarget target)Responsetrace()Invoke HTTP TRACE method for the current request synchronously.<T> Ttrace(GenericType<T> responseType)Invoke HTTP TRACE method for the current request synchronously.<T> Ttrace(Class<T> responseType)Invoke HTTP TRACE method for the current request synchronously.
-
-
-
Field Detail
-
invocation
protected ClientInvocation invocation
-
-
Constructor Detail
-
ClientInvocationBuilder
public ClientInvocationBuilder(ResteasyClient client, URI uri, ClientConfiguration configuration)
-
-
Method Detail
-
createClientInvocation
protected ClientInvocation createClientInvocation(ResteasyClient client, URI uri, ClientRequestHeaders headers, ClientConfiguration parent)
-
createClientInvocation
protected ClientInvocation createClientInvocation(ClientInvocation invocation)
-
getHeaders
public ClientRequestHeaders getHeaders()
-
setClientInvocation
public void setClientInvocation(ClientInvocation invocation)
-
getClientInvocation
public ClientInvocation getClientInvocation()
exposes the client invocation for easier integration with other libraries- Returns:
- the underlying client invocation
-
accept
public Invocation.Builder accept(String... mediaTypes)
Description copied from interface:Invocation.BuilderAdd the accepted response media types.- Specified by:
acceptin interfaceInvocation.Builder- Parameters:
mediaTypes- accepted response media types.- Returns:
- the updated builder.
-
accept
public Invocation.Builder accept(MediaType... mediaTypes)
Description copied from interface:Invocation.BuilderAdd the accepted response media types.- Specified by:
acceptin interfaceInvocation.Builder- Parameters:
mediaTypes- accepted response media types.- Returns:
- the updated builder.
-
acceptLanguage
public Invocation.Builder acceptLanguage(Locale... locales)
Description copied from interface:Invocation.BuilderAdd acceptable languages.- Specified by:
acceptLanguagein interfaceInvocation.Builder- Parameters:
locales- an array of the acceptable languages.- Returns:
- the updated builder.
-
acceptLanguage
public Invocation.Builder acceptLanguage(String... locales)
Description copied from interface:Invocation.BuilderAdd acceptable languages.- Specified by:
acceptLanguagein interfaceInvocation.Builder- Parameters:
locales- an array of the acceptable languages.- Returns:
- the updated builder.
-
acceptEncoding
public Invocation.Builder acceptEncoding(String... encodings)
Description copied from interface:Invocation.BuilderAdd acceptable encodings.- Specified by:
acceptEncodingin interfaceInvocation.Builder- Parameters:
encodings- an array of the acceptable encodings.- Returns:
- the updated builder.
-
cookie
public Invocation.Builder cookie(Cookie cookie)
Description copied from interface:Invocation.BuilderAdd a cookie to be set.- Specified by:
cookiein interfaceInvocation.Builder- Parameters:
cookie- to be set.- Returns:
- the updated builder.
-
cookie
public Invocation.Builder cookie(String name, String value)
Description copied from interface:Invocation.BuilderAdd a cookie to be set.- Specified by:
cookiein interfaceInvocation.Builder- Parameters:
name- the name of the cookie.value- the value of the cookie.- Returns:
- the updated builder.
-
cacheControl
public Invocation.Builder cacheControl(CacheControl cacheControl)
Description copied from interface:Invocation.BuilderSet the cache control data of the message.- Specified by:
cacheControlin interfaceInvocation.Builder- Parameters:
cacheControl- the cache control directives, ifnullany existing cache control directives will be removed.- Returns:
- the updated builder.
-
header
public Invocation.Builder header(String name, Object value)
Description copied from interface:Invocation.BuilderAdd an arbitrary header.- Specified by:
headerin interfaceInvocation.Builder- Parameters:
name- the name of the headervalue- the value of the header, the header will be serialized using aRuntimeDelegate.HeaderDelegateif one is available viaRuntimeDelegate.createHeaderDelegate(java.lang.Class)for the class ofvalueor using itstoStringmethod if a header delegate is not available. Ifvalueisnullthen all current headers of the same name will be removed.- Returns:
- the updated builder.
-
headers
public Invocation.Builder headers(MultivaluedMap<String,Object> headers)
Description copied from interface:Invocation.BuilderReplaces all existing headers with the newly supplied headers.- Specified by:
headersin interfaceInvocation.Builder- Parameters:
headers- new headers to be set, ifnullall existing headers will be removed.- Returns:
- the updated builder.
-
build
public Invocation build(String method)
Description copied from interface:Invocation.BuilderBuild a request invocation using an arbitrary request method name.- Specified by:
buildin interfaceInvocation.Builder- Parameters:
method- request method name.- Returns:
- invocation encapsulating the built request.
-
build
public Invocation build(String method, Entity<?> entity)
Description copied from interface:Invocation.BuilderBuild a request invocation using an arbitrary request method name and request entity.- Specified by:
buildin interfaceInvocation.Builder- Parameters:
method- request method name.entity- request entity, including it's fullVariantinformation. Any variant-related HTTP headers previously set (namelyContent-Type,Content-LanguageandContent-Encoding) will be overwritten using the entity variant information.- Returns:
- invocation encapsulating the built request.
-
buildGet
public Invocation buildGet()
Description copied from interface:Invocation.BuilderBuild a GET request invocation.- Specified by:
buildGetin interfaceInvocation.Builder- Returns:
- invocation encapsulating the built GET request.
-
buildDelete
public Invocation buildDelete()
Description copied from interface:Invocation.BuilderBuild a DELETE request invocation.- Specified by:
buildDeletein interfaceInvocation.Builder- Returns:
- invocation encapsulating the built DELETE request.
-
buildPost
public Invocation buildPost(Entity<?> entity)
Description copied from interface:Invocation.BuilderBuild a POST request invocation.- Specified by:
buildPostin interfaceInvocation.Builder- Parameters:
entity- request entity, including it's fullVariantinformation. Any variant-related HTTP headers previously set (namelyContent-Type,Content-LanguageandContent-Encoding) will be overwritten using the entity variant information.- Returns:
- invocation encapsulating the built POST request.
-
buildPut
public Invocation buildPut(Entity<?> entity)
Description copied from interface:Invocation.BuilderBuild a PUT request invocation.- Specified by:
buildPutin interfaceInvocation.Builder- Parameters:
entity- request entity, including it's fullVariantinformation. Any variant-related HTTP headers previously set (namelyContent-Type,Content-LanguageandContent-Encoding) will be overwritten using the entity variant information.- Returns:
- invocation encapsulating the built PUT request.
-
async
public AsyncInvoker async()
Description copied from interface:Invocation.BuilderAccess the asynchronous uniform request invocation interface to asynchronously invoke the built request.- Specified by:
asyncin interfaceInvocation.Builder- Returns:
- asynchronous uniform request invocation interface.
-
get
public Response get()
Description copied from interface:SyncInvokerInvoke HTTP GET method for the current request synchronously.- Specified by:
getin interfaceSyncInvoker- Returns:
- invocation response.
-
get
public <T> T get(Class<T> responseType)
Description copied from interface:SyncInvokerInvoke HTTP GET method for the current request synchronously.- Specified by:
getin interfaceSyncInvoker- Type Parameters:
T- response entity type.- Parameters:
responseType- Java type the response entity will be converted to.- Returns:
- invocation response.
-
get
public <T> T get(GenericType<T> responseType)
Description copied from interface:SyncInvokerInvoke HTTP GET method for the current request synchronously.- Specified by:
getin interfaceSyncInvoker- Type Parameters:
T- generic response entity type.- Parameters:
responseType- representation of a generic Java type the response entity will be converted to.- Returns:
- invocation response.
-
put
public Response put(Entity<?> entity)
Description copied from interface:SyncInvokerInvoke HTTP PUT method for the current request synchronously.- Specified by:
putin interfaceSyncInvoker- Parameters:
entity- request entity, including it's fullVariantinformation. Any variant-related HTTP headers previously set (namelyContent-Type,Content-LanguageandContent-Encoding) will be overwritten using the entity variant information.- Returns:
- invocation response.
-
put
public <T> T put(Entity<?> entity, Class<T> responseType)
Description copied from interface:SyncInvokerInvoke HTTP PUT method for the current request synchronously.- Specified by:
putin interfaceSyncInvoker- Type Parameters:
T- response entity type.- Parameters:
entity- request entity, including it's fullVariantinformation. Any variant-related HTTP headers previously set (namelyContent-Type,Content-LanguageandContent-Encoding) will be overwritten using the entity variant information.responseType- Java type the response entity will be converted to.- Returns:
- invocation response.
-
put
public <T> T put(Entity<?> entity, GenericType<T> responseType)
Description copied from interface:SyncInvokerInvoke HTTP PUT method for the current request synchronously.- Specified by:
putin interfaceSyncInvoker- Type Parameters:
T- generic response entity type.- Parameters:
entity- request entity, including it's fullVariantinformation. Any variant-related HTTP headers previously set (namelyContent-Type,Content-LanguageandContent-Encoding) will be overwritten using the entity variant information.responseType- representation of a generic Java type the response entity will be converted to.- Returns:
- invocation response.
-
post
public Response post(Entity<?> entity)
Description copied from interface:SyncInvokerInvoke HTTP POST method for the current request synchronously.- Specified by:
postin interfaceSyncInvoker- Parameters:
entity- request entity, including it's fullVariantinformation. Any variant-related HTTP headers previously set (namelyContent-Type,Content-LanguageandContent-Encoding) will be overwritten using the entity variant information.- Returns:
- invocation response.
-
post
public <T> T post(Entity<?> entity, Class<T> responseType)
Description copied from interface:SyncInvokerInvoke HTTP POST method for the current request synchronously.- Specified by:
postin interfaceSyncInvoker- Type Parameters:
T- response entity type.- Parameters:
entity- request entity, including it's fullVariantinformation. Any variant-related HTTP headers previously set (namelyContent-Type,Content-LanguageandContent-Encoding) will be overwritten using the entity variant information.responseType- Java type the response entity will be converted to.- Returns:
- invocation response.
-
post
public <T> T post(Entity<?> entity, GenericType<T> responseType)
Description copied from interface:SyncInvokerInvoke HTTP POST method for the current request synchronously.- Specified by:
postin interfaceSyncInvoker- Type Parameters:
T- generic response entity type.- Parameters:
entity- request entity, including it's fullVariantinformation. Any variant-related HTTP headers previously set (namelyContent-Type,Content-LanguageandContent-Encoding) will be overwritten using the entity variant information.responseType- representation of a generic Java type the response entity will be converted to.- Returns:
- invocation response.
-
delete
public Response delete()
Description copied from interface:SyncInvokerInvoke HTTP DELETE method for the current request synchronously.- Specified by:
deletein interfaceSyncInvoker- Returns:
- invocation response.
-
delete
public <T> T delete(Class<T> responseType)
Description copied from interface:SyncInvokerInvoke HTTP DELETE method for the current request synchronously.- Specified by:
deletein interfaceSyncInvoker- Type Parameters:
T- response entity type.- Parameters:
responseType- Java type the response entity will be converted to.- Returns:
- invocation response.
-
delete
public <T> T delete(GenericType<T> responseType)
Description copied from interface:SyncInvokerInvoke HTTP DELETE method for the current request synchronously.- Specified by:
deletein interfaceSyncInvoker- Type Parameters:
T- generic response entity type.- Parameters:
responseType- representation of a generic Java type the response entity will be converted to.- Returns:
- invocation response.
-
head
public Response head()
Description copied from interface:SyncInvokerInvoke HTTP HEAD method for the current request synchronously.- Specified by:
headin interfaceSyncInvoker- Returns:
- invocation response.
-
options
public Response options()
Description copied from interface:SyncInvokerInvoke HTTP OPTIONS method for the current request synchronously.- Specified by:
optionsin interfaceSyncInvoker- Returns:
- invocation response.
-
options
public <T> T options(Class<T> responseType)
Description copied from interface:SyncInvokerInvoke HTTP OPTIONS method for the current request synchronously.- Specified by:
optionsin interfaceSyncInvoker- Type Parameters:
T- response entity type.- Parameters:
responseType- Java type the response entity will be converted to.- Returns:
- invocation response.
-
options
public <T> T options(GenericType<T> responseType)
Description copied from interface:SyncInvokerInvoke HTTP OPTIONS method for the current request synchronously.- Specified by:
optionsin interfaceSyncInvoker- Type Parameters:
T- generic response entity type.- Parameters:
responseType- representation of a generic Java type the response entity will be converted to.- Returns:
- invocation response.
-
trace
public Response trace()
Description copied from interface:SyncInvokerInvoke HTTP TRACE method for the current request synchronously.- Specified by:
tracein interfaceSyncInvoker- Returns:
- invocation response.
-
trace
public <T> T trace(Class<T> responseType)
Description copied from interface:SyncInvokerInvoke HTTP TRACE method for the current request synchronously.- Specified by:
tracein interfaceSyncInvoker- Type Parameters:
T- response entity type.- Parameters:
responseType- Java type the response entity will be converted to.- Returns:
- invocation response.
-
trace
public <T> T trace(GenericType<T> responseType)
Description copied from interface:SyncInvokerInvoke HTTP TRACE method for the current request synchronously.- Specified by:
tracein interfaceSyncInvoker- Type Parameters:
T- generic response entity type.- Parameters:
responseType- representation of a generic Java type the response entity will be converted to.- Returns:
- invocation response.
-
method
public Response method(String name)
Description copied from interface:SyncInvokerInvoke an arbitrary method for the current request synchronously.- Specified by:
methodin interfaceSyncInvoker- Parameters:
name- method name.- Returns:
- invocation response.
-
method
public <T> T method(String name, Class<T> responseType)
Description copied from interface:SyncInvokerInvoke an arbitrary method for the current request synchronously.- Specified by:
methodin interfaceSyncInvoker- Type Parameters:
T- response entity type.- Parameters:
name- method name.responseType- Java type the response entity will be converted to.- Returns:
- invocation response.
-
method
public <T> T method(String name, GenericType<T> responseType)
Description copied from interface:SyncInvokerInvoke an arbitrary method for the current request synchronously.- Specified by:
methodin interfaceSyncInvoker- Type Parameters:
T- generic response entity type.- Parameters:
name- method name.responseType- representation of a generic Java type the response entity will be converted to.- Returns:
- invocation response.
-
method
public Response method(String name, Entity<?> entity)
Description copied from interface:SyncInvokerInvoke an arbitrary method for the current request synchronously.- Specified by:
methodin interfaceSyncInvoker- Parameters:
name- method name.entity- request entity, including it's fullVariantinformation. Any variant-related HTTP headers previously set (namelyContent-Type,Content-LanguageandContent-Encoding) will be overwritten using the entity variant information.- Returns:
- invocation response.
-
method
public <T> T method(String name, Entity<?> entity, Class<T> responseType)
Description copied from interface:SyncInvokerInvoke an arbitrary method for the current request synchronously.- Specified by:
methodin interfaceSyncInvoker- Type Parameters:
T- response entity type.- Parameters:
name- method name.entity- request entity, including it's fullVariantinformation. Any variant-related HTTP headers previously set (namelyContent-Type,Content-LanguageandContent-Encoding) will be overwritten using the entity variant information.responseType- Java type the response entity will be converted to.- Returns:
- invocation response.
-
method
public <T> T method(String name, Entity<?> entity, GenericType<T> responseType)
Description copied from interface:SyncInvokerInvoke an arbitrary method for the current request synchronously.- Specified by:
methodin interfaceSyncInvoker- Type Parameters:
T- generic response entity type.- Parameters:
name- method name.entity- request entity, including it's fullVariantinformation. Any variant-related HTTP headers previously set (namelyContent-Type,Content-LanguageandContent-Encoding) will be overwritten using the entity variant information.responseType- representation of a generic Java type the response entity will be converted to.- Returns:
- invocation response.
-
property
public Invocation.Builder property(String name, Object value)
Description copied from interface:Invocation.BuilderSet a new property in the context of a request represented by this invocation builder.The property is available for a later retrieval via
ClientRequestContext.getProperty(String)orInterceptorContext.getProperty(String). If a property with a given name is already set in the request context, the existing value of the property will be updated. Setting anullvalue into a property effectively removes the property from the request property bag.- Specified by:
propertyin interfaceInvocation.Builder- Parameters:
name- property name.value- (new) property value.nullvalue removes the property with the given name.- Returns:
- the updated builder.
- See Also:
Invocation.property(String, Object)
-
isChunked
public boolean isChunked()
-
setChunked
public void setChunked(boolean chunked)
-
rx
public CompletionStageRxInvoker rx()
Description copied from interface:Invocation.BuilderAccess the default reactive invoker based onCompletionStage.- Specified by:
rxin interfaceInvocation.Builder- Returns:
- default reactive invoker instance.
- See Also:
Invocation.Builder.rx(Class)
-
rx
public <T extends RxInvoker> T rx(Class<T> clazz)
Description copied from interface:Invocation.BuilderAccess a reactive invoker based on aRxInvokersubclass provider. Note that correspondingRxInvokerProvidermust be registered in the client runtime.This method is an extension point for JAX-RS implementations to support other types representing asynchronous computations.
- Specified by:
rxin interfaceInvocation.Builder- Type Parameters:
T- generic invoker type.- Parameters:
clazz-RxInvokersubclass.- Returns:
- reactive invoker instance.
- See Also:
Configurable.register(Class)
-
patch
public <T> T patch(Entity<?> entity, GenericType<T> responseType)
-
getURI
public URI getURI()
-
getTarget
public WebTarget getTarget()
-
setTarget
public void setTarget(WebTarget target)
-
-