2 * Copyright © 2015 Red Hat, 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.ovsdb.lib.impl;
10 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
11 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
12 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
13 import org.opendaylight.ovsdb.lib.ConfigActivator;
14 import org.opendaylight.ovsdb.lib.OvsdbConnection;
15 import org.osgi.framework.BundleContext;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 public class LibraryProvider implements BindingAwareProvider, AutoCloseable {
21 private static final Logger LOG = LoggerFactory.getLogger(LibraryProvider.class);
22 private final BundleContext bundleContext;
23 private DataBroker dataBroker;
24 private ConfigActivator activator;
26 public LibraryProvider(BundleContext bundleContext) {
27 LOG.info("LibraryProvider: bundleContext: {}", bundleContext);
28 this.bundleContext = bundleContext;
32 public void onSessionInitiated(ProviderContext providerContext) {
33 LOG.info("LibraryProvider Session Initiated");
34 dataBroker = providerContext.getSALService(DataBroker.class);
35 LOG.info("LibraryProvider: onSessionInitiated dataBroker: {}", dataBroker);
36 this.activator = new ConfigActivator(providerContext);
38 activator.start(bundleContext);
39 } catch (Exception e) {
40 LOG.warn("Failed to start LibraryProvider: ", e);
45 public void close() throws Exception {
46 LOG.info("LibraryProvider Closed");
47 if (activator != null) {
48 activator.stop(bundleContext);