类 CglibAopProxy
- 所有已实现的接口:
AopProxy,Serializable
- 直接已知子类:
SerializationCglibAopProxy
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
- 另请参阅:
-
嵌套类概要
嵌套类修饰符和类型类说明private static final recordDispatcher for any methods declared on the Advised class.(专用程序包) static classImplementation of AOP Alliance MethodInvocation used by this AOP proxy.private static final recordGeneral purpose AOP callback.private static final recordInterceptor for unadvised dynamic targets when the proxy needs exposing.private static final recordInterceptor used to invoke a dynamic target without creating a method invocation or evaluating an advice chain.private static final recordDispatcher for theequalsmethod.(专用程序包) static classInterceptor used specifically for advised methods on a frozen, static proxy.private static final recordDispatcher for thehashCodemethod.private static classCallbackFilter to assign Callbacks to methods.static classSerializable replacement for CGLIB's NoOp interface.private static final recordDispatcher for a static target.private static final recordMethod interceptor used for static targets with no advice chain, when the proxy is to be exposed.private static final recordMethod interceptor used for static targets with no advice chain. -
字段概要
字段修饰符和类型字段说明private static final int(专用程序包) final AdvisedSupportThe configuration used to configure this proxy.protected Object[]protected Class<?>[]private static final intprivate static final intprivate intprivate static final intprivate static final intprivate static final intprotected static final infra.logging.Loggerprivate static final intprivate static final longprivate static final infra.bytecode.core.GeneratorStrategyKeeps track of the Classes that we have validated for final methods. -
构造器概要
构造器构造器说明CglibAopProxy(AdvisedSupport config) Create a new CglibAopProxy for the given AOP configuration. -
方法概要
修饰符和类型方法说明private ObjectbuildProxy(ClassLoader classLoader, boolean classOnly) protected infra.bytecode.proxy.EnhancerCreates the CGLIBEnhancer.private static DefaultMethodInvocationcreateInvocation(Object proxy, Method method, Object[] args, infra.bytecode.proxy.MethodProxy methodProxy, Object target, Class<?> targetClass, MethodInterceptor[] chain) protected Class<?>createProxyClass(infra.bytecode.proxy.Enhancer enhancer) protected ObjectcreateProxyClassAndInstance(infra.bytecode.proxy.Enhancer enhancer, infra.bytecode.proxy.Callback[] callbacks) (专用程序包) voiddoValidateClass(Class<?> proxySuperClass, ClassLoader proxyClassLoader, Set<Class<?>> ifcs) Checks for final methods on the givenClass, as well as package-visible methods across ClassLoaders, and writes warnings to the log for each one found.booleanprivate infra.bytecode.proxy.Callback[]getCallbacks(Class<?> rootClass) getProxy()Create a new proxy object.getProxy(ClassLoader classLoader) Create a new proxy object.Class<?>getProxyClass(ClassLoader classLoader) Determine the proxy class.inthashCode()(专用程序包) static booleanimplementsInterface(Method method, Set<Class<?>> ifcs) Check whether the given method is declared on any of the given interfaces.private static ObjectinvokeMethod(Object target, Method method, Object[] args, infra.bytecode.proxy.MethodProxy methodProxy) 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.(专用程序包) static booleanisMethodProxyCompatible(Method method) (专用程序包) static voidlogClassGenerationFailure(Method method) private static ObjectprocessReturnValue(Object proxy, Object target, Method method, Object retVal) Process a return value.voidsetConstructorArguments(Object[] constructorArgs, Class<?>[] constructorArgTypes) Set constructor arguments to use for creating the proxy.(专用程序包) voidvalidateClassIfNecessary(Class<?> proxySuperClass, ClassLoader proxyClassLoader) Checks to see whether the suppliedClasshas already been validated and validates it if not.
-
字段详细资料
-
serialVersionUID
private static final long serialVersionUID- 另请参阅:
-
log
protected static final infra.logging.Logger log -
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
-
fixedInterceptorOffset
private transient int fixedInterceptorOffset -
config
The configuration used to configure this proxy. -
constructorArgs
-
constructorArgTypes
-
-
构造器详细资料
-
CglibAopProxy
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 valuesconstructorArgTypes- the constructor argument types
-
getProxy
从接口复制的说明:AopProxyCreate a new proxy object.Uses the AopProxy's default class loader (if necessary for proxy creation): usually, the thread context class loader.
-
getProxy
从接口复制的说明:AopProxyCreate a new proxy object.Uses the given class loader (if necessary for proxy creation).
nullwill 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'sAopProxy.getProxy()method. -
getProxyClass
从接口复制的说明:AopProxyDetermine the proxy class.- 指定者:
getProxyClass在接口中AopProxy- 参数:
classLoader- the class loader to create the proxy class with (ornullfor the low-level proxy facility's default)- 返回:
- the proxy class
-
buildProxy
-
createProxyClass
-
validateClassIfNecessary
Checks to see whether the suppliedClasshas 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 givenClass, as well as package-visible methods across ClassLoaders, and writes warnings to the log for each one found. -
implementsInterface
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 CGLIBEnhancer. Subclasses may wish to override this to return a customEnhancerimplementation. -
getCallbacks
- 抛出:
Exception
-
equals
-
hashCode
public int hashCode() -
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 ofthisif necessary to be theproxyand also verifies thatnullis 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
-
logClassGenerationFailure
-