org.springframework.aop.framework
Class ProxyConfig

java.lang.Object
  extended byorg.springframework.aop.framework.ProxyConfig
Direct Known Subclasses:
AbstractAutoProxyCreator, AdvisedSupport, TransactionProxyFactoryBean

public class ProxyConfig
extends java.lang.Object

Convenience superclass for configuration used in creating proxies, to ensure that all proxy creators have consistent properties.
Note that it is no 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.

Version:
$Id: ProxyConfig.java,v 1.9 2004/03/18 02:46:05 trisberg Exp $
Author:
Rod Johnson

Field Summary
protected  boolean exposeProxy
          Should proxies obtained from this configuration expose the AOP proxy for the AopContext class to retrieve for targets? The default is false, as enabling this property may impair performance.
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
ProxyConfig()
           
 
Method Summary
 void copyFrom(ProxyConfig other)
          Copy configuration from the other config
 AopProxyFactory getAopProxyFactory()
           
 boolean getExposeProxy()
           
 boolean getOptimize()
           
 boolean getProxyTargetClass()
           
 boolean isFrozen()
           
 void setAopProxyFactory(AopProxyFactory apf)
          Customise the AopProxyFactory, allowing different strategies to be dropped in without changing the core framework.
 void setExposeProxy(boolean exposeProxy)
          Set whether the proxy should be exposed by the AOP framework as a ThreadLocal for retrieval via the AopContext class.
 void setFrozen(boolean frozen)
          Set whether this config should be frozen.
 void setOptimize(boolean optimize)
          Set whether proxies should perform agressive optimizations.
 void setProxyTargetClass(boolean proxyTargetClass)
          Set whether to proxy the target class directly as well as any interfaces.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger

exposeProxy

protected boolean exposeProxy
Should proxies obtained from this configuration expose the AOP proxy for the AopContext class to retrieve for targets? The default is false, as enabling this property may impair performance.

Constructor Detail

ProxyConfig

public ProxyConfig()
Method Detail

copyFrom

public void copyFrom(ProxyConfig other)
Copy configuration from the other config

Parameters:
other - object to copy configuration from

getProxyTargetClass

public boolean getProxyTargetClass()

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

getOptimize

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

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.

getExposeProxy

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

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.

setAopProxyFactory

public void setAopProxyFactory(AopProxyFactory apf)
Customise the AopProxyFactory, allowing different strategies to be dropped in without changing the core framework. For example, an AopProxyFactory could return an AopProxy using dynamic proxies, CGLIB or code generation strategy.

Parameters:
apf - AopProxyFactory to use. The default uses dynamic proxies or CGLIB.

getAopProxyFactory

public AopProxyFactory getAopProxyFactory()

isFrozen

public boolean isFrozen()
Returns:
whether the config is frozen, and no advice changes can be made

setFrozen

public void setFrozen(boolean frozen)
Set whether this config should be frozen. When a config is frozen, no advice changes can be made. This is useful for optimization, and useful when we don't want callers to be able to manipulate configuration after casting to Advised.

Parameters:
frozen - is this config frozen?

toString

public java.lang.String toString()


Copyright (C) 2003-2004 The Spring Framework Project.