Open zyllt opened 6 years ago
第一种是在解析的时候会注册一个AspectJAwareAdvisorAutoProxyCreator,这个类继承自InstantiationAwareBeanPostProcessor的,具体对被注入了AOP的bean在实例化之前会调用AbstractAutoProxyCreator#postProcessBeforeInstantiation,在此中会生成代理对象。 如果配置了proxy-target-class=true或者该类没有接口,使用cglib来生成一个子类。如果为false并且有接口则使用jdk的proxy
if (beanName != null) {
TargetSource targetSource = getCustomTargetSource(beanClass, beanName);
if (targetSource != null) {
this.targetSourcedBeans.add(beanName);
Object[] specificInterceptors = getAdvicesAndAdvisorsForBean(beanClass, beanName, targetSource);
Object proxy = createProxy(beanClass, beanName, specificInterceptors, targetSource);
this.proxyTypes.put(cacheKey, proxy.getClass());
return proxy;
}
}
1、启用AOP的配置方式
这个AOP标签在解析的时候做了什么呢?