码迷,mamicode.com
首页 > 编程语言 > 详细

Springboot--事件监听

时间:2018-11-14 14:11:55      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:one   nbsp   cat   遍历   frame   调用   png   src   .com   

 

1 通过SpringApplication发布事件

技术分享图片

 

 2 springboot交给 SimpleApplicationEventMulticaster进行处理

  2.1会从缓存中寻找该事件的监听者。其中cachekey是由事件和sourceType确定的类似于这样 "ListenerCacheKey [eventType = org.springframework.boot.context.event.ApplicationReadyEvent, sourceType = class org.springframework.boot.SpringApplication]"

  补充:springboot会在发布事件的时候,遍历所有的listener,然后将监听本事件的listener缓存起来,后面再次发布该事件的时候可以从缓存中取

  技术分享图片

  2.2 将监听该事件的listner缓存起来。

技术分享图片

 

3 循环调用监听者相关接口,完成事件通知 

技术分享图片

 

 

 学习springboot事件监听源码,如有不对请大家多多指教

 

Springboot--事件监听

标签:one   nbsp   cat   遍历   frame   调用   png   src   .com   

原文地址:https://www.cnblogs.com/dachengcheng/p/9957144.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!