fix(): 修改事件处理基类架构
parent
8888b7430c
commit
a0c2d916f2
|
@ -3,6 +3,8 @@ package com.muyu.event.process.basic;
|
|||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: zi run
|
||||
* @Date 2024/9/30 15:37
|
||||
|
@ -12,17 +14,17 @@ import org.springframework.stereotype.Component;
|
|||
public class BasicEventHandler<T> implements ApplicationListener<BasicEvent<T>> {
|
||||
|
||||
/**
|
||||
* 具体事件监听器
|
||||
* 具体事件监听器列表
|
||||
*/
|
||||
private final BasicEventListener<T> listener;
|
||||
private final List<BasicEventListener<T>> listeners;
|
||||
|
||||
/**
|
||||
* 构造函数,用于注入具体事件监听器
|
||||
*
|
||||
* @param listener 具体事件监听器
|
||||
* @param listeners 具体事件监听器列表
|
||||
*/
|
||||
public BasicEventHandler(BasicEventListener<T> listener) {
|
||||
this.listener = listener;
|
||||
public BasicEventHandler(List<BasicEventListener<T>> listeners) {
|
||||
this.listeners = listeners;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,6 +34,6 @@ public class BasicEventHandler<T> implements ApplicationListener<BasicEvent<T>>
|
|||
*/
|
||||
@Override
|
||||
public void onApplicationEvent(BasicEvent<T> event) {
|
||||
listener.onEvent(event);
|
||||
listeners.forEach(l -> l.onEvent(event));
|
||||
}
|
||||
}
|
|
@ -5,16 +5,16 @@ import com.muyu.event.process.basic.BasicEvent;
|
|||
/**
|
||||
* @Author: zi run
|
||||
* @Date 2024/9/29 21:19
|
||||
* @Description 向IoTDB插入数据事件
|
||||
* @Description 数据处理事件
|
||||
*/
|
||||
public class IoTDBInsertDataEvent extends BasicEvent<String> {
|
||||
public class DataProcessEvent extends BasicEvent<String> {
|
||||
|
||||
/**
|
||||
* 构造函数,向IoTDB插入数据创建事件
|
||||
* 构造函数,数据处理创建事件
|
||||
*
|
||||
* @param messsge 消息
|
||||
*/
|
||||
public IoTDBInsertDataEvent(Object source, String messsge) {
|
||||
public DataProcessEvent(Object source, String messsge) {
|
||||
super(source, messsge);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue