@EventListener 是怎么被解析的
- org.springframework.context.support.AbstractApplicationContext#refresh
- org.springframework.context.support.AbstractApplicationContext#finishBeanFactoryInitialization
- org.springframework.beans.factory.support.DefaultListableBeanFactory#preInstantiateSingletons
- org.springframework.context.event.EventListenerMethodProcessor#afterSingletonsInstantiated
- org.springframework.context.event.EventListenerMethodProcessor#processBean
解析出方法名称有注解 @EventListener ,然后封装到 ApplicationListenerMethodAdapter,然后添加到
org.springframework.context.support.AbstractApplicationContext#applicationListeners 中,这样如果有事件发生就会通知到 加上 @EventListener 的方法上。前提是使用 @EventListener 注解的类被spring管理了