Top Description Fields Constructors Methods
org.springframework.aop.framework.adapter

public Class ThrowsAdviceInterceptor

extends Object
implements MethodInterceptor, AfterAdvice
Class Inheritance
All Implemented Interfaces
org.springframework.aop.AfterAdvice, org.aopalliance.aop.Advice, org.aopalliance.intercept.MethodInterceptor, org.aopalliance.intercept.Interceptor
Imports
java.lang.reflect.InvocationTargetException, .Method, java.util.HashMap, .Map, org.aopalliance.intercept.MethodInterceptor, .MethodInvocation, org.apache.commons.logging.Log, .LogFactory, org.springframework.aop.AfterAdvice, org.springframework.aop.framework.AopConfigException, org.springframework.lang.Nullable, org.springframework.util.Assert

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.

Authors
Rod Johnson, Juergen Hoeller
See Also
MethodBeforeAdviceInterceptor, AfterReturningAdviceInterceptor

Field Summary

Modifier and TypeField and Description
private static final String
private final Map<Class<?>, Method>
exceptionHandlerMap

Methods on throws advice, keyed by exception class.

private static final Log
private final Object

Constructor Summary

AccessConstructor and Description
public
ThrowsAdviceInterceptor(Object
the advice object that defines the exception handler methods (usually a org.springframework.aop.ThrowsAdvice implementation)
throwsAdvice
)

Create a new ThrowsAdviceInterceptor for the given ThrowsAdvice.

Method Summary

Modifier and TypeMethod and Description
private Method

Returns:

a handler for the given exception type, or null if none found
getExceptionHandler
(Throwable
the exception thrown
exception
)

Determine the exception handle method for the given exception.

public int
getHandlerMethodCount()

Return the number of handler methods in this advice.

public Object
invoke(MethodInvocation
the method invocation joinpoint
mi
)

Implements org.aopalliance.intercept.MethodInterceptor.invoke.

Implement this method to perform extra treatments before and after the invocation.
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

AFTER_THROWINGback to summary
private static final String AFTER_THROWING
exceptionHandlerMapback to summary
private final Map<Class<?>, Method> exceptionHandlerMap

Methods on throws advice, keyed by exception class.

loggerback to summary
private static final Log logger
throwsAdviceback to summary
private final Object throwsAdvice

Constructor Detail

ThrowsAdviceInterceptorback to summary
public ThrowsAdviceInterceptor(Object throwsAdvice)

Create a new ThrowsAdviceInterceptor for the given ThrowsAdvice.

Parameters
throwsAdvice:Object

the advice object that defines the exception handler methods (usually a org.springframework.aop.ThrowsAdvice implementation)

Method Detail

getExceptionHandlerback to summary
private Method getExceptionHandler(Throwable exception)

Determine the exception handle method for the given exception.

Parameters
exception:Throwable

the exception thrown

Returns:Method

a handler for the given exception type, or null if none found

Annotations
@Nullable
getHandlerMethodCountback to summary
public int getHandlerMethodCount()

Return the number of handler methods in this advice.

invokeback to summary
public Object invoke(MethodInvocation mi) throws Throwable

Implements org.aopalliance.intercept.MethodInterceptor.invoke.

Doc from org.aopalliance.intercept.MethodInterceptor.invoke.

Implement this method to perform extra treatments before and after the invocation. Polite implementations would certainly like to invoke Joinpoint#proceed().

Parameters
mi:MethodInvocation

the method invocation joinpoint

Returns:Object

the result of the call to Joinpoint#proceed(); might be intercepted by the interceptor

Annotations
@Override
@Nullable
Exceptions
Throwable:
if the interceptors or the target object throws an exception
invokeHandlerMethodback to summary
private void invokeHandlerMethod(MethodInvocation mi, Throwable ex, Method method) throws Throwable