Fixed wrong format in ShardedDOMDataTree
[mdsal.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / config / yang / md / sal / binding / impl / NotificationBrokerImplModule.java
index 154000038da517990a43423cc632cd691c8b311b..ec4bc76f554f3a8fb7bcff890fc1c047743b7057 100644 (file)
@@ -10,8 +10,13 @@ package org.opendaylight.controller.config.yang.md.sal.binding.impl;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
 import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter;
+import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceWithInterestListeners;
+import org.opendaylight.controller.md.sal.binding.compat.HydrogenNotificationBrokerImpl;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationPublishServiceAdapter;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationServiceAdapter;
+import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService;
+import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListenerRegistry;
 import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
-import org.opendaylight.controller.sal.binding.impl.NotificationBrokerImpl;
 
 /**
 *
@@ -43,7 +48,7 @@ public final class NotificationBrokerImplModule extends
         final NotificationService notificationService = getNotificationAdapterDependency();
 
         if(notificationPublishService != null & notificationService != null) {
-            return new HeliumNotificationProviderServiceAdapter(notificationPublishService, notificationService);
+            return createHeliumAdapter(notificationPublishService,notificationService);
         }
 
         /*
@@ -52,7 +57,25 @@ public final class NotificationBrokerImplModule extends
          *  we will have adapter implementation which will honor Helium
          *  threading model for notifications.
          */
+        return new HydrogenNotificationBrokerImpl(SingletonHolder.getDefaultNotificationExecutor());
+    }
 
-        return new NotificationBrokerImpl(SingletonHolder.getDefaultNotificationExecutor());
+    private static AutoCloseable createHeliumAdapter(final NotificationPublishService publishService,
+            final NotificationService listenService) {
+        if (listenService instanceof BindingDOMNotificationServiceAdapter
+                && publishService instanceof BindingDOMNotificationPublishServiceAdapter) {
+            final BindingDOMNotificationPublishServiceAdapter castedPublish =
+                    (BindingDOMNotificationPublishServiceAdapter) publishService;
+            final BindingDOMNotificationServiceAdapter castedListen =
+                    (BindingDOMNotificationServiceAdapter) listenService;
+            final DOMNotificationPublishService domPublishService = castedPublish.getDomPublishService();
+            if (domPublishService instanceof DOMNotificationSubscriptionListenerRegistry) {
+                final DOMNotificationSubscriptionListenerRegistry subsRegistry =
+                        (DOMNotificationSubscriptionListenerRegistry) domPublishService;
+                return new HeliumNotificationProviderServiceWithInterestListeners(castedPublish, castedListen,
+                        subsRegistry);
+            }
+        }
+        return new HeliumNotificationProviderServiceAdapter(publishService, listenService);
     }
 }