2 * Copyright (c) 2014, 2015 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 package org.opendaylight.openflowplugin.test;
10 import java.util.ArrayList;
11 import java.util.List;
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
15 import org.opendaylight.controller.sal.binding.api.NotificationService;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener;
21 import org.opendaylight.yangtools.concepts.Registration;
22 import org.osgi.framework.BundleContext;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 public class OpenflowpluginTestNodeConnectorNotification {
28 private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestNodeConnectorNotification.class);
30 private DataBroker dataBroker;
31 private ProviderContext pc;
32 private final BundleContext ctx;
33 private final PortEventListener portEventListener = new PortEventListener();
34 private static NotificationService notificationService;
35 private Registration listenerReg;
37 public OpenflowpluginTestNodeConnectorNotification(BundleContext ctx) {
41 public void onSessionInitiated(ProviderContext session) {
43 notificationService = session.getSALService(NotificationService.class);
45 listenerReg = notificationService.registerNotificationListener(portEventListener);
46 dataBroker = session.getSALService(DataBroker.class);
49 final class PortEventListener implements OpendaylightInventoryListener {
51 List<NodeUpdated> nodeUpdated = new ArrayList<>();
52 List<NodeRemoved> nodeRemoved = new ArrayList<>();
53 List<NodeConnectorUpdated> nodeConnectorUpdated = new ArrayList<>();
54 List<NodeConnectorRemoved> nodeConnectorRemoved = new ArrayList<>();
57 public void onNodeConnectorRemoved(NodeConnectorRemoved notification) {
58 LOG.debug("NodeConnectorRemoved Notification ...................");
59 LOG.debug("NodeConnectorRef " + notification.getNodeConnectorRef());
60 LOG.debug("----------------------------------------------------------------------");
61 nodeConnectorRemoved.add(notification);
65 public void onNodeConnectorUpdated(NodeConnectorUpdated notification) {
66 LOG.debug("NodeConnectorUpdated Notification...................");
67 LOG.debug("NodeConnectorRef " + notification.getNodeConnectorRef());
68 LOG.debug("----------------------------------------------------------------------");
69 nodeConnectorUpdated.add(notification);
73 public void onNodeRemoved(NodeRemoved notification) {
74 LOG.debug("NodeRemoved Notification ...................");
75 LOG.debug("NodeRef " + notification.getNodeRef());
76 LOG.debug("----------------------------------------------------------------------");
77 nodeRemoved.add(notification);
81 public void onNodeUpdated(NodeUpdated notification) {
82 LOG.debug("NodeUpdated Notification ...................");
83 LOG.debug("NodeRef " + notification.getNodeRef());
84 LOG.debug("----------------------------------------------------------------------");
85 nodeUpdated.add(notification);