类 AsyncRestTemplate
- java.lang.Object
- org.springframework.http.client.support.AsyncHttpAccessor
- org.springframework.http.client.support.InterceptingAsyncHttpAccessor
- org.springframework.web.client.AsyncRestTemplate
- 所有已实现的接口:
AsyncRestOperations
public class AsyncRestTemplate extends InterceptingAsyncHttpAccessor implements AsyncRestOperations
Spring's central class for asynchronous client-side HTTP access. Exposes similar methods asRestTemplate, but returnsListenableFuturewrappers as opposed to concrete results.The
AsyncRestTemplateexposes a synchronousRestTemplatevia thegetRestOperations()method and shares its error handler and message converters with thatRestTemplate.Note: by default
AsyncRestTemplaterelies 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 anAsyncClientHttpRequestFactory.For more information, please refer to the
RestTemplateAPI documentation.- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma
- 另请参阅:
RestTemplate
字段概要
从类继承的字段 org.springframework.http.client.support.AsyncHttpAccessor
logger
构造器概要
构造器 构造器 说明 AsyncRestTemplate()Create a new instance of theAsyncRestTemplateusing default settings.AsyncRestTemplate(AsyncListenableTaskExecutor taskExecutor)Create a new instance of theAsyncRestTemplateusing the givenAsyncTaskExecutor.AsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory)Create a new instance of theAsyncRestTemplateusing the givenAsyncClientHttpRequestFactory.AsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory, ClientHttpRequestFactory syncRequestFactory)Creates a new instance of theAsyncRestTemplateusing the given asynchronous and synchronous request factories.AsyncRestTemplate(AsyncClientHttpRequestFactory requestFactory, RestTemplate restTemplate)Create a new instance of theAsyncRestTemplateusing the givenAsyncClientHttpRequestFactoryand synchronousRestTemplate.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected <T> AsyncRequestCallbackacceptHeaderRequestCallback(Class<T> responseType)Returns a request callback implementation that prepares the requestAcceptheaders based on the given response type and configured message converters.ListenableFuture<?>delete(String url, Object... uriVariables)Asynchronously delete the resources at the specified URI.ListenableFuture<?>delete(String url, Map<String,?> uriVariables)Asynchronously delete the resources at the specified URI.ListenableFuture<?>delete(URI url)Asynchronously delete the resources at the specified URI.protected <T> ListenableFuture<T>doExecute(URI url, HttpMethod method, AsyncRequestCallback requestCallback, ResponseExtractor<T> responseExtractor)Execute the given method on the provided URI.<T> ListenableFuture<ResponseEntity<T>>exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables)Asynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asResponseEntity.<T> ListenableFuture<ResponseEntity<T>>exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType, Map<String,?> uriVariables)Asynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asResponseEntity.<T> ListenableFuture<ResponseEntity<T>>exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType, Object... uriVariables)Asynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asResponseEntity.<T> ListenableFuture<ResponseEntity<T>>exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType, Map<String,?> uriVariables)Asynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asResponseEntity.<T> ListenableFuture<ResponseEntity<T>>exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType)Asynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asResponseEntity.<T> ListenableFuture<ResponseEntity<T>>exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType)Asynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asResponseEntity.<T> ListenableFuture<T>execute(String url, HttpMethod method, AsyncRequestCallback requestCallback, ResponseExtractor<T> responseExtractor, Object... uriVariables)Asynchronously execute the HTTP method to the given URI template, preparing the request with theAsyncRequestCallback, and reading the response with aResponseExtractor.<T> ListenableFuture<T>execute(String url, HttpMethod method, AsyncRequestCallback requestCallback, ResponseExtractor<T> responseExtractor, Map<String,?> uriVariables)Asynchronously execute the HTTP method to the given URI template, preparing the request with theAsyncRequestCallback, and reading the response with aResponseExtractor.<T> ListenableFuture<T>execute(URI url, HttpMethod method, AsyncRequestCallback requestCallback, ResponseExtractor<T> responseExtractor)Asynchronously execute the HTTP method to the given URL, preparing the request with theAsyncRequestCallback, and reading the response with aResponseExtractor.ResponseErrorHandlergetErrorHandler()Return the error handler.<T> ListenableFuture<ResponseEntity<T>>getForEntity(String url, Class<T> responseType, Object... uriVariables)Asynchronously retrieve an entity by doing a GET on the specified URL.<T> ListenableFuture<ResponseEntity<T>>getForEntity(String url, Class<T> responseType, Map<String,?> uriVariables)Asynchronously retrieve a representation by doing a GET on the URI template.<T> ListenableFuture<ResponseEntity<T>>getForEntity(URI url, Class<T> responseType)Asynchronously retrieve a representation by doing a GET on the URL.List<HttpMessageConverter<?>>getMessageConverters()Return the message body converters.RestOperationsgetRestOperations()Expose the synchronous Spring RestTemplate to allow synchronous invocation.UriTemplateHandlergetUriTemplateHandler()Return the configured URI template handler.protected ResponseExtractor<HttpHeaders>headersExtractor()Returns a response extractor forHttpHeaders.ListenableFuture<HttpHeaders>headForHeaders(String url, Object... uriVariables)Asynchronously retrieve all headers of the resource specified by the URI template.ListenableFuture<HttpHeaders>headForHeaders(String url, Map<String,?> uriVariables)Asynchronously retrieve all headers of the resource specified by the URI template.ListenableFuture<HttpHeaders>headForHeaders(URI url)Asynchronously retrieve all headers of the resource specified by the URL.protected <T> AsyncRequestCallbackhttpEntityCallback(HttpEntity<T> requestBody)Returns a request callback implementation that writes the given object to the request stream.protected <T> AsyncRequestCallbackhttpEntityCallback(HttpEntity<T> request, Type responseType)Returns a request callback implementation that writes the given object to the request stream.ListenableFuture<Set<HttpMethod>>optionsForAllow(String url, Object... uriVars)Asynchronously return the value of the Allow header for the given URI.ListenableFuture<Set<HttpMethod>>optionsForAllow(String url, Map<String,?> uriVars)Asynchronously return the value of the Allow header for the given URI.ListenableFuture<Set<HttpMethod>>optionsForAllow(URI url)Asynchronously return the value of the Allow header for the given URL.<T> ListenableFuture<ResponseEntity<T>>postForEntity(String url, HttpEntity<?> request, Class<T> responseType, Object... uriVariables)Create a new resource by POSTing the given object to the URI template, and asynchronously returns the response asResponseEntity.<T> ListenableFuture<ResponseEntity<T>>postForEntity(String url, HttpEntity<?> request, Class<T> responseType, Map<String,?> uriVariables)Create a new resource by POSTing the given object to the URI template, and asynchronously returns the response asResponseEntity.<T> ListenableFuture<ResponseEntity<T>>postForEntity(URI url, HttpEntity<?> request, Class<T> responseType)Create a new resource by POSTing the given object to the URL, and asynchronously returns the response asResponseEntity.ListenableFuture<URI>postForLocation(String url, HttpEntity<?> request, Object... uriVars)Create a new resource by POSTing the given object to the URI template, and asynchronously returns the value of theLocationheader.ListenableFuture<URI>postForLocation(String url, HttpEntity<?> request, Map<String,?> uriVars)Create a new resource by POSTing the given object to the URI template, and asynchronously returns the value of theLocationheader.ListenableFuture<URI>postForLocation(URI url, HttpEntity<?> request)Create a new resource by POSTing the given object to the URL, and asynchronously returns the value of theLocationheader.ListenableFuture<?>put(String url, HttpEntity<?> request, Object... uriVariables)Create or update a resource by PUTting the given object to the URI.ListenableFuture<?>put(String url, HttpEntity<?> request, Map<String,?> uriVariables)Creates a new resource by PUTting the given object to URI template.ListenableFuture<?>put(URI url, HttpEntity<?> request)Creates a new resource by PUTting the given object to URL.protected <T> ResponseExtractor<ResponseEntity<T>>responseEntityExtractor(Type responseType)Returns a response extractor forResponseEntity.voidsetDefaultUriVariables(Map<String,?> defaultUriVariables)Configure default URI variable values.voidsetErrorHandler(ResponseErrorHandler errorHandler)Set the error handler.voidsetMessageConverters(List<HttpMessageConverter<?>> messageConverters)Set the message body converters to use.voidsetUriTemplateHandler(UriTemplateHandler handler)This property has the same purpose as the corresponding property on theRestTemplate.从类继承的方法 org.springframework.http.client.support.InterceptingAsyncHttpAccessor
getAsyncRequestFactory, getInterceptors, setInterceptors
从类继承的方法 org.springframework.http.client.support.AsyncHttpAccessor
createAsyncRequest, setAsyncRequestFactory
构造器详细资料
AsyncRestTemplate
public AsyncRestTemplate()
Create a new instance of theAsyncRestTemplateusing default settings.This constructor uses a
SimpleClientHttpRequestFactoryin combination with aSimpleAsyncTaskExecutorfor asynchronous execution.
AsyncRestTemplate
public AsyncRestTemplate(AsyncListenableTaskExecutor taskExecutor)
Create a new instance of theAsyncRestTemplateusing the givenAsyncTaskExecutor.This constructor uses a
SimpleClientHttpRequestFactoryin combination with the givenAsyncTaskExecutorfor asynchronous execution.
AsyncRestTemplate
public AsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory)
Create a new instance of theAsyncRestTemplateusing the givenAsyncClientHttpRequestFactory.This constructor will cast the given asynchronous
AsyncClientHttpRequestFactoryto aClientHttpRequestFactory. Since all implementations ofClientHttpRequestFactoryprovided in Spring also implementAsyncClientHttpRequestFactory, this should not result in aClassCastException.
AsyncRestTemplate
public AsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory, ClientHttpRequestFactory syncRequestFactory)
Creates a new instance of theAsyncRestTemplateusing the given asynchronous and synchronous request factories.- 参数:
asyncRequestFactory- the asynchronous request factorysyncRequestFactory- the synchronous request factory
AsyncRestTemplate
public AsyncRestTemplate(AsyncClientHttpRequestFactory requestFactory, RestTemplate restTemplate)
Create a new instance of theAsyncRestTemplateusing the givenAsyncClientHttpRequestFactoryand synchronousRestTemplate.- 参数:
requestFactory- the asynchronous request factory to userestTemplate- the synchronous template to use
方法详细资料
setErrorHandler
public void setErrorHandler(ResponseErrorHandler errorHandler)
Set the error handler.By default, AsyncRestTemplate uses a
DefaultResponseErrorHandler.
getErrorHandler
public ResponseErrorHandler getErrorHandler()
Return the error handler.
setDefaultUriVariables
public void setDefaultUriVariables(Map<String,?> defaultUriVariables)
Configure default URI variable values. This is a shortcut for:DefaultUriTemplateHandler handler = new DefaultUriTemplateHandler(); handler.setDefaultUriVariables(...); AsyncRestTemplate restTemplate = new AsyncRestTemplate(); restTemplate.setUriTemplateHandler(handler);
- 参数:
defaultUriVariables- the default URI variable values- 从以下版本开始:
- 4.3
setUriTemplateHandler
public void setUriTemplateHandler(UriTemplateHandler handler)
This property has the same purpose as the corresponding property on theRestTemplate. For more details seeRestTemplate.setUriTemplateHandler(org.springframework.web.util.UriTemplateHandler).- 参数:
handler- the URI template handler to use
getUriTemplateHandler
public UriTemplateHandler getUriTemplateHandler()
Return the configured URI template handler.
getRestOperations
public RestOperations getRestOperations()
从接口复制的说明:AsyncRestOperationsExpose the synchronous Spring RestTemplate to allow synchronous invocation.- 指定者:
getRestOperations在接口中AsyncRestOperations
setMessageConverters
public void setMessageConverters(List<HttpMessageConverter<?>> messageConverters)
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()
Return the message body converters.
getForEntity
public <T> ListenableFuture<ResponseEntity<T>> getForEntity(String url, Class<T> responseType, Object... uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously retrieve an entity by doing a GET on the specified URL. The response is converted and stored in anResponseEntity.URI Template variables are expanded using the given URI variables, if any.
- 指定者:
getForEntity在接口中AsyncRestOperations- 参数:
url- the URLresponseType- the type of the return valueuriVariables- the variables to expand the template- 返回:
- the entity wrapped in a
Future - 抛出:
RestClientException
getForEntity
public <T> ListenableFuture<ResponseEntity<T>> getForEntity(String url, Class<T> responseType, Map<String,?> uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously retrieve a representation by doing a GET on the URI template. The response is converted and stored in anResponseEntity.URI Template variables are expanded using the given map.
- 指定者:
getForEntity在接口中AsyncRestOperations- 参数:
url- the URLresponseType- the type of the return valueuriVariables- the map containing variables for the URI template- 返回:
- the entity wrapped in a
Future - 抛出:
RestClientException
getForEntity
public <T> ListenableFuture<ResponseEntity<T>> getForEntity(URI url, Class<T> responseType) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously retrieve a representation by doing a GET on the URL. The response is converted and stored in anResponseEntity.- 指定者:
getForEntity在接口中AsyncRestOperations- 参数:
url- the URLresponseType- the type of the return value- 返回:
- the entity wrapped in a
Future - 抛出:
RestClientException
headForHeaders
public ListenableFuture<HttpHeaders> headForHeaders(String url, Object... uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously retrieve all headers of the resource specified by the URI template.URI Template variables are expanded using the given URI variables, if any.
- 指定者:
headForHeaders在接口中AsyncRestOperations- 参数:
url- the URLuriVariables- the variables to expand the template- 返回:
- all HTTP headers of that resource wrapped in a
Future - 抛出:
RestClientException
headForHeaders
public ListenableFuture<HttpHeaders> headForHeaders(String url, Map<String,?> uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously retrieve all headers of the resource specified by the URI template.URI Template variables are expanded using the given map.
- 指定者:
headForHeaders在接口中AsyncRestOperations- 参数:
url- the URLuriVariables- the map containing variables for the URI template- 返回:
- all HTTP headers of that resource wrapped in a
Future - 抛出:
RestClientException
headForHeaders
public ListenableFuture<HttpHeaders> headForHeaders(URI url) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously retrieve all headers of the resource specified by the URL.- 指定者:
headForHeaders在接口中AsyncRestOperations- 参数:
url- the URL- 返回:
- all HTTP headers of that resource wrapped in a
Future - 抛出:
RestClientException
postForLocation
public ListenableFuture<URI> postForLocation(String url, HttpEntity<?> request, Object... uriVars) throws RestClientException
从接口复制的说明:AsyncRestOperationsCreate a new resource by POSTing the given object to the URI template, and asynchronously returns the value of theLocationheader. This header typically indicates where the new resource is stored.URI Template variables are expanded using the given URI variables, if any.
- 指定者:
postForLocation在接口中AsyncRestOperations- 参数:
url- the URLrequest- the Object to be POSTed (may benull)uriVars- the variables to expand the template- 返回:
- the value for the
Locationheader wrapped in aFuture - 抛出:
RestClientException- 另请参阅:
HttpEntity
postForLocation
public ListenableFuture<URI> postForLocation(String url, HttpEntity<?> request, Map<String,?> uriVars) throws RestClientException
从接口复制的说明:AsyncRestOperationsCreate a new resource by POSTing the given object to the URI template, and asynchronously returns the value of theLocationheader. This header typically indicates where the new resource is stored.URI Template variables are expanded using the given map.
- 指定者:
postForLocation在接口中AsyncRestOperations- 参数:
url- the URLrequest- the Object to be POSTed (may benull)uriVars- the variables to expand the template- 返回:
- the value for the
Locationheader wrapped in aFuture - 抛出:
RestClientException- 另请参阅:
HttpEntity
postForLocation
public ListenableFuture<URI> postForLocation(URI url, HttpEntity<?> request) throws RestClientException
从接口复制的说明:AsyncRestOperationsCreate a new resource by POSTing the given object to the URL, and asynchronously returns the value of theLocationheader. This header typically indicates where the new resource is stored.- 指定者:
postForLocation在接口中AsyncRestOperations- 参数:
url- the URLrequest- the Object to be POSTed (may benull)- 返回:
- the value for the
Locationheader wrapped in aFuture - 抛出:
RestClientException- 另请参阅:
HttpEntity
postForEntity
public <T> ListenableFuture<ResponseEntity<T>> postForEntity(String url, HttpEntity<?> request, Class<T> responseType, Object... uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsCreate a new resource by POSTing the given object to the URI template, and asynchronously returns the response asResponseEntity.URI Template variables are expanded using the given URI variables, if any.
- 指定者:
postForEntity在接口中AsyncRestOperations- 参数:
url- the URLrequest- the Object to be POSTed (may benull)uriVariables- the variables to expand the template- 返回:
- the entity wrapped in a
Future - 抛出:
RestClientException- 另请参阅:
HttpEntity
postForEntity
public <T> ListenableFuture<ResponseEntity<T>> postForEntity(String url, HttpEntity<?> request, Class<T> responseType, Map<String,?> uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsCreate a new resource by POSTing the given object to the URI template, and asynchronously returns the response asResponseEntity.URI Template variables are expanded using the given map.
- 指定者:
postForEntity在接口中AsyncRestOperations- 参数:
url- the URLrequest- the Object to be POSTed (may benull)uriVariables- the variables to expand the template- 返回:
- the entity wrapped in a
Future - 抛出:
RestClientException- 另请参阅:
HttpEntity
postForEntity
public <T> ListenableFuture<ResponseEntity<T>> postForEntity(URI url, HttpEntity<?> request, Class<T> responseType) throws RestClientException
从接口复制的说明:AsyncRestOperationsCreate a new resource by POSTing the given object to the URL, and asynchronously returns the response asResponseEntity.- 指定者:
postForEntity在接口中AsyncRestOperations- 参数:
url- the URLrequest- the Object to be POSTed (may benull)- 返回:
- the entity wrapped in a
Future - 抛出:
RestClientException- 另请参阅:
HttpEntity
put
public ListenableFuture<?> put(String url, HttpEntity<?> request, Object... uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsCreate 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
nullresult upon completion.- 指定者:
put在接口中AsyncRestOperations- 参数:
url- the URLrequest- the Object to be PUT (may benull)uriVariables- the variables to expand the template- 抛出:
RestClientException- 另请参阅:
HttpEntity
put
public ListenableFuture<?> put(String url, HttpEntity<?> request, Map<String,?> uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsCreates 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
nullresult upon completion.- 指定者:
put在接口中AsyncRestOperations- 参数:
url- the URLrequest- the Object to be PUT (may benull)uriVariables- the variables to expand the template- 抛出:
RestClientException- 另请参阅:
HttpEntity
put
public ListenableFuture<?> put(URI url, HttpEntity<?> request) throws RestClientException
从接口复制的说明:AsyncRestOperationsCreates a new resource by PUTting the given object to URL.The Future will return a
nullresult upon completion.- 指定者:
put在接口中AsyncRestOperations- 参数:
url- the URLrequest- the Object to be PUT (may benull)- 抛出:
RestClientException- 另请参阅:
HttpEntity
delete
public ListenableFuture<?> delete(String url, Object... uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously delete the resources at the specified URI.URI Template variables are expanded using the given URI variables, if any.
The Future will return a
nullresult upon completion.- 指定者:
delete在接口中AsyncRestOperations- 参数:
url- the URLuriVariables- the variables to expand in the template- 抛出:
RestClientException
delete
public ListenableFuture<?> delete(String url, Map<String,?> uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously delete the resources at the specified URI.URI Template variables are expanded using the given URI variables, if any.
The Future will return a
nullresult upon completion.- 指定者:
delete在接口中AsyncRestOperations- 参数:
url- the URLuriVariables- the variables to expand in the template- 抛出:
RestClientException
delete
public ListenableFuture<?> delete(URI url) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously delete the resources at the specified URI.URI Template variables are expanded using the given URI variables, if any.
The Future will return a
nullresult upon completion.- 指定者:
delete在接口中AsyncRestOperations- 参数:
url- the URL- 抛出:
RestClientException
optionsForAllow
public ListenableFuture<Set<HttpMethod>> optionsForAllow(String url, Object... uriVars) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously return the value of the Allow header for the given URI.URI Template variables are expanded using the given URI variables, if any.
- 指定者:
optionsForAllow在接口中AsyncRestOperations- 参数:
url- the URLuriVars- the variables to expand in the template- 返回:
- the value of the allow header wrapped in a
Future - 抛出:
RestClientException
optionsForAllow
public ListenableFuture<Set<HttpMethod>> optionsForAllow(String url, Map<String,?> uriVars) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously return the value of the Allow header for the given URI.URI Template variables are expanded using the given map.
- 指定者:
optionsForAllow在接口中AsyncRestOperations- 参数:
url- the URLuriVars- the variables to expand in the template- 返回:
- the value of the allow header wrapped in a
Future - 抛出:
RestClientException
optionsForAllow
public ListenableFuture<Set<HttpMethod>> optionsForAllow(URI url) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously return the value of the Allow header for the given URL.- 指定者:
optionsForAllow在接口中AsyncRestOperations- 参数:
url- the URL- 返回:
- the value of the allow header wrapped in a
Future - 抛出:
RestClientException
exchange
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asResponseEntity.URI Template variables are expanded using the given URI variables, if any.
- 指定者:
exchange在接口中AsyncRestOperations- 参数:
url- the URLmethod- the HTTP method (GET, POST, etc)requestEntity- the entity (headers and/or body) to write to the request (may benull)responseType- the type of the return valueuriVariables- the variables to expand in the template- 返回:
- the response as entity wrapped in a
Future - 抛出:
RestClientException
exchange
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType, Map<String,?> uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asResponseEntity.URI Template variables are expanded using the given URI variables, if any.
- 指定者:
exchange在接口中AsyncRestOperations- 参数:
url- the URLmethod- the HTTP method (GET, POST, etc)requestEntity- the entity (headers and/or body) to write to the request (may benull)responseType- the type of the return valueuriVariables- the variables to expand in the template- 返回:
- the response as entity wrapped in a
Future - 抛出:
RestClientException
exchange
public <T> ListenableFuture<ResponseEntity<T>> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asResponseEntity.- 指定者:
exchange在接口中AsyncRestOperations- 参数:
url- the URLmethod- the HTTP method (GET, POST, etc)requestEntity- the entity (headers and/or body) to write to the request (may benull)responseType- the type of the return value- 返回:
- the response as entity wrapped in a
Future - 抛出:
RestClientException
exchange
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType, Object... uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asResponseEntity. The givenParameterizedTypeReferenceis 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);- 指定者:
exchange在接口中AsyncRestOperations- 参数:
url- the URLmethod- the HTTP method (GET, POST, etc)requestEntity- the entity (headers and/or body) to write to the request (may benull)responseType- the type of the return valueuriVariables- the variables to expand in the template- 返回:
- the response as entity wrapped in a
Future - 抛出:
RestClientException
exchange
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType, Map<String,?> uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asResponseEntity. The givenParameterizedTypeReferenceis 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);- 指定者:
exchange在接口中AsyncRestOperations- 参数:
url- the URLmethod- the HTTP method (GET, POST, etc)requestEntity- the entity (headers and/or body) to write to the request (may benull)responseType- the type of the return valueuriVariables- the variables to expand in the template- 返回:
- the response as entity wrapped in a
Future - 抛出:
RestClientException
exchange
public <T> ListenableFuture<ResponseEntity<T>> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response asResponseEntity. The givenParameterizedTypeReferenceis 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);- 指定者:
exchange在接口中AsyncRestOperations- 参数:
url- the URLmethod- the HTTP method (GET, POST, etc)requestEntity- the entity (headers and/or body) to write to the request (may benull)responseType- the type of the return value- 返回:
- the response as entity wrapped in a
Future - 抛出:
RestClientException
execute
public <T> ListenableFuture<T> execute(String url, HttpMethod method, AsyncRequestCallback requestCallback, ResponseExtractor<T> responseExtractor, Object... uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously execute the HTTP method to the given URI template, preparing the request with theAsyncRequestCallback, and reading the response with aResponseExtractor.URI Template variables are expanded using the given URI variables, if any.
- 指定者:
execute在接口中AsyncRestOperations- 参数:
url- the URLmethod- the HTTP method (GET, POST, etc)requestCallback- object that prepares the requestresponseExtractor- object that extracts the return value from the responseuriVariables- the variables to expand in the template- 返回:
- an arbitrary object, as returned by the
ResponseExtractor - 抛出:
RestClientException
execute
public <T> ListenableFuture<T> execute(String url, HttpMethod method, AsyncRequestCallback requestCallback, ResponseExtractor<T> responseExtractor, Map<String,?> uriVariables) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously execute the HTTP method to the given URI template, preparing the request with theAsyncRequestCallback, and reading the response with aResponseExtractor.URI Template variables are expanded using the given URI variables map.
- 指定者:
execute在接口中AsyncRestOperations- 参数:
url- the URLmethod- the HTTP method (GET, POST, etc)requestCallback- object that prepares the requestresponseExtractor- object that extracts the return value from the responseuriVariables- the variables to expand in the template- 返回:
- an arbitrary object, as returned by the
ResponseExtractor - 抛出:
RestClientException
execute
public <T> ListenableFuture<T> execute(URI url, HttpMethod method, AsyncRequestCallback requestCallback, ResponseExtractor<T> responseExtractor) throws RestClientException
从接口复制的说明:AsyncRestOperationsAsynchronously execute the HTTP method to the given URL, preparing the request with theAsyncRequestCallback, and reading the response with aResponseExtractor.- 指定者:
execute在接口中AsyncRestOperations- 参数:
url- the URLmethod- the HTTP method (GET, POST, etc)requestCallback- object that prepares the requestresponseExtractor- object that extracts the return value from the response- 返回:
- an arbitrary object, as returned by the
ResponseExtractor - 抛出:
RestClientException
doExecute
protected <T> ListenableFuture<T> doExecute(URI url, HttpMethod method, AsyncRequestCallback requestCallback, ResponseExtractor<T> responseExtractor) throws RestClientException
Execute the given method on the provided URI. TheClientHttpRequestis processed using theRequestCallback; the response with theResponseExtractor.- 参数:
url- the fully-expanded URL to connect tomethod- the HTTP method to execute (GET, POST, etc.)requestCallback- object that prepares the request (can benull)responseExtractor- object that extracts the return value from the response (can benull)- 返回:
- an arbitrary object, as returned by the
ResponseExtractor - 抛出:
RestClientException
acceptHeaderRequestCallback
protected <T> AsyncRequestCallback acceptHeaderRequestCallback(Class<T> responseType)
Returns a request callback implementation that prepares the requestAcceptheaders based on the given response type and configured message converters.
httpEntityCallback
protected <T> AsyncRequestCallback httpEntityCallback(HttpEntity<T> requestBody)
Returns a request callback implementation that writes the given object to the request stream.
httpEntityCallback
protected <T> AsyncRequestCallback httpEntityCallback(HttpEntity<T> request, Type responseType)
Returns a request callback implementation that writes the given object to the request stream.
responseEntityExtractor
protected <T> ResponseExtractor<ResponseEntity<T>> responseEntityExtractor(Type responseType)
Returns a response extractor forResponseEntity.
headersExtractor
protected ResponseExtractor<HttpHeaders> headersExtractor()
Returns a response extractor forHttpHeaders.