Top Description Fields Constructors Methods
org.springframework.aop.interceptor

public final Class ExposeInvocationInterceptor

extends Object
implements MethodInterceptor, PriorityOrdered, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.springframework.core.PriorityOrdered, org.springframework.core.Ordered, org.aopalliance.intercept.MethodInterceptor, org.aopalliance.intercept.Interceptor, org.aopalliance.aop.Advice
Annotations
@SuppressWarnings:serial
Imports
java.io.Serializable, org.aopalliance.intercept.MethodInterceptor, .MethodInvocation, org.springframework.aop.Advisor, org.springframework.aop.support.DefaultPointcutAdvisor, org.springframework.core.NamedThreadLocal, .PriorityOrdered, org.springframework.lang.Nullable

Interceptor that exposes the current org.aopalliance.intercept.MethodInvocation 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.

Authors
Rod Johnson, Juergen Hoeller

Field Summary

Modifier and TypeField and Description
public static final Advisor
ADVISOR

Singleton advisor for this class.

public static final ExposeInvocationInterceptor
INSTANCE

Singleton instance of this class.

private static final ThreadLocal<MethodInvocation>

Constructor Summary

AccessConstructor and Description
private
ExposeInvocationInterceptor()

Ensures that only the canonical instance can be created.

Method Summary

Modifier and TypeMethod and Description
public static MethodInvocation

Returns:

the invocation object associated with the current invocation
currentInvocation
()

Return the AOP Alliance MethodInvocation object associated with the current invocation.

public int
getOrder()

Implements org.springframework.core.Ordered.getOrder.

Get the order value of this object.

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 Object
readResolve()

Required to support serialization.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ADVISORback to summary
public static final Advisor ADVISOR

Singleton advisor for this class. Use in preference to INSTANCE when using Spring AOP, as it prevents the need to create a new Advisor to wrap the instance.

INSTANCEback to summary
public static final ExposeInvocationInterceptor INSTANCE

Singleton instance of this class.

invocationback to summary
private static final ThreadLocal<MethodInvocation> invocation

Constructor Detail

ExposeInvocationInterceptorback to summary
private ExposeInvocationInterceptor()

Ensures that only the canonical instance can be created.

Method Detail

currentInvocationback to summary
public static MethodInvocation currentInvocation() throws IllegalStateException

Return the AOP Alliance MethodInvocation object associated with the current invocation.

Returns:MethodInvocation

the invocation object associated with the current invocation

Exceptions
IllegalStateException:
if there is no AOP invocation in progress, or if the ExposeInvocationInterceptor was not added to this interceptor chain
getOrderback to summary
public int getOrder()

Implements org.springframework.core.Ordered.getOrder.

Doc from org.springframework.core.Ordered.getOrder.

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.

Returns:int

the order value

Annotations
@Override
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
readResolveback to summary
private Object readResolve()

Required to support serialization. Replaces with canonical instance on deserialization, protecting Singleton pattern.

Alternative to overriding the equals method.