2 * Copyright (c) 2013 Cisco Systems, Inc. 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.applications.topology.lldp;
10 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
11 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
12 import org.opendaylight.openflowplugin.applications.topology.lldp.utils.LLDPDiscoveryUtils;
13 import org.opendaylight.yangtools.concepts.ListenerRegistration;
14 import org.opendaylight.yangtools.yang.binding.NotificationListener;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 public class LLDPDiscoveryProvider implements AutoCloseable {
19 private static final Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryProvider.class);
20 private DataProviderService dataService;
21 private NotificationProviderService notificationService;
23 private ListenerRegistration<NotificationListener> listenerRegistration;
24 private LLDPLinkAger lldpLinkAger;
26 public DataProviderService getDataService() {
27 return this.dataService;
30 public void setDataService(final DataProviderService dataService) {
31 this.dataService = dataService;
34 public NotificationProviderService getNotificationService() {
35 return this.notificationService;
38 public void setNotificationService(final NotificationProviderService notificationService) {
39 this.notificationService = notificationService;
43 lldpLinkAger = new LLDPLinkAger(LLDPDiscoveryUtils.LLDP_INTERVAL, LLDPDiscoveryUtils.LLDP_EXPIRATION_TIME);
44 lldpLinkAger.setNotificationService(notificationService);
46 LLDPDiscoveryListener committer = new LLDPDiscoveryListener(notificationService);
47 committer.setLldpLinkAger(lldpLinkAger);
49 ListenerRegistration<NotificationListener> registerNotificationListener =
50 notificationService.registerNotificationListener(committer);
51 this.listenerRegistration = registerNotificationListener;
52 LOG.info("LLDPDiscoveryListener Started.");
57 LOG.info("LLDPDiscoveryListener stopped.");
58 if (this.listenerRegistration!=null) {
59 this.listenerRegistration.close();
62 } catch (Exception e) {