搞一下ApplicationListener监听器,它是spring提供的基于事件驱动的功能,监听器通过监听容器中发布的一些事件,从而触发对应的回调函数,来完成事件驱动开发(事件驱动模型开发)
先来认识下这个接口
@FunctionalInterfacepublic interface ApplicationListener<E extends ApplicationEvent> extends EventListener {/*** Handle an application event.* @param event the event to respond to*/void onApplicationEvent(E event);}
原来这个监听器继承了EventListener接口 这个接口是java.util中的监听器,看来spring也是对其进行了封装,那么问题来了java.util中的监听器了解过吗
package java.util;/*** A tagging interface that all event listener interfaces must extend.* @since JDK1.1*/public interface EventListener {}

一起了解下java中的事件监听机制的实现
事件监听三要素: 事件源,事件对象,事件监听器
