mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-11-29 18:48:13 +08:00
refactor: 修改公共触发监听
This commit is contained in:
parent
c7340cea0a
commit
fb01646f23
@ -1,19 +1,5 @@
|
||||
package io.metersphere.sdk.listener;
|
||||
|
||||
public class Event {
|
||||
private String message;
|
||||
private String module;
|
||||
public record Event(String module, String message) {
|
||||
|
||||
public Event(String module, String message) {
|
||||
this.module = module;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public String getModule() {
|
||||
return module;
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,12 @@ package io.metersphere.sdk.listener;
|
||||
|
||||
public interface EventSource {
|
||||
/**
|
||||
* @param listener
|
||||
* 注册监听
|
||||
*/
|
||||
void addListener(EventListener<Event> listener);
|
||||
|
||||
/**
|
||||
* @param module
|
||||
* @param message
|
||||
* 触发事件
|
||||
*/
|
||||
void fireEvent(String module, String message);
|
||||
|
||||
}
|
||||
|
@ -24,10 +24,11 @@ public class EventSourceTests {
|
||||
// 注册所有监听源
|
||||
LogUtils.info("初始化接口事件源");
|
||||
APIEventSource apiEventSource = CommonBeanFactory.getBean(APIEventSource.class);
|
||||
assert apiEventSource != null;
|
||||
apiEventSource.addListener(new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) {
|
||||
LogUtils.info("ExecEventListener: " + event.getModule() + ":" + event.getMessage());
|
||||
LogUtils.info("ExecEventListener: " + event.module() + ":" + event.message());
|
||||
}
|
||||
});
|
||||
// 触发事件
|
||||
|
@ -10,6 +10,6 @@ public class ExecEventListener implements EventListener<Event> {
|
||||
@Override
|
||||
public void onEvent(Event event) {
|
||||
// todo: 测试计划事件处理逻辑
|
||||
LogUtils.info("ExecEventListener: " + event.getModule() + ":" + event.getMessage());
|
||||
LogUtils.info("ExecEventListener: " + event.module() + ":" + event.message());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user