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.md.controller.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.yangtools.concepts.Registration;
13 import org.opendaylight.yangtools.yang.binding.NotificationListener;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
17 public class LLDPDiscoveryProvider implements AutoCloseable {
18 private final static Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryProvider.class);
19 private DataProviderService dataService;
20 private NotificationProviderService notificationService;
21 private final LLDPDiscoveryListener commiter = new LLDPDiscoveryListener(LLDPDiscoveryProvider.this);
22 private Registration<NotificationListener> listenerRegistration;
24 public DataProviderService getDataService() {
25 return this.dataService;
28 public void setDataService(final DataProviderService dataService) {
29 this.dataService = dataService;
32 public NotificationProviderService getNotificationService() {
33 return this.notificationService;
36 public void setNotificationService(final NotificationProviderService notificationService) {
37 this.notificationService = notificationService;
41 Registration<NotificationListener> registerNotificationListener = this.getNotificationService().registerNotificationListener(this.commiter);
42 this.listenerRegistration = registerNotificationListener;
43 LLDPLinkAger.getInstance().setManager(this);
44 LOG.info("LLDPDiscoveryListener Started.");
49 LOG.info("LLDPDiscoveryListener stopped.");
50 if (this.listenerRegistration!=null) {
51 this.listenerRegistration.close();
53 LLDPLinkAger.getInstance().close();
54 } catch (Exception e) {