From 82339ea9bfa689995b8c614bba8646e9fa12f1ca Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 17 Jun 2011 13:14:34 +0000 Subject: [PATCH] SPR-7278 extension hook to extend the @ExceptionHandler methods for a controller git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4571 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../annotation/ExceptionHandlerExceptionResolver.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java index 16a6a005ecb..c0bbd8ca4f0 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java @@ -264,12 +264,23 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce ExceptionMethodMapping mapping = exceptionMethodMappingCache.get(handlerType); if (mapping == null) { Set methods = HandlerMethodSelector.selectMethods(handlerType, EXCEPTION_HANDLER_METHODS); + extendExceptionHandlerMethods(methods, handlerType); mapping = new ExceptionMethodMapping(methods); exceptionMethodMappingCache.put(handlerType, mapping); } return mapping; } + /** + * Extension hook that subclasses can override to register additional @{@link ExceptionHandler} methods + * by controller type. By default only @{@link ExceptionHandler} methods from the same controller are + * included. + * @param methods the list of @{@link ExceptionHandler} methods detected in the controller allowing to add more + * @param handlerType the controller type to which the @{@link ExceptionHandler} methods will apply + */ + protected void extendExceptionHandlerMethods(Set methods, Class handlerType) { + } + /** * MethodFilter that matches {@link ExceptionHandler @ExceptionHandler} methods. */