org.springframework.aop.support

## 类 AopUtils

- java.lang.Object
- - org.springframework.aop.support.AopUtils

-     public abstract class AopUtils
      extends Object

  Utility methods for AOP support code.

  Mainly for internal use within Spring's AOP support.

  See `AopProxyUtils` for a collection of framework-specific AOP utility methods which depend on internals of Spring's AOP framework implementation.

  作者:
    Rod Johnson, Juergen Hoeller, Rob Harrop
  另请参阅:
    `AopProxyUtils`

- - ### 构造器概要

    构造器
    构造器和说明
    `AopUtils()`

  - ### 方法概要

    所有方法 静态方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `static boolean` | `canApply(Advisor advisor, Class<?> targetClass)` Can the given advisor apply at all on the given class?
    `static boolean` | `canApply(Advisor advisor, Class<?> targetClass, boolean hasIntroductions)` Can the given advisor apply at all on the given class?
    `static boolean` | `canApply(Pointcut pc, Class<?> targetClass)` Can the given pointcut apply at all on the given class?
    `static boolean` | `canApply(Pointcut pc, Class<?> targetClass, boolean hasIntroductions)` Can the given pointcut apply at all on the given class?
    `static List<Advisor>` | `findAdvisorsThatCanApply(List<Advisor> candidateAdvisors, Class<?> clazz)` 找到合适的增强器对象
    `static Method` | `getMostSpecificMethod(Method method, Class<?> targetClass)` Given a method, which may come from an interface, and a target class used in the current AOP invocation, find the corresponding target method if there is one.
    `static Class<?>` | `getTargetClass(Object candidate)` Determine the target class of the given bean instance which might be an AOP proxy.
    `static Object` | `invokeJoinpointUsingReflection(Object target, Method method, Object[] args)` Invoke the given target via reflection, as part of an AOP method invocation.
    `static boolean` | `isAopProxy(Object object)` Check whether the given object is a JDK dynamic proxy or a CGLIB proxy.
    `static boolean` | `isCglibProxy(Object object)` Check whether the given object is a CGLIB proxy.
    `static boolean` | `isEqualsMethod(Method method)` Determine whether the given method is an "equals" method.
    `static boolean` | `isFinalizeMethod(Method method)` Determine whether the given method is a "finalize" method.
    `static boolean` | `isHashCodeMethod(Method method)` Determine whether the given method is a "hashCode" method.
    `static boolean` | `isJdkDynamicProxy(Object object)` Check whether the given object is a JDK dynamic proxy.
    `static boolean` | `isToStringMethod(Method method)` Determine whether the given method is a "toString" method.
    `static Method` | `selectInvocableMethod(Method method, Class<?> targetType)` 方法实现说明:判断传入的方法是不是一个 可调用的方法

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

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

- - ### 构造器详细资料

    - #### AopUtils

          public AopUtils()

  - ### 方法详细资料

    - #### isAopProxy

          public static boolean isAopProxy(@Nullable
                                           Object object)

      Check whether the given object is a JDK dynamic proxy or a CGLIB proxy.

      This method additionally checks if the given object is an instance of `SpringProxy`.

      参数:
        `object` - the object to check
      另请参阅:
        `isJdkDynamicProxy(java.lang.Object)`, `isCglibProxy(java.lang.Object)`

    - #### isJdkDynamicProxy

          public static boolean isJdkDynamicProxy(@Nullable
                                                  Object object)

      Check whether the given object is a JDK dynamic proxy.

      This method goes beyond the implementation of `Proxy.isProxyClass(Class)` by additionally checking if the given object is an instance of `SpringProxy`.

      参数:
        `object` - the object to check
      另请参阅:
        `Proxy.isProxyClass(java.lang.Class<?>)`

    - #### isCglibProxy

          public static boolean isCglibProxy(@Nullable
                                             Object object)

      Check whether the given object is a CGLIB proxy.

      This method goes beyond the implementation of `ClassUtils.isCglibProxy(Object)` by additionally checking if the given object is an instance of `SpringProxy`.

      参数:
        `object` - the object to check
      另请参阅:
        `ClassUtils.isCglibProxy(Object)`

    - #### getTargetClass

          public static Class<?> getTargetClass(Object candidate)

      Determine the target class of the given bean instance which might be an AOP proxy.

      Returns the target class for an AOP proxy or the plain class otherwise.

      参数:
        `candidate` - the instance to check (might be an AOP proxy)
      返回:
        the target class (or the plain class of the given object as fallback; never `null`)
      另请参阅:
        `TargetClassAware.getTargetClass()`, `AopProxyUtils.ultimateTargetClass(Object)`

    - #### selectInvocableMethod

          public static Method selectInvocableMethod(Method method,
                                                     @Nullable
                                                     Class<?> targetType)

      方法实现说明:判断传入的方法是不是一个 可调用的方法
      参数:
        `method` - 方法对象

    - #### isEqualsMethod

          public static boolean isEqualsMethod(@Nullable
                                               Method method)

      Determine whether the given method is an "equals" method.
      另请参阅:
        `Object.equals(java.lang.Object)`

    - #### isHashCodeMethod

          public static boolean isHashCodeMethod(@Nullable
                                                 Method method)

      Determine whether the given method is a "hashCode" method.
      另请参阅:
        `Object.hashCode()`

    - #### isToStringMethod

          public static boolean isToStringMethod(@Nullable
                                                 Method method)

      Determine whether the given method is a "toString" method.
      另请参阅:
        `Object.toString()`

    - #### isFinalizeMethod

          public static boolean isFinalizeMethod(@Nullable
                                                 Method method)

      Determine whether the given method is a "finalize" method.
      另请参阅:
        `Object.finalize()`

    - #### getMostSpecificMethod

          public static Method getMostSpecificMethod(Method method,
                                                     @Nullable
                                                     Class<?> targetClass)

      Given a method, which may come from an interface, and a target class used in the current AOP invocation, find the corresponding target method if there is one. E.g. the method may be `IFoo.bar()` and the target class may be `DefaultFoo`. In this case, the method may be `DefaultFoo.bar()`. This enables attributes on that method to be found.

      NOTE: In contrast to `ClassUtils.getMostSpecificMethod(java.lang.reflect.Method, java.lang.Class<?>)`, this method resolves Java 5 bridge methods in order to retrieve attributes from the original method definition.

      参数:
        `method` - the method to be invoked, which may come from an interface
        `targetClass` - the target class for the current invocation. May be `null` or may not even implement the method.
      返回:
        the specific target method, or the original method if the `targetClass` doesn't implement it or is `null`
      另请参阅:
        `ClassUtils.getMostSpecificMethod(java.lang.reflect.Method, java.lang.Class<?>)`

    - #### canApply

          public static boolean canApply(Pointcut pc,
                                         Class<?> targetClass)

      Can the given pointcut apply at all on the given class?

      This is an important test as it can be used to optimize out a pointcut for a class.

      参数:
        `pc` - the static or dynamic pointcut to check
        `targetClass` - the class to test
      返回:
        whether the pointcut can apply on any method

    - #### canApply

          public static boolean canApply(Pointcut pc,
                                         Class<?> targetClass,
                                         boolean hasIntroductions)

      Can the given pointcut apply at all on the given class?

      This is an important test as it can be used to optimize out a pointcut for a class.

      参数:
        `pc` - the static or dynamic pointcut to check
        `targetClass` - the class to test
        `hasIntroductions` - whether or not the advisor chain for this bean includes any introductions
      返回:
        whether the pointcut can apply on any method

    - #### canApply

          public static boolean canApply(Advisor advisor,
                                         Class<?> targetClass)

      Can the given advisor apply at all on the given class? This is an important test as it can be used to optimize out a advisor for a class.
      参数:
        `advisor` - the advisor to check
        `targetClass` - class we're testing
      返回:
        whether the pointcut can apply on any method

    - #### canApply

          public static boolean canApply(Advisor advisor,
                                         Class<?> targetClass,
                                         boolean hasIntroductions)

      Can the given advisor apply at all on the given class?

      This is an important test as it can be used to optimize out a advisor for a class. This version also takes into account introductions (for IntroductionAwareMethodMatchers).

      参数:
        `advisor` - the advisor to check
        `targetClass` - class we're testing
        `hasIntroductions` - whether or not the advisor chain for this bean includes any introductions
      返回:
        whether the pointcut can apply on any method

    - #### findAdvisorsThatCanApply

          public static List<Advisor> findAdvisorsThatCanApply(List<Advisor> candidateAdvisors,
                                                               Class<?> clazz)

      找到合适的增强器对象
      参数:
        `candidateAdvisors` - 候选的增强器对象
        `clazz` - 正在创建的class对象
      返回:
        返回适合本bean的增强器集合

    - #### invokeJoinpointUsingReflection

          @Nullable
          public static Object invokeJoinpointUsingReflection(@Nullable
                                                                         Object target,
                                                                         Method method,
                                                                         Object[] args)
                                                                  throws Throwable

      Invoke the given target via reflection, as part of an AOP method invocation.
      参数:
        `target` - the target object
        `method` - the method to invoke
        `args` - the arguments for the method
      返回:
        the invocation result, if any
      抛出:
        `Throwable` - if thrown by the target method
        `AopInvocationException` - in case of a reflection error