All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.kduck.core.event.LocalEventBus Maven / Gradle / Ivy

Go to download

The core of the K-Duck development framework encompasses all the featured components of the framework.

There is a newer version: 2.0.0
Show newest version
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);
            }
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy