org.springframework.aop.framework

## 类 ReflectiveMethodInvocation

- java.lang.Object
- - org.springframework.aop.framework.ReflectiveMethodInvocation

- 所有已实现的接口:
    Cloneable, Invocation, Joinpoint, MethodInvocation, ProxyMethodInvocation

      public class ReflectiveMethodInvocation
      extends Object
      implements ProxyMethodInvocation, Cloneable

  Spring's implementation of the AOP Alliance `MethodInvocation` interface, implementing the extended `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(java.lang.String, java.lang.Object)` / `getUserAttribute(java.lang.String)` 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.

  作者:
    Rod Johnson, Juergen Hoeller, Adrian Colyer
  另请参阅:
    `invokeJoinpoint()`, `proceed()`, `invocableClone()`, `setUserAttribute(java.lang.String, java.lang.Object)`, `getUserAttribute(java.lang.String)`

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `protected Object[]` | `arguments`
    `protected List<?>` | `interceptorsAndDynamicMethodMatchers` List of MethodInterceptor and InterceptorAndDynamicMethodMatcher that need dynamic checks.
    `protected Method` | `method`
    `protected Object` | `proxy`
    `protected Object` | `target`

  - ### 构造器概要

    构造器
    限定符 | 构造器和说明
    --- | ---
    `protected` | `ReflectiveMethodInvocation(Object proxy, Object target, Method method, Object[] arguments, Class<?> targetClass, List<Object> interceptorsAndDynamicMethodMatchers)` 创建一个方法调用对象

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `Object[]` | `getArguments()` 方法实现说明: 获取调用对象参数列表
    `Method` | `getMethod()` Return the method invoked on the proxied interface.
    `Object` | `getProxy()` Return the proxy that this method invocation was made through.
    `AccessibleObject` | `getStaticPart()` Return the static part of this joinpoint.
    `Object` | `getThis()` Return the object that holds the current joinpoint's static part.
    `Object` | `getUserAttribute(String key)` Return the value of the specified user attribute.
    `Map<String,Object>` | `getUserAttributes()` Return user attributes associated with this invocation.
    `MethodInvocation` | `invocableClone()` This implementation returns a shallow copy of this invocation object, including an independent copy of the original arguments array.
    `MethodInvocation` | `invocableClone(Object... arguments)` This implementation returns a shallow copy of this invocation object, using the given arguments array for the clone.
    `protected Object` | `invokeJoinpoint()` Invoke the joinpoint using reflection.
    `Object` | `proceed()` 方法实现说明:处理下一个拦截器对象
    `void` | `setArguments(Object... arguments)` Set the arguments to be used on subsequent invocations in the any advice in this chain.
    `void` | `setUserAttribute(String key, Object value)` Add the specified user attribute with the given value to this invocation.
    `String` | `toString()`

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### 字段详细资料

    - #### proxy

          protected final Object proxy

    - #### target

          @Nullable
          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.

  - ### 构造器详细资料

    - #### ReflectiveMethodInvocation

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

      创建一个方法调用对象
      参数:
        `proxy` - 代理对象
        `target` - 目标对象
        `method` - 执行的目标方法
        `arguments` - 执行目标方法的参数
        `targetClass` - 目标对象的class
        `interceptorsAndDynamicMethodMatchers` - 我们的方法拦截器 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.

  - ### 方法详细资料

    - #### getProxy

          public final Object getProxy()

      从接口复制的说明: `ProxyMethodInvocation`
      Return the proxy that this method invocation was made through.
      指定者:
        `getProxy` 在接口中 `ProxyMethodInvocation`
      返回:
        the original proxy object

    - #### getThis

          @Nullable
          public final Object getThis()

      从接口复制的说明: `Joinpoint`
      Return the object that holds the current joinpoint's static part.

      For instance, the target object for an invocation.

      指定者:
        `getThis` 在接口中 `Joinpoint`
      返回:
        the object (can be null if the accessible object is static)

    - #### getStaticPart

          public final AccessibleObject getStaticPart()

      从接口复制的说明: `Joinpoint`
      Return the static part of this joinpoint.

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

      指定者:
        `getStaticPart` 在接口中 `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.
      指定者:
        `getMethod` 在接口中 `MethodInvocation`

    - #### getArguments

          public final Object[] getArguments()

      从接口复制的说明: `Invocation`
      方法实现说明: 获取调用对象参数列表
      指定者:
        `getArguments` 在接口中 `Invocation`

    - #### setArguments

          public void setArguments(Object... arguments)

      从接口复制的说明: `ProxyMethodInvocation`
      Set the arguments to be used on subsequent invocations in the any advice in this chain.
      指定者:
        `setArguments` 在接口中 `ProxyMethodInvocation`
      参数:
        `arguments` - the argument array

    - #### proceed

          @Nullable
          public Object proceed()
                                    throws Throwable

      从接口复制的说明: `Joinpoint`
      方法实现说明:处理下一个拦截器对象
      指定者:
        `proceed` 在接口中 `Joinpoint`
      抛出:
        `Throwable`

    - #### invokeJoinpoint

          @Nullable
          protected Object invokeJoinpoint()
                                               throws Throwable

      Invoke the joinpoint using reflection. Subclasses can override this to use custom invocation.
      返回:
        the return value of the joinpoint
      抛出:
        `Throwable` - if invoking the joinpoint resulted in an exception

    - #### invocableClone

          public MethodInvocation 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.

      指定者:
        `invocableClone` 在接口中 `ProxyMethodInvocation`
      返回:
        an invocable clone of this invocation. `proceed()` can be called once per clone.
      另请参阅:
        `Object.clone()`

    - #### invocableClone

          public MethodInvocation invocableClone(Object... arguments)

      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.

      指定者:
        `invocableClone` 在接口中 `ProxyMethodInvocation`
      参数:
        `arguments` - the arguments that the cloned invocation is supposed to use, overriding the original arguments
      返回:
        an invocable clone of this invocation. `proceed()` can be called once per clone.
      另请参阅:
        `Object.clone()`

    - #### setUserAttribute

          public void setUserAttribute(String key,
                                       @Nullable
                                       Object value)

      从接口复制的说明: `ProxyMethodInvocation`
      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.

      指定者:
        `setUserAttribute` 在接口中 `ProxyMethodInvocation`
      参数:
        `key` - the name of the attribute
        `value` - the value of the attribute, or `null` to reset it

    - #### getUserAttribute

          @Nullable
          public Object getUserAttribute(String key)

      从接口复制的说明: `ProxyMethodInvocation`
      Return the value of the specified user attribute.
      指定者:
        `getUserAttribute` 在接口中 `ProxyMethodInvocation`
      参数:
        `key` - the name of the attribute
      返回:
        the value of the attribute, or `null` if not set
      另请参阅:
        `ProxyMethodInvocation.setUserAttribute(java.lang.String, java.lang.Object)`

    - #### getUserAttributes

          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.

      返回:
        any user attributes associated with this invocation (never `null`)

    - #### toString

          public String toString()

      覆盖:
        `toString` 在类中 `Object`