spring---事件


 /**
     * 【事件】
     *      org.springframework.context.ApplicationEvent
     *          Class to be extended by all application events. 所有 application events根接口
     *
     *          public abstract class ApplicationEvent extends EventObject {
     *
     *              private final long timestamp; // System time when the event happened.
     *
     *              public ApplicationEvent(Object source) {
     * 		            super(source);
     * 		            this.timestamp = System.currentTimeMillis();
     *              }
     *          }
     *
     *
     *          事件分类:
     *            1、直接 继承ApplicationEvent的事件
     *                  public class MySpringEvent extends ApplicationEvent{}
     *
     *            2、任意Java对象的事件
     *                  public class MyEvent {}
     *
     *                  发布的事件被封装在PayloadApplicationEvent中
     *
     *                      org.springframework.context.PayloadApplicationEvent
     *                          An ApplicationEvent that carries an arbitrary payload. 一个 携带任意内容的 ApplicationEvent
     *
     *                          public class PayloadApplicationEvent extends ApplicationEvent implements ResolvableTypeProvider {
     *
     *                              private final T payload;
     *
     *                              public PayloadApplicationEvent(Object source, T payload) {
     * 		                            super(source);
     * 		                            Assert.notNull(payload, "Payload must not be null");
     * 		                            this.payload = payload;
     *                              }
     *                          }
     */

    /**
     * 【事件发布器】
     *      org.springframework.context.ApplicationEventPublisher
     *          Interface that encapsulates event publication functionality. 封装事件发布功能的接口;
     *
     *          public interface ApplicationEventPublisher {
     *              default void publishEvent(ApplicationEvent event) {
     * 		            publishEvent((Object) event);
     *              }
     *
     *              void publishEvent(Object event);
     *          }
     */


    /**
     * 【监听器】
     *      org.springframework.context.ApplicationListener
     *
     *          public interface ApplicationListener extends EventListener {
     *              void onApplicationEvent(E event);
     *          }
     *
     *          监听器类型:
     *              1、直接实现ApplicationListener的监听器
     *                public class MySpringEventListener implements ApplicationListener{}
     *
     *                由 ApplicationEventMulticaster 调用 自定义监听器 直接执行监听任务
     *
     *              2、自定义Java类,方法用@EventListener修饰
     *                  public class MyEventListener{
     *                      @EventListener
     *                      void listen(MyEvent event){...}
     *                  }
     *
     *                  由 ApplicationEventMulticaster 调用 ApplicationListenerMethodAdapter 执行监听任务
     *
     *                  org.springframework.context.event.GenericApplicationListener
     *                      public interface GenericApplicationListener extends ApplicationListener, Ordered {}
     *
     *                  org.springframework.context.event.ApplicationListenerMethodAdapter
     *                      GenericApplicationListener adapter that delegates the processing of an event to an @EventListener annotated method.
     *                      一个ApplicationListener 用来处理@EventListener注解的方法
     *
     *                      public class ApplicationListenerMethodAdapter implements GenericApplicationListener {
     *
     *                          public void onApplicationEvent(ApplicationEvent event) {
     *                              processEvent(event);
     *                          }
     *                      }
     */

    /**
     * 【事件多播器】
     *      org.springframework.context.event.ApplicationEventMulticaster
     *          Interface to be implemented by objects that can manage a number of ApplicationListener objects and publish events to them.
     *          管理ApplicationListener 并 向ApplicationListener 发布事件;
     */