Javadoc
This commit is contained in:
parent
d83b601de0
commit
5367ec0ff7
|
@ -73,7 +73,7 @@ public class MediaType implements Comparable<MediaType> {
|
|||
/**
|
||||
* Create a new {@link MediaType} for the given primary type and subtype.
|
||||
* <p>The parameters are empty.
|
||||
* @param typethe primary type
|
||||
* @param type the primary type
|
||||
* @param subtype the subtype
|
||||
*/
|
||||
public MediaType(String type, String subtype) {
|
||||
|
|
|
@ -18,9 +18,6 @@ package org.springframework.web.client;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.HttpServerErrorException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
|
||||
|
@ -28,7 +25,8 @@ import org.springframework.http.client.ClientHttpResponse;
|
|||
* Default implementation of the {@link ResponseErrorHandler} interface.
|
||||
*
|
||||
* <p>This error handler checks for the status code on the {@link ClientHttpResponse}: any code with series
|
||||
* {@link HttpStatus.Series#CLIENT_ERROR} or {@link HttpStatus.Series#SERVER_ERROR} is considered to be an error.
|
||||
* {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR} or
|
||||
* {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR} is considered to be an error.
|
||||
* This behavior can be changed by overriding the {@link #hasError(HttpStatus)} method.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
|
@ -46,18 +44,24 @@ public class DefaultResponseErrorHandler implements ResponseErrorHandler {
|
|||
|
||||
/**
|
||||
* Template method called from {@link #hasError(ClientHttpResponse)}.
|
||||
* <p>The default implementation checks if the given status code is {@link HttpStatus.Series#CLIENT_ERROR}
|
||||
* or {@link HttpStatus.Series#SERVER_ERROR}. Can be overridden in subclasses.
|
||||
* <p>The default implementation checks if the given status code is
|
||||
* {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR CLIENT_ERROR}
|
||||
* or {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR SERVER_ERROR}. Can be overridden in subclasses.
|
||||
* @param statusCode the HTTP status code
|
||||
* @return <code>true</code> if the response has an error; <code>false</code> otherwise
|
||||
* @see HttpStatus.Series#CLIENT_ERROR
|
||||
* @see HttpStatus.Series#SERVER_ERROR
|
||||
*/
|
||||
protected boolean hasError(HttpStatus statusCode) {
|
||||
return (statusCode.series() == HttpStatus.Series.CLIENT_ERROR ||
|
||||
statusCode.series() == HttpStatus.Series.SERVER_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>The default implementation throws a {@link HttpClientErrorException} if the response status code is
|
||||
* {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}, a {@link HttpServerErrorException} if it is
|
||||
* {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR}, and a {@link RestClientException} in other
|
||||
* cases.
|
||||
*/
|
||||
public void handleError(ClientHttpResponse response) throws IOException {
|
||||
HttpStatus statusCode = response.getStatusCode();
|
||||
switch (statusCode.series()) {
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.springframework.web.util.UriTemplate;
|
|||
*
|
||||
* <p>The main entry points of this template are the methods named after the five main HTTP methods:
|
||||
* <table>
|
||||
* <tr><th>HTTP method<th><th>RestTemplate methods</th></tr>
|
||||
* <tr><th>HTTP method</th><th>RestTemplate methods</th></tr>
|
||||
* <tr><td>DELETE</td><td>{@link #delete}</td></tr>
|
||||
* <tr><td>GET</td><td>{@link #getForObject}</td></tr>
|
||||
* <tr><td>HEAD</td><td>{@link #headForHeaders}</td></tr>
|
||||
|
|
|
@ -19,9 +19,9 @@ package org.springframework.web.client.support;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
|
||||
/**
|
||||
* Convenient super class for application classes that need REST access.
|
||||
|
@ -50,7 +50,7 @@ public class RestGatewaySupport {
|
|||
|
||||
/**
|
||||
* Construct a new instance of the {@link RestGatewaySupport}, with the given {@link ClientHttpRequestFactory}.
|
||||
* @see RestTemplate#RestTemplate(ClientHttpRequestFactory
|
||||
* @see RestTemplate#RestTemplate(ClientHttpRequestFactory)
|
||||
*/
|
||||
public RestGatewaySupport(ClientHttpRequestFactory requestFactory) {
|
||||
Assert.notNull(requestFactory, "'requestFactory' must not be null");
|
||||
|
|
Loading…
Reference in New Issue