|
64 | 64 | import org.springframework.web.util.UriTemplateHandler;
|
65 | 65 |
|
66 | 66 | /**
|
67 |
| - * <strong>Spring's central class for synchronous client-side HTTP access.</strong> |
68 |
| - * It simplifies communication with HTTP servers, and enforces RESTful principles. |
69 |
| - * It handles HTTP connections, leaving application code to provide URLs |
70 |
| - * (with possible template variables) and extract results. |
| 67 | + * Synchronous client to perform HTTP requests, exposing a simple, template |
| 68 | + * method API over underlying HTTP client libraries such as the JDK |
| 69 | + * {@code HttpURLConnection}, Apache HttpComponents, and others. |
71 | 70 | *
|
72 |
| - * <p><strong>Note:</strong> by default the RestTemplate relies on standard JDK |
73 |
| - * facilities to establish HTTP connections. You can switch to use a different |
74 |
| - * HTTP library such as Apache HttpComponents, Netty, and OkHttp through the |
75 |
| - * {@link #setRequestFactory} property. |
| 71 | + * <p>The RestTemplate offers templates for common scenarios by HTTP method, in |
| 72 | + * addition to the generalized {@code exchange} and {@code execute} methods that |
| 73 | + * support of less frequent cases. |
76 | 74 | *
|
77 |
| - * <p>The main entry points of this template are the methods named after the six main HTTP methods: |
78 |
| - * <table> |
79 |
| - * <tr><th>HTTP method</th><th>RestTemplate methods</th></tr> |
80 |
| - * <tr><td>DELETE</td><td>{@link #delete}</td></tr> |
81 |
| - * <tr><td>GET</td><td>{@link #getForObject}</td></tr> |
82 |
| - * <tr><td></td><td>{@link #getForEntity}</td></tr> |
83 |
| - * <tr><td>HEAD</td><td>{@link #headForHeaders}</td></tr> |
84 |
| - * <tr><td>OPTIONS</td><td>{@link #optionsForAllow}</td></tr> |
85 |
| - * <tr><td>POST</td><td>{@link #postForLocation}</td></tr> |
86 |
| - * <tr><td></td><td>{@link #postForObject}</td></tr> |
87 |
| - * <tr><td>PUT</td><td>{@link #put}</td></tr> |
88 |
| - * <tr><td>any</td><td>{@link #exchange}</td></tr> |
89 |
| - * <tr><td></td><td>{@link #execute}</td></tr> </table> |
90 |
| - * |
91 |
| - * <p>In addition the {@code exchange} and {@code execute} methods are generalized versions of |
92 |
| - * the above methods and can be used to support additional, less frequent combinations (e.g. |
93 |
| - * HTTP PATCH, HTTP PUT with response body, etc.). Note however that the underlying HTTP |
94 |
| - * library used must also support the desired combination. |
95 |
| - * |
96 |
| - * <p><strong>Note:</strong> For URI templates it is assumed encoding is necessary, e.g. |
97 |
| - * {@code restTemplate.getForObject("http://example.com/hotel list")} becomes |
98 |
| - * {@code "http://example.com/hotel%20list"}. This also means if the URI template |
99 |
| - * or URI variables are already encoded, double encoding will occur, e.g. |
100 |
| - * {@code http://example.com/hotel%20list} becomes |
101 |
| - * {@code http://example.com/hotel%2520list}). To avoid that use a {@code URI} method |
102 |
| - * variant to provide (or re-use) a previously encoded URI. To prepare such an URI |
103 |
| - * with full control over encoding, consider using |
104 |
| - * {@link org.springframework.web.util.UriComponentsBuilder}. |
105 |
| - * |
106 |
| - * <p>Internally the template uses {@link HttpMessageConverter} instances to |
107 |
| - * convert HTTP messages to and from POJOs. Converters for the main mime types |
108 |
| - * are registered by default but you can also register additional converters |
109 |
| - * via {@link #setMessageConverters}. |
110 |
| - * |
111 |
| - * <p>This template uses a |
112 |
| - * {@link org.springframework.http.client.SimpleClientHttpRequestFactory} and a |
113 |
| - * {@link DefaultResponseErrorHandler} as default strategies for creating HTTP |
114 |
| - * connections or handling HTTP errors, respectively. These defaults can be overridden |
115 |
| - * through {@link #setRequestFactory} and {@link #setErrorHandler} respectively. |
| 75 | + * <p><strong>NOTE:</strong> As of 5.0, the non-blocking, reactive |
| 76 | + * {@link org.springframework.web.reactive.client.WebClient WebClient} offers a |
| 77 | + * modern alternative to the {@code RestTemplate} with efficient support for |
| 78 | + * both sync and async, as well as streaming scenarios. The {@code RestTemplate} |
| 79 | + * will be deprecated in a future version and will not have major new features |
| 80 | + * gong forward. |
116 | 81 | *
|
117 | 82 | * @author Arjen Poutsma
|
118 | 83 | * @author Brian Clozel
|
|
123 | 88 | * @see RequestCallback
|
124 | 89 | * @see ResponseExtractor
|
125 | 90 | * @see ResponseErrorHandler
|
126 |
| - * @see AsyncRestTemplate |
127 | 91 | */
|
128 | 92 | public class RestTemplate extends InterceptingHttpAccessor implements RestOperations {
|
129 | 93 |
|
|
0 commit comments