Browse Source

polishing

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4497 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/merge
Juergen Hoeller 15 years ago
parent
commit
80c86075f0
  1. 2
      org.springframework.beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
  2. 2
      org.springframework.web/src/main/java/org/springframework/http/HttpHeaders.java
  3. 32
      org.springframework.web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java
  4. 15
      org.springframework.web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java
  5. 8
      org.springframework.web/src/main/java/org/springframework/http/server/ServletServerHttpResponse.java
  6. 5
      org.springframework.web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java

2
org.springframework.beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

@ -567,7 +567,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -567,7 +567,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
}
@Override
protected Class predictBeanType(String beanName, RootBeanDefinition mbd, Class[] typesToMatch) {
protected Class predictBeanType(String beanName, RootBeanDefinition mbd, Class... typesToMatch) {
Class beanClass;
if (mbd.getFactoryMethodName() != null) {
beanClass = getTypeForFactoryMethod(beanName, mbd, typesToMatch);

2
org.springframework.web/src/main/java/org/springframework/http/HttpHeaders.java

@ -318,7 +318,7 @@ public class HttpHeaders implements MultiValueMap<String, String> { @@ -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.endsWith("\""), "Invalid eTag, does not end with \"");
}
set(ETAG, eTag);
set(ETAG, eTag);
}
/**

32
org.springframework.web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java

@ -86,6 +86,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue @@ -86,6 +86,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
private List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
public FormHttpMessageConverter() {
this.supportedMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);
this.supportedMediaTypes.add(MediaType.MULTIPART_FORM_DATA);
@ -97,13 +98,6 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue @@ -97,13 +98,6 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
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.
@ -113,6 +107,14 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue @@ -113,6 +107,14 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
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.
*/
@ -160,7 +162,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue @@ -160,7 +162,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
}
public List<MediaType> getSupportedMediaTypes() {
return Collections.unmodifiableList(supportedMediaTypes);
return Collections.unmodifiableList(this.supportedMediaTypes);
}
public MultiValueMap<String, String> read(Class<? extends MultiValueMap<String, ?>> clazz,
@ -325,8 +327,9 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue @@ -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
* subclasses.
* Generate a multipart boundary.
* <p>The default implementation returns a random boundary.
* Can be overridden in subclasses.
*/
protected byte[] generateMultipartBoundary() {
byte[] boundary = new byte[rnd.nextInt(11) + 30];
@ -337,10 +340,10 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue @@ -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.
* <p>Default implementation returns {@link Resource#getFilename()} if the part is a {@code Resource}, and {@code null}
* in other cases. Can be overridden in subclasses.
*
* Return the filename of the given multipart part. This value will be used for the
* {@code Content-Disposition} header.
* <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
* @return the filename, or {@code null} if not known
*/
@ -354,6 +357,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue @@ -354,6 +357,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
}
}
/**
* Implementation of {@link org.springframework.http.HttpOutputMessage} used for writing multipart data.
*/

15
org.springframework.web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java

@ -56,21 +56,22 @@ public class ServletServerHttpRequest implements ServerHttpRequest { @@ -56,21 +56,22 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
private HttpHeaders headers;
/**
* Construct a new instance of the ServletServerHttpRequest based on the given {@link HttpServletRequest}
*
* @param servletRequest the HttpServletRequest
* Construct a new instance of the ServletServerHttpRequest based on the given {@link HttpServletRequest}.
* @param servletRequest the servlet request
*/
public ServletServerHttpRequest(HttpServletRequest servletRequest) {
Assert.notNull(servletRequest, "'servletRequest' must not be null");
this.servletRequest = servletRequest;
}
/**
* Returns the {@code HttpServletRequest} this object is based on.
*/
public HttpServletRequest getServletRequest() {
return servletRequest;
return this.servletRequest;
}
public HttpMethod getMethod() {
@ -79,9 +80,9 @@ public class ServletServerHttpRequest implements ServerHttpRequest { @@ -79,9 +80,9 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
public URI getURI() {
try {
return new URI(servletRequest.getScheme(), null, servletRequest.getServerName(),
servletRequest.getServerPort(), servletRequest.getRequestURI(), servletRequest.getQueryString(),
null);
return new URI(this.servletRequest.getScheme(), null, this.servletRequest.getServerName(),
this.servletRequest.getServerPort(), this.servletRequest.getRequestURI(),
this.servletRequest.getQueryString(), null);
}
catch (URISyntaxException ex) {
throw new IllegalStateException("Could not get HttpServletRequest URI: " + ex.getMessage(), ex);

8
org.springframework.web/src/main/java/org/springframework/http/server/ServletServerHttpResponse.java

@ -43,7 +43,7 @@ public class ServletServerHttpResponse implements ServerHttpResponse { @@ -43,7 +43,7 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
/**
* 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) {
Assert.notNull(servletResponse, "'servletResponse' must not be null");
@ -52,10 +52,10 @@ public class ServletServerHttpResponse implements ServerHttpResponse { @@ -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() {
return servletResponse;
return this.servletResponse;
}
public void setStatusCode(HttpStatus status) {
@ -63,7 +63,7 @@ public class ServletServerHttpResponse implements ServerHttpResponse { @@ -63,7 +63,7 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
}
public HttpHeaders getHeaders() {
return headersWritten ? HttpHeaders.readOnlyHttpHeaders(headers) : this.headers;
return (this.headersWritten ? HttpHeaders.readOnlyHttpHeaders(this.headers) : this.headers);
}
public OutputStream getBody() throws IOException {

5
org.springframework.web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java

@ -46,7 +46,9 @@ import org.springframework.util.MultiValueMap; @@ -46,7 +46,9 @@ import org.springframework.util.MultiValueMap;
import static org.junit.Assert.*;
/** @author Arjen Poutsma */
/**
* @author Arjen Poutsma
*/
public class FormHttpMessageConverterTests {
private FormHttpMessageConverter converter;
@ -184,5 +186,4 @@ public class FormHttpMessageConverterTests { @@ -184,5 +186,4 @@ public class FormHttpMessageConverterTests {
}
}
}

Loading…
Cancel
Save