org.springframework.aop.framework.support
Class AopUtils

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

public abstract class AopUtils
extends java.lang.Object

Utility methods used by the AOP framework.

Version:
$Id: AopUtils.java,v 1.15 2004/03/19 21:35:54 johnsonr 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? This is an important test as it can be used to optimize out a pointcut for a 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)
           
static boolean isCglibProxy(java.lang.Object o)
           
static boolean isJdkDynamicProxy(java.lang.Object o)
           
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

isCglibProxy

public static boolean isCglibProxy(java.lang.Object o)

isJdkDynamicProxy

public static boolean isJdkDynamicProxy(java.lang.Object o)

isAopProxy

public static boolean isAopProxy(java.lang.Object o)

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 org.aopalliance.aop.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:
java.lang.ClassNotFoundException - if any of the classes can't be loaded
org.aopalliance.aop.AspectException - if any of the classes is not an interface

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.