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 edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
11 import javax.annotation.PreDestroy;
12 import javax.inject.Inject;
13 import javax.inject.Singleton;
14 import org.opendaylight.mdsal.binding.api.NotificationService;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.config.rev160511.TopologyLldpDiscoveryConfig;
16 import org.opendaylight.yangtools.concepts.ListenerRegistration;
17 import org.opendaylight.yangtools.yang.binding.NotificationListener;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
22 public class LLDPActivator implements AutoCloseable {
23 private static final Logger LOG = LoggerFactory.getLogger(LLDPActivator.class);
25 private static String lldpSecureKey;
27 private final ListenerRegistration<NotificationListener> lldpNotificationRegistration;
29 @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
31 public LLDPActivator(NotificationService notificationService,
32 LLDPDiscoveryListener lldpDiscoveryListener,
33 TopologyLldpDiscoveryConfig topologyLldpDiscoveryConfig) {
34 lldpSecureKey = topologyLldpDiscoveryConfig.getLldpSecureKey();
36 LOG.info("Starting LLDPActivator with lldpSecureKey: {}", lldpSecureKey);
38 lldpNotificationRegistration = notificationService.registerNotificationListener(lldpDiscoveryListener);
40 LOG.info("LLDPDiscoveryListener started.");
46 lldpNotificationRegistration.close();
48 LOG.info("LLDPDiscoveryListener stopped.");
51 public static String getLldpSecureKey() {