org.springframework.aop.framework
public class: DefaultAopProxyFactory [javadoc |
source]
java.lang.Object
org.springframework.aop.framework.DefaultAopProxyFactory
All Implemented Interfaces:
AopProxyFactory, Serializable
Default
AopProxyFactory implementation,
creating either a CGLIB proxy or a JDK dynamic proxy.
Creates a CGLIB proxy if one the following is true
for a given AdvisedSupport instance:
- the "optimize" flag is set
- the "proxyTargetClass" flag is set
- no proxy interfaces have been specified
Note that the CGLIB library classes have to be present on
the class path if an actual CGLIB proxy needs to be created.
In general, specify "proxyTargetClass" to enforce a CGLIB proxy,
or specify one or more interfaces to use a JDK dynamic proxy.
Also see:
- AdvisedSupport#setOptimize
- AdvisedSupport#setProxyTargetClass
- AdvisedSupport#setInterfaces
- author:
Rod - Johnson
- author:
Juergen - Hoeller
- since:
12.03.2004 -
| Method from org.springframework.aop.framework.DefaultAopProxyFactory Summary: |
|---|
|
createAopProxy |
| Method from org.springframework.aop.framework.DefaultAopProxyFactory Detail: |
public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException {
if (config.isOptimize() || config.isProxyTargetClass() || hasNoUserSuppliedProxyInterfaces(config)) {
Class targetClass = config.getTargetClass();
if (targetClass == null) {
throw new AopConfigException("TargetSource cannot determine target class: " +
"Either an interface or a target is required for proxy creation.");
}
if (targetClass.isInterface()) {
return new JdkDynamicAopProxy(config);
}
if (!cglibAvailable) {
throw new AopConfigException(
"Cannot proxy target class because CGLIB2 is not available. " +
"Add CGLIB to the class path or specify proxy interfaces.");
}
return CglibProxyFactory.createCglibProxy(config);
}
else {
return new JdkDynamicAopProxy(config);
}
}
|