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.apache.aries.blueprint.annotation.service.Reference;
15 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.config.rev160511.TopologyLldpDiscoveryConfig;
17 import org.opendaylight.yangtools.concepts.ListenerRegistration;
18 import org.opendaylight.yangtools.yang.binding.NotificationListener;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
23 public class LLDPActivator implements AutoCloseable {
24 private static final Logger LOG = LoggerFactory.getLogger(LLDPActivator.class);
26 private static String lldpSecureKey;
28 private final ListenerRegistration<NotificationListener> lldpNotificationRegistration;
30 @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
32 public LLDPActivator(@Reference NotificationProviderService notificationService,
33 LLDPDiscoveryListener lldpDiscoveryListener,
34 TopologyLldpDiscoveryConfig topologyLldpDiscoveryConfig) {
35 lldpSecureKey = topologyLldpDiscoveryConfig.getLldpSecureKey();
37 LOG.info("Starting LLDPActivator with lldpSecureKey: {}", lldpSecureKey);
39 lldpNotificationRegistration = notificationService.registerNotificationListener(lldpDiscoveryListener);
41 LOG.info("LLDPDiscoveryListener started.");
47 lldpNotificationRegistration.close();
49 LOG.info("LLDPDiscoveryListener stopped.");
52 public static String getLldpSecureKey() {