0a47edfb793b8a6b18fda994a450a8b8e9e22460
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginTestNodeConnectorNotification.java
1 /*
2  * Copyright (c) 2014, 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowplugin.test;
9
10 import java.util.ArrayList;
11 import java.util.List;
12 import org.opendaylight.mdsal.binding.api.NotificationService;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 public class OpenflowpluginTestNodeConnectorNotification {
22
23     private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestNodeConnectorNotification.class);
24
25     private final PortEventListener portEventListener = new PortEventListener();
26     private final NotificationService notificationService;
27
28     public OpenflowpluginTestNodeConnectorNotification(final NotificationService notificationService) {
29         this.notificationService = notificationService;
30     }
31
32     public void init() {
33         // For switch events
34         notificationService.registerNotificationListener(portEventListener);
35     }
36
37     private static final class PortEventListener implements OpendaylightInventoryListener {
38
39         List<NodeUpdated> nodeUpdated = new ArrayList<>();
40         List<NodeRemoved> nodeRemoved = new ArrayList<>();
41         List<NodeConnectorUpdated> nodeConnectorUpdated = new ArrayList<>();
42         List<NodeConnectorRemoved> nodeConnectorRemoved = new ArrayList<>();
43
44         @Override
45         @Deprecated
46         public void onNodeConnectorRemoved(final NodeConnectorRemoved notification) {
47             LOG.debug("NodeConnectorRemoved Notification");
48             LOG.debug("NodeConnectorRef {}", notification.getNodeConnectorRef());
49             nodeConnectorRemoved.add(notification);
50         }
51
52         @Override
53         @Deprecated
54         public void onNodeConnectorUpdated(final NodeConnectorUpdated notification) {
55             LOG.debug("NodeConnectorUpdated Notification");
56             LOG.debug("NodeConnectorRef {}", notification.getNodeConnectorRef());
57             nodeConnectorUpdated.add(notification);
58         }
59
60         @Override
61         @Deprecated
62         public void onNodeRemoved(final NodeRemoved notification) {
63             LOG.debug("NodeRemoved Notification");
64             LOG.debug("NodeRef {}", notification.getNodeRef());
65             nodeRemoved.add(notification);
66         }
67
68         @Override
69         @Deprecated
70         public void onNodeUpdated(final NodeUpdated notification) {
71             LOG.debug("NodeUpdated Notification");
72             LOG.debug("NodeRef {}", notification.getNodeRef());
73             nodeUpdated.add(notification);
74         }
75     }
76 }