ab30a083bf94dd5aa17d389603eb0dbdbbad47cc
[vpnservice.git] / interfacemgr / interfacemgr-impl / src / main / java / org / opendaylight / vpnservice / interfacemgr / InterfacemgrProvider.java
1 /*
2  * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.vpnservice.interfacemgr;
9
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.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15 import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
16
17 public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable, IInterfaceManager {
18
19     private static final Logger LOG = LoggerFactory.getLogger(InterfacemgrProvider.class);
20
21     private InterfaceManager interfaceManager;
22
23     @Override
24     public void onSessionInitiated(ProviderContext session) {
25         LOG.info("InterfacemgrProvider Session Initiated");
26         try {
27             final  DataBroker dataBroker = session.getSALService(DataBroker.class);
28             interfaceManager = new InterfaceManager(dataBroker);
29         } catch (Exception e) {
30             LOG.error("Error initializing services", e);
31         }
32     }
33
34     @Override
35     public void close() throws Exception {
36         LOG.info("InterfacemgrProvider Closed");
37         interfaceManager.close();
38     }
39
40     @Override
41     public void testApi() {
42         LOG.debug("Testing interface mgr api");
43     }
44 }