Add @ReplyTo/@ReplyToUser, remove deps on spring-web

This commit is contained in:
Rossen Stoyanchev
2013-07-16 22:07:46 -04:00
parent 55dae74f15
commit 078cfb3e78
30 changed files with 1385 additions and 307 deletions

View File

@@ -206,7 +206,7 @@ public class HandlerMethod {
* @return the annotation, or {@code null} if none found
*/
public <A extends Annotation> A getMethodAnnotation(Class<A> annotationType) {
return AnnotationUtils.findAnnotation(this.method, annotationType);
return AnnotationUtils.findAnnotation(this.bridgedMethod, annotationType);
}
/**

View File

@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -32,12 +32,13 @@ import org.springframework.util.ReflectionUtils.MethodFilter;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.method.HandlerMethodSelector;
/**
* Discovers {@linkplain ExceptionHandler @ExceptionHandler} methods in a given class
* type, including all super types, and helps to resolve an Exception to the method
* its mapped to. Exception mappings are defined through {@code @ExceptionHandler}
* annotation or by looking at the signature of an {@code @ExceptionHandler} method.
*
* Discovers annotated exception handling methods in a given class type, including all
* super types, and helps to resolve an Exception to a method that can handle it. The
* exception types supported by a given method can also be discovered from the method
* signature.
*
* @author Rossen Stoyanchev
* @since 3.1
*/
@@ -56,17 +57,13 @@ public class ExceptionHandlerMethodResolver {
* @param handlerType the type to introspect
*/
public ExceptionHandlerMethodResolver(Class<?> handlerType) {
for (Method method : HandlerMethodSelector.selectMethods(handlerType, getExceptionHandlerMethods())) {
for (Method method : HandlerMethodSelector.selectMethods(handlerType, EXCEPTION_HANDLER_METHODS)) {
for (Class<? extends Throwable> exceptionType : detectExceptionMappings(method)) {
addExceptionMapping(exceptionType, method);
}
}
}
protected MethodFilter getExceptionHandlerMethods() {
return EXCEPTION_HANDLER_METHODS;
}
/**
* Extract exception mappings from the {@code @ExceptionHandler} annotation
* first and as a fall-back from the method signature.
@@ -91,8 +88,8 @@ public class ExceptionHandlerMethodResolver {
}
protected void detectAnnotationExceptionMappings(Method method, List<Class<? extends Throwable>> result) {
ExceptionHandler annotation = AnnotationUtils.findAnnotation(method, ExceptionHandler.class);
result.addAll(Arrays.asList(annotation.value()));
ExceptionHandler annot = AnnotationUtils.findAnnotation(method, ExceptionHandler.class);
result.addAll(Arrays.asList(annot.value()));
}
private void addExceptionMapping(Class<? extends Throwable> exceptionType, Method method) {
@@ -146,9 +143,8 @@ public class ExceptionHandlerMethodResolver {
}
}
/**
* A filter for selecting {@code @ExceptionHandler} methods.
*/
/** A filter for selecting annotated exception handling methods. */
public final static MethodFilter EXCEPTION_HANDLER_METHODS = new MethodFilter() {
@Override