---
title: Spring源码系列-第7章-AOP的执行流程原理和监听器原理
tags:
- Spring源码
categories:
- Spring
- 源码V1
keywords: Spring,框架,spring源码
description: AOP执行流程和监听器原理
cover: 'https://npm.elemecdn.com/lql_static@latest/logo/spring.png'
abbrlink: fb3552e0
date: 2022-04-17 12:01:02
---
# 第7章-AOP的执行流程原理和监听器原理
## 流程图-AOP运行流程原理
## 由Aop的执行流程引出方法拦截器
### 创建完代理对象之后,怎么执行的呢?
断点打到这里,F7进入方法
自然而然的跳到了cglib这里
#### CglibAopProxy#intercept()
```java
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
Object oldProxy = null;
boolean setProxyContext = false;
Object target = null;
TargetSource targetSource = this.advised.getTargetSource();
try {
if (this.advised.exposeProxy) {
// Make invocation available if necessary.
oldProxy = AopContext.setCurrentProxy(proxy);
setProxyContext = true;
}
// Get as late as possible to minimize the time we "own" the target, in case it comes from a pool...
target = targetSource.getTarget();
Class> targetClass = (target != null ? target.getClass() : null);
List