feat:() 新增事件类型,事件监听接口,策略发送事件
parent
d02813f7e4
commit
4e1790a47c
|
@ -0,0 +1,24 @@
|
|||
package com.muyu.processing.basic;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
* @Author:杨鹏
|
||||
* @Package:com.muyu.processing.basic
|
||||
* @Project:car-cloud-server
|
||||
* @name:EventCustom
|
||||
* @Date:2024/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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.processing.basic;
|
||||
|
||||
import org.springframework.context.ApplicationListener;
|
||||
|
||||
/**
|
||||
* 事件监听接口
|
||||
* @Author:杨鹏
|
||||
* @Package:com.muyu.processing.basic
|
||||
* @Project:car-cloud-server
|
||||
* @name:EventListener
|
||||
* @Date:2024/9/29 22:29
|
||||
*/
|
||||
public interface EventListener extends ApplicationListener<EventCustom> {
|
||||
void onEvent(EventCustom event);
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.muyu.processing.basic;
|
||||
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
|
||||
/**
|
||||
* 策略发送事件
|
||||
* @Author:杨鹏
|
||||
* @Package:com.muyu.processing.basic
|
||||
* @Project:car-cloud-server
|
||||
* @name:EventPublisher
|
||||
* @Date:2024/9/29 22:31
|
||||
*/
|
||||
public class EventPublisher implements ApplicationEventPublisherAware {
|
||||
|
||||
private ApplicationEventPublisher publisher;
|
||||
|
||||
@Override
|
||||
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher){
|
||||
this.publisher = applicationEventPublisher;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue