- 判断需要AOP增强;
- 查找对应的增强类或者增强器;
- 创建代理对象植入增强;
- 代理对象执行方法的增强。
后面的代码大部分基于常用的 SpringAOP + Aspectj 注解的形式展开。
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
https://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 基于aspectj 注解 -->
<aop:aspectj-autoproxy proxy-target-class="true"/>
<!-- 接口 -->
<bean id="userService" class="cn.lichenghao.aop.jdk.service.impl.UserServiceImpl"></bean>
<!-- 通知类 -->
<bean id="aopLogger" class="cn.lichenghao.aop.AopLogger2"></bean>
</beans>