File tree 1 file changed +2
-2
lines changed
docs/system-design/framework/spring
1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -206,7 +206,7 @@ Spring 中默认存在以下事件,他们都是对 `ApplicationContextEvent`
206
206
207
207
#### 事件监听者角色
208
208
209
- ` ApplicationListener ` 充当了事件监听者角色,它是一个接口,里面只定义了一个 ` onApplicationEvent() ` 方法来处理` ApplicationEvent ` 。` ApplicationListener ` 接口类源码如下,可以看出接口定义看出接口中的事件只要实现了 ` ApplicationEvent ` 就可以了。所以,在 Spring 中我们只要实现 ` ApplicationListener ` 接口的 ` onApplicationEvent() ` 方法即可完成监听事件
209
+ ` ApplicationListener ` 充当了事件监听者角色,它是一个接口,里面只定义了一个 ` onApplicationEvent() ` 方法来处理` ApplicationEvent ` 。` ApplicationListener ` 接口类源码如下,可以看出接口定义看出接口中的事件只要实现了 ` ApplicationEvent ` 就可以了。所以,在 Spring 中我们只要实现 ` ApplicationListener ` 接口的 ` onApplicationEvent() ` 方法即可完成监听事件
210
210
211
211
``` java
212
212
package org.springframework.context ;
@@ -233,7 +233,7 @@ public interface ApplicationEventPublisher {
233
233
234
234
```
235
235
236
- ` ApplicationEventPublisher ` 接口的` publishEvent() ` 这个方法在` AbstractApplicationContext ` 类中被实现,阅读这个方法的实现,你会发现实际上事件真正是通过` ApplicationEventMulticaster ` 来广播出去的。具体内容过多,就不在这里分析了,后面可能会单独写一篇文章提到。
236
+ ` ApplicationEventPublisher ` 接口的` publishEvent() ` 这个方法在` AbstractApplicationContext ` 类中被实现,阅读这个方法的实现,你会发现实际上事件真正是通过` ApplicationEventMulticaster ` 来广播出去的。具体内容过多,就不在这里分析了,后面可能会单独写一篇文章提到。
237
237
238
238
### Spring 的事件流程总结
239
239
You can’t perform that action at this time.
0 commit comments