feat:() 新增事件类型,事件监听接口,策略发送事件

dev.processing
晨哀 2024-10-04 10:24:15 +08:00
parent d02813f7e4
commit 4e1790a47c
3 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,24 @@
package com.muyu.processing.basic;
import cn.hutool.json.JSONObject;
import org.springframework.context.ApplicationEvent;
/**
*
* @Author
* @Packagecom.muyu.processing.basic
* @Projectcar-cloud-server
* @nameEventCustom
* @Date2024/9/29 21:18
*/
public class EventCustom extends ApplicationEvent{
private JSONObject data;
public EventCustom(Object source, JSONObject data) {
super(source);
this.data = data;
}
public JSONObject getData(){
return data;
}
}

View File

@ -0,0 +1,16 @@
package com.muyu.processing.basic;
import org.springframework.context.ApplicationListener;
/**
*
* @Author
* @Packagecom.muyu.processing.basic
* @Projectcar-cloud-server
* @nameEventListener
* @Date2024/9/29 22:29
*/
public interface EventListener extends ApplicationListener<EventCustom> {
void onEvent(EventCustom event);
}

View File

@ -0,0 +1,23 @@
package com.muyu.processing.basic;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
/**
*
* @Author
* @Packagecom.muyu.processing.basic
* @Projectcar-cloud-server
* @nameEventPublisher
* @Date2024/9/29 22:31
*/
public class EventPublisher implements ApplicationEventPublisherAware {
private ApplicationEventPublisher publisher;
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher){
this.publisher = applicationEventPublisher;
}
}