class CglibAopProxy extends java.lang.Object implements AopProxy, java.io.Serializable
AopProxy
implementation for the Spring AOP framework.
Formerly named Cglib2AopProxy
, as of Spring 3.2, this class depends on
Spring's own internally repackaged version of CGLIB 3..
Objects of this type should be obtained through proxy factories,
configured by an AdvisedSupport
object. This class is internal
to Spring's 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.
org.springframework.cglib.proxy.Enhancer
,
ProxyConfig.setProxyTargetClass(boolean)
,
DefaultAopProxyFactory
Modifier and Type | Class and Description |
---|---|
private static class |
CglibAopProxy.AdvisedDispatcher
Dispatcher for any methods declared on the Advised class.
|
private static class |
CglibAopProxy.CglibMethodInvocation
Implementation of AOP Alliance MethodInvocation used by this AOP proxy.
|
private static class |
CglibAopProxy.DynamicAdvisedInterceptor
General purpose AOP callback.
|
private static class |
CglibAopProxy.DynamicUnadvisedExposedInterceptor
Interceptor for unadvised dynamic targets when the proxy needs exposing.
|
private static class |
CglibAopProxy.DynamicUnadvisedInterceptor
Interceptor used to invoke a dynamic target without creating a method
invocation or evaluating an advice chain.
|
private static class |
CglibAopProxy.EqualsInterceptor
Dispatcher for the
equals method. |
private static class |
CglibAopProxy.FixedChainStaticTargetInterceptor
Interceptor used specifically for advised methods on a frozen, static proxy.
|
private static class |
CglibAopProxy.HashCodeInterceptor
Dispatcher for the
hashCode method. |
private static class |
CglibAopProxy.ProxyCallbackFilter
CallbackFilter to assign Callbacks to methods.
|
static class |
CglibAopProxy.SerializableNoOp
Serializable replacement for CGLIB's NoOp interface.
|
private static class |
CglibAopProxy.StaticDispatcher
Dispatcher for a static target.
|
private static class |
CglibAopProxy.StaticUnadvisedExposedInterceptor
Method interceptor used for static targets with no advice chain, when the
proxy is to be exposed.
|
private static class |
CglibAopProxy.StaticUnadvisedInterceptor
Method interceptor used for static targets with no advice chain.
|
Modifier and Type | Field and Description |
---|---|
protected AdvisedSupport |
advised
The configuration used to configure this proxy
|
private CglibAopProxy.AdvisedDispatcher |
advisedDispatcher
Dispatcher used for methods on Advised
|
private static int |
AOP_PROXY |
private java.lang.Object[] |
constructorArgs |
private java.lang.Class<?>[] |
constructorArgTypes |
private static int |
DISPATCH_ADVISED |
private static int |
DISPATCH_TARGET |
private java.util.Map<java.lang.String,java.lang.Integer> |
fixedInterceptorMap |
private int |
fixedInterceptorOffset |
private static int |
INVOKE_EQUALS |
private static int |
INVOKE_HASHCODE |
private static int |
INVOKE_TARGET |
protected static Log |
logger
Logger available to subclasses; static to optimize serialization
|
private static int |
NO_OVERRIDE |
private static java.util.Map<java.lang.Class<?>,java.lang.Boolean> |
validatedClasses
Keeps track of the Classes that we have validated for final methods
|
Constructor and Description |
---|
CglibAopProxy(AdvisedSupport config)
Create a new CglibAopProxy for the given AOP configuration.
|
Modifier and Type | Method and Description |
---|---|
protected Enhancer |
createEnhancer()
Creates the CGLIB
Enhancer . |
protected java.lang.Object |
createProxyClassAndInstance(Enhancer enhancer,
Callback[] callbacks) |
private void |
doValidateClass(java.lang.Class<?> proxySuperClass)
Checks for final methods on the
Class and writes warnings to the log
for each one found. |
boolean |
equals(java.lang.Object other) |
private Callback[] |
getCallbacks(java.lang.Class<?> rootClass) |
java.lang.Object |
getProxy()
Create a new proxy object.
|
java.lang.Object |
getProxy(java.lang.ClassLoader classLoader)
Create a new proxy object.
|
int |
hashCode() |
private static java.lang.Object |
processReturnType(java.lang.Object proxy,
java.lang.Object target,
java.lang.reflect.Method method,
java.lang.Object retVal)
Process a return value.
|
void |
setConstructorArguments(java.lang.Object[] constructorArgs,
java.lang.Class<?>[] constructorArgTypes)
Set constructor arguments to use for creating the proxy.
|
private void |
validateClassIfNecessary(java.lang.Class<?> proxySuperClass)
Checks to see whether the supplied
Class has already been validated and
validates it if not. |
private static final int AOP_PROXY
private static final int INVOKE_TARGET
private static final int NO_OVERRIDE
private static final int DISPATCH_TARGET
private static final int DISPATCH_ADVISED
private static final int INVOKE_EQUALS
private static final int INVOKE_HASHCODE
protected static final Log logger
private static final java.util.Map<java.lang.Class<?>,java.lang.Boolean> validatedClasses
protected final AdvisedSupport advised
private java.lang.Object[] constructorArgs
private java.lang.Class<?>[] constructorArgTypes
private final transient CglibAopProxy.AdvisedDispatcher advisedDispatcher
private transient java.util.Map<java.lang.String,java.lang.Integer> fixedInterceptorMap
private transient int fixedInterceptorOffset
public CglibAopProxy(AdvisedSupport config) throws AopConfigException
config
- the AOP configuration as AdvisedSupport objectAopConfigException
- if the config is invalid. We try to throw an informative
exception in this case, rather than let a mysterious failure happen later.public void setConstructorArguments(java.lang.Object[] constructorArgs, java.lang.Class<?>[] constructorArgTypes)
constructorArgs
- the constructor argument valuesconstructorArgTypes
- the constructor argument typespublic java.lang.Object getProxy()
AopProxy
Uses the AopProxy's default class loader (if necessary for proxy creation): usually, the thread context class loader.
public java.lang.Object getProxy(java.lang.ClassLoader classLoader)
AopProxy
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.
protected java.lang.Object createProxyClassAndInstance(Enhancer enhancer, Callback[] callbacks)
protected Enhancer createEnhancer()
Enhancer
. Subclasses may wish to override this to return a custom
Enhancer
implementation.private void validateClassIfNecessary(java.lang.Class<?> proxySuperClass)
Class
has already been validated and
validates it if not.private void doValidateClass(java.lang.Class<?> proxySuperClass)
Class
and writes warnings to the log
for each one found.private Callback[] getCallbacks(java.lang.Class<?> rootClass) throws java.lang.Exception
java.lang.Exception
private static java.lang.Object processReturnType(java.lang.Object proxy, java.lang.Object target, java.lang.reflect.Method method, java.lang.Object retVal)
this
if necessary to be the
proxy
and also verifies that null
is not returned as a primitive.public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object