* 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;
import com.google.common.base.Preconditions;
import java.util.Collection;
-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.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.NotificationSupplierForItemRoot;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
* Class is package protected abstract implementation for all Root Items
- * Notification Suppliers
+ * Notification Suppliers.
*
* @param <O> - data tree item Object
* @param <C> - Create notification
* @param <D> - Delete notification
*/
-abstract class AbstractNotificationSupplierForItemRoot<O extends DataObject,
- C extends Notification,
- D extends Notification>
- extends AbstractNotificationSupplierBase<O>
- implements NotificationSupplierForItemRoot<O, C, D> {
+public abstract class AbstractNotificationSupplierForItemRoot<O extends DataObject, C extends Notification, D extends
+ Notification> extends AbstractNotificationSupplierBase<O> implements NotificationSupplierForItemRoot<O, C, D> {
- private final NotificationProviderService notificationProviderService;
+ private final NotificationPublishService notificationProviderService;
/**
- * Default constructor for all Root Item Notification Supplier implementation
+ * Default constructor for all Root Item Notification Supplier implementation.
*
* @param notificationProviderService - notification publisher
- * @param db - DataBroker for DataTreeChangeListener registration
- * @param clazz - Statistics Notification Class
+ * @param db - DataBroker for DataTreeChangeListener registration
+ * @param clazz - Statistics Notification Class
*/
- public AbstractNotificationSupplierForItemRoot(final NotificationProviderService notificationProviderService,
- final DataBroker db,
- final Class<O> clazz) {
+ public AbstractNotificationSupplierForItemRoot(final NotificationPublishService notificationProviderService,
+ final DataBroker db, final Class<O> clazz) {
super(db, clazz);
this.notificationProviderService = Preconditions.checkNotNull(notificationProviderService);
}
}
- public void add(InstanceIdentifier<O> identifier , O add ){
-
- final C notif = createNotification(add, identifier);
- if (notif != null) {
- notificationProviderService.publish(notif);
- }
+ public void add(InstanceIdentifier<O> identifier, O add) {
+ putNotification(createNotification(add, identifier));
}
- public void remove(InstanceIdentifier<O> identifier , O del){
- final D notif = deleteNotification(identifier.firstIdentifierOf(clazz));
- if (notif != null) {
- notificationProviderService.publish(notif);
- }
+ public void remove(InstanceIdentifier<O> identifier, O del) {
+ putNotification(deleteNotification(identifier.firstIdentifierOf(clazz)));
}
- public void update(InstanceIdentifier<O> identifier , O before, O after){
+ public void update(InstanceIdentifier<O> identifier, O before, O after) {
//EMPTY NO-OP
}
+ private void putNotification(Notification notif) {
+ if (notif != null) {
+ try {
+ notificationProviderService.putNotification(notif);
+ } catch (InterruptedException e) {
+ throw new IllegalStateException("Interrupted while publishing " + notif, e);
+ }
+ }
+ }
}