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

public Class ReflectiveMethodInvocation

extends Object
implements ProxyMethodInvocation, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, org.springframework.aop.ProxyMethodInvocation, org.aopalliance.intercept.MethodInvocation, org.aopalliance.intercept.Invocation, org.aopalliance.intercept.Joinpoint
Known Direct Subclasses
org.springframework.aop.framework.CglibAopProxy.CglibMethodInvocation
Imports
java.lang.reflect.AccessibleObject, .Method, java.util.HashMap, .List, .Map, org.aopalliance.intercept.MethodInterceptor, .MethodInvocation, org.springframework.aop.ProxyMethodInvocation, org.springframework.aop.support.AopUtils, org.springframework.core.BridgeMethodResolver, org.springframework.lang.Nullable

Spring's implementation of the AOP Alliance org.aopalliance.intercept.MethodInvocation interface, implementing the extended org.springframework.aop.ProxyMethodInvocation interface.

Invokes the target object using reflection. Subclasses can override the invokeJoinpoint() method to change this behavior, so this is also a useful base class for more specialized MethodInvocation implementations.

It is possible to clone an invocation, to invoke proceed() repeatedly (once per clone), using the invocableClone() method. It is also possible to attach custom attributes to the invocation, using the setUserAttribute / getUserAttribute methods.

Note

This class is considered internal and should not be directly accessed. The sole reason for it being public is compatibility with existing framework integrations (e.g. Pitchfork). For any other purposes, use the ProxyMethodInvocation interface instead.

Authors
Rod Johnson, Juergen Hoeller, Adrian Colyer
See Also
invokeJoinpoint, proceed, invocableClone, setUserAttribute, getUserAttribute

Field Summary

Modifier and TypeField and Description
protected Object[]
private int
currentInterceptorIndex

Index from 0 of the current interceptor we're invoking.

protected final List<?>
interceptorsAndDynamicMethodMatchers

List of MethodInterceptor and InterceptorAndDynamicMethodMatcher that need dynamic checks.

protected final Method
protected final Object
protected final Object
private final Class<?>
private Map<String, Object>
userAttributes

Lazily initialized map of user-specific attributes for this invocation.

Constructor Summary

AccessConstructor and Description
protected
ReflectiveMethodInvocation(Object
the proxy object that the invocation was made on
proxy
,
Object
the target object to invoke
target
,
Method
the method to invoke
method
,
Object[]
the arguments to invoke the method with
arguments
,
Class<?>
the target class, for MethodMatcher invocations
targetClass
,
List<Object>
interceptors that should be applied, along with any InterceptorAndDynamicMethodMatchers that need evaluation at runtime. MethodMatchers included in this struct must already have been found to have matched as far as was possibly statically. Passing an array might be about 10% faster, but would complicate the code. And it would work only for static pointcuts.
interceptorsAndDynamicMethodMatchers
)

Construct a new ReflectiveMethodInvocation with the given arguments.

Method Summary

Modifier and TypeMethod and Description
public final Object[]
getArguments()

Implements org.aopalliance.intercept.Invocation.getArguments.

Get the arguments as an array object.

public final Method
getMethod()

Implements org.aopalliance.intercept.MethodInvocation.getMethod.

Return the method invoked on the proxied interface.

public final Object
getProxy()

Implements org.springframework.aop.ProxyMethodInvocation.getProxy.

Return the proxy that this method invocation was made through.

public final AccessibleObject
getStaticPart()

Implements org.aopalliance.intercept.Joinpoint.getStaticPart.

Return the static part of this joinpoint.

public final Object
getThis()

Implements org.aopalliance.intercept.Joinpoint.getThis.

Return the object that holds the current joinpoint's static part.

public Object
getUserAttribute(String
the name of the attribute
key
)

Implements org.springframework.aop.ProxyMethodInvocation.getUserAttribute.

Return the value of the specified user attribute.

public Map<String, Object>

Returns:

any user attributes associated with this invocation (never null)
getUserAttributes
()

Return user attributes associated with this invocation.

public MethodInvocation
invocableClone()

Implements org.springframework.aop.ProxyMethodInvocation.invocableClone.

This implementation returns a shallow copy of this invocation object, including an independent copy of the original arguments array.

public MethodInvocation
invocableClone(Object...
the arguments that the cloned invocation is supposed to use, overriding the original arguments
arguments
)

Implements org.springframework.aop.ProxyMethodInvocation.invocableClone.

This implementation returns a shallow copy of this invocation object, using the given arguments array for the clone.

protected Object

Returns:

the return value of the joinpoint
invokeJoinpoint
()

Invoke the joinpoint using reflection.

public Object
proceed()

Implements org.aopalliance.intercept.Joinpoint.proceed.

Proceed to the next interceptor in the chain.

public void
setArguments(Object...
the argument array
arguments
)

Implements org.springframework.aop.ProxyMethodInvocation.setArguments.

Set the arguments to be used on subsequent invocations in the any advice in this chain.

public void
setUserAttribute(String
the name of the attribute
key
,
Object
the value of the attribute, or null to reset it
value
)

Implements org.springframework.aop.ProxyMethodInvocation.setUserAttribute.

Add the specified user attribute with the given value to this invocation.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

argumentsback to summary
protected Object[] arguments
currentInterceptorIndexback to summary
private int currentInterceptorIndex

Index from 0 of the current interceptor we're invoking. -1 until we invoke: then the current interceptor.

interceptorsAndDynamicMethodMatchersback to summary
protected final List<?> interceptorsAndDynamicMethodMatchers

List of MethodInterceptor and InterceptorAndDynamicMethodMatcher that need dynamic checks.

methodback to summary
protected final Method method
proxyback to summary
protected final Object proxy
targetback to summary
protected final Object target
Annotations
@Nullable
targetClassback to summary
private final Class<?> targetClass
Annotations
@Nullable
userAttributesback to summary
private Map<String, Object> userAttributes

Lazily initialized map of user-specific attributes for this invocation.

Annotations
@Nullable

Constructor Detail

ReflectiveMethodInvocationback to summary
protected ReflectiveMethodInvocation(Object proxy, Object target, Method method, Object[] arguments, Class<?> targetClass, List<Object> interceptorsAndDynamicMethodMatchers)

Construct a new ReflectiveMethodInvocation with the given arguments.

Parameters
proxy:Object

the proxy object that the invocation was made on

target:Object

the target object to invoke

method:Method

the method to invoke

arguments:Object[]

the arguments to invoke the method with

targetClass:Class<?>

the target class, for MethodMatcher invocations

interceptorsAndDynamicMethodMatchers:List<Object>

interceptors that should be applied, along with any InterceptorAndDynamicMethodMatchers that need evaluation at runtime. MethodMatchers included in this struct must already have been found to have matched as far as was possibly statically. Passing an array might be about 10% faster, but would complicate the code. And it would work only for static pointcuts.

Method Detail

getArgumentsback to summary
public final Object[] getArguments()

Implements org.aopalliance.intercept.Invocation.getArguments.

Doc from org.aopalliance.intercept.Invocation.getArguments.

Get the arguments as an array object. It is possible to change element values within this array to change the arguments.

Returns:Object[]

the argument of the invocation

Annotations
@Override
getMethodback to summary
public final Method getMethod()

Implements org.aopalliance.intercept.MethodInvocation.getMethod.

Return the method invoked on the proxied interface. May or may not correspond with a method invoked on an underlying implementation of that interface.

Returns:Method

Doc from org.aopalliance.intercept.MethodInvocation.getMethod.

the method being called

Annotations
@Override
getProxyback to summary
public final Object getProxy()

Implements org.springframework.aop.ProxyMethodInvocation.getProxy.

Doc from org.springframework.aop.ProxyMethodInvocation.getProxy.

Return the proxy that this method invocation was made through.

Returns:Object

the original proxy object

Annotations
@Override
getStaticPartback to summary
public final AccessibleObject getStaticPart()

Implements org.aopalliance.intercept.Joinpoint.getStaticPart.

Doc from org.aopalliance.intercept.Joinpoint.getStaticPart.

Return the static part of this joinpoint.

The static part is an accessible object on which a chain of interceptors is installed.

Annotations
@Override
getThisback to summary
public final Object getThis()

Implements org.aopalliance.intercept.Joinpoint.getThis.

Doc from org.aopalliance.intercept.Joinpoint.getThis.

Return the object that holds the current joinpoint's static part.

For instance, the target object for an invocation.

Returns:Object

the object (can be null if the accessible object is static)

Annotations
@Override
@Nullable
getUserAttributeback to summary
public Object getUserAttribute(String key)

Implements org.springframework.aop.ProxyMethodInvocation.getUserAttribute.

Doc from org.springframework.aop.ProxyMethodInvocation.getUserAttribute.

Return the value of the specified user attribute.

Parameters
key:String

the name of the attribute

Returns:Object

the value of the attribute, or null if not set

Annotations
@Override
@Nullable
getUserAttributesback to summary
public Map<String, Object> getUserAttributes()

Return user attributes associated with this invocation. This method provides an invocation-bound alternative to a ThreadLocal.

This map is initialized lazily and is not used in the AOP framework itself.

Returns:Map<String, Object>

any user attributes associated with this invocation (never null)

invocableCloneback to summary
public MethodInvocation invocableClone()

Implements org.springframework.aop.ProxyMethodInvocation.invocableClone.

This implementation returns a shallow copy of this invocation object, including an independent copy of the original arguments array.

We want a shallow copy in this case: We want to use the same interceptor chain and other object references, but we want an independent value for the current interceptor index.

Returns:MethodInvocation

Doc from org.springframework.aop.ProxyMethodInvocation.invocableClone.

an invocable clone of this invocation. proceed() can be called once per clone.

Annotations
@Override
See Also
java.lang.Object#clone()
invocableCloneback to summary
public MethodInvocation invocableClone(Object... arguments)

Implements org.springframework.aop.ProxyMethodInvocation.invocableClone.

This implementation returns a shallow copy of this invocation object, using the given arguments array for the clone.

We want a shallow copy in this case: We want to use the same interceptor chain and other object references, but we want an independent value for the current interceptor index.

Parameters
arguments:Object[]

Doc from org.springframework.aop.ProxyMethodInvocation.invocableClone.

the arguments that the cloned invocation is supposed to use, overriding the original arguments

Returns:MethodInvocation

Doc from org.springframework.aop.ProxyMethodInvocation.invocableClone.

an invocable clone of this invocation. proceed() can be called once per clone.

Annotations
@Override
See Also
java.lang.Object#clone()
invokeJoinpointback to summary
protected Object invokeJoinpoint() throws Throwable

Invoke the joinpoint using reflection. Subclasses can override this to use custom invocation.

Returns:Object

the return value of the joinpoint

Annotations
@Nullable
Exceptions
Throwable:
if invoking the joinpoint resulted in an exception
proceedback to summary
public Object proceed() throws Throwable

Implements org.aopalliance.intercept.Joinpoint.proceed.

Doc from org.aopalliance.intercept.Joinpoint.proceed.

Proceed to the next interceptor in the chain.

The implementation and the semantics of this method depends on the actual joinpoint type (see the children interfaces).

Returns:Object

see the children interfaces' proceed definition

Annotations
@Override
@Nullable
Exceptions
Throwable:
if the joinpoint throws an exception
setArgumentsback to summary
public void setArguments(Object... arguments)

Implements org.springframework.aop.ProxyMethodInvocation.setArguments.

Doc from org.springframework.aop.ProxyMethodInvocation.setArguments.

Set the arguments to be used on subsequent invocations in the any advice in this chain.

Parameters
arguments:Object[]

the argument array

Annotations
@Override
setUserAttributeback to summary
public void setUserAttribute(String key, Object value)

Implements org.springframework.aop.ProxyMethodInvocation.setUserAttribute.

Doc from org.springframework.aop.ProxyMethodInvocation.setUserAttribute.

Add the specified user attribute with the given value to this invocation.

Such attributes are not used within the AOP framework itself. They are just kept as part of the invocation object, for use in special interceptors.

Parameters
key:String

the name of the attribute

value:Object

the value of the attribute, or null to reset it

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override