ProxyFactoryBean determines actual proxy class in getObjectType()
AopProxy implementations accept empty Advisor chains for early proxy class creation. Closes gh-29097
This commit is contained in:
@@ -126,9 +126,6 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||
*/
|
||||
public CglibAopProxy(AdvisedSupport config) throws AopConfigException {
|
||||
Assert.notNull(config, "AdvisedSupport must not be null");
|
||||
if (config.getAdvisorCount() == 0 && config.getTargetSource() == AdvisedSupport.EMPTY_TARGET_SOURCE) {
|
||||
throw new AopConfigException("No advisors and no TargetSource specified");
|
||||
}
|
||||
this.advised = config;
|
||||
this.advisedDispatcher = new AdvisedDispatcher(this.advised);
|
||||
}
|
||||
|
||||
@@ -104,9 +104,6 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
|
||||
*/
|
||||
public JdkDynamicAopProxy(AdvisedSupport config) throws AopConfigException {
|
||||
Assert.notNull(config, "AdvisedSupport must not be null");
|
||||
if (config.getAdvisorCount() == 0 && config.getTargetSource() == AdvisedSupport.EMPTY_TARGET_SOURCE) {
|
||||
throw new AopConfigException("No advisors and no TargetSource specified");
|
||||
}
|
||||
this.advised = config;
|
||||
this.proxiedInterfaces = AopProxyUtils.completeProxiedInterfaces(this.advised, true);
|
||||
findDefinedEqualsAndHashCodeMethods(this.proxiedInterfaces);
|
||||
|
||||
@@ -274,19 +274,9 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||
return this.singletonInstance.getClass();
|
||||
}
|
||||
}
|
||||
Class<?>[] ifcs = getProxiedInterfaces();
|
||||
if (ifcs.length == 1) {
|
||||
return ifcs[0];
|
||||
}
|
||||
else if (ifcs.length > 1) {
|
||||
return createCompositeInterface(ifcs);
|
||||
}
|
||||
else if (this.targetName != null && this.beanFactory != null) {
|
||||
return this.beanFactory.getType(this.targetName);
|
||||
}
|
||||
else {
|
||||
return getTargetClass();
|
||||
}
|
||||
// This might be incomplete since it potentially misses introduced interfaces
|
||||
// from Advisors that will be lazily retrieved via setInterceptorNames.
|
||||
return createAopProxy().getProxyClass(this.proxyClassLoader);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -295,19 +285,6 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a composite interface Class for the given interfaces,
|
||||
* implementing the given interfaces in one single Class.
|
||||
* <p>The default implementation builds a JDK proxy class for the
|
||||
* given interfaces.
|
||||
* @param interfaces the interfaces to merge
|
||||
* @return the merged interface as Class
|
||||
* @see java.lang.reflect.Proxy#getProxyClass
|
||||
*/
|
||||
protected Class<?> createCompositeInterface(Class<?>[] interfaces) {
|
||||
return ClassUtils.createCompositeInterface(interfaces, this.proxyClassLoader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the singleton instance of this class's proxy object,
|
||||
* lazily creating it if it hasn't been created already.
|
||||
|
||||
Reference in New Issue
Block a user