org.springframework.aop.support
Class AopUtils

java.lang.Object
  extended byorg.springframework.aop.support.AopUtils

public abstract class AopUtils
extends java.lang.Object

Utility methods used by the AOP framework. Not intended to be used directly by applications.

Version:
$Id: AopUtils.java,v 1.2 2004/05/23 20:50:29 jhoeller Exp $
Author:
Rod Johnson, Juergen Hoeller

Constructor Summary
AopUtils()
           
 
Method Summary
static boolean canApply(Advisor advisor, java.lang.Class targetClass, java.lang.Class[] proxyInterfaces)
           
static boolean canApply(Pointcut pc, java.lang.Class targetClass, java.lang.Class[] proxyInterfaces)
          Can the given pointcut apply at all on the given class?
static java.lang.Class[] getAllInterfaces(java.lang.Object object)
          Return all interfaces that the given object implements as array, including ones implemented by superclasses.
static java.util.List getAllInterfacesAsList(java.lang.Object object)
          Return all interfaces that the given object implements as List, including ones implemented by superclasses.
static java.lang.reflect.Method getMostSpecificMethod(java.lang.reflect.Method method, java.lang.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 boolean isAopProxy(java.lang.Object o)
          Return whether the given object is either a J2SE dynamic proxy or a CGLIB proxy.
static boolean isCglibProxy(java.lang.Object o)
          Return whether the given object is a CGLIB proxy.
static boolean isJdkDynamicProxy(java.lang.Object o)
          Return whether the given object is a J2SE dynamic proxy.
static boolean methodIsOnOneOfTheseInterfaces(java.lang.reflect.Method m, java.lang.Class[] interfaces)
          Is the given method declared on one of these interfaces?
static java.lang.Class[] toInterfaceArray(java.lang.String[] interfaceNames)
          Convenience method to convert a string array of interface names to a class array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AopUtils

public AopUtils()
Method Detail

isJdkDynamicProxy

public static boolean isJdkDynamicProxy(java.lang.Object o)
Return whether the given object is a J2SE dynamic proxy.

See Also:
Proxy.isProxyClass(java.lang.Class)

isCglibProxy

public static boolean isCglibProxy(java.lang.Object o)
Return whether the given object is a CGLIB proxy.


isAopProxy

public static boolean isAopProxy(java.lang.Object o)
Return whether the given object is either a J2SE dynamic proxy or a CGLIB proxy.

See Also:
isJdkDynamicProxy(java.lang.Object), isCglibProxy(java.lang.Object)

getMostSpecificMethod

public static java.lang.reflect.Method getMostSpecificMethod(java.lang.reflect.Method method,
                                                             java.lang.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

toInterfaceArray

public static java.lang.Class[] toInterfaceArray(java.lang.String[] interfaceNames)
                                          throws java.lang.IllegalArgumentException,
                                                 java.lang.ClassNotFoundException
Convenience method to convert a string array of interface names to a class array.

Returns:
an array of interface classes
Throws:
java.lang.IllegalArgumentException - if any of the classes is not an interface
java.lang.ClassNotFoundException - if any of the classes can't be loaded

getAllInterfaces

public static java.lang.Class[] getAllInterfaces(java.lang.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 java.util.List getAllInterfacesAsList(java.lang.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

methodIsOnOneOfTheseInterfaces

public static boolean methodIsOnOneOfTheseInterfaces(java.lang.reflect.Method m,
                                                     java.lang.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

canApply

public static boolean canApply(Pointcut pc,
                               java.lang.Class targetClass,
                               java.lang.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,
                               java.lang.Class targetClass,
                               java.lang.Class[] proxyInterfaces)


Copyright (C) 2003-2004 The Spring Framework Project.