资料内容:
	
	
		1. 简介
		 
	
		1.1 ApplicationEvent
		 
	
		ApplicationEvent 是 Spring 框架中的一个重要概念,它是基于观察者模式的事件。简单来说,它是一个用
		于在 Spring 应用程序上下文中传播信息的对象。当某个特定的事件发生时,ApplicationEvent 对象会被创
		建并发布到 ApplicationContext 中,所有注册监听该事件的监听器就会收到通知并执行相应的操作。
		ApplicationEvent 是一个泛型类,可以用来传递任何类型的数据。当事件被发布时,所有注册的监听器将会
		接收到一个 ApplicationEvent 对象,通过该对象的 getSource() 方法可以获取到事件源,即触发事件的组
		件。同时,通过 getTimestamp() 方法可以获取到事件发生的时间戳。
		 
	
		1.2 ApplicationListener
		 
	
		ApplicationListener 是 Spring 框架中的一个接口,用于监听容器中发布的事件。这个接口定义了一个方
		法:void onApplicationEvent(E event),当某个 ApplicationEvent 被发布时,所有注册监听该事件的
		ApplicationListener 将会被调用。
		ApplicationListener 是一个泛型接口,其参数 E 代表事件的类型。开发者需要实现这个接口,并指定要监听
		的事件类型。例如,如果要监听 CustomEvent 类型的事件,可以创建一个实现了 ApplicationListener 接口
		的类。
		 
	
		1.3 @EventListener
		 
	
		@EventListener 是一个 Spring 框架提供的注解,用于实现事件驱动编程。它允许定义事件和事件监听器,
		当事件被触发时,所有注册监听该事件的监听器将会被调用。
		public class MyCustomEvent extends ApplicationEvent {
		private String message;
		public MyCustomEvent(Object source, String message) {
		super(source);
		this.message = message;
		}
		public String getMessage() {
		return message;
		}
		}
		public interface ApplicationListener<E extends ApplicationEvent> {
		void onApplicationEvent(E event);
		}
		 
	
		2. 使用示例
		 
	
		2.1 监听事件
		 
	
		2.1.1 使用ApplicationListener
		 
	
		要监听事件,需要实现 ApplicationListener 接口,并指定要监听的事件类型。然后,可以将这个监听器
		注册到 ApplicationContext 中。
		 
	
		2.1.2 使用@EventListener
		 
	
		在该类中定义一个带有 @EventListener 注解的方法。这个方法将在事件被触发时自动执行。
		如果希望通过一定的条件对事件进行过滤,可以使用 @EventListener 的 condition 属性。以下实例中只有
		event 的 message属性是 my-event 时才会进行调用。
		@Component
		public class MyCustomEventListener implements ApplicationListener<MyCustomEvent> {
		@Override
		public void onApplicationEvent(MyCustomEvent event) {
		System.out.println("Received event: " + event.getMessage());
		}
		}
		@Component
		public class MyCustomListener {
		@EventListener
		public void handleMyCustomEvent(MyCustomEvent event) {
		System.out.println("Received event: " + event.getMessage());
		}
		}