Add blueprint wiring for the TopologyLldpDiscovery app
[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 org.opendaylight.controller.sal.binding.api.NotificationProviderService;
11 import org.opendaylight.yangtools.concepts.ListenerRegistration;
12 import org.opendaylight.yangtools.yang.binding.NotificationListener;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16 public class LLDPActivator implements AutoCloseable {
17     private static final Logger LOG = LoggerFactory.getLogger(LLDPActivator.class);
18
19     private static String lldpSecureKey;
20
21     private final ListenerRegistration<NotificationListener> lldpNotificationRegistration;
22
23     public LLDPActivator(NotificationProviderService notificationService, LLDPDiscoveryListener lldpDiscoveryListener,
24             String secureKey) {
25         lldpSecureKey = secureKey;
26
27         LOG.info("Starting LLDPActivator with lldpSecureKey: {}", lldpSecureKey);
28
29         lldpNotificationRegistration = notificationService.registerNotificationListener(lldpDiscoveryListener);
30
31         LOG.info("LLDPDiscoveryListener started.");
32     }
33
34     @Override
35     public void close() {
36         lldpNotificationRegistration.close();
37
38         LOG.info("LLDPDiscoveryListener stopped.");
39     }
40
41     public static String getLldpSecureKey() {
42         return lldpSecureKey;
43     }
44 }