AOP底层是如何判断哪些方法被代理了

洛翼轻尘 洛翼轻尘 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
如下代码:Spring容器启动完成后,是怎么知道* com.spring.service.*.*(..)的中的方法被执行了的?
个人理解是Spring容器在启动时将* com.spring.service.*.*(..)下的方法都存在一个map里面,每当执行一个方法的时候都到这个map里面匹配一下看是否需要代理,不知带这样理解对不对??
<aop:config>
<aop:aspect id="TestAspect" ref="aspectBean">
<!--配置com.spring.service包下所有类或接口的所有方法-->
<aop:pointcut id="businessService" expression="execution(* com.spring.service.*.*(..))" />
<aop:before pointcut-ref="businessService" method="doBefore"/>
<aop:after pointcut-ref="businessService" method="doAfter"/>
<aop:around pointcut-ref="businessService" method="doAround"/>
<aop:after-throwing pointcut-ref="businessService" method="doThrowing" throwing="ex"/>
</aop:aspect>
</aop:config>

<bean id="aspectBean" class="com.spring.aop.TestAspect" />
<bean id="aService" class="com.spring.service.AServiceImpl"></bean>
<bean id="bService" class="com.spring.service.BServiceImpl"></bean>
...全文
评论
收藏 已收藏
分享
返回顶部
洛翼轻尘
Java 51,407 成员 86,128 内容