public class
AsyncRestTemplate
extends
InterceptingAsyncHttpAccessor
implements
AsyncRestOperations
Spring's central class for asynchronous client-side HTTP access.
Exposes similar methods as
RestTemplate
, but returns
ListenableFuture
wrappers as opposed to concrete results.
The
AsyncRestTemplate
exposes a synchronous
RestTemplate
via the
getRestOperations()
method and shares its
error handler
and
message converters
with that
RestTemplate
.
Note:
by default
AsyncRestTemplate
relies on
standard JDK facilities to establish HTTP connections. You can switch to use
a different HTTP library such as Apache HttpComponents, Netty, and OkHttp by
using a constructor accepting an
AsyncClientHttpRequestFactory
.
For more information, please refer to the
RestTemplate
API documentation.
Since:
Author:
Arjen Poutsma
See Also:
RestTemplate
AsyncRestTemplate
(
AsyncClientHttpRequestFactory
asyncRequestFactory)
Deprecated.
AsyncRestTemplate
(
AsyncClientHttpRequestFactory
asyncRequestFactory,
ClientHttpRequestFactory
syncRequestFactory)
Deprecated.
Creates a new instance of the
AsyncRestTemplate
using the given
asynchronous and synchronous request factories.
AsyncRestTemplate
(
AsyncClientHttpRequestFactory
requestFactory,
RestTemplate
restTemplate)
Deprecated.
AsyncRestTemplate
(
AsyncListenableTaskExecutor
taskExecutor)
Deprecated.
protected <T>
AsyncRequestCallback
acceptHeaderRequestCallback
(
Class
<T> responseType)
Deprecated.
Returns a request callback implementation that prepares the request
Accept
headers based on the given response type and configured
message converters
.
ListenableFuture
<?>
delete
(
String
url,
Map
<
String
,?> uriVariables)
Deprecated.
Asynchronously delete the resources at the specified URI.
ListenableFuture
<?>
delete
(
String
url,
Object
... uriVariables)
Deprecated.
Asynchronously delete the resources at the specified URI.
ListenableFuture
<?>
delete
(
URI
url)
Deprecated.
Asynchronously delete the resources at the specified URI.
protected <T>
ListenableFuture
<T>
doExecute
(
URI
url,
HttpMethod
method,
AsyncRequestCallback
requestCallback,
ResponseExtractor
<T> responseExtractor)
Deprecated.
Execute the given method on the provided URI.
<T>
ListenableFuture
<
ResponseEntity
<T>>
exchange
(
String
url,
HttpMethod
method,
HttpEntity
<?> requestEntity,
Class
<T> responseType,
Map
<
String
,?> uriVariables)
Deprecated.
Asynchronously execute the HTTP method to the given URI template, writing the
given request entity to the request, and returns the response as
ResponseEntity
.
<T>
ListenableFuture
<
ResponseEntity
<T>>
exchange
(
String
url,
HttpMethod
method,
HttpEntity
<?> requestEntity,
Class
<T> responseType,
Object
... uriVariables)
Deprecated.
Asynchronously execute the HTTP method to the given URI template, writing the
given request entity to the request, and returns the response as
ResponseEntity
.
<T>
ListenableFuture
<
ResponseEntity
<T>>
exchange
(
String
url,
HttpMethod
method,
HttpEntity
<?> requestEntity,
ParameterizedTypeReference
<T> responseType,
Map
<
String
,?> uriVariables)
Deprecated.
Asynchronously execute the HTTP method to the given URI template, writing the given
request entity to the request, and returns the response as
ResponseEntity
.
<T>
ListenableFuture
<
ResponseEntity
<T>>
exchange
(
String
url,
HttpMethod
method,
HttpEntity
<?> requestEntity,
ParameterizedTypeReference
<T> responseType,
Object
... uriVariables)
Deprecated.
Asynchronously execute the HTTP method to the given URI template, writing the given
request entity to the request, and returns the response as
ResponseEntity
.
<T>
ListenableFuture
<
ResponseEntity
<T>>
exchange
(
URI
url,
HttpMethod
method,
HttpEntity
<?> requestEntity,
Class
<T> responseType)
Deprecated.
Asynchronously execute the HTTP method to the given URI template, writing the
given request entity to the request, and returns the response as
ResponseEntity
.
<T>
ListenableFuture
<
ResponseEntity
<T>>
exchange
(
URI
url,
HttpMethod
method,
HttpEntity
<?> requestEntity,
ParameterizedTypeReference
<T> responseType)
Deprecated.
Asynchronously execute the HTTP method to the given URI template, writing the given
request entity to the request, and returns the response as
ResponseEntity
.
<T>
ListenableFuture
<T>
execute
(
String
url,
HttpMethod
method,
AsyncRequestCallback
requestCallback,
ResponseExtractor
<T> responseExtractor,
Map
<
String
,?> uriVariables)
Deprecated.
<T>
ListenableFuture
<T>
execute
(
String
url,
HttpMethod
method,
AsyncRequestCallback
requestCallback,
ResponseExtractor
<T> responseExtractor,
Object
... uriVariables)
Deprecated.
<T>
ListenableFuture
<T>
execute
(
URI
url,
HttpMethod
method,
AsyncRequestCallback
requestCallback,
ResponseExtractor
<T> responseExtractor)
Deprecated.
ResponseErrorHandler
getErrorHandler
()
Deprecated.
Return the error handler.
<T>
ListenableFuture
<
ResponseEntity
<T>>
getForEntity
(
String
url,
Class
<T> responseType,
Map
<
String
,?> uriVariables)
Deprecated.
Asynchronously retrieve a representation by doing a GET on the URI template.
<T>
ListenableFuture
<
ResponseEntity
<T>>
getForEntity
(
String
url,
Class
<T> responseType,
Object
... uriVariables)
Deprecated.
Asynchronously retrieve an entity by doing a GET on the specified URL.
<T>
ListenableFuture
<
ResponseEntity
<T>>
getForEntity
(
URI
url,
Class
<T> responseType)
Deprecated.
Asynchronously retrieve a representation by doing a GET on the URL.
List
<
HttpMessageConverter
<?>>
getMessageConverters
()
Deprecated.
Return the message body converters.
RestOperations
getRestOperations
()
Deprecated.
Expose the synchronous Spring RestTemplate to allow synchronous invocation.
UriTemplateHandler
getUriTemplateHandler
()
Deprecated.
Return the configured URI template handler.
protected
ResponseExtractor
<
HttpHeaders
>
headersExtractor
()
Deprecated.
ListenableFuture
<
HttpHeaders
>
headForHeaders
(
String
url,
Map
<
String
,?> uriVariables)
Deprecated.
Asynchronously retrieve all headers of the resource specified by the URI template.
ListenableFuture
<
HttpHeaders
>
headForHeaders
(
String
url,
Object
... uriVariables)
Deprecated.
Asynchronously retrieve all headers of the resource specified by the URI template.
ListenableFuture
<
HttpHeaders
>
headForHeaders
(
URI
url)
Deprecated.
Asynchronously retrieve all headers of the resource specified by the URL.
protected <T>
AsyncRequestCallback
httpEntityCallback
(
HttpEntity
<T> requestBody)
Deprecated.
Returns a request callback implementation that writes the given object to the
request stream.
protected <T>
AsyncRequestCallback
httpEntityCallback
(
HttpEntity
<T> request,
Type
responseType)
Deprecated.
Returns a request callback implementation that writes the given object to the
request stream.
ListenableFuture
<
Set
<
HttpMethod
>>
optionsForAllow
(
String
url,
Map
<
String
,?> uriVars)
Deprecated.
Asynchronously return the value of the Allow header for the given URI.
ListenableFuture
<
Set
<
HttpMethod
>>
optionsForAllow
(
String
url,
Object
... uriVars)
Deprecated.
Asynchronously return the value of the Allow header for the given URI.
ListenableFuture
<
Set
<
HttpMethod
>>
optionsForAllow
(
URI
url)
Deprecated.
Asynchronously return the value of the Allow header for the given URL.
<T>
ListenableFuture
<
ResponseEntity
<T>>
postForEntity
(
String
url,
HttpEntity
<?> request,
Class
<T> responseType,
Map
<
String
,?> uriVariables)
Deprecated.
Create a new resource by POSTing the given object to the URI template,
and asynchronously returns the response as
ResponseEntity
.
<T>
ListenableFuture
<
ResponseEntity
<T>>
postForEntity
(
String
url,
HttpEntity
<?> request,
Class
<T> responseType,
Object
... uriVariables)
Deprecated.
Create a new resource by POSTing the given object to the URI template,
and asynchronously returns the response as
ResponseEntity
.
<T>
ListenableFuture
<
ResponseEntity
<T>>
postForEntity
(
URI
url,
HttpEntity
<?> request,
Class
<T> responseType)
Deprecated.
Create a new resource by POSTing the given object to the URL,
and asynchronously returns the response as
ResponseEntity
.
ListenableFuture
<
URI
>
postForLocation
(
String
url,
HttpEntity
<?> request,
Map
<
String
,?> uriVars)
Deprecated.
Create a new resource by POSTing the given object to the URI template, and
asynchronously returns the value of the
Location
header.
ListenableFuture
<
URI
>
postForLocation
(
String
url,
HttpEntity
<?> request,
Object
... uriVars)
Deprecated.
Create a new resource by POSTing the given object to the URI template, and
asynchronously returns the value of the
Location
header.
ListenableFuture
<
URI
>
postForLocation
(
URI
url,
HttpEntity
<?> request)
Deprecated.
Create a new resource by POSTing the given object to the URL, and asynchronously
returns the value of the
Location
header.
ListenableFuture
<?>
put
(
String
url,
HttpEntity
<?> request,
Map
<
String
,?> uriVars)
Deprecated.
Creates a new resource by PUTting the given object to URI template.
ListenableFuture
<?>
put
(
String
url,
HttpEntity
<?> request,
Object
... uriVars)
Deprecated.
Create or update a resource by PUTting the given object to the URI.
ListenableFuture
<?>
put
(
URI
url,
HttpEntity
<?> request)
Deprecated.
Creates a new resource by PUTting the given object to URL.
protected <T>
ResponseExtractor
<
ResponseEntity
<T>>
responseEntityExtractor
(
Type
responseType)
Deprecated.
setDefaultUriVariables
(
Map
<
String
,?> defaultUriVariables)
Deprecated.
Configure default URI variable values.
setErrorHandler
(
ResponseErrorHandler
errorHandler)
Deprecated.
Set the error handler.
setMessageConverters
(
List
<
HttpMessageConverter
<?>> messageConverters)
Deprecated.
Set the message body converters to use.
setUriTemplateHandler
(
UriTemplateHandler
handler)
Deprecated.
This property has the same purpose as the corresponding property on the
RestTemplate
.
Methods inherited from class org.springframework.http.client.support.
InterceptingAsyncHttpAccessor
getAsyncRequestFactory
,
getInterceptors
,
setInterceptors
public AsyncRestTemplate()
Deprecated.
AsyncRestTemplate
public AsyncRestTemplate(AsyncListenableTaskExecutor taskExecutor)
Deprecated.
AsyncRestTemplate
public AsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory)
Deprecated.
Create a new instance of the
AsyncRestTemplate
using the given
AsyncClientHttpRequestFactory
.
This constructor will cast the given asynchronous
AsyncClientHttpRequestFactory
to a
ClientHttpRequestFactory
. Since
all implementations of
ClientHttpRequestFactory
provided in Spring also
implement
AsyncClientHttpRequestFactory
, this should not result in a
ClassCastException
.
AsyncRestTemplate
public AsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory,
ClientHttpRequestFactory syncRequestFactory)
Deprecated.
Creates a new instance of the
AsyncRestTemplate
using the given
asynchronous and synchronous request factories.
Parameters:
asyncRequestFactory
- the asynchronous request factory
syncRequestFactory
- the synchronous request factory
AsyncRestTemplate
public AsyncRestTemplate(AsyncClientHttpRequestFactory requestFactory,
RestTemplate restTemplate)
Deprecated.
Parameters:
requestFactory
- the asynchronous request factory to use
restTemplate
- the synchronous template to use
setErrorHandler
public void setErrorHandler(ResponseErrorHandler errorHandler)
Deprecated.
setDefaultUriVariables
public void setDefaultUriVariables(Map<String,?> defaultUriVariables)
Deprecated.
Configure default URI variable values. This is a shortcut for:
DefaultUriTemplateHandler handler = new DefaultUriTemplateHandler();
handler.setDefaultUriVariables(...);
AsyncRestTemplate restTemplate = new AsyncRestTemplate();
restTemplate.setUriTemplateHandler(handler);
Parameters:
defaultUriVariables
- the default URI variable values
Since:
setUriTemplateHandler
public void setUriTemplateHandler(UriTemplateHandler handler)
Deprecated.
Parameters:
handler
- the URI template handler to use
public RestOperations getRestOperations()
Deprecated.
Expose the synchronous Spring RestTemplate to allow synchronous invocation.
Specified by:
getRestOperations
in interface
AsyncRestOperations
setMessageConverters
public void setMessageConverters(List<HttpMessageConverter<?>> messageConverters)
Deprecated.
Set the message body converters to use.
These converters are used to convert from and to HTTP requests and responses.
getMessageConverters
public List<HttpMessageConverter<?>> getMessageConverters()
Deprecated.
Return the message body converters.
getForEntity
public <T> ListenableFuture<ResponseEntity<T>> getForEntity(String url,
Class<T> responseType,
Object... uriVariables)
throws RestClientException
Deprecated.
Asynchronously retrieve an entity by doing a GET on the specified URL.
The response is converted and stored in an
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
Specified by:
getForEntity
in interface
AsyncRestOperations
Parameters:
url
- the URL
responseType
- the type of the return value
uriVariables
- the variables to expand the template
Returns:
the entity wrapped in a
Future
Throws:
RestClientException
getForEntity
public <T> ListenableFuture<ResponseEntity<T>> getForEntity(String url,
Class<T> responseType,
Map<String,?> uriVariables)
throws RestClientException
Deprecated.
Asynchronously retrieve a representation by doing a GET on the URI template.
The response is converted and stored in an
ResponseEntity
.
URI Template variables are expanded using the given map.
Specified by:
getForEntity
in interface
AsyncRestOperations
Parameters:
url
- the URL
responseType
- the type of the return value
uriVariables
- the map containing variables for the URI template
Returns:
the entity wrapped in a
Future
Throws:
RestClientException
getForEntity
public <T> ListenableFuture<ResponseEntity<T>> getForEntity(URI url,
Class<T> responseType)
throws RestClientException
Deprecated.
Asynchronously retrieve a representation by doing a GET on the URL.
The response is converted and stored in an
ResponseEntity
.
Specified by:
getForEntity
in interface
AsyncRestOperations
Parameters:
url
- the URL
responseType
- the type of the return value
Returns:
the entity wrapped in a
Future
Throws:
RestClientException
headForHeaders
public ListenableFuture<HttpHeaders> headForHeaders(String url,
Object... uriVariables)
throws RestClientException
Deprecated.
Asynchronously retrieve all headers of the resource specified by the URI template.
URI Template variables are expanded using the given URI variables, if any.
Specified by:
headForHeaders
in interface
AsyncRestOperations
Parameters:
url
- the URL
uriVariables
- the variables to expand the template
Returns:
all HTTP headers of that resource wrapped in a
Future
Throws:
RestClientException
headForHeaders
public ListenableFuture<HttpHeaders> headForHeaders(String url,
Map<String,?> uriVariables)
throws RestClientException
Deprecated.
Asynchronously retrieve all headers of the resource specified by the URI template.
URI Template variables are expanded using the given map.
Specified by:
headForHeaders
in interface
AsyncRestOperations
Parameters:
url
- the URL
uriVariables
- the map containing variables for the URI template
Returns:
all HTTP headers of that resource wrapped in a
Future
Throws:
RestClientException
headForHeaders
public ListenableFuture<HttpHeaders> headForHeaders(URI url)
throws RestClientException
Deprecated.
Asynchronously retrieve all headers of the resource specified by the URL.
Specified by:
headForHeaders
in interface
AsyncRestOperations
Parameters:
url
- the URL
Returns:
all HTTP headers of that resource wrapped in a
Future
Throws:
RestClientException
public ListenableFuture<URI> postForLocation(String url,
@Nullable
HttpEntity<?> request,
Object... uriVars)
throws RestClientException
Deprecated.
Create a new resource by POSTing the given object to the URI template, and
asynchronously returns the value of the
Location
header. This header
typically indicates where the new resource is stored.
URI Template variables are expanded using the given URI variables, if any.
Specified by:
postForLocation
in interface
AsyncRestOperations
Parameters:
url
- the URL
request
- the Object to be POSTed (may be
null
)
uriVars
- the variables to expand the template
Returns:
the value for the
Location
header wrapped in a
Future
Throws:
RestClientException
See Also:
HttpEntity
public ListenableFuture<URI> postForLocation(String url,
@Nullable
HttpEntity<?> request,
Map<String,?> uriVars)
throws RestClientException
Deprecated.
Create a new resource by POSTing the given object to the URI template, and
asynchronously returns the value of the
Location
header. This header
typically indicates where the new resource is stored.
URI Template variables are expanded using the given map.
Specified by:
postForLocation
in interface
AsyncRestOperations
Parameters:
url
- the URL
request
- the Object to be POSTed (may be
null
)
uriVars
- the variables to expand the template
Returns:
the value for the
Location
header wrapped in a
Future
Throws:
RestClientException
See Also:
HttpEntity
throws
RestClientException
Deprecated.
Create a new resource by POSTing the given object to the URL, and asynchronously
returns the value of the
Location
header. This header typically indicates
where the new resource is stored.
Specified by:
postForLocation
in interface
AsyncRestOperations
Parameters:
url
- the URL
request
- the Object to be POSTed (may be
null
)
Returns:
the value for the
Location
header wrapped in a
Future
Throws:
RestClientException
See Also:
HttpEntity
postForEntity
public <T> ListenableFuture<ResponseEntity<T>> postForEntity(String url,
@Nullable
HttpEntity<?> request,
Class<T> responseType,
Object... uriVariables)
throws RestClientException
Deprecated.
Create a new resource by POSTing the given object to the URI template,
and asynchronously returns the response as
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
Specified by:
postForEntity
in interface
AsyncRestOperations
Parameters:
url
- the URL
request
- the Object to be POSTed (may be
null
)
uriVariables
- the variables to expand the template
Returns:
the entity wrapped in a
Future
Throws:
RestClientException
See Also:
HttpEntity
postForEntity
public <T> ListenableFuture<ResponseEntity<T>> postForEntity(String url,
@Nullable
HttpEntity<?> request,
Class<T> responseType,
Map<String,?> uriVariables)
throws RestClientException
Deprecated.
Create a new resource by POSTing the given object to the URI template,
and asynchronously returns the response as
ResponseEntity
.
URI Template variables are expanded using the given map.
Specified by:
postForEntity
in interface
AsyncRestOperations
Parameters:
url
- the URL
request
- the Object to be POSTed (may be
null
)
uriVariables
- the variables to expand the template
Returns:
the entity wrapped in a
Future
Throws:
RestClientException
See Also:
HttpEntity
postForEntity
public <T> ListenableFuture<ResponseEntity<T>> postForEntity(URI url,
@Nullable
HttpEntity<?> request,
Class<T> responseType)
throws RestClientException
Deprecated.
Create a new resource by POSTing the given object to the URL,
and asynchronously returns the response as
ResponseEntity
.
Specified by:
postForEntity
in interface
AsyncRestOperations
Parameters:
url
- the URL
request
- the Object to be POSTed (may be
null
)
Returns:
the entity wrapped in a
Future
Throws:
RestClientException
See Also:
HttpEntity
throws
RestClientException
Deprecated.
Create or update a resource by PUTting the given object to the URI.
URI Template variables are expanded using the given URI variables, if any.
The Future will return a
null
result upon completion.
Specified by:
put
in interface
AsyncRestOperations
Parameters:
url
- the URL
request
- the Object to be PUT (may be
null
)
uriVars
- the variables to expand the template
Throws:
RestClientException
See Also:
HttpEntity
throws
RestClientException
Deprecated.
Creates a new resource by PUTting the given object to URI template.
URI Template variables are expanded using the given map.
The Future will return a
null
result upon completion.
Specified by:
put
in interface
AsyncRestOperations
Parameters:
url
- the URL
request
- the Object to be PUT (may be
null
)
uriVars
- the variables to expand the template
Throws:
RestClientException
See Also:
HttpEntity
throws
RestClientException
Deprecated.
Creates a new resource by PUTting the given object to URL.
The Future will return a
null
result upon completion.
Specified by:
put
in interface
AsyncRestOperations
Parameters:
url
- the URL
request
- the Object to be PUT (may be
null
)
Throws:
RestClientException
See Also:
HttpEntity
public ListenableFuture<?> delete(String url,
Object... uriVariables)
throws RestClientException
Deprecated.
Asynchronously delete the resources at the specified URI.
URI Template variables are expanded using the given URI variables, if any.
The Future will return a
null
result upon completion.
Specified by:
delete
in interface
AsyncRestOperations
Parameters:
url
- the URL
uriVariables
- the variables to expand in the template
Throws:
RestClientException
public ListenableFuture<?> delete(String url,
Map<String,?> uriVariables)
throws RestClientException
Deprecated.
Asynchronously delete the resources at the specified URI.
URI Template variables are expanded using the given URI variables, if any.
The Future will return a
null
result upon completion.
Specified by:
delete
in interface
AsyncRestOperations
Parameters:
url
- the URL
uriVariables
- the variables to expand in the template
Throws:
RestClientException
throws
RestClientException
Deprecated.
Asynchronously delete the resources at the specified URI.
URI Template variables are expanded using the given URI variables, if any.
The Future will return a
null
result upon completion.
Specified by:
delete
in interface
AsyncRestOperations
Parameters:
url
- the URL
Throws:
RestClientException
optionsForAllow
public ListenableFuture<Set<HttpMethod>> optionsForAllow(String url,
Object... uriVars)
throws RestClientException
Deprecated.
Asynchronously return the value of the Allow header for the given URI.
URI Template variables are expanded using the given URI variables, if any.
Specified by:
optionsForAllow
in interface
AsyncRestOperations
Parameters:
url
- the URL
uriVars
- the variables to expand in the template
Returns:
the value of the allow header wrapped in a
Future
Throws:
RestClientException
optionsForAllow
public ListenableFuture<Set<HttpMethod>> optionsForAllow(String url,
Map<String,?> uriVars)
throws RestClientException
Deprecated.
Asynchronously return the value of the Allow header for the given URI.
URI Template variables are expanded using the given map.
Specified by:
optionsForAllow
in interface
AsyncRestOperations
Parameters:
url
- the URL
uriVars
- the variables to expand in the template
Returns:
the value of the allow header wrapped in a
Future
Throws:
RestClientException
optionsForAllow
public ListenableFuture<Set<HttpMethod>> optionsForAllow(URI url)
throws RestClientException
Deprecated.
Asynchronously return the value of the Allow header for the given URL.
Specified by:
optionsForAllow
in interface
AsyncRestOperations
Parameters:
url
- the URL
Returns:
the value of the allow header wrapped in a
Future
Throws:
RestClientException
exchange
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url,
HttpMethod method,
@Nullable
HttpEntity<?> requestEntity,
Class<T> responseType,
Object... uriVariables)
throws RestClientException
Deprecated.
Asynchronously execute the HTTP method to the given URI template, writing the
given request entity to the request, and returns the response as
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
Specified by:
exchange
in interface
AsyncRestOperations
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestEntity
- the entity (headers and/or body) to write to the request
(may be
null
)
responseType
- the type of the return value
uriVariables
- the variables to expand in the template
Returns:
the response as entity wrapped in a
Future
Throws:
RestClientException
exchange
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url,
HttpMethod method,
@Nullable
HttpEntity<?> requestEntity,
Class<T> responseType,
Map<String,?> uriVariables)
throws RestClientException
Deprecated.
Asynchronously execute the HTTP method to the given URI template, writing the
given request entity to the request, and returns the response as
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
Specified by:
exchange
in interface
AsyncRestOperations
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestEntity
- the entity (headers and/or body) to write to the request
(may be
null
)
responseType
- the type of the return value
uriVariables
- the variables to expand in the template
Returns:
the response as entity wrapped in a
Future
Throws:
RestClientException
exchange
public <T> ListenableFuture<ResponseEntity<T>> exchange(URI url,
HttpMethod method,
@Nullable
HttpEntity<?> requestEntity,
Class<T> responseType)
throws RestClientException
Deprecated.
Asynchronously execute the HTTP method to the given URI template, writing the
given request entity to the request, and returns the response as
ResponseEntity
.
Specified by:
exchange
in interface
AsyncRestOperations
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestEntity
- the entity (headers and/or body) to write to the request
(may be
null
)
responseType
- the type of the return value
Returns:
the response as entity wrapped in a
Future
Throws:
RestClientException
exchange
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url,
HttpMethod method,
@Nullable
HttpEntity<?> requestEntity,
ParameterizedTypeReference<T> responseType,
Object... uriVariables)
throws RestClientException
Deprecated.
Asynchronously execute the HTTP method to the given URI template, writing the given
request entity to the request, and returns the response as
ResponseEntity
.
The given
ParameterizedTypeReference
is used to pass generic type
information:
ParameterizedTypeReference<List<MyBean>> myBean =
new ParameterizedTypeReference<List<MyBean>>() {};
ResponseEntity<List<MyBean>> response =
template.exchange("https://example.com",HttpMethod.GET, null, myBean);
Specified by:
exchange
in interface
AsyncRestOperations
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestEntity
- the entity (headers and/or body) to write to the
request (may be
null
)
responseType
- the type of the return value
uriVariables
- the variables to expand in the template
Returns:
the response as entity wrapped in a
Future
Throws:
RestClientException
exchange
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url,
HttpMethod method,
@Nullable
HttpEntity<?> requestEntity,
ParameterizedTypeReference<T> responseType,
Map<String,?> uriVariables)
throws RestClientException
Deprecated.
Asynchronously execute the HTTP method to the given URI template, writing the given
request entity to the request, and returns the response as
ResponseEntity
.
The given
ParameterizedTypeReference
is used to pass generic type
information:
ParameterizedTypeReference<List<MyBean>> myBean =
new ParameterizedTypeReference<List<MyBean>>() {};
ResponseEntity<List<MyBean>> response =
template.exchange("https://example.com",HttpMethod.GET, null, myBean);
Specified by:
exchange
in interface
AsyncRestOperations
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestEntity
- the entity (headers and/or body) to write to the request
(may be
null
)
responseType
- the type of the return value
uriVariables
- the variables to expand in the template
Returns:
the response as entity wrapped in a
Future
Throws:
RestClientException
exchange
public <T> ListenableFuture<ResponseEntity<T>> exchange(URI url,
HttpMethod method,
@Nullable
HttpEntity<?> requestEntity,
ParameterizedTypeReference<T> responseType)
throws RestClientException
Deprecated.
Asynchronously execute the HTTP method to the given URI template, writing the given
request entity to the request, and returns the response as
ResponseEntity
.
The given
ParameterizedTypeReference
is used to pass generic type
information:
ParameterizedTypeReference<List<MyBean>> myBean =
new ParameterizedTypeReference<List<MyBean>>() {};
ResponseEntity<List<MyBean>> response =
template.exchange("https://example.com",HttpMethod.GET, null, myBean);
Specified by:
exchange
in interface
AsyncRestOperations
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestEntity
- the entity (headers and/or body) to write to the request
(may be
null
)
responseType
- the type of the return value
Returns:
the response as entity wrapped in a
Future
Throws:
RestClientException
ResponseExtractor
<T> responseExtractor,
Object
... uriVariables)
throws
RestClientException
Deprecated.
Asynchronously execute the HTTP method to the given URI template, preparing the
request with the
AsyncRequestCallback
, and reading the response with a
ResponseExtractor
.
URI Template variables are expanded using the given URI variables, if any.
Specified by:
execute
in interface
AsyncRestOperations
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestCallback
- object that prepares the request
responseExtractor
- object that extracts the return value from the response
uriVariables
- the variables to expand in the template
Returns:
an arbitrary object, as returned by the
ResponseExtractor
Throws:
RestClientException
ResponseExtractor
<T> responseExtractor,
Map
<
String
,?> uriVariables)
throws
RestClientException
Deprecated.
Asynchronously execute the HTTP method to the given URI template, preparing the
request with the
AsyncRequestCallback
, and reading the response with a
ResponseExtractor
.
URI Template variables are expanded using the given URI variables map.
Specified by:
execute
in interface
AsyncRestOperations
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestCallback
- object that prepares the request
responseExtractor
- object that extracts the return value from the response
uriVariables
- the variables to expand in the template
Returns:
an arbitrary object, as returned by the
ResponseExtractor
Throws:
RestClientException
throws
RestClientException
Deprecated.
Specified by:
execute
in interface
AsyncRestOperations
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestCallback
- object that prepares the request
responseExtractor
- object that extracts the return value from the response
Returns:
an arbitrary object, as returned by the
ResponseExtractor
Throws:
RestClientException
Parameters:
url
- the fully-expanded URL to connect to
method
- the HTTP method to execute (GET, POST, etc.)
requestCallback
- object that prepares the request (can be
null
)
responseExtractor
- object that extracts the return value from the response (can
be
null
)
Returns:
an arbitrary object, as returned by the
ResponseExtractor
Throws:
RestClientException
acceptHeaderRequestCallback
protected <T> AsyncRequestCallback acceptHeaderRequestCallback(Class<T> responseType)
Deprecated.
Returns a request callback implementation that prepares the request
Accept
headers based on the given response type and configured
message converters
.
httpEntityCallback
protected <T> AsyncRequestCallback httpEntityCallback(@Nullable
HttpEntity<T> requestBody)
Deprecated.
Returns a request callback implementation that writes the given object to the
request stream.
httpEntityCallback
protected <T> AsyncRequestCallback httpEntityCallback(@Nullable
HttpEntity<T> request,
Type responseType)
Deprecated.
Returns a request callback implementation that writes the given object to the
request stream.
responseEntityExtractor
protected <T> ResponseExtractor<ResponseEntity<T>> responseEntityExtractor(Type responseType)
Deprecated.