public class ClientInvocation extends Object implements Invocation
Invocation.Builder
Modifier and Type | Field and Description |
---|---|
protected WebTarget |
actualTarget |
protected boolean |
chunked |
protected ResteasyClient |
client |
protected ClientInvoker |
clientInvoker |
protected ClientConfiguration |
configuration |
protected DelegatingOutputStream |
delegatingOutputStream |
protected Object |
entity |
protected Annotation[] |
entityAnnotations |
protected Class<?> |
entityClass |
protected Type |
entityGenericType |
protected OutputStream |
entityStream |
protected ClientRequestHeaders |
headers |
protected String |
method |
protected URI |
uri |
Constructor and Description |
---|
ClientInvocation(ResteasyClient client,
URI uri,
ClientRequestHeaders headers,
ClientConfiguration parent) |
Modifier and Type | Method and Description |
---|---|
static <T> T |
extractResult(GenericType<T> responseType,
Response response,
Annotation[] annotations)
Extracts result from response throwing an appropriate exception if not a successful response.
|
protected ClientResponse |
filterResponse(ClientRequestContextImpl requestContext,
ClientResponse response) |
WebTarget |
getActualTarget() |
ResteasyClient |
getClient() |
ClientConfiguration |
getClientConfiguration() |
ClientInvoker |
getClientInvoker() |
Configuration |
getConfiguration() |
DelegatingOutputStream |
getDelegatingOutputStream() |
Object |
getEntity() |
Annotation[] |
getEntityAnnotations() |
Class<?> |
getEntityClass() |
Type |
getEntityGenericType() |
OutputStream |
getEntityStream() |
ClientRequestHeaders |
getHeaders() |
String |
getMethod() |
Map<String,Object> |
getMutableProperties() |
ClientRequestFilter[] |
getRequestFilters() |
ClientResponseFilter[] |
getResponseFilters() |
URI |
getUri() |
WriterInterceptor[] |
getWriterInterceptors() |
static <T> T |
handleErrorStatus(Response response)
Throw an exception.
|
ClientResponse |
invoke()
Synchronously invoke the request and receive a response back.
|
<T> T |
invoke(Class<T> responseType)
Synchronously invoke the request and receive a response of the specified
type back.
|
<T> T |
invoke(GenericType<T> responseType)
Synchronously invoke the request and receive a response of the specified
generic type back.
|
boolean |
isChunked() |
Invocation |
property(String name,
Object value)
Set a new property in the context of a request represented by this invocation.
|
void |
setActualTarget(WebTarget target) |
void |
setChunked(boolean chunked) |
void |
setClientInvoker(ClientInvoker clientInvoker) |
void |
setDelegatingOutputStream(DelegatingOutputStream delegatingOutputStream) |
void |
setEntity(Entity<?> entity) |
void |
setEntityAnnotations(Annotation[] entityAnnotations) |
void |
setEntityObject(Object ent) |
void |
setEntityStream(OutputStream entityStream) |
void |
setHeaders(ClientRequestHeaders headers) |
void |
setMethod(String method) |
void |
setUri(URI uri) |
Future<Response> |
submit()
Submit the request for an asynchronous invocation and receive a future
response 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.
|
<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(InvocationCallback<T> callback)
Submit the request for an asynchronous invocation and register an
InvocationCallback to process the future result of the invocation. |
void |
writeRequestBody(OutputStream outputStream) |
protected ResteasyClient client
protected ClientRequestHeaders headers
protected String method
protected Object entity
protected Type entityGenericType
protected Class<?> entityClass
protected Annotation[] entityAnnotations
protected ClientConfiguration configuration
protected URI uri
protected boolean chunked
protected ClientInvoker clientInvoker
protected WebTarget actualTarget
protected DelegatingOutputStream delegatingOutputStream
protected OutputStream entityStream
public ClientInvocation(ResteasyClient client, URI uri, ClientRequestHeaders headers, ClientConfiguration parent)
public static <T> T extractResult(GenericType<T> responseType, Response response, Annotation[] annotations)
T
- typeresponseType
- generic typeresponse
- response entityannotations
- array of annotationspublic static <T> T handleErrorStatus(Response response)
T
- typeresponse
- response entitypublic ClientConfiguration getClientConfiguration()
public ResteasyClient getClient()
public DelegatingOutputStream getDelegatingOutputStream()
public void setDelegatingOutputStream(DelegatingOutputStream delegatingOutputStream)
public OutputStream getEntityStream()
public void setEntityStream(OutputStream entityStream)
public URI getUri()
public void setUri(URI uri)
public Annotation[] getEntityAnnotations()
public void setEntityAnnotations(Annotation[] entityAnnotations)
public String getMethod()
public void setMethod(String method)
public void setHeaders(ClientRequestHeaders headers)
public Object getEntity()
public Type getEntityGenericType()
public Class<?> getEntityClass()
public ClientRequestHeaders getHeaders()
public void setEntity(Entity<?> entity)
public void setEntityObject(Object ent)
public void writeRequestBody(OutputStream outputStream) throws IOException
IOException
public WriterInterceptor[] getWriterInterceptors()
public ClientRequestFilter[] getRequestFilters()
public ClientResponseFilter[] getResponseFilters()
public Configuration getConfiguration()
public boolean isChunked()
public void setChunked(boolean chunked)
public ClientResponse invoke()
Invocation
invoke
in interface Invocation
response
object as a result of the request
invocation.public <T> T invoke(Class<T> responseType)
Invocation
invoke
in interface Invocation
T
- response typeresponseType
- Java type the response should be converted into.public <T> T invoke(GenericType<T> responseType)
Invocation
invoke
in interface Invocation
T
- generic response typeresponseType
- type literal representing a generic Java type the
response should be converted into.public Future<Response> submit()
Invocation
Note that calling the Future.get()
method on the returned
Future
instance may throw an ExecutionException
that wraps a ProcessingException
thrown in case of an invocation processing
failure.
In case a processing of a properly received response fails, the wrapped processing exception
will be of ResponseProcessingException
type and will contain the Response
instance whose processing has failed.
submit
in interface Invocation
response
object as a result of the request
invocation.public <T> Future<T> submit(Class<T> responseType)
Invocation
Note that calling the Future.get()
method on the returned
Future
instance may throw an ExecutionException
that wraps either a ProcessingException
thrown in case of an invocation processing
failure or a WebApplicationException
or one of its subclasses thrown in case the
received response status code is not successful
and the specified response type is not Response
.
In case a processing of a properly received response fails, the wrapped processing exception
will be of ResponseProcessingException
type and will contain the Response
instance whose processing has failed.
submit
in interface Invocation
T
- response typeresponseType
- Java type the response should be converted into.public <T> Future<T> submit(GenericType<T> responseType)
Invocation
Note that calling the Future.get()
method on the returned
Future
instance may throw an ExecutionException
that wraps either a ProcessingException
thrown in case of an invocation processing
failure or a WebApplicationException
or one of its subclasses thrown in case the
received response status code is not successful
and the specified response type is not Response
.
In case a processing of a properly received response fails, the wrapped processing exception
will be of ResponseProcessingException
type and will contain the Response
instance whose processing has failed.
submit
in interface Invocation
T
- generic response typeresponseType
- type literal representing a generic Java type the
response should be converted into.public <T> Future<T> submit(InvocationCallback<T> callback)
Invocation
InvocationCallback
to process the future result of the invocation.
Note that calling the Future.get()
method on the returned
Future
instance may throw an ExecutionException
that wraps either a ProcessingException
thrown in case of an invocation processing
failure or a WebApplicationException
or one of its subclasses thrown in case the
received response status code is not successful
and the generic type of the supplied response callback is not
Response
.
In case a processing of a properly received response fails, the wrapped processing exception
will be of ResponseProcessingException
type and will contain the Response
instance whose processing has failed.
submit
in interface Invocation
T
- response typecallback
- invocation callback for asynchronous processing of the
request invocation result.public Invocation property(String name, Object value)
Invocation
The property is available for a later retrieval via ClientRequestContext.getProperty(String)
or InterceptorContext.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 a null
value into a property effectively removes the property
from the request property bag.
property
in interface Invocation
name
- property name.value
- (new) property value. null
value removes the property
with the given name.Invocation.Builder.property(String, Object)
public ClientInvoker getClientInvoker()
public void setClientInvoker(ClientInvoker clientInvoker)
protected ClientResponse filterResponse(ClientRequestContextImpl requestContext, ClientResponse response)
public void setActualTarget(WebTarget target)
public WebTarget getActualTarget()
Copyright © 2020 JBoss by Red Hat. All rights reserved.