org.springframework.aop.framework

Class AopProxyUtils

  • java.lang.Object
    • org.springframework.aop.framework.AopProxyUtils


  • public abstract class AopProxyUtils
    extends java.lang.Object
    Utility methods for AOP proxy factories. Mainly for internal use within the AOP framework.

    See AopUtils for a collection of generic AOP utility methods which do not depend on AOP framework internals.

    Author:
    Rod Johnson, Juergen Hoeller
    See Also:
    AopUtils
    • Constructor Summary

      Constructors 
      Constructor and Description
      AopProxyUtils() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.lang.Class<?>[] completeProxiedInterfaces(AdvisedSupport advised)
      Determine the complete set of interfaces to proxy for the given AOP configuration.
      static boolean equalsAdvisors(AdvisedSupport a, AdvisedSupport b)
      Check equality of the advisors behind the given AdvisedSupport objects.
      static boolean equalsInProxy(AdvisedSupport a, AdvisedSupport b)
      Check equality of the proxies behind the given AdvisedSupport objects.
      static boolean equalsProxiedInterfaces(AdvisedSupport a, AdvisedSupport b)
      Check equality of the proxied interfaces behind the given AdvisedSupport objects.
      static java.lang.Object getSingletonTarget(java.lang.Object candidate)
      Obtain the singleton target object behind the given proxy, if any.
      static java.lang.Class<?>[] proxiedUserInterfaces(java.lang.Object proxy)
      Extract the user-specified interfaces that the given proxy implements, i.e.
      static java.lang.Class<?> ultimateTargetClass(java.lang.Object candidate)
      Determine the ultimate target class of the given bean instance, traversing not only a top-level proxy but any number of nested proxies as well — as long as possible without side effects, that is, just for singleton targets.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AopProxyUtils

        public AopProxyUtils()
    • Method Detail

      • getSingletonTarget

        @Nullable
        public static java.lang.Object getSingletonTarget(java.lang.Object candidate)
        Obtain the singleton target object behind the given proxy, if any.
        Parameters:
        candidate - the (potential) proxy to check
        Returns:
        the singleton target object managed in a SingletonTargetSource, or null in any other case (not a proxy, not an existing singleton target)
        Since:
        4.3.8
        See Also:
        Advised.getTargetSource(), SingletonTargetSource.getTarget()
      • ultimateTargetClass

        public static java.lang.Class<?> ultimateTargetClass(java.lang.Object candidate)
        Determine the ultimate target class of the given bean instance, traversing not only a top-level proxy but any number of nested proxies as well — as long as possible without side effects, that is, just for singleton targets.
        Parameters:
        candidate - the instance to check (might be an AOP proxy)
        Returns:
        the ultimate target class (or the plain class of the given object as fallback; never null)
        See Also:
        TargetClassAware.getTargetClass(), Advised.getTargetSource()
      • completeProxiedInterfaces

        public static java.lang.Class<?>[] completeProxiedInterfaces(AdvisedSupport advised)
        Determine the complete set of interfaces to proxy for the given AOP configuration.

        This will always add the Advised interface unless the AdvisedSupport's "opaque" flag is on. Always adds the SpringProxy marker interface.

        Parameters:
        advised - the proxy config
        Returns:
        the complete set of interfaces to proxy
        See Also:
        SpringProxy, Advised
      • proxiedUserInterfaces

        public static java.lang.Class<?>[] proxiedUserInterfaces(java.lang.Object proxy)
        Extract the user-specified interfaces that the given proxy implements, i.e. all non-Advised interfaces that the proxy implements.
        Parameters:
        proxy - the proxy to analyze (usually a JDK dynamic proxy)
        Returns:
        all user-specified interfaces that the proxy implements, in the original order (never null or empty)
        See Also:
        Advised
      • equalsInProxy

        public static boolean equalsInProxy(AdvisedSupport a,
                                            AdvisedSupport b)
        Check equality of the proxies behind the given AdvisedSupport objects. Not the same as equality of the AdvisedSupport objects: rather, equality of interfaces, advisors and target sources.
      • equalsProxiedInterfaces

        public static boolean equalsProxiedInterfaces(AdvisedSupport a,
                                                      AdvisedSupport b)
        Check equality of the proxied interfaces behind the given AdvisedSupport objects.
      • equalsAdvisors

        public static boolean equalsAdvisors(AdvisedSupport a,
                                             AdvisedSupport b)
        Check equality of the advisors behind the given AdvisedSupport objects.