X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fdom%2Fbroker%2FNotificationModule.java;h=b298a02a633cda2760347417266bb4d06e48dbca;hp=9a002ec467734155451de8d272b1a740053153ab;hb=f9aae7377704eed8a43c9a984f585165042ce5f7;hpb=2887eded48bd70a9e332e98530f23304ce153bc7 diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/NotificationModule.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/NotificationModule.java index 9a002ec467..b298a02a63 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/NotificationModule.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/NotificationModule.java @@ -9,20 +9,20 @@ package org.opendaylight.controller.sal.dom.broker; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import org.opendaylight.controller.sal.core.api.BrokerService; import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; +import org.opendaylight.controller.sal.core.api.BrokerService; import org.opendaylight.controller.sal.core.api.Consumer.ConsumerFunctionality; import org.opendaylight.controller.sal.core.api.Provider.ProviderFunctionality; import org.opendaylight.controller.sal.core.api.notify.NotificationListener; -import org.opendaylight.controller.sal.core.api.notify.NotificationProviderService; +import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService; import org.opendaylight.controller.sal.core.api.notify.NotificationService; import org.opendaylight.controller.sal.core.spi.BrokerModule; +import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; import org.slf4j.Logger; @@ -36,12 +36,12 @@ public class NotificationModule implements BrokerModule { private static Logger log = LoggerFactory .getLogger(NotificationModule.class); - private Multimap listeners = HashMultimap + private final Multimap listeners = HashMultimap .create(); private static final Set> PROVIDED_SERVICE_TYPE = ImmutableSet - .of((Class) NotificationService.class, - NotificationProviderService.class); + .>of(NotificationService.class, + NotificationPublishService.class); private static final Set> SUPPORTED_CONSUMER_FUNCTIONALITY = ImmutableSet .of((Class) NotificationListener.class, @@ -63,10 +63,10 @@ public class NotificationModule implements BrokerModule { @Override public T getServiceForSession(Class service, ConsumerSession session) { - if (NotificationProviderService.class.equals(service) + if (NotificationPublishService.class.equals(service) && session instanceof ProviderSession) { @SuppressWarnings("unchecked") - T ret = (T) newNotificationProviderService(session); + T ret = (T) newNotificationPublishService(session); return ret; } else if (NotificationService.class.equals(service)) { @@ -82,7 +82,7 @@ public class NotificationModule implements BrokerModule { private void sendNotification(CompositeNode notification) { QName type = notification.getNodeType(); Collection toNotify = listeners.get(type); - log.info("Publishing notification " + type); + log.trace("Publishing notification " + type); if (toNotify == null) { // No listeners were registered - returns. @@ -105,7 +105,7 @@ public class NotificationModule implements BrokerModule { return new NotificationConsumerSessionImpl(); } - private NotificationProviderService newNotificationProviderService( + private NotificationPublishService newNotificationPublishService( ConsumerSession session) { return new NotificationProviderSessionImpl(); } @@ -113,12 +113,13 @@ public class NotificationModule implements BrokerModule { private class NotificationConsumerSessionImpl implements NotificationService { - private Multimap consumerListeners = HashMultimap + private final Multimap consumerListeners = HashMultimap .create(); private boolean closed = false; + @Override - public void addNotificationListener(QName notification, + public Registration addNotificationListener(QName notification, NotificationListener listener) { checkSessionState(); if (notification == null) { @@ -131,10 +132,10 @@ public class NotificationModule implements BrokerModule { consumerListeners.put(notification, listener); listeners.put(notification, listener); - log.info("Registered listener for notification: " + notification); + log.trace("Registered listener for notification: " + notification); + return null; // Return registration Object. } - @Override public void removeNotificationListener(QName notification, NotificationListener listener) { checkSessionState(); @@ -149,7 +150,6 @@ public class NotificationModule implements BrokerModule { listeners.remove(notification, listener); } - @Override public void closeSession() { closed = true; Map> toRemove = consumerListeners @@ -168,10 +168,10 @@ public class NotificationModule implements BrokerModule { private class NotificationProviderSessionImpl extends NotificationConsumerSessionImpl implements - NotificationProviderService { + NotificationPublishService { @Override - public void sendNotification(CompositeNode notification) { + public void publish(CompositeNode notification) { checkSessionState(); if (notification == null) throw new IllegalArgumentException(