spring自动代理

spring默认提供的几种自动代理

  • BeanNameAutoProxyCreator   :  可以配置需要被进行auto-proxy的bean names列表,它控制的是需要代理的bean列表
  • DefaultAdvisorAutoProxyCreator :  将对应匹配的advisor,自动添加到spring的bean。它控制的是advisor的匹配,所有的bean都会被自动代理

 

1。DefaultAdvisorAutoProxyCreator

.

2BeanNameAutoProxyCreator

.

 BeanNameAutoProxyCreator : 故名思义, 根据 bean name 进行 auto proxy, bean name 的 match 规则参见 org.springframework.util.PatternMatchUtils 

  
   DefaultAdvisorAutoProxyCreator : 更强大的 auto proxy creator, 强大之处在于它会 cahce 容器中所有注册的 advisor, 然后搜索容器中所有的 bean , 
      如果某个 bean 满足 advisor 中的 Pointcut, 那么将会被自动代理, 与 BeanNameAutoProxyCreator 相比, 省去了配置 beanNames 的工作, 

 

posted @ 2017-10-18 22:02  许海峰  阅读(368)  评论(0编辑  收藏  举报