|
24 | 24 | import org.springframework.http.HttpMethod;
|
25 | 25 |
|
26 | 26 | /**
|
27 |
| - * Interface specifying a basic set of RESTful operations. |
28 |
| - * Implemented by {@link RestTemplate}. Not often used directly, but a useful |
29 |
| - * option to enhance testability, as it can easily be mocked or stubbed. |
| 27 | + * Interface specifying a basic set of RESTful operations. Implemented by {@link RestTemplate}. Not often used directly, |
| 28 | + * but a useful option to enhance testability, as it can easily be mocked or stubbed. |
30 | 29 | *
|
31 | 30 | * @author Arjen Poutsma
|
32 |
| - * @since 3.0 |
33 | 31 | * @see RestTemplate
|
| 32 | + * @since 3.0 |
34 | 33 | */
|
35 | 34 | public interface RestOperations {
|
36 | 35 |
|
37 | 36 | // GET
|
38 | 37 |
|
39 | 38 | /**
|
40 |
| - * Retrieve a representation by doing a GET on the specified URL. |
| 39 | + * Retrieve a representation by doing a GET on the specified URL. The response (if any) is converted and returned. |
41 | 40 | * <p>URI Template variables are expanded using the given URI variables, if any.
|
42 |
| - * @param uri the URI |
| 41 | + * |
| 42 | + * @param url the URL |
43 | 43 | * @param responseType the type of the return value
|
44 | 44 | * @param uriVariables the variables to expand the template
|
45 | 45 | * @return the converted object
|
46 | 46 | */
|
47 |
| - <T> T getForObject(String uri, Class<T> responseType, String... uriVariables) throws RestClientException; |
| 47 | + <T> T getForObject(String url, Class<T> responseType, String... uriVariables) throws RestClientException; |
48 | 48 |
|
49 | 49 | /**
|
50 |
| - * Retrieve a representation by doing a GET on the URI template. |
| 50 | + * Retrieve a representation by doing a GET on the URI template. The response (if any) is converted and returned. |
51 | 51 | * <p>URI Template variables are expanded using the given map.
|
52 |
| - * @param uri the URI |
| 52 | + * |
| 53 | + * @param url the URL |
53 | 54 | * @param responseType the type of the return value
|
54 | 55 | * @param uriVariables the map containing variables for the URI template
|
55 | 56 | * @return the converted object
|
56 | 57 | */
|
57 |
| - <T> T getForObject(String uri, Class<T> responseType, Map<String, String> uriVariables) throws RestClientException; |
58 |
| - |
| 58 | + <T> T getForObject(String url, Class<T> responseType, Map<String, String> uriVariables) throws RestClientException; |
59 | 59 |
|
60 | 60 | // HEAD
|
61 | 61 |
|
62 | 62 | /**
|
63 |
| - * Retrieve all headers of the resource specified by the URI template. |
64 |
| - * <p>URI Template variables are expanded using the given URI variables, if any. |
65 |
| - * @param uri the URI |
| 63 | + * Retrieve all headers of the resource specified by the URI template. <p>URI Template variables are expanded using the |
| 64 | + * given URI variables, if any. |
| 65 | + * |
| 66 | + * @param url the URL |
66 | 67 | * @param uriVariables the variables to expand the template
|
67 | 68 | * @return all HTTP headers of that resource
|
68 | 69 | */
|
69 |
| - HttpHeaders headForHeaders(String uri, String... uriVariables) throws RestClientException; |
| 70 | + HttpHeaders headForHeaders(String url, String... uriVariables) throws RestClientException; |
70 | 71 |
|
71 | 72 | /**
|
72 |
| - * Retrieve all headers of the resource specified by the URI template. |
73 |
| - * <p>URI Template variables are expanded using the given map. |
74 |
| - * @param uri the URI |
| 73 | + * Retrieve all headers of the resource specified by the URI template. <p>URI Template variables are expanded using the |
| 74 | + * given map. |
| 75 | + * |
| 76 | + * @param url the URL |
75 | 77 | * @param uriVariables the map containing variables for the URI template
|
76 | 78 | * @return all HTTP headers of that resource
|
77 | 79 | */
|
78 |
| - HttpHeaders headForHeaders(String uri, Map<String, String> uriVariables) throws RestClientException; |
79 |
| - |
| 80 | + HttpHeaders headForHeaders(String url, Map<String, String> uriVariables) throws RestClientException; |
80 | 81 |
|
81 | 82 | // POST
|
82 | 83 |
|
83 | 84 | /**
|
84 |
| - * Create a new resource by POSTing the given object to the URI template. The value of the <code>Location</code> |
85 |
| - * header, indicating where the new resource is stored, is returned. |
86 |
| - * <p>URI Template variables are expanded using the given URI variables, if any. |
87 |
| - * @param uri the URI |
| 85 | + * Create a new resource by POSTing the given object to the URI template, and returns the value of the |
| 86 | + * <code>Location</code> header. This header typically indicates where the new resource is stored. <p>URI Template |
| 87 | + * variables are expanded using the given URI variables, if any. |
| 88 | + * |
| 89 | + * @param url the URL |
88 | 90 | * @param request the Object to be POSTed, may be <code>null</code>
|
89 | 91 | * @return the value for the <code>Location</code> header
|
90 | 92 | */
|
91 |
| - URI postForLocation(String uri, Object request, String... uriVariables) throws RestClientException; |
| 93 | + URI postForLocation(String url, Object request, String... uriVariables) throws RestClientException; |
92 | 94 |
|
93 | 95 | /**
|
94 |
| - * Create a new resource by POSTing the given object to URI template. The value of the <code>Location</code> header, |
95 |
| - * indicating where the new resource is stored, is returned. |
96 |
| - * <p>URI Template variables are expanded using the given map. |
97 |
| - * @param uri the URI |
98 |
| - * @param request the Object to be POSTed, may be <code>null</code> |
| 96 | + * Create a new resource by POSTing the given object to the URI template, and returns the value of the |
| 97 | + * <code>Location</code> header. This header typically indicates where the new resource is stored. <p>URI Template |
| 98 | + * variables are expanded using the given map. |
| 99 | + * |
| 100 | + * @param url the URL |
| 101 | + * @param request the Object to be POSTed, may be <code>null</code> |
99 | 102 | * @param uriVariables the variables to expand the template
|
100 | 103 | * @return the value for the <code>Location</code> header
|
101 | 104 | */
|
102 |
| - URI postForLocation(String uri, Object request, Map<String, String> uriVariables) throws RestClientException; |
| 105 | + URI postForLocation(String url, Object request, Map<String, String> uriVariables) throws RestClientException; |
103 | 106 |
|
| 107 | + /** |
| 108 | + * Create a new resource by POSTing the given object to the URI template, and returns the converted representation |
| 109 | + * found in the response. <p>URI Template variables are expanded using the given URI variables, if any. |
| 110 | + * |
| 111 | + * @param url the URL |
| 112 | + * @param request the Object to be POSTed, may be <code>null</code> |
| 113 | + * @return the converted object |
| 114 | + */ |
| 115 | + <T> T postForObject(String url, Object request, Class<T> responseType, String... uriVariables) |
| 116 | + throws RestClientException; |
| 117 | + |
| 118 | + /** |
| 119 | + * Create a new resource by POSTing the given object to the URI template, and returns the converted representation |
| 120 | + * found in the response. <p>URI Template variables are expanded using the given map. |
| 121 | + * |
| 122 | + * @param url the URL |
| 123 | + * @param request the Object to be POSTed, may be <code>null</code> |
| 124 | + * @return the converted object |
| 125 | + */ |
| 126 | + <T> T postForObject(String url, Object request, Class<T> responseType, Map<String, String> uriVariables) |
| 127 | + throws RestClientException; |
104 | 128 |
|
105 | 129 | // PUT
|
106 | 130 |
|
107 | 131 | /**
|
108 |
| - * Create or update a resource by PUTting the given object to the URI. |
109 |
| - * <p>URI Template variables are expanded using the given URI variables, if any. |
110 |
| - * @param uri the URI |
111 |
| - * @param request the Object to be PUT, may be <code>null</code> |
| 132 | + * Create or update a resource by PUTting the given object to the URI. <p>URI Template variables are expanded using the |
| 133 | + * given URI variables, if any. |
| 134 | + * |
| 135 | + * @param url the URL |
| 136 | + * @param request the Object to be PUT, may be <code>null</code> |
112 | 137 | * @param uriVariables the variables to expand the template
|
113 | 138 | */
|
114 |
| - void put(String uri, Object request, String... uriVariables) throws RestClientException; |
| 139 | + void put(String url, Object request, String... uriVariables) throws RestClientException; |
115 | 140 |
|
116 | 141 | /**
|
117 |
| - * Creates a new resource by PUTting the given object to URI template. |
118 |
| - * <p>URI Template variables are expanded using the given map. |
119 |
| - * @param uri the URI |
120 |
| - * @param request the Object to be PUT, may be <code>null</code> |
| 142 | + * Creates a new resource by PUTting the given object to URI template. <p>URI Template variables are expanded using the |
| 143 | + * given map. |
| 144 | + * |
| 145 | + * @param url the URL |
| 146 | + * @param request the Object to be PUT, may be <code>null</code> |
121 | 147 | * @param uriVariables the variables to expand the template
|
122 | 148 | */
|
123 |
| - void put(String uri, Object request, Map<String, String> uriVariables) throws RestClientException; |
124 |
| - |
| 149 | + void put(String url, Object request, Map<String, String> uriVariables) throws RestClientException; |
125 | 150 |
|
126 | 151 | // DELETE
|
127 | 152 |
|
128 | 153 | /**
|
129 |
| - * Delete the resources at the specified URI. |
130 |
| - * <p>URI Template variables are expanded using the given URI variables, if any. |
131 |
| - * @param uri the URI |
| 154 | + * Delete the resources at the specified URI. <p>URI Template variables are expanded using the given URI variables, if |
| 155 | + * any. |
| 156 | + * |
| 157 | + * @param url the URL |
132 | 158 | * @param uriVariables the variables to expand in the template
|
133 | 159 | */
|
134 |
| - void delete(String uri, String... uriVariables) throws RestClientException; |
| 160 | + void delete(String url, String... uriVariables) throws RestClientException; |
135 | 161 |
|
136 | 162 | /**
|
137 |
| - * Delete the resources at the specified URI. |
138 |
| - * <p>URI Template variables are expanded using the given map. |
139 |
| - * @param uri the URI |
| 163 | + * Delete the resources at the specified URI. <p>URI Template variables are expanded using the given map. |
| 164 | + * |
| 165 | + * @param url the URL |
140 | 166 | * @param uriVariables the variables to expand the template
|
141 | 167 | */
|
142 |
| - void delete(String uri, Map<String, String> uriVariables) throws RestClientException; |
143 |
| - |
| 168 | + void delete(String url, Map<String, String> uriVariables) throws RestClientException; |
144 | 169 |
|
145 | 170 | // OPTIONS
|
146 | 171 |
|
147 | 172 | /**
|
148 |
| - * Return the value of the Allow header for the given URI. |
149 |
| - * <p>URI Template variables are expanded using the given URI variables, if any. |
150 |
| - * @param uri the URI |
| 173 | + * Return the value of the Allow header for the given URI. <p>URI Template variables are expanded using the given URI |
| 174 | + * variables, if any. |
| 175 | + * |
| 176 | + * @param url the URL |
151 | 177 | * @param uriVariables the variables to expand in the template
|
152 | 178 | * @return the value of the allow header
|
153 | 179 | */
|
154 |
| - Set<HttpMethod> optionsForAllow(String uri, String... uriVariables) throws RestClientException; |
| 180 | + Set<HttpMethod> optionsForAllow(String url, String... uriVariables) throws RestClientException; |
155 | 181 |
|
156 | 182 | /**
|
157 |
| - * Return the value of the Allow header for the given URI. |
158 |
| - * <p>URI Template variables are expanded using the given map. |
159 |
| - * @param uri the URI |
| 183 | + * Return the value of the Allow header for the given URI. <p>URI Template variables are expanded using the given map. |
| 184 | + * |
| 185 | + * @param url the URL |
160 | 186 | * @param uriVariables the variables to expand in the template
|
161 | 187 | * @return the value of the allow header
|
162 | 188 | */
|
163 |
| - Set<HttpMethod> optionsForAllow(String uri, Map<String, String> uriVariables) throws RestClientException; |
164 |
| - |
| 189 | + Set<HttpMethod> optionsForAllow(String url, Map<String, String> uriVariables) throws RestClientException; |
165 | 190 |
|
166 | 191 | // general execution
|
167 | 192 |
|
168 | 193 | /**
|
169 |
| - * Execute the HTTP methods to the given URI, preparing the request with the {@link RequestCallback}, |
170 |
| - * and reading the response with a {@link ResponseExtractor}. |
171 |
| - * <p>URI Template variables are expanded using the given URI variables, if any. |
172 |
| - * @param uri the URI |
173 |
| - * @param method the HTTP method (GET, POST, etc) |
174 |
| - * @param requestCallback object that prepares the request |
| 194 | + * Execute the HTTP methods to the given URI, preparing the request with the {@link RequestCallback}, and reading the |
| 195 | + * response with a {@link ResponseExtractor}. <p>URI Template variables are expanded using the given URI variables, if |
| 196 | + * any. |
| 197 | + * |
| 198 | + * @param url the URL |
| 199 | + * @param method the HTTP method (GET, POST, etc) |
| 200 | + * @param requestCallback object that prepares the request |
175 | 201 | * @param responseExtractor object that extracts the return value from the response
|
176 |
| - * @param uriVariables the variables to expand in the template |
| 202 | + * @param uriVariables the variables to expand in the template |
177 | 203 | * @return an arbitrary object, as returned by the {@link ResponseExtractor}
|
178 | 204 | */
|
179 |
| - <T> T execute(String uri, |
| 205 | + <T> T execute(String url, |
180 | 206 | HttpMethod method,
|
181 | 207 | RequestCallback requestCallback,
|
182 | 208 | ResponseExtractor<T> responseExtractor,
|
183 | 209 | String... uriVariables) throws RestClientException;
|
184 | 210 |
|
185 | 211 | /**
|
186 |
| - * Execute the HTTP methods to the given URI, preparing the request with the {@link RequestCallback}, |
187 |
| - * and reading the response with a {@link ResponseExtractor}. |
188 |
| - * <p>URI Template variables are expanded using the given URI variables map. |
189 |
| - * @param uri the URI |
190 |
| - * @param method the HTTP method (GET, POST, etc) |
191 |
| - * @param requestCallback object that prepares the request |
| 212 | + * Execute the HTTP methods to the given URI, preparing the request with the {@link RequestCallback}, and reading the |
| 213 | + * response with a {@link ResponseExtractor}. <p>URI Template variables are expanded using the given URI variables |
| 214 | + * map. |
| 215 | + * |
| 216 | + * @param url the URL |
| 217 | + * @param method the HTTP method (GET, POST, etc) |
| 218 | + * @param requestCallback object that prepares the request |
192 | 219 | * @param responseExtractor object that extracts the return value from the response
|
193 |
| - * @param uriVariables the variables to expand in the template |
| 220 | + * @param uriVariables the variables to expand in the template |
194 | 221 | * @return an arbitrary object, as returned by the {@link ResponseExtractor}
|
195 | 222 | */
|
196 |
| - <T> T execute(String uri, |
| 223 | + <T> T execute(String url, |
197 | 224 | HttpMethod method,
|
198 | 225 | RequestCallback requestCallback,
|
199 | 226 | ResponseExtractor<T> responseExtractor,
|
|
0 commit comments