org.springframework.aop.framework
Class ProxyConfig

Direct Known Subclasses:
AdvisedSupport, AbstractAutoProxyCreator, TransactionProxyFactoryBean

public class ProxyConfig

Convenience superclass for configuration used in creating proxies, to ensure that all proxy creators have consistent properties.
Note that it is now longer possible to configure subclasses to expose the MethodInvocation. Interceptors should normally manage their own ThreadLocals if they need to make resources available to advised objects. If it's absolutely necessary to expose the MethodInvocation, use an interceptor to do so.

Author:
Rod Johnson
Version: $Id: ProxyConfig.java,v 1.6 2003/12/19 10:22:02 johnsonr Exp $

Constructor Summary
ProxyConfig()
           

Method Summary
 voidcopyFrom(ProxyConfig other)
           
 final booleangetExposeProxy()
           
 booleangetOptimize()
           
 booleangetProxyTargetClass()
           
 final voidsetExposeProxy(boolean exposeProxy)
          Set whether the proxy should be exposed by the AOP framework as a ThreadLocal for retrieval via the AopContext class.
 voidsetOptimize(boolean optimize)
          Set whether proxies should perform agressive optimizations.
 voidsetProxyTargetClass(boolean proxyTargetClass)
          Set whether to proxy the target class directly as well as any interfaces.
 StringtoString()
           

Constructor Detail

ProxyConfig

public ProxyConfig()
Method Detail

copyFrom

public void copyFrom(ProxyConfig other)

getExposeProxy

public final boolean getExposeProxy()
Returns: whether the AOP proxy will expose the AOP proxy for each invocation.

getOptimize

public boolean getOptimize()
Returns: whether proxies should perform agressive optimizations.

getProxyTargetClass

public boolean getProxyTargetClass()

setExposeProxy

public final void setExposeProxy(boolean exposeProxy)
Set whether the proxy should be exposed by the AOP framework as a ThreadLocal for retrieval via the AopContext class. This is useful if an advised object needs to call another advised method on itself. (If it uses this, the invocation will not be advised).
Parameters:
exposeProxy - whether the proxy should be exposed. Default is false, for optimal pe3rformance.

setOptimize

public void setOptimize(boolean optimize)
Set whether proxies should perform agressive optimizations. The exact meaning of "agressive optimizations" will differ between proxies, but there is usually some tradeoff. For example, optimization will usually mean that advice changes won't take effect after a proxy has been created. For this reason, optimization is disabled by default. An optimize value of true may be ignored if other settings preclude optimization: for example, if exposeProxy is set to true and that's not compatible with the optimization.
For example, CGLIB-enhanced proxies may optimize out. overriding methods with no advice chain. This can produce 2.5x performance improvement for methods with no advice.
Warning: Setting this to true can produce large performance gains when using CGLIB (also set proxyTargetClass to true), so it's a good setting for performance-critical proxies. However, enabling this will mean that advice cannot be changed after a proxy has been obtained from this factory.
Parameters:
optimize - whether to enable agressive optimizations. Default is false.

setProxyTargetClass

public void setProxyTargetClass(boolean proxyTargetClass)
Set whether to proxy the target class directly as well as any interfaces. We can set this to true to force CGLIB proxying. Default is false
Parameters:
proxyTargetClass - whether to proxy the target class directly as well as any interfaces

toString

public String toString()