Fix findbugs violations in applications
[openflowplugin.git] / applications / topology-lldp-discovery / src / main / java / org / opendaylight / openflowplugin / applications / topology / lldp / LLDPActivator.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowplugin.applications.topology.lldp;
9
10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
11 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.config.rev160511.TopologyLldpDiscoveryConfig;
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;
17
18 public class LLDPActivator implements AutoCloseable {
19     private static final Logger LOG = LoggerFactory.getLogger(LLDPActivator.class);
20
21     private static String lldpSecureKey;
22
23     private final ListenerRegistration<NotificationListener> lldpNotificationRegistration;
24
25     @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
26     public LLDPActivator(NotificationProviderService notificationService, LLDPDiscoveryListener lldpDiscoveryListener,
27                          TopologyLldpDiscoveryConfig topologyLldpDiscoveryConfig) {
28         lldpSecureKey = topologyLldpDiscoveryConfig.getLldpSecureKey();
29
30         LOG.info("Starting LLDPActivator with lldpSecureKey: {}", lldpSecureKey);
31
32         lldpNotificationRegistration = notificationService.registerNotificationListener(lldpDiscoveryListener);
33
34         LOG.info("LLDPDiscoveryListener started.");
35     }
36
37     @Override
38     public void close() {
39         lldpNotificationRegistration.close();
40
41         LOG.info("LLDPDiscoveryListener stopped.");
42     }
43
44     public static String getLldpSecureKey() {
45         return lldpSecureKey;
46     }
47 }