Browse Source

Polishing

pull/762/head
Juergen Hoeller 11 years ago
parent
commit
beae336627
  1. 7
      spring-context/src/main/java/org/springframework/cache/interceptor/CacheResolver.java
  2. 4
      spring-web/src/main/java/org/springframework/http/ResponseEntity.java
  3. 17
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessor.java

7
spring-context/src/main/java/org/springframework/cache/interceptor/CacheResolver.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,7 +23,7 @@ import org.springframework.cache.Cache; @@ -23,7 +23,7 @@ import org.springframework.cache.Cache;
/**
* Determine the {@link Cache} instance(s) to use for an intercepted method invocation.
*
* <p>Implementations MUST be thread-safe.
* <p>Implementations must be thread-safe.
*
* @author Stephane Nicoll
* @since 4.1
@ -32,9 +32,8 @@ public interface CacheResolver { @@ -32,9 +32,8 @@ public interface CacheResolver {
/**
* Return the cache(s) to use for the specified invocation.
*
* @param context the context of the particular invocation
* @return the cache(s) to use (never null)
* @return the cache(s) to use (never {@code null})
*/
Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context);

4
spring-web/src/main/java/org/springframework/http/ResponseEntity.java

@ -322,10 +322,8 @@ public class ResponseEntity<T> extends HttpEntity<T> { @@ -322,10 +322,8 @@ public class ResponseEntity<T> extends HttpEntity<T> {
/**
* Set the caching directives for the resource, as specified by the
* {@code Cache-Control} header.
*
* <p>A {@code CacheControl} instance can be built like
* {@code CacheControl.maxAge(3600).cachePublic().noTransform()}.
*
* @param cacheControl the instance that builds cache related HTTP response headers
* @return this builder
* @see <a href="https://tools.ietf.org/html/rfc7234#section-5.2">RFC-7234 Section 5.2</a>
@ -441,7 +439,7 @@ public class ResponseEntity<T> extends HttpEntity<T> { @@ -441,7 +439,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
@Override
public BodyBuilder cacheControl(CacheControl cacheControl) {
String ccValue = cacheControl.getHeaderValue();
if(ccValue != null) {
if (ccValue != null) {
this.headers.setCacheControl(cacheControl.getHeaderValue());
}
return this;

17
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessor.java

@ -49,6 +49,7 @@ import org.springframework.web.method.support.ModelAndViewContainer; @@ -49,6 +49,7 @@ import org.springframework.web.method.support.ModelAndViewContainer;
*
* @author Arjen Poutsma
* @author Rossen Stoyanchev
* @author Brian Clozel
* @since 3.1
*/
public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodProcessor {
@ -59,25 +60,27 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro @@ -59,25 +60,27 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro
public HttpEntityMethodProcessor(List<HttpMessageConverter<?>> messageConverters,
ContentNegotiationManager contentNegotiationManager) {
super(messageConverters, contentNegotiationManager);
}
public HttpEntityMethodProcessor(List<HttpMessageConverter<?>> messageConverters,
ContentNegotiationManager contentNegotiationManager, List<Object> responseBodyAdvice) {
super(messageConverters, contentNegotiationManager, responseBodyAdvice);
}
@Override
public boolean supportsParameter(MethodParameter parameter) {
return HttpEntity.class.equals(parameter.getParameterType()) ||
RequestEntity.class.equals(parameter.getParameterType());
return (HttpEntity.class.equals(parameter.getParameterType()) ||
RequestEntity.class.equals(parameter.getParameterType()));
}
@Override
public boolean supportsReturnType(MethodParameter returnType) {
return HttpEntity.class.isAssignableFrom(returnType.getParameterType()) &&
!RequestEntity.class.isAssignableFrom(returnType.getParameterType());
return (HttpEntity.class.isAssignableFrom(returnType.getParameterType()) &&
!RequestEntity.class.isAssignableFrom(returnType.getParameterType()));
}
@Override
@ -142,9 +145,9 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro @@ -142,9 +145,9 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro
Object body = responseEntity.getBody();
if (responseEntity instanceof ResponseEntity) {
if (isResourceNotModified(webRequest, (ResponseEntity<?>) responseEntity)) {
// Ensure headers are flushed, no body should be written
// Ensure headers are flushed, no body should be written.
outputMessage.flush();
// skip call to converters, as they may update the body
// Skip call to converters, as they may update the body.
return;
}
}
@ -152,7 +155,7 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro @@ -152,7 +155,7 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro
// Try even with null body. ResponseBodyAdvice could get involved.
writeWithMessageConverters(body, returnType, inputMessage, outputMessage);
// Ensure headers are flushed even if no body was written
// Ensure headers are flushed even if no body was written.
outputMessage.flush();
}

Loading…
Cancel
Save