org.springframework.aop.framework.adapter
Class ThrowsAdviceInterceptor

java.lang.Object
  extended by org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor
All Implemented Interfaces:
AfterAdvice

public class ThrowsAdviceInterceptor
extends java.lang.Object
implements AfterAdvice

Interceptor to wrap an after-throwing advice.

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.

Author:
Rod Johnson, Juergen Hoeller

Field Summary
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 Summary
ThrowsAdviceInterceptor(java.lang.Object throwsAdvice)
          Create a new ThrowsAdviceInterceptor for the given ThrowsAdvice.
 
Method Summary
private  java.lang.reflect.Method getExceptionHandler(java.lang.Throwable exception)
          Determine the exception handle method.
 int getHandlerMethodCount()
           
 java.lang.Object invoke(MethodInvocation mi)
           
private  void invokeHandlerMethod(MethodInvocation mi, java.lang.Throwable ex, java.lang.reflect.Method method)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AFTER_THROWING

private static final java.lang.String AFTER_THROWING
See Also:
Constant Field Values

logger

private static final Log logger

throwsAdvice

private final java.lang.Object throwsAdvice

exceptionHandlerMap

private final java.util.Map<java.lang.Class,java.lang.reflect.Method> exceptionHandlerMap
Methods on throws advice, keyed by exception class

Constructor Detail

ThrowsAdviceInterceptor

public ThrowsAdviceInterceptor(java.lang.Object throwsAdvice)
Create a new ThrowsAdviceInterceptor for the given ThrowsAdvice.

Parameters:
throwsAdvice - the advice object that defines the exception handler methods (usually a ThrowsAdvice implementation)
Method Detail

getHandlerMethodCount

public int getHandlerMethodCount()

getExceptionHandler

private java.lang.reflect.Method getExceptionHandler(java.lang.Throwable exception)
Determine the exception handle method. Can return null if not found.

Parameters:
exception - the exception thrown
Returns:
a handler for the given exception type

invoke

public java.lang.Object invoke(MethodInvocation mi)
                        throws java.lang.Throwable
Throws:
java.lang.Throwable

invokeHandlerMethod

private void invokeHandlerMethod(MethodInvocation mi,
                                 java.lang.Throwable ex,
                                 java.lang.reflect.Method method)
                          throws java.lang.Throwable
Throws:
java.lang.Throwable