Initial code to handle changes to DS
[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
16 public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable {
17
18     private static final Logger LOG = LoggerFactory.getLogger(InterfacemgrProvider.class);
19     
20     private InterfaceManager interfaceManager;
21
22     @Override
23     public void onSessionInitiated(ProviderContext session) {
24         LOG.info("InterfacemgrProvider Session Initiated");
25         try {
26             final  DataBroker dataBroker = session.getSALService(DataBroker.class);
27             interfaceManager = new InterfaceManager(dataBroker);
28         } catch (Exception e) {
29             LOG.error("Error initializing services", e);
30         }
31     }
32
33     @Override
34     public void close() throws Exception {
35         LOG.info("InterfacemgrProvider Closed");
36         interfaceManager.close();
37     }
38
39 }