Class ExposeInvocationInterceptor
- java.lang.Object
- org.springframework.aop.interceptor.ExposeInvocationInterceptor
- All Implemented Interfaces:
Serializable
,Advice
,Interceptor
,MethodInterceptor
,Ordered
,PriorityOrdered
public class ExposeInvocationInterceptor extends Object implements MethodInterceptor, PriorityOrdered, Serializable
Interceptor that exposes the currentMethodInvocation
as a thread-local object. We occasionally need to do this; for example, when a pointcut (e.g. an AspectJ expression pointcut) needs to know the full invocation context.Don't use this interceptor unless this is really necessary. Target objects should not normally know about Spring AOP, as this creates a dependency on Spring API. Target objects should be plain POJOs as far as possible.
If used, this interceptor will normally be the first in the interceptor chain.
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
- Serialized Form
Field Summary
Fields Modifier and Type Field Description static Advisor
ADVISOR
Singleton advisor for this class.static ExposeInvocationInterceptor
INSTANCE
Singleton instance of this classFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MethodInvocation
currentInvocation()
Return the AOP Alliance MethodInvocation object associated with the current invocation.int
getOrder()
Get the order value of this object.Object
invoke(MethodInvocation mi)
Implement this method to perform extra treatments before and after the invocation.
Field Detail
INSTANCE
public static final ExposeInvocationInterceptor INSTANCE
Singleton instance of this class
Method Detail
currentInvocation
public static MethodInvocation currentInvocation() throws IllegalStateException
Return the AOP Alliance MethodInvocation object associated with the current invocation.- Returns:
- the invocation object associated with the current invocation
- Throws:
IllegalStateException
- if there is no AOP invocation in progress, or if the ExposeInvocationInterceptor was not added to this interceptor chain
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
getOrder
public int getOrder()
Description copied from interface:Ordered
Get the order value of this object.Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet
load-on-startup
values).Same order values will result in arbitrary sort positions for the affected objects.
- Specified by:
getOrder
in interfaceOrdered
- Returns:
- the order value
- See Also:
Ordered.HIGHEST_PRECEDENCE
,Ordered.LOWEST_PRECEDENCE