final class JdkDynamicAopProxy extends java.lang.Object implements AopProxy, java.lang.reflect.InvocationHandler, java.io.Serializable
AopProxy implementation for the Spring AOP framework,
based on JDK dynamic proxies.
Creates a dynamic proxy, implementing the interfaces exposed by the AopProxy. Dynamic proxies cannot be used to proxy methods defined in classes, rather than interfaces.
Objects of this type should be obtained through proxy factories,
configured by an AdvisedSupport class. This class is internal
to Spring's AOP framework and need not be used directly by client code.
Proxies created using this class will be thread-safe if the underlying (target) class is thread-safe.
Proxies are serializable so long as all Advisors (including Advices and Pointcuts) and the TargetSource are serializable.
Proxy,
AdvisedSupport,
ProxyFactory| Modifier and Type | Field and Description |
|---|---|
private AdvisedSupport |
advised
Config used to configure this proxy
|
private boolean |
equalsDefined
Is the
equals(java.lang.Object) method defined on the proxied interfaces? |
private boolean |
hashCodeDefined
Is the
hashCode() method defined on the proxied interfaces? |
private static Log |
logger
We use a static Log to avoid serialization issues
|
private static long |
serialVersionUID
use serialVersionUID from Spring 1.2 for interoperability
|
| Constructor and Description |
|---|
JdkDynamicAopProxy(AdvisedSupport config)
Construct a new JdkDynamicAopProxy for the given AOP configuration.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object other)
Equality means interfaces, advisors and TargetSource are equal.
|
private void |
findDefinedEqualsAndHashCodeMethods(java.lang.Class<?>[] proxiedInterfaces)
Finds any
equals(java.lang.Object) or hashCode() method that may be defined
on the supplied set of interfaces. |
java.lang.Object |
getProxy()
Create a new proxy object.
|
java.lang.Object |
getProxy(java.lang.ClassLoader classLoader)
Create a new proxy object.
|
int |
hashCode()
Proxy uses the hash code of the TargetSource.
|
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
Implementation of
InvocationHandler.invoke. |
private static final long serialVersionUID
private static final Log logger
private final AdvisedSupport advised
private boolean equalsDefined
equals(java.lang.Object) method defined on the proxied interfaces?private boolean hashCodeDefined
hashCode() method defined on the proxied interfaces?public JdkDynamicAopProxy(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 java.lang.Object getProxy()
AopProxyUses 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)
AopProxyUses 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.
private void findDefinedEqualsAndHashCodeMethods(java.lang.Class<?>[] proxiedInterfaces)
equals(java.lang.Object) or hashCode() method that may be defined
on the supplied set of interfaces.proxiedInterfaces - the interfaces to introspectpublic java.lang.Object invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
throws java.lang.Throwable
InvocationHandler.invoke.
Callers will see exactly the exception thrown by the target, unless a hook method throws an exception.
invoke in interface java.lang.reflect.InvocationHandlerjava.lang.Throwablepublic boolean equals(java.lang.Object other)
The compared object may be a JdkDynamicAopProxy instance itself or a dynamic proxy wrapping a JdkDynamicAopProxy instance.
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object