org.springframework.aop.framework
Class JdkDynamicAopProxy

java.lang.Object
  extended by org.springframework.aop.framework.JdkDynamicAopProxy
All Implemented Interfaces:
Serializable, InvocationHandler, AopProxy

final class JdkDynamicAopProxy
extends Object
implements AopProxy, InvocationHandler, Serializable

JDK-based AopProxy implementation for the Spring AOP framework, based on JDK 1.3+ 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.

Author:
Rod Johnson, Juergen Hoeller
See Also:
Proxy, AdvisedSupport, ProxyFactory

Constructor Summary
protected JdkDynamicAopProxy(AdvisedSupport config)
          Construct a new JDK proxy.
 
Method Summary
 boolean equals(Object other)
          Equality means interfaces, advisors and TargetSource are equal.
 Object getProxy()
          Create a new proxy object.
 Object getProxy(ClassLoader classLoader)
          Create a new proxy object.
 int hashCode()
          Proxy uses the hash code of the TargetSource.
 Object invoke(Object proxy, Method method, Object[] args)
          Implementation of InvocationHandler.invoke.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdkDynamicAopProxy

protected JdkDynamicAopProxy(AdvisedSupport config)
                      throws AopConfigException
Construct a new JDK proxy.

Throws:
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

getProxy

public Object getProxy()
Description copied from interface: AopProxy
Create a new proxy object.

Uses the most optimal default class loader (if necessary for proxy creation): usually, the thread context class loader.

Specified by:
getProxy in interface AopProxy
See Also:
Thread.getContextClassLoader()

getProxy

public Object getProxy(ClassLoader classLoader)
Description copied from interface: 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 getProxy method.

Specified by:
getProxy in interface AopProxy
Parameters:
classLoader - the class loader to create the proxy with (or null for the low-level proxy facility's default)

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Implementation of InvocationHandler.invoke.

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

Specified by:
invoke in interface InvocationHandler
Throws:
Throwable

equals

public boolean equals(Object other)
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.

Overrides:
equals in class Object

hashCode

public int hashCode()
Proxy uses the hash code of the TargetSource.

Overrides:
hashCode in class Object


Copyright (c) 2002-2007 The Spring Framework Project.