一、spring-boot框架中的应用
1、服务启动时,会加载spring-boot-autoconfigure的jar中spring.factories文件,加载服务启动自动装配的类
2、关于动态代理的装配类为
org.springframework.boot.autoconfigure.EnableAutoConfiguration=org.springframework.boot.autoconfigure.aop.AopAutoConfiguration
3、会导入注解@EnableAspectJAutoProxy,导入注解后,会引入org.springframework.context.annotation.AspectJAutoProxyRegistrar
4、3中的类会向spring容器中注入:org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator
二、spring容器中bean:AnnotationAwareAspectJAutoProxyCreator
org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator
该类是org.springframework.beans.factory.config.BeanPostProcessor接口的实现,在spring容器创建bean的时候,会调用该类的方式识别bean是否需要被代理。
遵循spring-aop的规范
advice中隐藏了代理的逻辑
advisor:
org.springframework.aop.aspectj.annotation.InstantiationModelAwarePointcutAdvisorImpl
pointcut:
org.springframework.aop.aspectj.AspectJExpressionPointcut
advice:
org.springframework.aop.aspectj.AspectJMethodBeforeAdvice
org.springframework.aop.aspectj.AspectJAroundAdvice
org.springframework.aop.aspectj.AspectJAfterAdvice
org.springframework.aop.aspectj.AspectJAfterThrowingAdvice
org.springframework.aop.aspectj.AspectJAfterReturningAdvice