event-publisher-library/src/main/java/org/gcube/event/publisher/AbstractEventPublisher.java

36 lines
848 B
Java
Raw Normal View History

2020-06-18 12:55:34 +02:00
package org.gcube.event.publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class AbstractEventPublisher implements EventPublisher {
protected static final Logger logger = LoggerFactory.getLogger(AbstractEventPublisher.class);
private EventSender eventSender;
public AbstractEventPublisher() {
this.eventSender = createEventSender();
}
@Override
public void publish(Event event) {
if (event != null) {
eventSender.send(event);
} else {
2020-06-29 16:58:16 +02:00
logger.warn("Cannot publish a null event");
2020-06-18 12:55:34 +02:00
}
}
protected abstract EventSender createEventSender();
public EventSender getEventSender() {
return eventSender;
}
public void setEventSender(EventSender eventSender) {
this.eventSender = eventSender;
}
}