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 java.net.InetAddress;
11 import java.util.Collection;
13 import javax.net.ssl.SSLContext;
15 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
16 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
17 import org.opendaylight.ovsdb.lib.OvsdbClient;
18 import org.opendaylight.ovsdb.lib.OvsdbConnection;
19 import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
20 import org.osgi.framework.BundleContext;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 public class LibraryProvider implements BindingAwareProvider, AutoCloseable, OvsdbConnection {
26 private static final Logger LOG = LoggerFactory.getLogger(LibraryProvider.class);
28 public LibraryProvider(BundleContext bundleContext) {
29 LOG.info("LibraryProvider: bundleContext: {}", bundleContext);
33 public void onSessionInitiated(ProviderContext providerContext) {
34 LOG.info("LibraryProvider Session Initiated");
38 public void close() throws Exception {
39 LOG.info("LibraryProvider Closed");
43 public OvsdbClient connect(InetAddress address, int port) {
44 return OvsdbConnectionService.getService().connect(address, port);
48 public OvsdbClient connectWithSsl(
49 InetAddress address, int port, SSLContext sslContext) {
50 return OvsdbConnectionService.getService().connectWithSsl(address, port, sslContext);
54 public void disconnect(OvsdbClient client) {
55 OvsdbConnectionService.getService().disconnect(client);
59 public boolean startOvsdbManager(int ovsdbListenPort) {
60 return OvsdbConnectionService.getService().startOvsdbManager(ovsdbListenPort);
64 public boolean startOvsdbManagerWithSsl(int ovsdbListenPort, SSLContext sslContext) {
65 return OvsdbConnectionService.getService().startOvsdbManagerWithSsl(ovsdbListenPort, sslContext);
69 public void registerConnectionListener(OvsdbConnectionListener listener) {
70 OvsdbConnectionService.getService().registerConnectionListener(listener);
74 public void unregisterConnectionListener(OvsdbConnectionListener listener) {
75 OvsdbConnectionService.getService().unregisterConnectionListener(listener);
79 public Collection<OvsdbClient> getConnections() {
80 return OvsdbConnectionService.getService().getConnections();