org.springframework.aop.framework
Class ProxyConfig

java.lang.Object
  extended by org.springframework.aop.framework.ProxyConfig
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AbstractAutoProxyCreator, AdvisedSupport, TransactionProxyFactoryBean

public class ProxyConfig
extends Object
implements Serializable

Convenience superclass for configuration used in creating proxies, to ensure that all proxy creators have consistent properties.

Author:
Rod Johnson, Juergen Hoeller
See Also:
AdvisedSupport, Serialized Form

Field Summary
protected  boolean exposeProxy
           
protected  Log logger
          Transient to optimize serialization: AdvisedSupport resets it
 
Constructor Summary
ProxyConfig()
           
 
Method Summary
 void copyFrom(ProxyConfig other)
          Copy configuration from the other config object.
 AopProxyFactory getAopProxyFactory()
          Return the AopProxyFactory that this ProxyConfig uses.
 boolean isExposeProxy()
          Return whether the AOP proxy will expose the AOP proxy for each invocation.
 boolean isFrozen()
          Return whether the config is frozen, and no advice changes can be made.
 boolean isOpaque()
          Return whether proxies created by this configuration should be prevented from being cast to Advised.
 boolean isOptimize()
          Return whether proxies should perform aggressive optimizations.
 boolean isProxyTargetClass()
          Return whether to proxy the target class directly as well as any interfaces.
 void setAopProxyFactory(AopProxyFactory aopProxyFactory)
          Customize 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 setOpaque(boolean opaque)
          Set whether proxies created by this configuration should be prevented from being cast to Advised to query proxy status.
 void setOptimize(boolean optimize)
          Set whether proxies should perform aggressive optimizations.
 void setProxyTargetClass(boolean proxyTargetClass)
          Set whether to proxy the target class directly, instead of just proxying specific interfaces.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected transient Log logger
Transient to optimize serialization: AdvisedSupport resets it


exposeProxy

protected boolean exposeProxy
Constructor Detail

ProxyConfig

public ProxyConfig()
Method Detail

setProxyTargetClass

public void setProxyTargetClass(boolean proxyTargetClass)
Set whether to proxy the target class directly, instead of just proxying specific interfaces. Default is "false".

Set this to "true" to force proxying for the TargetSource's exposed target class, creating a CGLIB proxy for the given class.

Note: Depending on the configuration of the concrete proxy factory, the proxy-target-class behavior will also be applied if no interfaces have been specified (and no interface autodetection is activated).

See Also:
TargetSource.getTargetClass()

isProxyTargetClass

public boolean isProxyTargetClass()
Return whether to proxy the target class directly as well as any interfaces.


setOptimize

public void setOptimize(boolean optimize)
Set whether proxies should perform aggressive optimizations. The exact meaning of "aggressive optimizations" will differ between proxies, but there is usually some tradeoff. Default is "false".

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.


isOptimize

public boolean isOptimize()
Return whether proxies should perform aggressive optimizations.


setOpaque

public void setOpaque(boolean opaque)
Set whether proxies created by this configuration should be prevented from being cast to Advised to query proxy status.

Default is "false", meaning that any AOP proxy can be cast to Advised.


isOpaque

public boolean isOpaque()
Return whether proxies created by this configuration should be prevented from being cast to Advised.


setExposeProxy

public 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).

Default is "false", for optimal performance.


isExposeProxy

public boolean isExposeProxy()
Return whether the AOP proxy will expose the AOP proxy for each invocation.


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.


isFrozen

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


setAopProxyFactory

public void setAopProxyFactory(AopProxyFactory aopProxyFactory)
Customize the AopProxyFactory, allowing different strategies to be dropped in without changing the core framework.

Default is DefaultAopProxyFactory, using dynamic JDK proxies or CGLIB proxies based on the requirements.


getAopProxyFactory

public AopProxyFactory getAopProxyFactory()
Return the AopProxyFactory that this ProxyConfig uses.


copyFrom

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

Parameters:
other - object to copy configuration from

toString

public String toString()
Overrides:
toString in class Object


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