Switch to AnnotatedElementUtils.findXxx for @MVC

Issue: SPR-12296
master
Rossen Stoyanchev 10 years ago
parent 8376e1eca1
commit 86fd0afbf2
  1. 4
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java
  2. 4
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java

@ -379,7 +379,7 @@ public class MvcUriComponentsBuilder {
private static String getTypeRequestMapping(Class<?> controllerType) { private static String getTypeRequestMapping(Class<?> controllerType) {
Assert.notNull(controllerType, "'controllerType' must not be null"); Assert.notNull(controllerType, "'controllerType' must not be null");
String annotType = RequestMapping.class.getName(); String annotType = RequestMapping.class.getName();
AnnotationAttributes attrs = AnnotatedElementUtils.getAnnotationAttributes(controllerType, annotType); AnnotationAttributes attrs = AnnotatedElementUtils.findAnnotationAttributes(controllerType, annotType);
if (attrs == null) { if (attrs == null) {
return "/"; return "/";
} }
@ -396,7 +396,7 @@ public class MvcUriComponentsBuilder {
private static String getMethodRequestMapping(Method method) { private static String getMethodRequestMapping(Method method) {
String annotType = RequestMapping.class.getName(); String annotType = RequestMapping.class.getName();
AnnotationAttributes attrs = AnnotatedElementUtils.getAnnotationAttributes(method, annotType); AnnotationAttributes attrs = AnnotatedElementUtils.findAnnotationAttributes(method, annotType);
if (attrs == null) { if (attrs == null) {
throw new IllegalArgumentException("No @RequestMapping on: " + method.toGenericString()); throw new IllegalArgumentException("No @RequestMapping on: " + method.toGenericString());
} }

@ -246,13 +246,13 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
if (annotatedElement instanceof Class<?>) { if (annotatedElement instanceof Class<?>) {
Class<?> type = (Class<?>) annotatedElement; Class<?> type = (Class<?>) annotatedElement;
annotation = AnnotationUtils.findAnnotation(type, RequestMapping.class); annotation = AnnotationUtils.findAnnotation(type, RequestMapping.class);
attributes = AnnotatedElementUtils.getAnnotationAttributes(type, annotationType); attributes = AnnotatedElementUtils.findAnnotationAttributes(type, annotationType);
customCondition = getCustomTypeCondition(type); customCondition = getCustomTypeCondition(type);
} }
else { else {
Method method = (Method) annotatedElement; Method method = (Method) annotatedElement;
annotation = AnnotationUtils.findAnnotation(method, RequestMapping.class); annotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
attributes = AnnotatedElementUtils.getAnnotationAttributes(method, annotationType); attributes = AnnotatedElementUtils.findAnnotationAttributes(method, annotationType);
customCondition = getCustomMethodCondition(method); customCondition = getCustomMethodCondition(method);
} }
RequestMappingInfo info = null; RequestMappingInfo info = null;

Loading…
Cancel
Save