org.springframework.aop.framework.autoproxy
public class: BeanNameAutoProxyCreator [javadoc |
source]
java.lang.Object
org.springframework.aop.framework.ProxyConfig
org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator
All Implemented Interfaces:
Ordered, BeanClassLoaderAware, AopInfrastructureBean, SmartInstantiationAwareBeanPostProcessor, BeanFactoryAware, Serializable
Auto proxy creator that identifies beans to proxy via a list of names.
Checks for direct, "xxx*", and "*xxx" matches.
For configuration details, see the javadoc of the parent class
AbstractAutoProxyCreator. Typically, you will specify a list of
interceptor names to apply to all identified beans, via the
"interceptorNames" property.
| Methods from org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator: |
|---|
|
advisorsPreFiltered, buildAdvisors, createProxy, customizeProxyFactory, determineCandidateConstructors, getAdvicesAndAdvisorsForBean, getBeanFactory, getCacheKey, getCustomTargetSource, getEarlyBeanReference, getOrder, isFrozen, isInfrastructureClass, isInfrastructureClass, postProcessAfterInitialization, postProcessAfterInstantiation, postProcessBeforeInitialization, postProcessBeforeInstantiation, postProcessPropertyValues, predictBeanType, setAdvisorAdapterRegistry, setApplyCommonInterceptorsFirst, setBeanClassLoader, setBeanFactory, setCustomTargetSourceCreators, setFrozen, setInterceptorNames, setOrder, setProxyClassLoader, shouldProxyTargetClass, shouldSkip, wrapIfNecessary |
| Methods from org.springframework.aop.framework.ProxyConfig: |
|---|
|
copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass, toString |
| Method from org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator Detail: |
protected Object[] getAdvicesAndAdvisorsForBean(Class beanClass,
String beanName,
TargetSource targetSource) {
if (this.beanNames != null) {
for (Iterator it = this.beanNames.iterator(); it.hasNext();) {
String mappedName = (String) it.next();
if (FactoryBean.class.isAssignableFrom(beanClass)) {
if (!mappedName.startsWith(BeanFactory.FACTORY_BEAN_PREFIX)) {
continue;
}
mappedName = mappedName.substring(BeanFactory.FACTORY_BEAN_PREFIX.length());
}
if (isMatch(beanName, mappedName)) {
return PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS;
}
}
}
return DO_NOT_PROXY;
}
Identify as bean to proxy if the bean name is in the configured list of names. |
protected boolean isMatch(String beanName,
String mappedName) {
return PatternMatchUtils.simpleMatch(mappedName, beanName);
}
Return if the given bean name matches the mapped name.
The default implementation checks for "xxx*", "*xxx" and "*xxx*" matches,
as well as direct equality. Can be overridden in subclasses. |
public void setBeanNames(String[] beanNames) {
Assert.notEmpty(beanNames, "'beanNames' must not be empty");
this.beanNames = new ArrayList(beanNames.length);
for (int i = 0; i < beanNames.length; i++) {
this.beanNames.add(StringUtils.trimWhitespace(beanNames[i]));
}
}
Set the names of the beans that should automatically get wrapped with proxies.
A name can specify a prefix to match by ending with "*", e.g. "myBean,tx*"
will match the bean named "myBean" and all beans whose name start with "tx".
NOTE: In case of a FactoryBean, only the objects created by the
FactoryBean will get proxied. This default behavior applies as of Spring 2.0.
If you intend to proxy a FactoryBean instance itself (a rare use case, but
Spring 1.2's default behavior), specify the bean name of the FactoryBean
including the factory-bean prefix "&": e.g. "&myFactoryBean". |