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.md.controller.topology.manager;
10 import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
11 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
12 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
13 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
14 import org.opendaylight.yangtools.concepts.Registration;
15 import org.opendaylight.yangtools.yang.binding.NotificationListener;
16 import org.osgi.framework.BundleContext;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 public class FlowCapableTopologyProvider extends AbstractBindingAwareProvider implements AutoCloseable {
21 private final static Logger LOG = LoggerFactory.getLogger(FlowCapableTopologyProvider.class);
23 private DataProviderService dataService;
25 public DataProviderService getDataService() {
26 return this.dataService;
29 public void setDataService(final DataProviderService dataService) {
30 this.dataService = dataService;
33 private NotificationProviderService notificationService;
35 public NotificationProviderService getNotificationService() {
36 return this.notificationService;
39 public void setNotificationService(final NotificationProviderService notificationService) {
40 this.notificationService = notificationService;
43 private final FlowCapableTopologyExporter exporter = new FlowCapableTopologyExporter();
44 private Registration<NotificationListener> listenerRegistration;
49 FlowCapableTopologyProvider.LOG.info("FlowCapableTopologyProvider stopped.");
51 notificationService = null;
52 if (this.listenerRegistration != null) {
54 this.listenerRegistration.close();
55 } catch (Exception e) {
56 throw new IllegalStateException("Exception during close of listener registration.",e);
62 * Gets called on start of a bundle.
67 public void onSessionInitiated(final ProviderContext session) {
68 dataService = session.getSALService(DataProviderService.class);
69 notificationService = session.getSALService(NotificationProviderService.class);
70 this.exporter.setDataService(dataService);
71 this.exporter.start();
72 this.listenerRegistration = notificationService.registerNotificationListener(this.exporter);
77 * Gets called during stop bundle
80 * The execution context of the bundle being stopped.
83 public void stopImpl(final BundleContext context) {