spring-framework / org.springframework.aop.support / AopUtils

AopUtils

abstract class AopUtils

Utility methods for AOP support code.

Mainly for internal use within Spring's AOP support.

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

Author
Rod Johnson

Author
Juergen Hoeller

Author
Rob Harrop

See Also
org.springframework.aop.framework.AopProxyUtils

Constructors

<init>

AopUtils()

Utility methods for AOP support code.

Mainly for internal use within Spring's AOP support.

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

Functions

canApply

open static fun canApply(pc: Pointcut, targetClass: Class<*>): Boolean
open static fun canApply(pc: Pointcut, targetClass: Class<*>, hasIntroductions: Boolean): Boolean

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.

open static fun canApply(advisor: Advisor, targetClass: Class<*>): Boolean

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.

open static fun canApply(advisor: Advisor, targetClass: Class<*>, hasIntroductions: Boolean): Boolean

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).

findAdvisorsThatCanApply

open static fun findAdvisorsThatCanApply(candidateAdvisors: MutableList<Advisor>, clazz: Class<*>): MutableList<Advisor>

Determine the sublist of the candidateAdvisors list that is applicable to the given class.

getMostSpecificMethod

open static fun getMostSpecificMethod(method: Method, targetClass: Class<*>): Method

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 org.springframework.util.ClassUtils#getMostSpecificMethod, this method resolves Java 5 bridge methods in order to retrieve attributes from the original method definition.

getTargetClass

open static fun getTargetClass(candidate: Any): Class<*>

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.

invokeJoinpointUsingReflection

open static fun invokeJoinpointUsingReflection(target: Any, method: Method, args: Array<Any>): Any

Invoke the given target via reflection, as part of an AOP method invocation.

isAopProxy

open static fun isAopProxy(object: Any): Boolean

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.

isCglibProxy

open static fun isCglibProxy(object: Any): Boolean

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.

isEqualsMethod

open static fun isEqualsMethod(method: Method): Boolean

Determine whether the given method is an "equals" method.

isFinalizeMethod

open static fun isFinalizeMethod(method: Method): Boolean

Determine whether the given method is a "finalize" method.

isHashCodeMethod

open static fun isHashCodeMethod(method: Method): Boolean

Determine whether the given method is a "hashCode" method.

isJdkDynamicProxy

open static fun isJdkDynamicProxy(object: Any): Boolean

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.

isToStringMethod

open static fun isToStringMethod(method: Method): Boolean

Determine whether the given method is a "toString" method.

selectInvocableMethod

open static fun selectInvocableMethod(method: Method, targetType: Class<*>): Method

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.