fix(): 修改事件处理基类架构

dev.entOperation
xinzirun 2024-10-07 09:01:19 +08:00
parent 8888b7430c
commit a0c2d916f2
2 changed files with 12 additions and 10 deletions

View File

@ -3,6 +3,8 @@ package com.muyu.event.process.basic;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
/** /**
* @Author: zi run * @Author: zi run
* @Date 2024/9/30 15:37 * @Date 2024/9/30 15:37
@ -12,17 +14,17 @@ import org.springframework.stereotype.Component;
public class BasicEventHandler<T> implements ApplicationListener<BasicEvent<T>> { 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) { public BasicEventHandler(List<BasicEventListener<T>> listeners) {
this.listener = listener; this.listeners = listeners;
} }
/** /**
@ -32,6 +34,6 @@ public class BasicEventHandler<T> implements ApplicationListener<BasicEvent<T>>
*/ */
@Override @Override
public void onApplicationEvent(BasicEvent<T> event) { public void onApplicationEvent(BasicEvent<T> event) {
listener.onEvent(event); listeners.forEach(l -> l.onEvent(event));
} }
} }

View File

@ -5,16 +5,16 @@ import com.muyu.event.process.basic.BasicEvent;
/** /**
* @Author: zi run * @Author: zi run
* @Date 2024/9/29 21:19 * @Date 2024/9/29 21:19
* @Description IoTDB * @Description
*/ */
public class IoTDBInsertDataEvent extends BasicEvent<String> { public class DataProcessEvent extends BasicEvent<String> {
/** /**
* IoTDB *
* *
* @param messsge * @param messsge
*/ */
public IoTDBInsertDataEvent(Object source, String messsge) { public DataProcessEvent(Object source, String messsge) {
super(source, messsge); super(source, messsge);
} }
} }