Switch to MD-SAL APIs
[openflowplugin.git] / applications / notification-supplier / src / main / java / org / opendaylight / openflowplugin / applications / notification / supplier / impl / item / stat / AbstractNotificationSupplierForItemStat.java
index 49fdf4744d62e84fbe4286efd1c9cfc34cedb550..c2fa646e29de08b20d9d7c3e29b03d755f699cf5 100644 (file)
@@ -5,18 +5,14 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
 
 import com.google.common.base.Preconditions;
-
 import java.util.Collection;
-import java.util.Map.Entry;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataObjectModification;
+import org.opendaylight.mdsal.binding.api.DataTreeModification;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
 import org.opendaylight.openflowplugin.applications.notification.supplier.NotificationSupplierForItemStat;
 import org.opendaylight.openflowplugin.applications.notification.supplier.impl.AbstractNotificationSupplierBase;
 import org.opendaylight.yangtools.yang.binding.DataObject;
@@ -25,27 +21,25 @@ import org.opendaylight.yangtools.yang.binding.Notification;
 
 /**
  * Class is package protected abstract implementation for all Old Statistics
- * Notification Suppliers
+ * Notification Suppliers.
  *
  * @param <O> - Statistics {@link DataObject}
  * @param <N> - Statistics Notification
  */
-abstract class AbstractNotificationSupplierForItemStat<O extends DataObject,
-                                                N extends Notification>
-                    extends AbstractNotificationSupplierBase<O>
-                    implements NotificationSupplierForItemStat<O, N> {
+public abstract class AbstractNotificationSupplierForItemStat<O extends DataObject, N extends Notification> extends
+        AbstractNotificationSupplierBase<O> implements NotificationSupplierForItemStat<O, N> {
 
-    private final NotificationProviderService notifProviderService;
+    private final NotificationPublishService notifProviderService;
 
     /**
-     * Default constructor for all Statistic Notification Supplier implementation
+     * Default constructor for all Statistic Notification Supplier implementation.
      *
      * @param notifProviderService - notification publisher
-     * @param db - DataBroker for DataChangeEvent registration
-     * @param clazz - Statistics Notification Class
+     * @param db                   - DataBroker for DataTreeChangeListener registration
+     * @param clazz                - Statistics Notification Class
      */
-    public AbstractNotificationSupplierForItemStat(final NotificationProviderService notifProviderService,
-            final DataBroker db, final Class<O> clazz) {
+    public AbstractNotificationSupplierForItemStat(final NotificationPublishService notifProviderService,
+                                                   final DataBroker db, final Class<O> clazz) {
         super(db, clazz);
         this.notifProviderService = Preconditions.checkNotNull(notifProviderService);
     }
@@ -79,22 +73,23 @@ abstract class AbstractNotificationSupplierForItemStat<O extends DataObject,
     }
 
 
-    public void add(InstanceIdentifier<O> identifier , O add ){
+    public void add(InstanceIdentifier<O> identifier, O add) {
         final N notif = createNotification(add, identifier);
         if (notif != null) {
-            notifProviderService.publish(notif);
+            try {
+                notifProviderService.putNotification(notif);
+            } catch (InterruptedException e) {
+                throw new IllegalStateException("Interrupted while publishing " + notif, e);
+            }
         }
     }
 
-
-    public void remove(InstanceIdentifier<O> identifier , O del){
+    public void remove(InstanceIdentifier<O> identifier, O del) {
         //EMPTY NO-OP
     }
 
-
-    public void update(InstanceIdentifier<O> identifier , O before, O after){
+    public void update(InstanceIdentifier<O> identifier, O before, O after) {
         //EMPTY NO-OP
     }
-
 }