From 157e3382ab300c0017be84553d22d63a002f4bf5 Mon Sep 17 00:00:00 2001 From: Cleverson Sacramento Date: Mon, 22 Apr 2013 09:16:48 -0300 Subject: [PATCH] Tentativa de resolver o problema de detecção de @ExceptionHandler com uso de Proxy --- impl/core/src/main/java/br/gov/frameworkdemoiselle/exception/ExceptionHandlerInterceptor.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/exception/ExceptionHandlerInterceptor.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/exception/ExceptionHandlerInterceptor.java index 1f75d31..c9abc6b 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/exception/ExceptionHandlerInterceptor.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/exception/ExceptionHandlerInterceptor.java @@ -39,7 +39,10 @@ package br.gov.frameworkdemoiselle.exception; import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.interceptor.AroundInvoke; @@ -70,7 +73,7 @@ public class ExceptionHandlerInterceptor implements Serializable { getLogger().info(getBundle().getString("handling-exception", cause.getClass().getCanonicalName())); boolean handled = false; - Class type = target.getClass().getSuperclass(); + Class type = target.getClass(); if (!isLoaded(type)) { loadHandlers(type); @@ -115,7 +118,14 @@ public class ExceptionHandlerInterceptor implements Serializable { */ private void loadHandlers(final Class type) { Map, Method> mapHandlers = new HashMap, Method>(); - Method[] methods = type.getMethods(); + + List methods = new ArrayList(); + Class tempType = type; + + while (tempType != null) { + methods.addAll(Arrays.asList(tempType.getMethods())); + tempType = tempType.getSuperclass(); + } for (Method method : methods) { if (method.isAnnotationPresent(ExceptionHandler.class)) { @@ -123,6 +133,7 @@ public class ExceptionHandlerInterceptor implements Serializable { mapHandlers.put(method.getParameterTypes()[0], method); } } + cache.put(type, mapHandlers); } -- libgit2 0.21.2