类 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
    • 构造器详细资料

    • 方法详细资料

      • selectInvocableMethod

        public static Method selectInvocableMethod​(Method method,
                                                   Class<?> targetType)
        Select an invocable method on the target type: either the given method itself if actually exposed on the target type, or otherwise a corresponding method on one of the target type's interfaces or on the target type itself.
        参数:
        method - the method to check
        targetType - the target type to search methods on (typically an AOP proxy)
        返回:
        a corresponding invocable method on the target type
        抛出:
        IllegalStateException - if the given method is not invocable on the given target type (typically due to a proxy mismatch)
        从以下版本开始:
        4.3
        另请参阅:
        MethodIntrospector.selectInvocableMethod(Method, Class)
      • getMostSpecificMethod

        public 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. 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<AdvisorfindAdvisorsThatCanApply​(List<Advisor> candidateAdvisors,
                                                             Class<?> clazz)
        Determine the sublist of the candidateAdvisors list that is applicable to the given class.
        参数:
        candidateAdvisors - the Advisors to evaluate
        clazz - the target class
        返回:
        sublist of Advisors that can apply to an object of the given class (may be the incoming List as-is)