fixed isProxyFactoryBeanDefinition check (SPR-6842)
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2981 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
c8103fc175
commit
d0269c0756
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2006 the original author or authors.
|
* Copyright 2002-2010 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -34,22 +34,25 @@ import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base implementation for {@link org.springframework.beans.factory.xml.BeanDefinitionDecorator BeanDefinitionDecorators} wishing
|
* Base implementation for
|
||||||
* to add an {@link org.aopalliance.intercept.MethodInterceptor interceptor} to the resulting
|
* {@link org.springframework.beans.factory.xml.BeanDefinitionDecorator BeanDefinitionDecorators}
|
||||||
* bean.
|
* wishing to add an {@link org.aopalliance.intercept.MethodInterceptor interceptor}
|
||||||
|
* to the resulting bean.
|
||||||
*
|
*
|
||||||
* <p>This base class controls the creation of the {@link ProxyFactoryBean} bean definition
|
* <p>This base class controls the creation of the {@link ProxyFactoryBean} bean definition
|
||||||
* and wraps the original as an inner-bean definition for the <code>target</code> property of
|
* and wraps the original as an inner-bean definition for the <code>target</code> property
|
||||||
* {@link ProxyFactoryBean}.
|
* of {@link ProxyFactoryBean}.
|
||||||
*
|
*
|
||||||
* <p>Chaining is correctly handled, ensuring that only one {@link ProxyFactoryBean} definition
|
* <p>Chaining is correctly handled, ensuring that only one {@link ProxyFactoryBean} definition
|
||||||
* is created. If a previous {@link org.springframework.beans.factory.xml.BeanDefinitionDecorator} already created the {@link org.springframework.aop.framework.ProxyFactoryBean}
|
* is created. If a previous {@link org.springframework.beans.factory.xml.BeanDefinitionDecorator}
|
||||||
* then the interceptor is simply added to the existing definition.
|
* already created the {@link org.springframework.aop.framework.ProxyFactoryBean} then the
|
||||||
|
* interceptor is simply added to the existing definition.
|
||||||
*
|
*
|
||||||
* <p>Subclasses have only to create the <code>BeanDefinition</code> to the interceptor they
|
* <p>Subclasses have only to create the <code>BeanDefinition</code> to the interceptor that
|
||||||
* wish to add.
|
* they wish to add.
|
||||||
*
|
*
|
||||||
* @author Rob Harrop
|
* @author Rob Harrop
|
||||||
|
* @author Juergen Hoeller
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
* @see org.aopalliance.intercept.MethodInterceptor
|
* @see org.aopalliance.intercept.MethodInterceptor
|
||||||
*/
|
*/
|
||||||
|
|
@ -72,7 +75,6 @@ public abstract class AbstractInterceptorDrivenBeanDefinitionDecorator implement
|
||||||
BeanDefinitionHolder result = definitionHolder;
|
BeanDefinitionHolder result = definitionHolder;
|
||||||
|
|
||||||
if (!isProxyFactoryBeanDefinition(existingDefinition)) {
|
if (!isProxyFactoryBeanDefinition(existingDefinition)) {
|
||||||
|
|
||||||
// create the proxy definitionHolder
|
// create the proxy definitionHolder
|
||||||
RootBeanDefinition proxyDefinition = new RootBeanDefinition();
|
RootBeanDefinition proxyDefinition = new RootBeanDefinition();
|
||||||
// create proxy factory bean definitionHolder
|
// create proxy factory bean definitionHolder
|
||||||
|
|
@ -93,18 +95,17 @@ public abstract class AbstractInterceptorDrivenBeanDefinitionDecorator implement
|
||||||
}
|
}
|
||||||
|
|
||||||
addInterceptorNameToList(interceptorName, result.getBeanDefinition());
|
addInterceptorNameToList(interceptorName, result.getBeanDefinition());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private void addInterceptorNameToList(String interceptorName, BeanDefinition beanDefinition) {
|
private void addInterceptorNameToList(String interceptorName, BeanDefinition beanDefinition) {
|
||||||
List list = (List) beanDefinition.getPropertyValues().getPropertyValue("interceptorNames").getValue();
|
List<String> list = (List<String>) beanDefinition.getPropertyValues().getPropertyValue("interceptorNames").getValue();
|
||||||
list.add(interceptorName);
|
list.add(interceptorName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isProxyFactoryBeanDefinition(BeanDefinition existingDefinition) {
|
private boolean isProxyFactoryBeanDefinition(BeanDefinition existingDefinition) {
|
||||||
return existingDefinition.getBeanClassName().equals(ProxyFactoryBean.class.getName());
|
return ProxyFactoryBean.class.getName().equals(existingDefinition.getBeanClassName());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getInterceptorNameSuffix(BeanDefinition interceptorDefinition) {
|
protected String getInterceptorNameSuffix(BeanDefinition interceptorDefinition) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue