Merge "Use Java 7 new method getLoopbackAddress in ClusterManager"
[controller.git] / opendaylight / md-sal / topology-manager / src / main / java / org / opendaylight / md / controller / topology / manager / FlowCapableTopologyProvider.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.manager
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 import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider
16 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
17
18 class FlowCapableTopologyProvider extends AbstractBindingAwareProvider implements AutoCloseable {
19
20
21
22     static val LOG = LoggerFactory.getLogger(FlowCapableTopologyProvider);
23
24     @Property
25     DataProviderService dataService;        
26
27     @Property
28     NotificationProviderService notificationService;
29
30     val FlowCapableTopologyExporter exporter = new FlowCapableTopologyExporter();
31
32     Registration<NotificationListener> listenerRegistration
33     
34     override close() {
35        LOG.info("FlowCapableTopologyProvider stopped.");
36         listenerRegistration?.close();
37     }
38     
39     override onSessionInitiated(ProviderContext session) {
40         dataService = session.getSALService(DataProviderService)
41         notificationService = session.getSALService(NotificationProviderService)
42         exporter.setDataService(dataService);
43         exporter.start();
44         listenerRegistration = notificationService.registerNotificationListener(exporter);
45     }
46     
47 }
48
49