org.springframework.aop.framework
Class ReflectiveMethodInvocation

java.lang.Object
  extended by org.springframework.aop.framework.ReflectiveMethodInvocation
All Implemented Interfaces:
Cloneable, Invocation, Joinpoint, MethodInvocation, ProxyMethodInvocation

public class ReflectiveMethodInvocation
extends Object
implements ProxyMethodInvocation, Cloneable

Spring's implementation of AOP Alliance MethodInvocation 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 add custom attributes to the invocation (since 1.2.6) using the getUserAttributes() method.

Author:
Rod Johnson, Juergen Hoeller
See Also:
invokeJoinpoint(), proceed(), invocableClone()

Field Summary
protected  Object[] arguments
           
protected  List interceptorsAndDynamicMethodMatchers
          List of MethodInterceptor and InterceptorAndDynamicMethodMatcher that need dynamic checks.
protected  Method method
           
protected  Object proxy
           
protected  Object target
           
 
Constructor Summary
ReflectiveMethodInvocation(Object proxy, Object target, Method method, Object[] arguments, Class targetClass, List interceptorsAndDynamicMethodMatchers)
          Construct a new MethodInvocation with given arguments
 
Method Summary
 Object[] getArguments()
           
 Method getMethod()
          Return the method invoked on the proxied interface.
 Object getProxy()
          Return the proxy that this interception was made through.
 AccessibleObject getStaticPart()
           
 Object getThis()
           
 Map getUserAttributes()
          Return user attributes associated with this invocation.
 MethodInvocation invocableClone()
          Create a clone of this object.
protected  Object invokeJoinpoint()
          Invoke the joinpoint using reflection.
 Object proceed()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

proxy

protected final Object proxy

target

protected final Object target

method

protected final Method method

arguments

protected Object[] arguments

interceptorsAndDynamicMethodMatchers

protected final List interceptorsAndDynamicMethodMatchers
List of MethodInterceptor and InterceptorAndDynamicMethodMatcher that need dynamic checks.

Constructor Detail

ReflectiveMethodInvocation

public ReflectiveMethodInvocation(Object proxy,
                                  Object target,
                                  Method method,
                                  Object[] arguments,
                                  Class targetClass,
                                  List interceptorsAndDynamicMethodMatchers)
Construct a new MethodInvocation with given arguments

Parameters:
interceptorsAndDynamicMethodMatchers - 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

getProxy

public final Object getProxy()
Return the proxy that this interception was made through.

Specified by:
getProxy in interface ProxyMethodInvocation

getThis

public final Object getThis()
Specified by:
getThis in interface Joinpoint

getStaticPart

public final AccessibleObject getStaticPart()
Specified by:
getStaticPart in interface Joinpoint

getMethod

public final Method 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.

Specified by:
getMethod in interface MethodInvocation

getArguments

public final Object[] getArguments()
Specified by:
getArguments in interface Invocation

getUserAttributes

public Map getUserAttributes()
Return user attributes associated with this invocation. This map is initialized lazily and is not used in the AOP framework itself. This method provides an invocation-bound alternative to a ThreadLocal.

Returns:
any user attributes associated with this invocation (never null)

proceed

public Object proceed()
               throws Throwable
Specified by:
proceed in interface Joinpoint
Throws:
Throwable

invokeJoinpoint

protected Object invokeJoinpoint()
                          throws Throwable
Invoke the joinpoint using reflection. Subclasses can override this to use custom invocation.

Returns:
the return value of the joinpoint
Throws:
Throwable - if invoking the joinpoint resulted in an exception

invocableClone

public MethodInvocation invocableClone()
Create a clone of this object. If cloning is done before proceed() is invoked on this object, proceed() can be invoked once per clone to invoke the joinpoint (and the rest of the advice chain) more than once.

This method returns a shallow copy, except for the argument array, which is deep-copied to allow for independent modification. 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:
an invocable clone of this invocation. proceed() can be called once per clone.
See Also:
Object.clone()

toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2002-2006 The Spring Framework Project.