Update to MD-SAL APIs
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / sal / dom / broker / NotificationModule.java
index 9a002ec467734155451de8d272b1a740053153ab..8c272e5a4c8a957b64bcf2d6b139d7e10c8ed8c3 100644 (file)
@@ -20,9 +20,10 @@ import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
 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;
@@ -40,8 +41,8 @@ public class NotificationModule implements BrokerModule {
             .create();
 
     private static final Set<Class<? extends BrokerService>> PROVIDED_SERVICE_TYPE = ImmutableSet
-            .of((Class<? extends BrokerService>) NotificationService.class,
-                    NotificationProviderService.class);
+            .<Class<? extends BrokerService>>of(NotificationService.class,
+                    NotificationPublishService.class);
 
     private static final Set<Class<? extends ConsumerFunctionality>> SUPPORTED_CONSUMER_FUNCTIONALITY = ImmutableSet
             .of((Class<? extends ConsumerFunctionality>) NotificationListener.class,
@@ -63,10 +64,10 @@ public class NotificationModule implements BrokerModule {
     @Override
     public <T extends BrokerService> T getServiceForSession(Class<T> 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)) {
 
@@ -105,7 +106,7 @@ public class NotificationModule implements BrokerModule {
         return new NotificationConsumerSessionImpl();
     }
 
-    private NotificationProviderService newNotificationProviderService(
+    private NotificationPublishService newNotificationPublishService(
             ConsumerSession session) {
         return new NotificationProviderSessionImpl();
     }
@@ -117,8 +118,8 @@ public class NotificationModule implements BrokerModule {
                 .create();
         private boolean closed = false;
 
-        @Override
-        public void addNotificationListener(QName notification,
+    
+        public Registration<NotificationListener> addNotificationListener(QName notification,
                 NotificationListener listener) {
             checkSessionState();
             if (notification == null) {
@@ -132,9 +133,9 @@ public class NotificationModule implements BrokerModule {
             consumerListeners.put(notification, listener);
             listeners.put(notification, listener);
             log.info("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<QName, Collection<NotificationListener>> toRemove = consumerListeners
@@ -168,7 +168,7 @@ public class NotificationModule implements BrokerModule {
 
     private class NotificationProviderSessionImpl extends
             NotificationConsumerSessionImpl implements
-            NotificationProviderService {
+            NotificationPublishService {
 
         @Override
         public void sendNotification(CompositeNode notification) {
@@ -178,6 +178,11 @@ public class NotificationModule implements BrokerModule {
                         "Notification must not be null.");
             NotificationModule.this.sendNotification(notification);
         }
+
+        @Override
+        public void publish(CompositeNode notification) {
+            sendNotification(notification);
+        }
     }
 
     @Override