Top Description Inners Fields Constructors Methods
org.springframework.aop.framework

pack-priv final Class JdkDynamicAopProxy

extends Object
implements AopProxy, InvocationHandler, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.reflect.InvocationHandler, org.springframework.aop.framework.AopProxy
Imports
java.io.IOException, .ObjectInputStream, .Serializable, java.lang.reflect.InvocationHandler, .Method, .Proxy, java.util.List, org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log, .LogFactory, org.springframework.aop.AopInvocationException, .RawTargetAccess, .TargetSource, org.springframework.aop.support.AopUtils, org.springframework.core.DecoratingProxy, .KotlinDetector, .MethodParameter, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils

JDK-based 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.

Authors
Rod Johnson, Juergen Hoeller, Rob Harrop, Dave Syer, Sergey Tsypanov, Sebastien Deleuze
See Also
java.lang.reflect.Proxy, AdvisedSupport, ProxyFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
JdkDynamicAopProxy.ProxiedInterfacesCache

Holder for the complete proxied interfaces and derived metadata, to be cached in AdvisedSupport#proxyMetadataCache.

Field Summary

Modifier and TypeField and Description
private final AdvisedSupport
advised

Config used to configure this proxy.

private transient JdkDynamicAopProxy.ProxiedInterfacesCache
private static final String
private static final Log
logger

We use a static Log to avoid serialization issues.

private static final long
serialVersionUID

use serialVersionUID from Spring 1.2 for interoperability.

Constructor Summary

AccessConstructor and Description
public
JdkDynamicAopProxy(AdvisedSupport
the AOP configuration as AdvisedSupport object
config
)

Construct a new JdkDynamicAopProxy for the given AOP configuration.

Method Summary

Modifier and TypeMethod and Description
private ClassLoader
determineClassLoader(ClassLoader classLoader)

Determine whether the JDK bootstrap or platform loader has been suggested -> use higher-level loader which can see Spring infrastructure classes instead.

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Equality means interfaces, advisors and TargetSource are equal.
public Object
getProxy()

Implements org.springframework.aop.framework.AopProxy.getProxy.

Create a new proxy object.
public Object
getProxy(ClassLoader
the class loader to create the proxy with (or null for the low-level proxy facility's default)
classLoader
)

Implements org.springframework.aop.framework.AopProxy.getProxy.

Create a new proxy object.
public Class<?>
getProxyClass(ClassLoader
the class loader to create the proxy class with (or null for the low-level proxy facility's default)
classLoader
)

Implements org.springframework.aop.framework.AopProxy.getProxyClass.

Determine the proxy class.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Proxy uses the hash code of the TargetSource.
public Object
invoke(Object
the proxy instance that the method was invoked on
proxy
,
Method
the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
method
,
Object[]
an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
args
)

Implements java.lang.reflect.InvocationHandler.invoke.

Implementation of InvocationHandler.invoke.
private void
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

advisedback to summary
private final AdvisedSupport advised

Config used to configure this proxy.

cacheback to summary
private transient JdkDynamicAopProxy.ProxiedInterfacesCache cache

Cached in AdvisedSupport#proxyMetadataCache.

COROUTINES_FLOW_CLASS_NAMEback to summary
private static final String COROUTINES_FLOW_CLASS_NAME
loggerback to summary
private static final Log logger

We use a static Log to avoid serialization issues.

serialVersionUIDback to summary
private static final long serialVersionUID

use serialVersionUID from Spring 1.2 for interoperability.

Constructor Detail

JdkDynamicAopProxyback to summary
public JdkDynamicAopProxy(AdvisedSupport config) throws AopConfigException

Construct a new JdkDynamicAopProxy for the given AOP configuration.

Parameters
config:AdvisedSupport

the AOP configuration as AdvisedSupport object

Exceptions
AopConfigException:
if the config is invalid. We try to throw an informative exception in this case, rather than let a mysterious failure happen later.

Method Detail

determineClassLoaderback to summary
private ClassLoader determineClassLoader(ClassLoader classLoader)

Determine whether the JDK bootstrap or platform loader has been suggested -> use higher-level loader which can see Spring infrastructure classes instead.

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Equality means interfaces, advisors and TargetSource are equal.

The compared object may be a JdkDynamicAopProxy instance itself or a dynamic proxy wrapping a JdkDynamicAopProxy instance.

Parameters
other:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getProxyback to summary
public Object getProxy()

Implements org.springframework.aop.framework.AopProxy.getProxy.

Doc from org.springframework.aop.framework.AopProxy.getProxy.

Create a new proxy object.

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

Returns:Object

the new proxy object (never null)

Annotations
@Override
getProxyback to summary
public Object getProxy(ClassLoader classLoader)

Implements org.springframework.aop.framework.AopProxy.getProxy.

Doc from org.springframework.aop.framework.AopProxy.getProxy.

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 getProxy() method.

Parameters
classLoader:ClassLoader

the class loader to create the proxy with (or null for the low-level proxy facility's default)

Returns:Object

the new proxy object (never null)

Annotations
@Override
getProxyClassback to summary
public Class<?> getProxyClass(ClassLoader classLoader)

Implements org.springframework.aop.framework.AopProxy.getProxyClass.

Doc from org.springframework.aop.framework.AopProxy.getProxyClass.

Determine the proxy class.

Parameters
classLoader:ClassLoader

the class loader to create the proxy class with (or null for the low-level proxy facility's default)

Returns:Class<?>

the proxy class

Annotations
@SuppressWarnings:deprecation
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Proxy uses the hash code of the TargetSource.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object.

Annotations
@Override
invokeback to summary
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable

Implements java.lang.reflect.InvocationHandler.invoke.

Implementation of InvocationHandler.invoke.

Callers will see exactly the exception thrown by the target, unless a hook method throws an exception.

Parameters
proxy:Object

Doc from java.lang.reflect.InvocationHandler.invoke.

the proxy instance that the method was invoked on

method:Method

Doc from java.lang.reflect.InvocationHandler.invoke.

the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.

args:Object[]

Doc from java.lang.reflect.InvocationHandler.invoke.

an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.

Returns:Object

Doc from java.lang.reflect.InvocationHandler.invoke.

the value to return from the method invocation on the proxy instance. If the declared return type of the interface method is a primitive type, then the value returned by this method must be an instance of the corresponding primitive wrapper class; otherwise, it must be a type assignable to the declared return type. If the value returned by this method is null and the interface method's return type is primitive, then a NullPointerException will be thrown by the method invocation on the proxy instance. If the value returned by this method is otherwise not compatible with the interface method's declared return type as described above, a ClassCastException will be thrown by the method invocation on the proxy instance.

Annotations
@Override
@Nullable
Exceptions
Throwable:

Doc from java.lang.reflect.InvocationHandler.invoke.

the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the throws clause of the interface method or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the interface method, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.

readObjectback to summary
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException
org.springframework.aop.framework back to summary

private final Class JdkDynamicAopProxy.ProxiedInterfacesCache

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.aop.framework.JdkDynamicAopProxy.ProxiedInterfacesCache

Holder for the complete proxied interfaces and derived metadata, to be cached in AdvisedSupport#proxyMetadataCache.
Since
6.1.3

Field Summary

Modifier and TypeField and Description
pack-priv final boolean
pack-priv final boolean
pack-priv final Class<?>[]

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

equalsDefinedback to summary
pack-priv final boolean equalsDefined
hashCodeDefinedback to summary
pack-priv final boolean hashCodeDefined
proxiedInterfacesback to summary
pack-priv final Class<?>[] proxiedInterfaces

Constructor Detail

ProxiedInterfacesCacheback to summary
pack-priv ProxiedInterfacesCache(AdvisedSupport config)