|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2012 the original author or authors. |
|
|
|
* Copyright 2002-2014 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -106,6 +106,7 @@ public interface RestOperations { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
<T> ResponseEntity<T> getForEntity(URI url, Class<T> responseType) throws RestClientException; |
|
|
|
<T> ResponseEntity<T> getForEntity(URI url, Class<T> responseType) throws RestClientException; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// HEAD
|
|
|
|
// HEAD
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -133,6 +134,7 @@ public interface RestOperations { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
HttpHeaders headForHeaders(URI url) throws RestClientException; |
|
|
|
HttpHeaders headForHeaders(URI url) throws RestClientException; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// POST
|
|
|
|
// POST
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -265,6 +267,7 @@ public interface RestOperations { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
<T> ResponseEntity<T> postForEntity(URI url, Object request, Class<T> responseType) throws RestClientException; |
|
|
|
<T> ResponseEntity<T> postForEntity(URI url, Object request, Class<T> responseType) throws RestClientException; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PUT
|
|
|
|
// PUT
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -301,6 +304,7 @@ public interface RestOperations { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void put(URI url, Object request) throws RestClientException; |
|
|
|
void put(URI url, Object request) throws RestClientException; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DELETE
|
|
|
|
// DELETE
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -326,6 +330,7 @@ public interface RestOperations { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void delete(URI url) throws RestClientException; |
|
|
|
void delete(URI url) throws RestClientException; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// OPTIONS
|
|
|
|
// OPTIONS
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -353,6 +358,7 @@ public interface RestOperations { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
Set<HttpMethod> optionsForAllow(URI url) throws RestClientException; |
|
|
|
Set<HttpMethod> optionsForAllow(URI url) throws RestClientException; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// exchange
|
|
|
|
// exchange
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -402,12 +408,10 @@ public interface RestOperations { |
|
|
|
* Execute the HTTP method to the given URI template, writing the given |
|
|
|
* Execute the HTTP method to the given URI template, writing the given |
|
|
|
* request entity to the request, and returns the response as {@link ResponseEntity}. |
|
|
|
* request entity to the request, and returns the response as {@link ResponseEntity}. |
|
|
|
* The given {@link ParameterizedTypeReference} is used to pass generic type information: |
|
|
|
* The given {@link ParameterizedTypeReference} is used to pass generic type information: |
|
|
|
* |
|
|
|
|
|
|
|
* <pre class="code"> |
|
|
|
* <pre class="code"> |
|
|
|
* ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {}; |
|
|
|
* ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {}; |
|
|
|
* ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
|
|
|
|
* ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
|
|
|
|
* </pre> |
|
|
|
* </pre> |
|
|
|
* |
|
|
|
|
|
|
|
* @param url the URL |
|
|
|
* @param url the URL |
|
|
|
* @param method the HTTP method (GET, POST, etc) |
|
|
|
* @param method the HTTP method (GET, POST, etc) |
|
|
|
* @param requestEntity the entity (headers and/or body) to write to the |
|
|
|
* @param requestEntity the entity (headers and/or body) to write to the |
|
|
|
@ -415,7 +419,7 @@ public interface RestOperations { |
|
|
|
* @param responseType the type of the return value |
|
|
|
* @param responseType the type of the return value |
|
|
|
* @param uriVariables the variables to expand in the template |
|
|
|
* @param uriVariables the variables to expand in the template |
|
|
|
* @return the response as entity |
|
|
|
* @return the response as entity |
|
|
|
* @since 3.2.0 |
|
|
|
* @since 3.2 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
<T> ResponseEntity<T> exchange(String url,HttpMethod method, HttpEntity<?> requestEntity, |
|
|
|
<T> ResponseEntity<T> exchange(String url,HttpMethod method, HttpEntity<?> requestEntity, |
|
|
|
ParameterizedTypeReference<T> responseType, Object... uriVariables) throws RestClientException; |
|
|
|
ParameterizedTypeReference<T> responseType, Object... uriVariables) throws RestClientException; |
|
|
|
@ -424,19 +428,17 @@ public interface RestOperations { |
|
|
|
* Execute the HTTP method to the given URI template, writing the given |
|
|
|
* Execute the HTTP method to the given URI template, writing the given |
|
|
|
* request entity to the request, and returns the response as {@link ResponseEntity}. |
|
|
|
* request entity to the request, and returns the response as {@link ResponseEntity}. |
|
|
|
* The given {@link ParameterizedTypeReference} is used to pass generic type information: |
|
|
|
* The given {@link ParameterizedTypeReference} is used to pass generic type information: |
|
|
|
* |
|
|
|
|
|
|
|
* <pre class="code"> |
|
|
|
* <pre class="code"> |
|
|
|
* ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {}; |
|
|
|
* ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {}; |
|
|
|
* ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
|
|
|
|
* ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
|
|
|
|
* </pre> |
|
|
|
* </pre> |
|
|
|
* |
|
|
|
|
|
|
|
* @param url the URL |
|
|
|
* @param url the URL |
|
|
|
* @param method the HTTP method (GET, POST, etc) |
|
|
|
* @param method the HTTP method (GET, POST, etc) |
|
|
|
* @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null} |
|
|
|
* @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null} |
|
|
|
* @param responseType the type of the return value |
|
|
|
* @param responseType the type of the return value |
|
|
|
* @param uriVariables the variables to expand in the template |
|
|
|
* @param uriVariables the variables to expand in the template |
|
|
|
* @return the response as entity |
|
|
|
* @return the response as entity |
|
|
|
* @since 3.2.0 |
|
|
|
* @since 3.2 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
<T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, |
|
|
|
<T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, |
|
|
|
ParameterizedTypeReference<T> responseType, Map<String, ?> uriVariables) throws RestClientException; |
|
|
|
ParameterizedTypeReference<T> responseType, Map<String, ?> uriVariables) throws RestClientException; |
|
|
|
@ -445,22 +447,21 @@ public interface RestOperations { |
|
|
|
* Execute the HTTP method to the given URI template, writing the given |
|
|
|
* Execute the HTTP method to the given URI template, writing the given |
|
|
|
* request entity to the request, and returns the response as {@link ResponseEntity}. |
|
|
|
* request entity to the request, and returns the response as {@link ResponseEntity}. |
|
|
|
* The given {@link ParameterizedTypeReference} is used to pass generic type information: |
|
|
|
* The given {@link ParameterizedTypeReference} is used to pass generic type information: |
|
|
|
* |
|
|
|
|
|
|
|
* <pre class="code"> |
|
|
|
* <pre class="code"> |
|
|
|
* ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {}; |
|
|
|
* ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {}; |
|
|
|
* ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
|
|
|
|
* ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
|
|
|
|
* </pre> |
|
|
|
* </pre> |
|
|
|
* |
|
|
|
|
|
|
|
* @param url the URL |
|
|
|
* @param url the URL |
|
|
|
* @param method the HTTP method (GET, POST, etc) |
|
|
|
* @param method the HTTP method (GET, POST, etc) |
|
|
|
* @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null} |
|
|
|
* @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null} |
|
|
|
* @param responseType the type of the return value |
|
|
|
* @param responseType the type of the return value |
|
|
|
* @return the response as entity |
|
|
|
* @return the response as entity |
|
|
|
* @since 3.2.0 |
|
|
|
* @since 3.2 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
<T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity, |
|
|
|
<T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity, |
|
|
|
ParameterizedTypeReference<T> responseType) throws RestClientException; |
|
|
|
ParameterizedTypeReference<T> responseType) throws RestClientException; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// general execution
|
|
|
|
// general execution
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|