Switch to MD-SAL APIs
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginTestTopologyNotification.java
index c4116a899e0bee21b68252f2aa1ab69ba23e8775..8760cb05a602bbe65e1a0be455c6e10417f035e6 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -7,19 +7,12 @@
  */
 package org.opendaylight.openflowplugin.test;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.NotificationService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.FlowTopologyDiscoveryListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscovered;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkOverutilized;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkUtilizationNormal;
-import org.opendaylight.yangtools.concepts.Registration;
-import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -27,32 +20,19 @@ public class OpenflowpluginTestTopologyNotification {
 
     private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestTopologyNotification.class);
 
-    private DataBroker dataBroker;
-    private ProviderContext pc;
-    private final BundleContext ctx;
     private final TopologyEventListener topologyEventListener = new TopologyEventListener();
-    private static NotificationService notificationService;
-    private Registration listenerReg;
+    private final NotificationService notificationService;
 
-    public OpenflowpluginTestTopologyNotification(BundleContext ctx) {
-        this.ctx = ctx;
+    public OpenflowpluginTestTopologyNotification(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(topologyEventListener);
-        dataBroker = session.getSALService(DataBroker.class);
+        notificationService.registerNotificationListener(topologyEventListener);
     }
 
-    final class TopologyEventListener implements FlowTopologyDiscoveryListener {
-
-        List<LinkDiscovered> linkdiscovered = new ArrayList<>();
-        List<LinkOverutilized> linkoverutilized = new ArrayList<>();
-        List<LinkRemoved> linkremoved = new ArrayList<>();
-        List<LinkUtilizationNormal> linkutilizationnormal = new ArrayList<>();
-
+    private static final class TopologyEventListener implements FlowTopologyDiscoveryListener {
         @Override
         public void onLinkDiscovered(LinkDiscovered notification) {
             LOG.debug("-------------------------------------------");