Spring知识点回顾(07)事件发布和监听

时间:2023-03-09 17:57:54
Spring知识点回顾(07)事件发布和监听

Spring知识点回顾(07)事件发布和监听

1、DemoEvent extends ApplicationEvent {

public DemoEvent(Object source, String msg){

super(source);

this.msg = msg;

}

}

2、DemoListener implements ApplicationEventListener<DemoEvent> {

public void onApplicationEvent(DemoEvent event){

}

}

3、DemoPublisher {

public void publish(){

applicationContext.publishEvent( new DemoEvent(this, msg) );

}

}