org.springframework.aop.framework.support
Class AopUtils


public abstract class AopUtils

Utility methods used by the AOP framework.

Author:
Rod Johnson, Juergen Hoeller
Version: $Id: AopUtils.java,v 1.12 2004/01/13 13:58:42 johnsonr Exp $

Method Summary
 static booleancanApply(Pointcut pc, Class targetClass, Class[] proxyInterfaces)
          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
 static booleancanApply(Advisor advisor, Class targetClass, Class[] proxyInterfaces)
           
 static Class[]getAllInterfaces(Object object)
          Return all interfaces that the given object implements as array, including ones implemented by superclasses.
 static ListgetAllInterfacesAsList(Object object)
          Return all interfaces that the given object implements as List, including ones implemented by superclasses.
 static MethodgetMostSpecificMethod(Method method, Class targetClass)
          Given a method, which may come from an interface, and a targetClass used in the current AOP invocation, find the most specific method if there is one.
 static booleanisAopProxy(Object o)
           
 static booleanisCglibProxy(Object o)
           
 static booleanisJdkDynamicProxy(Object o)
           
 static booleanmethodIsOnOneOfTheseInterfaces(Method m, Class[] interfaces)
          Is the given method declared on one of these interfaces?
 static Class[]toInterfaceArray(String[] interfaceNames)
          Convenience method to convert a string array of interface names to a class array.

Method Detail

canApply

public static boolean canApply(Pointcut pc, Class targetClass, Class[] proxyInterfaces)
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
Parameters:
pc - pc static or dynamic pointcut
targetClass - class we're testing
proxyInterfaces - proxy interfaces. If null, all methods on class may be proxied
Returns: whether the pointcut can apply on any method

canApply

public static boolean canApply(Advisor advisor, Class targetClass, Class[] proxyInterfaces)

getAllInterfaces

public static Class[] getAllInterfaces(Object object)
Return all interfaces that the given object implements as array, including ones implemented by superclasses.
Parameters:
object - the object to analyse for interfaces
Returns: all interfaces that the given object implements as array

getAllInterfacesAsList

public static List getAllInterfacesAsList(Object object)
Return all interfaces that the given object implements as List, including ones implemented by superclasses.
Parameters:
object - the object to analyse for interfaces
Returns: all interfaces that the given object implements as List

getMostSpecificMethod

public static Method getMostSpecificMethod(Method method, Class targetClass)
Given a method, which may come from an interface, and a targetClass used in the current AOP invocation, find the most specific 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.
Parameters:
method - method to be invoked, which may come from an interface
targetClass - target class for the curren invocation. May be null or may not even implement the method.
Returns: the more specific method, or the original method if the targetClass doesn't specialize it or implement it, or is null.

isAopProxy

public static boolean isAopProxy(Object o)

isCglibProxy

public static boolean isCglibProxy(Object o)

isJdkDynamicProxy

public static boolean isJdkDynamicProxy(Object o)

methodIsOnOneOfTheseInterfaces

public static boolean methodIsOnOneOfTheseInterfaces(Method m, Class[] interfaces)
Is the given method declared on one of these interfaces?
Parameters:
m - method to check
interfaces - array of interfaces we want to check
Returns: whether the method is declared on one of these interfaces

toInterfaceArray

public static Class[] toInterfaceArray(String[] interfaceNames)
throws AspectException,
java.lang.ClassNotFoundException
Convenience method to convert a string array of interface names to a class array.
Returns: an array of interface classes
Throws:
ClassNotFoundException - if any of the classes can't be loaded
AspectException - if any of the classes is not an interface