Fix for openflow devices not connecting to controller
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginTestNodeConnectorNotification.java
index 6eb0d32e20af20b3f456562315d287e44ff5827a..75f775a858eb19e6cf16f520347bb2a53abacce0 100644 (file)
@@ -1,54 +1,40 @@
-/**
- * Copyright (c) 2014 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+/*
+ * Copyright (c) 2014, 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor: gaurav.bhagwani@ericsson.com
  */
 package org.opendaylight.openflowplugin.test;
 
 import java.util.ArrayList;
 import java.util.List;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.NotificationService;
-import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+import org.opendaylight.mdsal.binding.api.NotificationService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener;
-import org.opendaylight.yangtools.concepts.Registration;
-import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class OpenflowpluginTestNodeConnectorNotification {
 
-    private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
+    private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestNodeConnectorNotification.class);
 
-    private DataBrokerService dataBrokerService;
-    private ProviderContext pc;
-    private final BundleContext ctx;
     private final PortEventListener portEventListener = new PortEventListener();
-    private static NotificationService notificationService;
-    private Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> listenerReg;
+    private final NotificationService notificationService;
 
-    public OpenflowpluginTestNodeConnectorNotification(BundleContext ctx) {
-        this.ctx = ctx;
+    public OpenflowpluginTestNodeConnectorNotification(NotificationService notificationService) {
+        this.notificationService = notificationService;
     }
 
-    public void onSessionInitiated(ProviderContext session) {
-        pc = session;
-        notificationService = session.getSALService(NotificationService.class);
+    public void init() {
         // For switch events
-        listenerReg = notificationService.registerNotificationListener(portEventListener);
-        dataBrokerService = session.getSALService(DataBrokerService.class);
+        notificationService.registerNotificationListener(portEventListener);
     }
 
-    final class PortEventListener implements OpendaylightInventoryListener {
+    private static final class PortEventListener implements OpendaylightInventoryListener {
 
         List<NodeUpdated> nodeUpdated = new ArrayList<>();
         List<NodeRemoved> nodeRemoved = new ArrayList<>();
@@ -57,33 +43,29 @@ public class OpenflowpluginTestNodeConnectorNotification {
 
         @Override
         public void onNodeConnectorRemoved(NodeConnectorRemoved notification) {
-            LOG.debug("NodeConnectorRemoved Notification ...................");
-            LOG.debug("NodeConnectorRef " + notification.getNodeConnectorRef());
-            LOG.debug("----------------------------------------------------------------------");
+            LOG.debug("NodeConnectorRemoved Notification");
+            LOG.debug("NodeConnectorRef {}", notification.getNodeConnectorRef());
             nodeConnectorRemoved.add(notification);
         }
 
         @Override
         public void onNodeConnectorUpdated(NodeConnectorUpdated notification) {
-            LOG.debug("NodeConnectorUpdated Notification...................");
-            LOG.debug("NodeConnectorRef " + notification.getNodeConnectorRef());
-            LOG.debug("----------------------------------------------------------------------");
+            LOG.debug("NodeConnectorUpdated Notification");
+            LOG.debug("NodeConnectorRef {}", notification.getNodeConnectorRef());
             nodeConnectorUpdated.add(notification);
         }
 
         @Override
         public void onNodeRemoved(NodeRemoved notification) {
-            LOG.debug("NodeRemoved Notification ...................");
-            LOG.debug("NodeRef " + notification.getNodeRef());
-            LOG.debug("----------------------------------------------------------------------");
+            LOG.debug("NodeRemoved Notification");
+            LOG.debug("NodeRef {}", notification.getNodeRef());
             nodeRemoved.add(notification);
         }
 
         @Override
         public void onNodeUpdated(NodeUpdated notification) {
-            LOG.debug("NodeUpdated Notification ...................");
-            LOG.debug("NodeRef " + notification.getNodeRef());
-            LOG.debug("----------------------------------------------------------------------");
+            LOG.debug("NodeUpdated Notification");
+            LOG.debug("NodeRef {}", notification.getNodeRef());
             nodeUpdated.add(notification);
         }
     }