Use config for southbound (take 2)
[ovsdb.git] / library / impl / src / main / java / org / opendaylight / ovsdb / lib / impl / LibraryProvider.java
1 /*
2  * Copyright © 2015 Red Hat, 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.ovsdb.lib.impl;
9
10 import java.net.InetAddress;
11 import java.util.Collection;
12
13 import javax.net.ssl.SSLContext;
14
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;
23
24 public class LibraryProvider implements BindingAwareProvider, AutoCloseable, OvsdbConnection {
25
26     private static final Logger LOG = LoggerFactory.getLogger(LibraryProvider.class);
27
28     public LibraryProvider(BundleContext bundleContext) {
29         LOG.info("LibraryProvider: bundleContext: {}", bundleContext);
30     }
31
32     @Override
33     public void onSessionInitiated(ProviderContext providerContext) {
34         LOG.info("LibraryProvider Session Initiated");
35     }
36
37     @Override
38     public void close() throws Exception {
39         LOG.info("LibraryProvider Closed");
40     }
41
42     @Override
43     public OvsdbClient connect(InetAddress address, int port) {
44         return OvsdbConnectionService.getService().connect(address, port);
45     }
46
47     @Override
48     public OvsdbClient connectWithSsl(
49             InetAddress address, int port, SSLContext sslContext) {
50         return OvsdbConnectionService.getService().connectWithSsl(address, port, sslContext);
51     }
52
53     @Override
54     public void disconnect(OvsdbClient client) {
55         OvsdbConnectionService.getService().disconnect(client);
56     }
57
58     @Override
59     public boolean startOvsdbManager(int ovsdbListenPort) {
60         return OvsdbConnectionService.getService().startOvsdbManager(ovsdbListenPort);
61     }
62
63     @Override
64     public boolean startOvsdbManagerWithSsl(int ovsdbListenPort, SSLContext sslContext) {
65         return OvsdbConnectionService.getService().startOvsdbManagerWithSsl(ovsdbListenPort, sslContext);
66     }
67
68     @Override
69     public void registerConnectionListener(OvsdbConnectionListener listener) {
70         OvsdbConnectionService.getService().registerConnectionListener(listener);
71     }
72
73     @Override
74     public void unregisterConnectionListener(OvsdbConnectionListener listener) {
75         OvsdbConnectionService.getService().unregisterConnectionListener(listener);
76     }
77
78     @Override
79     public Collection<OvsdbClient> getConnections() {
80         return OvsdbConnectionService.getService().getConnections();
81     }
82 }