Unit test for ovsdb.southbound.ovsdb.transact
[netvirt.git] / openstack / net-virt-sfc / impl / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / sfc / NetvirtSfcProvider.java
1 /*
2  * Copyright © 2015 Dell, 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
9 package org.opendaylight.ovsdb.openstack.netvirt.sfc;
10
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
13 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
14 import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.INetvirtSfcOF13Provider;
15 import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.NetvirtSfcOF13Provider;
16 import org.osgi.framework.BundleContext;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 public class NetvirtSfcProvider implements BindingAwareProvider, AutoCloseable {
21     private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcProvider.class);
22     private DataBroker dataBroker = null;
23     private BundleContext bundleContext = null;
24     private NetvirtSfcAclListener aclListener;
25
26     private NetvirtSfcClassifierListener classfierListener;
27     private INetvirtSfcOF13Provider provider;
28
29     public NetvirtSfcProvider(BundleContext bundleContext) {
30         LOG.info("NetvirtProvider: bundleContext: {}", bundleContext);
31         this.bundleContext = bundleContext;
32     }
33
34     @Override
35     public void onSessionInitiated(ProviderContext session) {
36         LOG.info("NetvirtSfcProvider Session Initiated");
37         dataBroker = session.getSALService(DataBroker.class);
38
39         provider = new NetvirtSfcOF13Provider(this.dataBroker);
40         aclListener = new NetvirtSfcAclListener(provider, this.dataBroker);
41         classfierListener = new NetvirtSfcClassifierListener(provider, this.dataBroker);
42     }
43
44     @Override
45     public void close() throws Exception {
46         LOG.info("NetvirtSfcProvider Closed");
47         aclListener.close();
48         classfierListener.close();
49     }
50 }