[TOC]
Joinpoint
Pointcut
Advice
Advisor
IntroductionInfo
ProxyCreatorSupport
ProxyFactory
、ProxyFactoryBean
AopProxyFactory
配置管理器 - AdvisedSupport
AbstractAutoProxyCreator
MethodInvocation
ConstructorInvocation
ReflectiveMethodInvocation
CglibMethodInvocation
核心组件:
ClassFilter
MethodMatcher
org.springframework.aop.support.ComposablePointcut
ClassFilter
工具类 - ClassFilters
MethodMatcher
工具类 - MethodMatchers
Pointcut
工具类 - Pointcuts
Pointcut
- StaticMethodMatcherPointcut
Pointcut
- JdkRegexpMethodPointcut
Pointcut
- ControlFlowPointcut
org.springframework.aop.aspectj.AspectJExpressionPointcut
SUPPORTED_PRIMITIVES
字段org.aspectj.weaver.tools.PointcutExpression
MethodInterceptor
ConstructorInterceptor
org.springframework.aop.BeforeAdvice
org.springframework.aop.MethodBeforeAdvice
org.springframework.aop.AfterAdvice
org.springframework.aop.AfterReturningAdvice
org.springframework.aop.ThrowsAdvice
接口:
org.springframework.aop.BeforeAdvice
org.springframework.aop.MethodBeforeAdvice
实现:
org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor
org.springframework.aop.aspectj.AspectJMethodBeforeAdvice
org.springframework.aop.AfterAdvice
org.springframework.aop.AfterReturningAdvice
org.springframework.aop.ThrowsAdvice
org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor
org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor
org.springframework.aop.AfterAdvice
org.springframework.aop.AfterReturningAdvice
org.springframework.aop.ThrowsAdvice
org.springframework.aop.aspectj.AspectJAfterAdvice
org.springframework.aop.aspectj.AspectJAfterReturningAdvice
org.springframework.aop.aspectj.AspectJAfterThrowingAdvice
org.springframework.aop.support.DefaultPointcutAdvisor
IntroductionAdvisor
org.springframework.aop.support.DefaultPointcutAdvisor
org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor
org.springframework.aop.aspectj.AspectJPointcutAdvisor
org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor
org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor
org.springframework.aop.IntroductionInfo
org.springframework.aop.support.DefaultIntroductionAdvisor
org.springframework.aop.aspectj.DeclareParentsAdvisor
org.springframework.aop.framework.adapter.MethodBeforeAdviceAdapter
org.springframework.aop.framework.adapter.AfterReturningAdviceAdapter
org.springframework.aop.framework.adapter.ThrowsAdviceAdapter
org.springframework.aop.framework.AopProxy
org.springframework.aop.framework.JdkDynamicAopProxy
org.springframework.aop.framework.CglibAopProxy
org.springframework.aop.framework.ObjenesisCglibAopProxy
org.springframework.aop.framework.AopProxyFactory
org.springframework.aop.framework.JdkDynamicAopProxy
org.springframework.aop.framework.CglibAopProxy
org.springframework.aop.framework.ObjenesisCglibAopProxy
org.springframework.aop.framework.AdvisedSupport
org.springframework.aop.framework.DefaultAopProxyFactory
org.springframework.aop.framework.AdvisedSupport
org.springframework.aop.framework.DefaultAopProxyFactory
org.springframework.aop.framework.ProxyConfig
org.springframework.aop.framework.Advised
org.springframework.aop.framework.AopProxy
实现org.springframework.aop.framework.DefaultAdvisorChainFactory
org.springframework.aop.framework.InterceptorAndDynamicMethodMatcher
org.aopalliance.intercept.Interceptor
org.springframework.aop.target.HotSwappableTargetSource
org.springframework.aop.target.AbstractPoolingTargetSource
org.springframework.aop.target.PrototypeTargetSource
org.springframework.aop.target.ThreadLocalTargetSource
org.springframework.aop.target.SingletonTargetSource
org.springframework.aop.framework.AdvisedSupport
org.springframework.aop.framework.ProxyCreatorSupport
org.springframework.aop.framework.ProxyCreatorSupport
org.springframework.beans.factory.BeanClassLoaderAware
org.springframework.beans.factory.BeanFactoryAware
org.springframework.beans.factory.FactoryBean
org.springframework.aop.framework.ProxyCreatorSupport
org.springframework.aop.aspectj.annotation.AspectMetadata
org.springframework.aop.aspectj.annotation.AspectJAdvisorFactory
org.springframework.aop.framework.AdvisedSupport
org.springframework.aop.framework.ProxyCreatorSupport
ProxyCreatorSupport#createAopProxy
org.springframework.aop.framework.ProxyProcessorSupport
org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor
DefaultAdvisorAutoProxyCreator
BeanNameAutoProxyCreator
InfrastructureAdvisorAutoProxyCreator
org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator
org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
org.springframework.aop.scope.ScopedProxyFactoryBean
AbstractAutoProxyCreator#isInfrastructureClass
ConfigurationClassUtils#checkConfigurationClassCandidate
ThreadLocal
的扩展,临时存储 AOP 对象getSingletonTarget
- 从实例中获取单例对象ultimateTargetClass
- 从实例中获取最终目标类completeProxiedInterfaces
- 计算 AdvisedSupport
配置中所有被代理的接口proxiedUserInterfaces
- 从代理对象中获取代理接口isAopProxy
- 判断对象是否为代理对象isJdkDynamicProxy
- 判断对象是否为 JDK 动态代理对象isCglibProxy
- 判断对象是否为 CGLIB 代理对象getTargetClass
- 从对象中获取目标类型invokeJoinpointUsingReflection
- 使用 Java 反射调用 Joinpoint(目标方法)org.springframework.context.annotation.EnableAspectJAutoProxy
proxyTargetClass
- 是否已类型代理exposeProxy
- 是否将代理对象暴露在 AopContext
中ImportBeanDefinitionRegistrar
实现 - org.springframework.context.annotation.AspectJAutoProxyRegistrar
org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator
<aop:aspectj-autoproxy/>
proxy-target-class
- 是否已类型代理expose-proxy
- 是否将代理对象暴露在 AopContext
中org.springframework.aop.config.AspectJAutoProxyBeanDefinitionParser
<aop:config/>
、<aop:aspect/>
proxy-target-class
- 是否已类型代理expose-proxy
- 是否将代理对象暴露在 AopContext
中pointcut
advisor
aspect
org.springframework.aop.config.ConfigBeanDefinitionParser
<aop:config/>
ref
- Spring Bean 引用的名称order
- Aspect 顺序数pointcut
declare-parents
before
after
after-returning
after-throwing
around
<aop:pointcut/>
<aop:aspect/>
或 <aop:config/>
id
- Pointcut IDexpression
- (必须)AspectJ 表达式org.springframework.aop.Pointcut
<aop:around/>
<aop:aspect/>
pointcut
- AspectJ Pointcut 表达式pointcut-ref
- 引用的 AspectJ Pointcut 名称method
- 拦截目标方法arg-names
- 目标方法参数名称<aop:before/>
<aop:aspect/>
pointcut
- AspectJ Pointcut 表达式pointcut-ref
- 引用的 AspectJ Pointcut 名称method
- 拦截目标方法arg-names
- 目标方法参数名称<aop:after/>
<aop:aspect/>
pointcut
- AspectJ Pointcut 表达式pointcut-ref
- 引用的 AspectJ Pointcut 名称method
- 拦截目标方法arg-names
- 目标方法参数名称<aop:after-returning/>
<aop:aspect/>
pointcut
- AspectJ Pointcut 表达式pointcut-ref
- 引用的 AspectJ Pointcut 名称method
- 拦截目标方法arg-names
- 目标方法参数名称returning
- 方法参数名称<aop:after-throwing/>
<aop:aspect/>
pointcut
- AspectJ Pointcut 表达式pointcut-ref
- 引用的 AspectJ Pointcut 名称method
- 拦截目标方法arg-names
- 目标方法参数名称throwing
- 方法参数名称<aop:advisor/>
<aop:config/>
advice-ref
- Advice Bean 引用pointcut
- AspectJ Pointcut 表达式pointcut-ref
- AspectJ Pointcut Bean 引用order
- Advisor 顺序数<aop:declare-parents/>
<aop:aspect/>
types-matching
- 是否已类型代理implement-interface
- 实现接口全类名default-impl
- 默认实现全类名delegate-ref
- 委派实现 Bean 引用<aop:scoped-proxy/>
<aop:scoped-proxy/>
proxy-target-class
- 是否已类型代理