Merge "Integration build failure fix:"
[vpnservice.git] / vpnmanager / vpnmanager-impl / src / main / java / org / opendaylight / vpnservice / VpnserviceProvider.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;
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
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 public class VpnserviceProvider implements BindingAwareProvider,
18                                                        AutoCloseable {
19
20     private static final Logger LOG = LoggerFactory.getLogger(VpnserviceProvider.class);
21     private VpnInterfaceManager vpnInterfaceManager;
22     private VpnManager vpnManager;
23
24     @Override
25     public void onSessionInitiated(ProviderContext session) {
26         LOG.info("VpnserviceProvider Session Initiated");
27         try {
28             final  DataBroker dataBroker = session.getSALService(DataBroker.class);
29             vpnManager = new VpnManager(dataBroker);
30             vpnInterfaceManager = new VpnInterfaceManager(dataBroker);
31         } catch (Exception e) {
32             LOG.error("Error initializing services", e);
33         }
34     }
35
36     @Override
37     public void close() throws Exception {
38         vpnManager.close();
39         vpnInterfaceManager.close();
40     }
41 }