类 CglibAopProxy

java.lang.Object
infra.aop.framework.CglibAopProxy
所有已实现的接口:
AopProxy, Serializable
直接已知子类:
SerializationCglibAopProxy

class CglibAopProxy extends Object implements AopProxy, Serializable
CGLIB-based AopProxy implementation for the AOP framework.

Objects of this type should be obtained through proxy factories, configured by an AdvisedSupport object. This class is internal to AOP framework and need not be used directly by client code.

DefaultAopProxyFactory will automatically create CGLIB-based proxies if necessary, for example in case of proxying a target class (see the attendant javadoc for details).

Proxies created using this class are thread-safe if the underlying (target) class is thread-safe.

从以下版本开始:
3.0 2021/2/1 21:47
作者:
Rod Johnson, Rob Harrop, Juergen Hoeller, Ramnivas Laddad, Chris Beams, Dave Syer, TODAY
另请参阅:
  • 字段详细资料

    • serialVersionUID

      private static final long serialVersionUID
      另请参阅:
    • log

      protected static final infra.logging.Logger log
    • validatedClasses

      private static final Map<Class<?>,Boolean> validatedClasses
      Keeps track of the Classes that we have validated for final methods.
    • undeclaredThrowableStrategy

      private static final infra.bytecode.core.GeneratorStrategy undeclaredThrowableStrategy
    • AOP_PROXY

      private static final int AOP_PROXY
      另请参阅:
    • INVOKE_TARGET

      private static final int INVOKE_TARGET
      另请参阅:
    • NO_OVERRIDE

      private static final int NO_OVERRIDE
      另请参阅:
    • DISPATCH_TARGET

      private static final int DISPATCH_TARGET
      另请参阅:
    • DISPATCH_ADVISED

      private static final int DISPATCH_ADVISED
      另请参阅:
    • INVOKE_EQUALS

      private static final int INVOKE_EQUALS
      另请参阅:
    • INVOKE_HASHCODE

      private static final int INVOKE_HASHCODE
      另请参阅:
    • fixedInterceptorMap

      private transient Map<Method,Integer> fixedInterceptorMap
    • fixedInterceptorOffset

      private transient int fixedInterceptorOffset
    • config

      final AdvisedSupport config
      The configuration used to configure this proxy.
    • constructorArgs

      @Nullable protected Object[] constructorArgs
    • constructorArgTypes

      @Nullable protected Class<?>[] constructorArgTypes
  • 构造器详细资料

    • CglibAopProxy

      public CglibAopProxy(AdvisedSupport config)
      Create a new CglibAopProxy for the given AOP configuration.
      参数:
      config - the AOP configuration as AdvisedSupport object
      抛出:
      AopConfigException - if the config is invalid. We try to throw an informative exception in this case, rather than let a mysterious failure happen later.
  • 方法详细资料

    • setConstructorArguments

      public void setConstructorArguments(@Nullable Object[] constructorArgs, @Nullable Class<?>[] constructorArgTypes)
      Set constructor arguments to use for creating the proxy.
      参数:
      constructorArgs - the constructor argument values
      constructorArgTypes - the constructor argument types
    • getProxy

      public Object getProxy()
      从接口复制的说明: AopProxy
      Create a new proxy object.

      Uses the AopProxy's default class loader (if necessary for proxy creation): usually, the thread context class loader.

      指定者:
      getProxy 在接口中 AopProxy
      返回:
      the new proxy object (never null)
      另请参阅:
    • getProxy

      public Object getProxy(@Nullable ClassLoader classLoader)
      从接口复制的说明: AopProxy
      Create a new proxy object.

      Uses the given class loader (if necessary for proxy creation). null will simply be passed down and thus lead to the low-level proxy facility's default, which is usually different from the default chosen by the AopProxy implementation's AopProxy.getProxy() method.

      指定者:
      getProxy 在接口中 AopProxy
      参数:
      classLoader - the class loader to create the proxy with (or null for the low-level proxy facility's default)
      返回:
      the new proxy object (never null)
    • getProxyClass

      public Class<?> getProxyClass(@Nullable ClassLoader classLoader)
      从接口复制的说明: AopProxy
      Determine the proxy class.
      指定者:
      getProxyClass 在接口中 AopProxy
      参数:
      classLoader - the class loader to create the proxy class with (or null for the low-level proxy facility's default)
      返回:
      the proxy class
    • buildProxy

      private Object buildProxy(@Nullable ClassLoader classLoader, boolean classOnly)
    • createProxyClass

      protected Class<?> createProxyClass(infra.bytecode.proxy.Enhancer enhancer)
    • validateClassIfNecessary

      void validateClassIfNecessary(Class<?> proxySuperClass, @Nullable ClassLoader proxyClassLoader)
      Checks to see whether the supplied Class has already been validated and validates it if not.
    • doValidateClass

      void doValidateClass(Class<?> proxySuperClass, @Nullable ClassLoader proxyClassLoader, Set<Class<?>> ifcs)
      Checks for final methods on the given Class, as well as package-visible methods across ClassLoaders, and writes warnings to the log for each one found.
    • implementsInterface

      static boolean implementsInterface(Method method, Set<Class<?>> ifcs)
      Check whether the given method is declared on any of the given interfaces.
    • createProxyClassAndInstance

      protected Object createProxyClassAndInstance(infra.bytecode.proxy.Enhancer enhancer, infra.bytecode.proxy.Callback[] callbacks) throws Exception
      抛出:
      Exception
    • createEnhancer

      protected infra.bytecode.proxy.Enhancer createEnhancer()
      Creates the CGLIB Enhancer. Subclasses may wish to override this to return a custom Enhancer implementation.
    • getCallbacks

      private infra.bytecode.proxy.Callback[] getCallbacks(Class<?> rootClass) throws Exception
      抛出:
      Exception
    • equals

      public boolean equals(Object other)
      覆盖:
      equals 在类中 Object
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object
    • invokeMethod

      @Nullable private static Object invokeMethod(@Nullable Object target, Method method, Object[] args, infra.bytecode.proxy.MethodProxy methodProxy) throws Throwable
      Invoke the given method with a CGLIB MethodProxy if possible, falling back to a plain reflection invocation in case of a fast-class generation failure.
      抛出:
      Throwable
    • processReturnValue

      @Nullable private static Object processReturnValue(Object proxy, @Nullable Object target, Method method, @Nullable Object retVal)
      Process a return value. Wraps a return of this if necessary to be the proxy and also verifies that null is not returned as a primitive.
    • createInvocation

      private static DefaultMethodInvocation createInvocation(Object proxy, Method method, Object[] args, infra.bytecode.proxy.MethodProxy methodProxy, @Nullable Object target, @Nullable Class<?> targetClass, MethodInterceptor[] chain)
    • isMethodProxyCompatible

      static boolean isMethodProxyCompatible(Method method)
    • logClassGenerationFailure

      static void logClassGenerationFailure(Method method)