2 * Copyright (c) 2013 Cisco Systems, Inc. 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
9 package org.opendaylight.controller.sal.connector.remoterpc;
11 import com.google.common.base.Optional;
12 import org.opendaylight.controller.sal.connector.api.RpcRouter;
13 import org.opendaylight.controller.sal.connector.remoterpc.api.RouteChangeListener;
14 import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
15 import org.opendaylight.controller.sal.connector.remoterpc.dto.RouteIdentifierImpl;
16 import org.opendaylight.controller.sal.connector.remoterpc.impl.RoutingTableImpl;
17 import org.osgi.framework.BundleContext;
18 import org.osgi.util.tracker.ServiceTracker;
20 public class RoutingTableProvider implements AutoCloseable {
22 @SuppressWarnings("rawtypes")
23 final ServiceTracker<RoutingTable,RoutingTable> tracker;
25 private RoutingTableImpl routingTableImpl = null;
27 //final private RouteChangeListener routeChangeListener;
30 public RoutingTableProvider(BundleContext ctx){//,RouteChangeListener rcl) {
31 @SuppressWarnings("rawtypes")
32 ServiceTracker<RoutingTable, RoutingTable> rawTracker = new ServiceTracker<>(ctx, RoutingTable.class, null);
36 //routeChangeListener = rcl;
39 public Optional<RoutingTable<RpcRouter.RouteIdentifier, String>> getRoutingTable() {
40 @SuppressWarnings("unchecked")
41 RoutingTable<RpcRouter.RouteIdentifier,String> tracked = tracker.getService();
43 if(tracked instanceof RoutingTableImpl){
44 if(routingTableImpl != tracked){
45 routingTableImpl= (RoutingTableImpl)tracked;
46 //routingTableImpl.setRouteChangeListener(routeChangeListener);
50 return Optional.fromNullable(tracked);
54 public void close() throws Exception {