2 * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
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
8 package org.opendaylight.vpnservice.nexthopmgr;
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.opendaylight.vpnservice.nexthopmgr.NexthopManager;
14 import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
15 import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
16 import org.opendaylight.idmanager.IdManager;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 public class NexthopmgrProvider implements BindingAwareProvider, AutoCloseable {
23 private static final Logger LOG = LoggerFactory.getLogger(NexthopmgrProvider.class);
24 private VpnInterfaceChangeListener vpnIfListener;
25 private OdlInterfaceChangeListener odlIfListener;
26 private NexthopManager nhManager;
27 private IMdsalApiManager mdsalManager;
28 private IInterfaceManager interfaceManager;
29 private IdManager idManager;
32 public void onSessionInitiated(ProviderContext session) {
33 final DataBroker dbx = session.getSALService(DataBroker.class);
34 nhManager = new NexthopManager(dbx);
35 vpnIfListener = new VpnInterfaceChangeListener(dbx, nhManager);
36 odlIfListener = new OdlInterfaceChangeListener(dbx, nhManager, interfaceManager);
37 idManager = new IdManager(dbx);
38 nhManager.setMdsalManager(mdsalManager);
39 nhManager.setInterfaceManager(interfaceManager);
40 nhManager.setIdManager(idManager);
41 LOG.info("NexthopmgrProvider Session Initiated");
44 public void setMdsalManager(IMdsalApiManager mdsalManager) {
45 this.mdsalManager = mdsalManager;
48 public void setInterfaceManager(IInterfaceManager interfaceManager) {
49 this.interfaceManager = interfaceManager;
53 public void close() throws Exception {
54 vpnIfListener.close();
55 odlIfListener.close();
57 LOG.info("NexthopmgrProvider Closed");