Class ThrowsAdviceInterceptor
- java.lang.Object
- org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor
- All Implemented Interfaces:
Advice
,Interceptor
,MethodInterceptor
,AfterAdvice
public class ThrowsAdviceInterceptor extends Object implements MethodInterceptor, 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
- See Also:
MethodBeforeAdviceInterceptor
,AfterReturningAdviceInterceptor
Constructor Summary
Constructors Constructor Description ThrowsAdviceInterceptor(Object throwsAdvice)
Create a new ThrowsAdviceInterceptor for the given ThrowsAdvice.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getHandlerMethodCount()
Return the number of handler methods in this advice.Object
invoke(MethodInvocation mi)
Implement this method to perform extra treatments before and after the invocation.
Constructor Detail
ThrowsAdviceInterceptor
public ThrowsAdviceInterceptor(Object throwsAdvice)
Create a new ThrowsAdviceInterceptor for the given ThrowsAdvice.- Parameters:
throwsAdvice
- the advice object that defines the exception handler methods (usually aThrowsAdvice
implementation)
Method Detail
getHandlerMethodCount
public int getHandlerMethodCount()
Return the number of handler methods in this advice.
invoke
public Object invoke(MethodInvocation mi) throws Throwable
Description copied from interface:MethodInterceptor
Implement this method to perform extra treatments before and after the invocation. Polite implementations would certainly like to invokeJoinpoint.proceed()
.- Specified by:
invoke
in interfaceMethodInterceptor
- Parameters:
mi
- the method invocation joinpoint- Returns:
- the result of the call to
Joinpoint.proceed()
; might be intercepted by the interceptor - Throws:
Throwable
- if the interceptors or the target object throws an exception