fc724ac6807603a10e20af9b60ad51f59983092e
[controller.git] / opendaylight / md-sal / topology-lldp-discovery / src / main / java / org / opendaylight / md / controller / topology / lldp / LLDPDiscoveryProvider.xtend
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.md.controller.topology.lldp
9
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.LoggerFactory
15
16 class LLDPDiscoveryProvider implements AutoCloseable {
17
18
19     static val LOG = LoggerFactory.getLogger(LLDPDiscoveryProvider);
20
21     @Property
22     DataProviderService dataService;        
23
24     @Property
25     NotificationProviderService notificationService;
26
27     val LLDPDiscoveryListener commiter = new LLDPDiscoveryListener(this);
28
29     Registration<NotificationListener> listenerRegistration
30
31     def void start() {
32         listenerRegistration = notificationService.registerNotificationListener(commiter);
33         LLDPLinkAger.instance.manager = this;
34         LOG.info("LLDPDiscoveryListener Started.");
35         
36     }   
37     
38     override close() {
39        LOG.info("LLDPDiscoveryListener stopped.");
40         listenerRegistration?.close();
41         LLDPLinkAger.instance.close();
42     }
43     
44 }
45
46