• 与路同飞
    2020-10-13
    注解的监 听器如何注册? 1.org.springframework.context.annotation.AnnotationConfigUtils#registerAnnotationConfigProcessors(org.springframework.beans.factory.support.BeanDefinitionRegistry) 注册所有相关注解的post processor到beanRegistry里面,其中就包括监 听器相关的EventListenerMethodProcessor 2. 该类的这个方法org.springframework.context.event.EventListenerMethodProcessor#afterSingletonsInstantiated会在bean实例化的中被调用。 3. org.springframework.context.event.EventListenerMethodProcessor#processBean 最终在这个方法找到相关注解并不linstener注册到ApplicationContext中 其实spring的很多功能都是通过扩展post processor来完成的,像aop估计也是这种套路。 面向接口的就不说了比较简单。
    展开

    作者回复: 666

    
    10
  • 与路同飞
    2020-10-13
    老师,这节的pdf是不是有误?ApplicationListener应该是观察者模式里面的【观察者】吧,而SimpleApplicationEventMulticaster是作为【被观察者】

    作者回复: 是的

    
    6