2 * Copyright (c) 2014 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 * Contributor: gaurav.bhagwani@ericsson.com
10 package org.opendaylight.openflowplugin.test;
12 import java.util.ArrayList;
13 import java.util.List;
15 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
16 import org.opendaylight.controller.sal.binding.api.NotificationService;
17 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener;
23 import org.opendaylight.yangtools.concepts.Registration;
24 import org.osgi.framework.BundleContext;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
28 public class OpenflowpluginTestNodeConnectorNotification {
30 private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
32 private DataBrokerService dataBrokerService;
33 private ProviderContext pc;
34 private final BundleContext ctx;
35 private final PortEventListener portEventListener = new PortEventListener();
36 private static NotificationService notificationService;
37 private Registration listenerReg;
39 public OpenflowpluginTestNodeConnectorNotification(BundleContext ctx) {
43 public void onSessionInitiated(ProviderContext session) {
45 notificationService = session.getSALService(NotificationService.class);
47 listenerReg = notificationService.registerNotificationListener(portEventListener);
48 dataBrokerService = session.getSALService(DataBrokerService.class);
51 final class PortEventListener implements OpendaylightInventoryListener {
53 List<NodeUpdated> nodeUpdated = new ArrayList<>();
54 List<NodeRemoved> nodeRemoved = new ArrayList<>();
55 List<NodeConnectorUpdated> nodeConnectorUpdated = new ArrayList<>();
56 List<NodeConnectorRemoved> nodeConnectorRemoved = new ArrayList<>();
59 public void onNodeConnectorRemoved(NodeConnectorRemoved notification) {
60 LOG.debug("NodeConnectorRemoved Notification ...................");
61 LOG.debug("NodeConnectorRef " + notification.getNodeConnectorRef());
62 LOG.debug("----------------------------------------------------------------------");
63 nodeConnectorRemoved.add(notification);
67 public void onNodeConnectorUpdated(NodeConnectorUpdated notification) {
68 LOG.debug("NodeConnectorUpdated Notification...................");
69 LOG.debug("NodeConnectorRef " + notification.getNodeConnectorRef());
70 LOG.debug("----------------------------------------------------------------------");
71 nodeConnectorUpdated.add(notification);
75 public void onNodeRemoved(NodeRemoved notification) {
76 LOG.debug("NodeRemoved Notification ...................");
77 LOG.debug("NodeRef " + notification.getNodeRef());
78 LOG.debug("----------------------------------------------------------------------");
79 nodeRemoved.add(notification);
83 public void onNodeUpdated(NodeUpdated notification) {
84 LOG.debug("NodeUpdated Notification ...................");
85 LOG.debug("NodeRef " + notification.getNodeRef());
86 LOG.debug("----------------------------------------------------------------------");
87 nodeUpdated.add(notification);