org.springframework.aop.framework
Class Cglib2AopProxy

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

public class Cglib2AopProxy
extends Object
implements AopProxy, Serializable

CGLIB2-based AopProxy implementation for the Spring AOP framework. Requires CGLIB2 on the class path.

Built and tested against CGLIB 2.0.2, as of Spring 1.1. It is recommended to use CGLIB 2.1+.

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 CGLIB2-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.

Author:
Rod Johnson, Rob Harrop, Juergen Hoeller
See Also:
Enhancer, ProxyConfig.setProxyTargetClass(boolean), DefaultAopProxyFactory, Serialized Form

Nested Class Summary
static class Cglib2AopProxy.SerializableNoOp
          Serializable replacement for CGLIB's NoOp interface.
 
Field Summary
protected  AdvisedSupport advised
          The configuration used to configure this proxy
protected static Log logger
          Logger available to subclasses; static to optimize serialization
 
Constructor Summary
protected Cglib2AopProxy(AdvisedSupport config)
          Create a new Cglib2AopProxy for the given AOP configuration.
 
Method Summary
protected  Enhancer createEnhancer()
          Creates the CGLIB Enhancer.
 boolean equals(Object other)
           
 Object getProxy()
          Create a new proxy object.
 Object getProxy(ClassLoader classLoader)
          Create a new proxy object.
 int hashCode()
           
protected  void setConstructorArguments(Object[] constructorArgs, Class[] constructorArgTypes)
          Set constructor arguments to use for creating the proxy.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final Log logger
Logger available to subclasses; static to optimize serialization


advised

protected final AdvisedSupport advised
The configuration used to configure this proxy

Constructor Detail

Cglib2AopProxy

protected Cglib2AopProxy(AdvisedSupport config)
                  throws AopConfigException
Create a new Cglib2AopProxy for the given AOP configuration.

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

setConstructorArguments

protected void setConstructorArguments(Object[] constructorArgs,
                                       Class[] constructorArgTypes)
Set constructor arguments to use for creating the proxy.

Parameters:
constructorArgs - the constructor argument values
constructorArgTypes - the constructor argument types

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)

createEnhancer

protected Enhancer createEnhancer()
Creates the CGLIB Enhancer. Subclasses may wish to override this to return a custom Enhancer implementation.


equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


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