public class ThrowsAdviceInterceptor extends java.lang.Object implements MethodInterceptor, AfterAdvice
The signatures on handler methods on the ThrowsAdvice
implementation method argument must be of the form:
void afterThrowing([Method, args, target], ThrowableSubclass);
Only the last argument is required.
Some examples of valid methods would be:
public void afterThrowing(Exception ex)
public void afterThrowing(RemoteException)
public void afterThrowing(Method method, Object[] args, Object target, Exception ex)
public void afterThrowing(Method method, Object[] args, Object target, ServletException ex)
This is a framework class that need not be used directly by Spring users.
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
AFTER_THROWING |
private java.util.Map<java.lang.Class<?>,java.lang.reflect.Method> |
exceptionHandlerMap
Methods on throws advice, keyed by exception class
|
private static Log |
logger |
private java.lang.Object |
throwsAdvice |
Constructor and Description |
---|
ThrowsAdviceInterceptor(java.lang.Object throwsAdvice)
Create a new ThrowsAdviceInterceptor for the given ThrowsAdvice.
|
Modifier and Type | Method and Description |
---|---|
private java.lang.reflect.Method |
getExceptionHandler(java.lang.Throwable exception)
Determine the exception handle method.
|
int |
getHandlerMethodCount() |
java.lang.Object |
invoke(MethodInvocation mi)
Implement this method to perform extra treatments before and
after the invocation.
|
private void |
invokeHandlerMethod(MethodInvocation mi,
java.lang.Throwable ex,
java.lang.reflect.Method method) |
private static final java.lang.String AFTER_THROWING
private static final Log logger
private final java.lang.Object throwsAdvice
private final java.util.Map<java.lang.Class<?>,java.lang.reflect.Method> exceptionHandlerMap
public ThrowsAdviceInterceptor(java.lang.Object throwsAdvice)
throwsAdvice
- the advice object that defines the exception
handler methods (usually a ThrowsAdvice
implementation)public int getHandlerMethodCount()
private java.lang.reflect.Method getExceptionHandler(java.lang.Throwable exception)
exception
- the exception thrownpublic java.lang.Object invoke(MethodInvocation mi) throws java.lang.Throwable
MethodInterceptor
Joinpoint.proceed()
.invoke
in interface MethodInterceptor
mi
- the method invocation joinpointJoinpoint.proceed()
;
might be intercepted by the interceptorjava.lang.Throwable
- if the interceptors or the target object
throws an exceptionprivate void invokeHandlerMethod(MethodInvocation mi, java.lang.Throwable ex, java.lang.reflect.Method method) throws java.lang.Throwable
java.lang.Throwable