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

net.n2oapp.framework.api.event.N2oEventBus Maven / Gradle / Ivy

There is a newer version: 7.28.2
Show newest version
package net.n2oapp.framework.api.event;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;

/**
 * Отправщик событий N2O
 */
public class N2oEventBus {
    private Logger logger = LoggerFactory.getLogger(N2oEventBus.class);
    private ApplicationEventPublisher publisher;

    public N2oEventBus(ApplicationEventPublisher publisher) {
        this.publisher = publisher;
    }

    /**
     * Отправить событие
     * @param e Событие
     * @param  Тип события
     */
    @SuppressWarnings("unchecked")
    public  void publish(final E e) {
        long i = 0;
        if (logger.isDebugEnabled()) {
            i = System.currentTimeMillis();
        }
        publisher.publishEvent(e);
        if (logger.isDebugEnabled()) {
            logger.debug("publishing event '{}' took {} ms", e.getClass().getSimpleName(), System.currentTimeMillis() - i);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy