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 javax.annotation.PreDestroy;
14 import javax.inject.Inject;
15 import javax.inject.Singleton;
16 import org.opendaylight.mdsal.binding.api.NotificationService;
17 import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener;
18 //import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener.Component;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
23 import org.opendaylight.yangtools.concepts.Registration;
24 import org.osgi.service.component.annotations.Activate;
25 import org.osgi.service.component.annotations.Component;
26 import org.osgi.service.component.annotations.Deactivate;
27 import org.osgi.service.component.annotations.Reference;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
32 @Component(service = { })
33 public final class OpenflowpluginTestNodeConnectorNotification implements AutoCloseable {
34 private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestNodeConnectorNotification.class);
36 private final PortEventListener portEventListener = new PortEventListener();
37 private final Registration reg;
41 public OpenflowpluginTestNodeConnectorNotification(@Reference final NotificationService notificationService) {
43 reg = notificationService.registerCompositeListener(portEventListener.toListener());
53 private static final class PortEventListener {
54 List<NodeUpdated> nodeUpdated = new ArrayList<>();
55 List<NodeRemoved> nodeRemoved = new ArrayList<>();
56 List<NodeConnectorUpdated> nodeConnectorUpdated = new ArrayList<>();
57 List<NodeConnectorRemoved> nodeConnectorRemoved = new ArrayList<>();
59 CompositeListener toListener() {
60 return new CompositeListener(Set.of(
61 new CompositeListener.Component<>(NodeConnectorRemoved.class, notification -> {
62 LOG.debug("NodeConnectorRemoved Notification");
63 LOG.debug("NodeConnectorRef {}", notification.getNodeConnectorRef());
64 nodeConnectorRemoved.add(notification);
66 new CompositeListener.Component<>(NodeConnectorUpdated.class, notification -> {
67 LOG.debug("NodeConnectorUpdated Notification");
68 LOG.debug("NodeConnectorRef {}", notification.getNodeConnectorRef());
69 nodeConnectorUpdated.add(notification);
71 new CompositeListener.Component<>(NodeRemoved.class, notification -> {
72 LOG.debug("NodeRemoved Notification");
73 LOG.debug("NodeRef {}", notification.getNodeRef());
74 nodeRemoved.add(notification);
76 new CompositeListener.Component<>(NodeUpdated.class, notification -> {
77 LOG.debug("NodeUpdated Notification");
78 LOG.debug("NodeRef {}", notification.getNodeRef());
79 nodeUpdated.add(notification);