if (this.beanNames != null) {
for (Iterator it = this.beanNames.iterator(); it.hasNext();) {
String mappedName = (String) it.next();
if (isMatch(beanName, mappedName)) {
if (ProxyFactoryBean.class.isAssignableFrom(bean.getClass())) {
ProxyFactoryBean proxyFactoryBean = (ProxyFactoryBean) bean;
String[] orignInterceptorNames = getInterceptorFromProxyFactoryBean(proxyFactoryBean);
String[] newInterceptorNames = new String[orignInterceptorNames.length
+ interceptorNames.length];
if (applyCommonInterceptorsFirst) {// 如果是true,则将Auto-proxy的拦截器定义到最前面
// 构造新的的拦截器列表
System.arraycopy(interceptorNames, 0, newInterceptorNames, 0, interceptorNames.length);
System.arraycopy(orignInterceptorNames, 0, newInterceptorNames, interceptorNames.length,
orignInterceptorNames.length);
} else {
System.arraycopy(orignInterceptorNames, 0, newInterceptorNames, 0,
orignInterceptorNames.length);
System.arraycopy(interceptorNames, 0, newInterceptorNames, orignInterceptorNames.length,
interceptorNames.length);
}
// 重新设置新的inteceptorNames
proxyFactoryBean.setInterceptorNames(newInterceptorNames);
return proxyFactoryBean;
} else {
// 如果是单例,对应的代理bean对象为同一个
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setBeanFactory(beanFactory);
proxyFactoryBean.setBeanClassLoader(proxyClassLoader);
proxyFactoryBean.setInterceptorNames(interceptorNames);
proxyFactoryBean.copyFrom(this); // 拷贝对应的一些Proxy config
proxyFactoryBean.setTarget(bean);
return proxyFactoryBean.getObject();
}
}
}
}