Class ClientInvocation
- java.lang.Object
-
- org.jboss.resteasy.client.jaxrs.internal.ClientInvocation
-
- All Implemented Interfaces:
Invocation
public class ClientInvocation extends Object implements Invocation
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jakarta.ws.rs.client.Invocation
Invocation.Builder
-
-
Field Summary
Fields Modifier and Type Field Description protected WebTargetactualTargetprotected booleanchunkedprotected ResteasyClientclientprotected ClientInvokerclientInvokerprotected ClientConfigurationconfigurationprotected DelegatingOutputStreamdelegatingOutputStreamprotected Objectentityprotected Annotation[]entityAnnotationsprotected Class<?>entityClassprotected TypeentityGenericTypeprotected OutputStreamentityStreamprotected ClientRequestHeadersheadersprotected Stringmethodprotected RESTEasyTracingLoggertracingLoggerprotected URIuri
-
Constructor Summary
Constructors Modifier Constructor Description protectedClientInvocation(ClientInvocation clientInvocation)ClientInvocation(ResteasyClient client, URI uri, ClientRequestHeaders headers, ClientConfiguration parent)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ExecutorServiceasyncInvocationExecutor()static <T> TextractResult(GenericType<T> responseType, Response response, Annotation[] annotations)Extracts result from response throwing an appropriate exception if not a successful response.protected ClientResponsefilterRequest(ClientRequestContextImpl requestContext)protected ClientResponsefilterResponse(ClientRequestContextImpl requestContext, ClientResponse response)WebTargetgetActualTarget()ResteasyClientgetClient()ClientConfigurationgetClientConfiguration()ClientInvokergetClientInvoker()ConfigurationgetConfiguration()DelegatingOutputStreamgetDelegatingOutputStream()ObjectgetEntity()Annotation[]getEntityAnnotations()Class<?>getEntityClass()TypegetEntityGenericType()OutputStreamgetEntityStream()protected static <T> AsyncClientHttpEngine.ResultExtractor<T>getGenericTypeExtractor(GenericType<T> responseType)ClientRequestHeadersgetHeaders()StringgetMethod()Map<String,Object>getMutableProperties()ClientRequestFilter[]getRequestFilters()ClientResponseFilter[]getResponseFilters()protected static <T> AsyncClientHttpEngine.ResultExtractor<T>getResponseTypeExtractor(Class<T> responseType)RESTEasyTracingLoggergetTracingLogger()URIgetUri()WriterInterceptor[]getWriterInterceptors()static <T> ThandleErrorStatus(Response response)Throw an exception.ClientResponseinvoke()Synchronously invoke the request and receive a response back.<T> Tinvoke(GenericType<T> responseType)Synchronously invoke the request and receive a response of the specified generic type back.<T> Tinvoke(Class<T> responseType)Synchronously invoke the request and receive a response of the specified type back.booleanisChunked()Invocationproperty(String name, Object value)Set a new property in the context of a request represented by this invocation.Optional<org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.ReactiveInvocation>reactive()If the client's HTTP engine implementsReactiveClientHttpEnginethen you can access the latter'sPublishervia this method.voidsetActualTarget(WebTarget target)voidsetChunked(boolean chunked)voidsetClientInvoker(ClientInvoker clientInvoker)voidsetDelegatingOutputStream(DelegatingOutputStream delegatingOutputStream)voidsetEntity(Entity<?> entity)voidsetEntityAnnotations(Annotation[] entityAnnotations)voidsetEntityObject(Object ent)voidsetEntityStream(OutputStream entityStream)voidsetHeaders(ClientRequestHeaders headers)voidsetMethod(String method)voidsetUri(URI uri)Future<Response>submit()Submit the request for an asynchronous invocation and receive a future response back.<T> Future<T>submit(InvocationCallback<T> callback)Submit the request for an asynchronous invocation and register anInvocationCallbackto process the future result of the invocation.<T> Future<T>submit(GenericType<T> responseType)Submit the request for an asynchronous invocation and receive a future response of the specified generic type back.<T> Future<T>submit(Class<T> responseType)Submit the request for an asynchronous invocation and receive a future response of the specified type back.CompletableFuture<Response>submitCF()<T> CompletableFuture<T>submitCF(GenericType<T> responseType)<T> CompletableFuture<T>submitCF(Class<T> responseType)voidwriteRequestBody(OutputStream outputStream)
-
-
-
Field Detail
-
tracingLogger
protected RESTEasyTracingLogger tracingLogger
-
client
protected ResteasyClient client
-
headers
protected ClientRequestHeaders headers
-
method
protected String method
-
entity
protected Object entity
-
entityGenericType
protected Type entityGenericType
-
entityClass
protected Class<?> entityClass
-
entityAnnotations
protected Annotation[] entityAnnotations
-
configuration
protected ClientConfiguration configuration
-
uri
protected URI uri
-
chunked
protected boolean chunked
-
clientInvoker
protected ClientInvoker clientInvoker
-
actualTarget
protected WebTarget actualTarget
-
delegatingOutputStream
protected DelegatingOutputStream delegatingOutputStream
-
entityStream
protected OutputStream entityStream
-
-
Constructor Detail
-
ClientInvocation
public ClientInvocation(ResteasyClient client, URI uri, ClientRequestHeaders headers, ClientConfiguration parent)
-
ClientInvocation
protected ClientInvocation(ClientInvocation clientInvocation)
-
-
Method Detail
-
extractResult
public static <T> T extractResult(GenericType<T> responseType, Response response, Annotation[] annotations)
Extracts result from response throwing an appropriate exception if not a successful response.- Type Parameters:
T- type- Parameters:
responseType- generic typeresponse- response entityannotations- array of annotations- Returns:
- extracted result of type T
-
handleErrorStatus
public static <T> T handleErrorStatus(Response response)
Throw an exception. Expecting a status of 400 or greater.- Type Parameters:
T- type- Parameters:
response- response entity- Returns:
- unreachable
-
getClientConfiguration
public ClientConfiguration getClientConfiguration()
-
getClient
public ResteasyClient getClient()
-
getDelegatingOutputStream
public DelegatingOutputStream getDelegatingOutputStream()
-
setDelegatingOutputStream
public void setDelegatingOutputStream(DelegatingOutputStream delegatingOutputStream)
-
getEntityStream
public OutputStream getEntityStream()
-
setEntityStream
public void setEntityStream(OutputStream entityStream)
-
getUri
public URI getUri()
-
setUri
public void setUri(URI uri)
-
getEntityAnnotations
public Annotation[] getEntityAnnotations()
-
setEntityAnnotations
public void setEntityAnnotations(Annotation[] entityAnnotations)
-
getMethod
public String getMethod()
-
setMethod
public void setMethod(String method)
-
setHeaders
public void setHeaders(ClientRequestHeaders headers)
-
getEntity
public Object getEntity()
-
getEntityGenericType
public Type getEntityGenericType()
-
getEntityClass
public Class<?> getEntityClass()
-
getHeaders
public ClientRequestHeaders getHeaders()
-
setEntity
public void setEntity(Entity<?> entity)
-
setEntityObject
public void setEntityObject(Object ent)
-
writeRequestBody
public void writeRequestBody(OutputStream outputStream) throws IOException
- Throws:
IOException
-
getWriterInterceptors
public WriterInterceptor[] getWriterInterceptors()
-
getRequestFilters
public ClientRequestFilter[] getRequestFilters()
-
getResponseFilters
public ClientResponseFilter[] getResponseFilters()
-
getConfiguration
public Configuration getConfiguration()
-
isChunked
public boolean isChunked()
-
setChunked
public void setChunked(boolean chunked)
-
invoke
public ClientResponse invoke()
Description copied from interface:InvocationSynchronously invoke the request and receive a response back.- Specified by:
invokein interfaceInvocation- Returns:
responseobject as a result of the request invocation.
-
invoke
public <T> T invoke(Class<T> responseType)
Description copied from interface:InvocationSynchronously invoke the request and receive a response of the specified type back.- Specified by:
invokein interfaceInvocation- Type Parameters:
T- response type- Parameters:
responseType- Java type the response should be converted into.- Returns:
- response object of the specified type as a result of the request invocation.
-
invoke
public <T> T invoke(GenericType<T> responseType)
Description copied from interface:InvocationSynchronously invoke the request and receive a response of the specified generic type back.- Specified by:
invokein interfaceInvocation- Type Parameters:
T- generic response type- Parameters:
responseType- type literal representing a generic Java type the response should be converted into.- Returns:
- response object of the specified generic type as a result of the request invocation.
-
submit
public Future<Response> submit()
Description copied from interface:InvocationSubmit the request for an asynchronous invocation and receive a future response back.Note that calling the
Future.get()method on the returnedFutureinstance may throw anExecutionExceptionthat wraps aProcessingExceptionthrown in case of an invocation processing failure. In case a processing of a properly received response fails, the wrapped processing exception will be ofResponseProcessingExceptiontype and will contain theResponseinstance whose processing has failed.- Specified by:
submitin interfaceInvocation- Returns:
- future
responseobject as a result of the request invocation.
-
submit
public <T> Future<T> submit(Class<T> responseType)
Description copied from interface:InvocationSubmit the request for an asynchronous invocation and receive a future response of the specified type back.Note that calling the
Future.get()method on the returnedFutureinstance may throw anExecutionExceptionthat wraps either aProcessingExceptionthrown in case of an invocation processing failure or aWebApplicationExceptionor one of its subclasses thrown in case the received response status code is notsuccessfuland the specified response type is notResponse. In case a processing of a properly received response fails, the wrapped processing exception will be ofResponseProcessingExceptiontype and will contain theResponseinstance whose processing has failed.- Specified by:
submitin interfaceInvocation- Type Parameters:
T- response type- Parameters:
responseType- Java type the response should be converted into.- Returns:
- future response object of the specified type as a result of the request invocation.
-
submit
public <T> Future<T> submit(GenericType<T> responseType)
Description copied from interface:InvocationSubmit the request for an asynchronous invocation and receive a future response of the specified generic type back.Note that calling the
Future.get()method on the returnedFutureinstance may throw anExecutionExceptionthat wraps either aProcessingExceptionthrown in case of an invocation processing failure or aWebApplicationExceptionor one of its subclasses thrown in case the received response status code is notsuccessfuland the specified response type is notResponse. In case a processing of a properly received response fails, the wrapped processing exception will be ofResponseProcessingExceptiontype and will contain theResponseinstance whose processing has failed.- Specified by:
submitin interfaceInvocation- Type Parameters:
T- generic response type- Parameters:
responseType- type literal representing a generic Java type the response should be converted into.- Returns:
- future response object of the specified generic type as a result of the request invocation.
-
submit
public <T> Future<T> submit(InvocationCallback<T> callback)
Description copied from interface:InvocationSubmit the request for an asynchronous invocation and register anInvocationCallbackto process the future result of the invocation.Note that calling the
Future.get()method on the returnedFutureinstance may throw anExecutionExceptionthat wraps either aProcessingExceptionthrown in case of an invocation processing failure or aWebApplicationExceptionor one of its subclasses thrown in case the received response status code is notsuccessfuland the generic type of the supplied response callback is notResponse. In case a processing of a properly received response fails, the wrapped processing exception will be ofResponseProcessingExceptiontype and will contain theResponseinstance whose processing has failed.- Specified by:
submitin interfaceInvocation- Type Parameters:
T- response type- Parameters:
callback- invocation callback for asynchronous processing of the request invocation result.- Returns:
- future response object of the specified type as a result of the request invocation.
-
asyncInvocationExecutor
public ExecutorService asyncInvocationExecutor()
-
getGenericTypeExtractor
protected static <T> AsyncClientHttpEngine.ResultExtractor<T> getGenericTypeExtractor(GenericType<T> responseType)
-
getResponseTypeExtractor
protected static <T> AsyncClientHttpEngine.ResultExtractor<T> getResponseTypeExtractor(Class<T> responseType)
-
submitCF
public CompletableFuture<Response> submitCF()
-
submitCF
public <T> CompletableFuture<T> submitCF(Class<T> responseType)
-
submitCF
public <T> CompletableFuture<T> submitCF(GenericType<T> responseType)
-
reactive
public Optional<org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.ReactiveInvocation> reactive()
If the client's HTTP engine implementsReactiveClientHttpEnginethen you can access the latter'sPublishervia this method.
-
property
public Invocation property(String name, Object value)
Description copied from interface:InvocationSet a new property in the context of a request represented by this invocation.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- Parameters:
name- property name.value- (new) property value.nullvalue removes the property with the given name.- Returns:
- the updated invocation.
- See Also:
Invocation.Builder.property(String, Object)
-
getClientInvoker
public ClientInvoker getClientInvoker()
-
setClientInvoker
public void setClientInvoker(ClientInvoker clientInvoker)
-
filterRequest
protected ClientResponse filterRequest(ClientRequestContextImpl requestContext)
-
filterResponse
protected ClientResponse filterResponse(ClientRequestContextImpl requestContext, ClientResponse response)
-
getTracingLogger
public RESTEasyTracingLogger getTracingLogger()
-
setActualTarget
public void setActualTarget(WebTarget target)
-
getActualTarget
public WebTarget getActualTarget()
-
-