Interfacemgr: Listener for NodeConnector events
[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     private IfmNodeConnectorListener ifmNcListener;
23
24     @Override
25     public void onSessionInitiated(ProviderContext session) {
26         LOG.info("InterfacemgrProvider Session Initiated");
27         try {
28             final  DataBroker dataBroker = session.getSALService(DataBroker.class);
29             interfaceManager = new InterfaceManager(dataBroker);
30             ifmNcListener = new IfmNodeConnectorListener(dataBroker, interfaceManager);
31         } catch (Exception e) {
32             LOG.error("Error initializing services", e);
33         }
34         //TODO: Make this debug
35         LOG.info("Interfacemgr services initiated");
36     }
37
38     @Override
39     public void close() throws Exception {
40         LOG.info("InterfacemgrProvider Closed");
41         interfaceManager.close();
42         ifmNcListener.close();
43     }
44
45     @Override
46     public void testApi() {
47         LOG.debug("Testing interface mgr api");
48     }
49 }