polishing
This commit is contained in:
		
							parent
							
								
									fc11102e34
								
							
						
					
					
						commit
						3b704272e3
					
				| 
						 | 
					@ -567,7 +567,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	protected Class predictBeanType(String beanName, RootBeanDefinition mbd, Class[] typesToMatch) {
 | 
						protected Class predictBeanType(String beanName, RootBeanDefinition mbd, Class... typesToMatch) {
 | 
				
			||||||
		Class beanClass;
 | 
							Class beanClass;
 | 
				
			||||||
		if (mbd.getFactoryMethodName() != null) {
 | 
							if (mbd.getFactoryMethodName() != null) {
 | 
				
			||||||
			beanClass = getTypeForFactoryMethod(beanName, mbd, typesToMatch);
 | 
								beanClass = getTypeForFactoryMethod(beanName, mbd, typesToMatch);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -318,7 +318,7 @@ public class HttpHeaders implements MultiValueMap<String, String> {
 | 
				
			||||||
			Assert.isTrue(eTag.startsWith("\"") || eTag.startsWith("W/"), "Invalid eTag, does not start with W/ or \"");
 | 
								Assert.isTrue(eTag.startsWith("\"") || eTag.startsWith("W/"), "Invalid eTag, does not start with W/ or \"");
 | 
				
			||||||
			Assert.isTrue(eTag.endsWith("\""), "Invalid eTag, does not end with \"");
 | 
								Assert.isTrue(eTag.endsWith("\""), "Invalid eTag, does not end with \"");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
			set(ETAG, eTag);
 | 
							set(ETAG, eTag);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,6 +86,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
 | 
						private List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public FormHttpMessageConverter() {
 | 
						public FormHttpMessageConverter() {
 | 
				
			||||||
		this.supportedMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);
 | 
							this.supportedMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);
 | 
				
			||||||
		this.supportedMediaTypes.add(MediaType.MULTIPART_FORM_DATA);
 | 
							this.supportedMediaTypes.add(MediaType.MULTIPART_FORM_DATA);
 | 
				
			||||||
| 
						 | 
					@ -97,13 +98,6 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
 | 
				
			||||||
		this.partConverters.add(new ResourceHttpMessageConverter());
 | 
							this.partConverters.add(new ResourceHttpMessageConverter());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * Add a message body converter. Such a converters is used to convert objects to MIME parts.
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	public final void addPartConverter(HttpMessageConverter<?> partConverter) {
 | 
					 | 
				
			||||||
		Assert.notNull(partConverter, "'partConverter' must not be NULL");
 | 
					 | 
				
			||||||
		this.partConverters.add(partConverter);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Set the message body converters to use. These converters are used to convert objects to MIME parts.
 | 
						 * Set the message body converters to use. These converters are used to convert objects to MIME parts.
 | 
				
			||||||
| 
						 | 
					@ -113,6 +107,14 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
 | 
				
			||||||
		this.partConverters = partConverters;
 | 
							this.partConverters = partConverters;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Add a message body converter. Such a converters is used to convert objects to MIME parts.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public final void addPartConverter(HttpMessageConverter<?> partConverter) {
 | 
				
			||||||
 | 
							Assert.notNull(partConverter, "'partConverter' must not be NULL");
 | 
				
			||||||
 | 
							this.partConverters.add(partConverter);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Sets the character set used for writing form data.
 | 
						 * Sets the character set used for writing form data.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
| 
						 | 
					@ -160,7 +162,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public List<MediaType> getSupportedMediaTypes() {
 | 
						public List<MediaType> getSupportedMediaTypes() {
 | 
				
			||||||
		return Collections.unmodifiableList(supportedMediaTypes);
 | 
							return Collections.unmodifiableList(this.supportedMediaTypes);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public MultiValueMap<String, String> read(Class<? extends MultiValueMap<String, ?>> clazz,
 | 
						public MultiValueMap<String, String> read(Class<? extends MultiValueMap<String, ?>> clazz,
 | 
				
			||||||
| 
						 | 
					@ -325,8 +327,9 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Generate a multipart boundary. <p>Default implementation returns a random boundary. Can be overridden in
 | 
						 * Generate a multipart boundary.
 | 
				
			||||||
	 * subclasses.
 | 
						 * <p>The default implementation returns a random boundary.
 | 
				
			||||||
 | 
						 * Can be overridden in subclasses.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	protected byte[] generateMultipartBoundary() {
 | 
						protected byte[] generateMultipartBoundary() {
 | 
				
			||||||
		byte[] boundary = new byte[rnd.nextInt(11) + 30];
 | 
							byte[] boundary = new byte[rnd.nextInt(11) + 30];
 | 
				
			||||||
| 
						 | 
					@ -337,10 +340,10 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Return the filename of the given multipart part. This value will be used for the {@code Content-Disposition} header.
 | 
						 * Return the filename of the given multipart part. This value will be used for the
 | 
				
			||||||
	 * <p>Default implementation returns {@link Resource#getFilename()} if the part is a {@code Resource}, and {@code null}
 | 
						 * {@code Content-Disposition} header.
 | 
				
			||||||
	 * in other cases. Can be overridden in subclasses.
 | 
						 * <p>The default implementation returns {@link Resource#getFilename()} if the part is a
 | 
				
			||||||
	 *
 | 
						 * {@code Resource}, and {@code null} in other cases. Can be overridden in subclasses.
 | 
				
			||||||
	 * @param part the part to determine the file name for
 | 
						 * @param part the part to determine the file name for
 | 
				
			||||||
	 * @return the filename, or {@code null} if not known
 | 
						 * @return the filename, or {@code null} if not known
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
| 
						 | 
					@ -354,6 +357,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Implementation of {@link org.springframework.http.HttpOutputMessage} used for writing multipart data.
 | 
						 * Implementation of {@link org.springframework.http.HttpOutputMessage} used for writing multipart data.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -56,21 +56,22 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private HttpHeaders headers;
 | 
						private HttpHeaders headers;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Construct a new instance of the ServletServerHttpRequest based on the given {@link HttpServletRequest}
 | 
						 * Construct a new instance of the ServletServerHttpRequest based on the given {@link HttpServletRequest}.
 | 
				
			||||||
	 *
 | 
						 * @param servletRequest the servlet request
 | 
				
			||||||
	 * @param servletRequest the HttpServletRequest
 | 
					 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public ServletServerHttpRequest(HttpServletRequest servletRequest) {
 | 
						public ServletServerHttpRequest(HttpServletRequest servletRequest) {
 | 
				
			||||||
		Assert.notNull(servletRequest, "'servletRequest' must not be null");
 | 
							Assert.notNull(servletRequest, "'servletRequest' must not be null");
 | 
				
			||||||
		this.servletRequest = servletRequest;
 | 
							this.servletRequest = servletRequest;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Returns the {@code HttpServletRequest} this object is based on.
 | 
						 * Returns the {@code HttpServletRequest} this object is based on.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public HttpServletRequest getServletRequest() {
 | 
						public HttpServletRequest getServletRequest() {
 | 
				
			||||||
		return servletRequest;
 | 
							return this.servletRequest;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public HttpMethod getMethod() {
 | 
						public HttpMethod getMethod() {
 | 
				
			||||||
| 
						 | 
					@ -79,9 +80,9 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public URI getURI() {
 | 
						public URI getURI() {
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			return new URI(servletRequest.getScheme(), null, servletRequest.getServerName(),
 | 
								return new URI(this.servletRequest.getScheme(), null, this.servletRequest.getServerName(),
 | 
				
			||||||
					servletRequest.getServerPort(), servletRequest.getRequestURI(), servletRequest.getQueryString(),
 | 
										this.servletRequest.getServerPort(), this.servletRequest.getRequestURI(),
 | 
				
			||||||
					null);
 | 
										this.servletRequest.getQueryString(), null);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		catch (URISyntaxException ex) {
 | 
							catch (URISyntaxException ex) {
 | 
				
			||||||
			throw new IllegalStateException("Could not get HttpServletRequest URI: " + ex.getMessage(), ex);
 | 
								throw new IllegalStateException("Could not get HttpServletRequest URI: " + ex.getMessage(), ex);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,7 +43,7 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Construct a new instance of the ServletServerHttpResponse based on the given {@link HttpServletResponse}.
 | 
						 * Construct a new instance of the ServletServerHttpResponse based on the given {@link HttpServletResponse}.
 | 
				
			||||||
	 * @param servletResponse the HTTP Servlet response
 | 
						 * @param servletResponse the servlet response
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public ServletServerHttpResponse(HttpServletResponse servletResponse) {
 | 
						public ServletServerHttpResponse(HttpServletResponse servletResponse) {
 | 
				
			||||||
		Assert.notNull(servletResponse, "'servletResponse' must not be null");
 | 
							Assert.notNull(servletResponse, "'servletResponse' must not be null");
 | 
				
			||||||
| 
						 | 
					@ -52,10 +52,10 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Returns the {@code HttpServletResponse} this object is based on.
 | 
						 * Return the {@code HttpServletResponse} this object is based on.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public HttpServletResponse getServletResponse() {
 | 
						public HttpServletResponse getServletResponse() {
 | 
				
			||||||
		return servletResponse;
 | 
							return this.servletResponse;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void setStatusCode(HttpStatus status) {
 | 
						public void setStatusCode(HttpStatus status) {
 | 
				
			||||||
| 
						 | 
					@ -63,7 +63,7 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public HttpHeaders getHeaders() {
 | 
						public HttpHeaders getHeaders() {
 | 
				
			||||||
		return headersWritten ? HttpHeaders.readOnlyHttpHeaders(headers) : this.headers;
 | 
							return (this.headersWritten ? HttpHeaders.readOnlyHttpHeaders(this.headers) : this.headers);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public OutputStream getBody() throws IOException {
 | 
						public OutputStream getBody() throws IOException {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,7 +46,9 @@ import org.springframework.util.MultiValueMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import static org.junit.Assert.*;
 | 
					import static org.junit.Assert.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** @author Arjen Poutsma */
 | 
					/**
 | 
				
			||||||
 | 
					 * @author Arjen Poutsma
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class FormHttpMessageConverterTests {
 | 
					public class FormHttpMessageConverterTests {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private FormHttpMessageConverter converter;
 | 
						private FormHttpMessageConverter converter;
 | 
				
			||||||
| 
						 | 
					@ -184,5 +186,4 @@ public class FormHttpMessageConverterTests {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue