cn.kduck.core.event.LocalEventBus Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kduck-core Show documentation
Show all versions of kduck-core Show documentation
The core of the K-Duck development framework encompasses all the featured components of the framework.
package cn.kduck.core.event;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
public class LocalEventBus implements EventPublisher{
@Autowired(required = false)
private List listenerList;
private EventTrigger eventTrigger = new EventTrigger();
public LocalEventBus(List listenerList){
this.listenerList = listenerList;
}
public void publish(Event event) {
if(listenerList == null){
return;
}
for (EventListener eventListener : listenerList) {
if(eventListener.eventCode().equals(event.getCode())
&& eventListener.eventType().equals(event.getType())){
eventTrigger.onEvent(event, eventListener);
}
}
}
}