Browse Source

Polish

pull/802/merge
Rossen Stoyanchev 10 years ago
parent
commit
3e74476c11
  1. 36
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java

36
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java

@ -200,6 +200,22 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi @@ -200,6 +200,22 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
return info;
}
/**
* Delegates to {@link #createRequestMappingInfo(RequestMapping, RequestCondition)},
* supplying the appropriate custom {@link RequestCondition} depending on whether
* the supplied {@code annotatedElement} is a class or method.
*
* @see #getCustomTypeCondition(Class)
* @see #getCustomMethodCondition(Method)
*/
private RequestMappingInfo createRequestMappingInfo(AnnotatedElement element) {
RequestMapping requestMapping = AnnotatedElementUtils.findAnnotation(element, RequestMapping.class);
RequestCondition<?> condition = (element instanceof Class<?> ?
getCustomTypeCondition((Class<?>) element) :
getCustomMethodCondition((Method) element));
return (requestMapping != null ? createRequestMappingInfo(requestMapping, condition) : null);
}
/**
* Provide a custom type-level request condition.
* The custom {@link RequestCondition} can be of any type so long as the
@ -211,6 +227,7 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi @@ -211,6 +227,7 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
* @param handlerType the handler type for which to create the condition
* @return the condition, or {@code null}
*/
@SuppressWarnings("unused")
protected RequestCondition<?> getCustomTypeCondition(Class<?> handlerType) {
return null;
}
@ -226,25 +243,11 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi @@ -226,25 +243,11 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
* @param method the handler method for which to create the condition
* @return the condition, or {@code null}
*/
@SuppressWarnings("unused")
protected RequestCondition<?> getCustomMethodCondition(Method method) {
return null;
}
/**
* Delegates to {@link #createRequestMappingInfo(RequestMapping, RequestCondition)},
* supplying the appropriate custom {@link RequestCondition} depending on whether
* the supplied {@code annotatedElement} is a class or method.
*
* @see #getCustomTypeCondition(Class)
* @see #getCustomMethodCondition(Method)
*/
private RequestMappingInfo createRequestMappingInfo(AnnotatedElement annotatedElement) {
RequestMapping requestMapping = AnnotatedElementUtils.findAnnotation(annotatedElement, RequestMapping.class);
RequestCondition<?> customCondition = ((annotatedElement instanceof Class<?>) ? getCustomTypeCondition((Class<?>) annotatedElement)
: getCustomMethodCondition((Method) annotatedElement));
return ((requestMapping != null) ? createRequestMappingInfo(requestMapping, customCondition) : null);
}
/**
* Create a {@link RequestMappingInfo} from the supplied
* {@link RequestMapping @RequestMapping} annotation, which is either
@ -254,7 +257,8 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi @@ -254,7 +257,8 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
protected RequestMappingInfo createRequestMappingInfo(RequestMapping requestMapping,
RequestCondition<?> customCondition) {
return RequestMappingInfo.paths(resolveEmbeddedValuesInPatterns(requestMapping.path()))
return RequestMappingInfo
.paths(resolveEmbeddedValuesInPatterns(requestMapping.path()))
.methods(requestMapping.method())
.params(requestMapping.params())
.headers(requestMapping.headers())

Loading…
Cancel
Save