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 org.opendaylight.controller.sal.connector.api.RpcRouter;
12 import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
13 import org.opendaylight.controller.sal.connector.remoterpc.impl.RoutingTableImpl;
14 import org.osgi.framework.BundleContext;
15 import org.osgi.util.tracker.ServiceTracker;
17 import com.google.common.base.Optional;
19 public class RoutingTableProvider implements AutoCloseable {
21 @SuppressWarnings("rawtypes")
22 final ServiceTracker<RoutingTable,RoutingTable> tracker;
24 private RoutingTableImpl<?, ?> routingTableImpl = null;
26 //final private RouteChangeListener routeChangeListener;
29 public RoutingTableProvider(BundleContext ctx){//,RouteChangeListener rcl) {
30 @SuppressWarnings("rawtypes")
31 ServiceTracker<RoutingTable, RoutingTable> rawTracker = new ServiceTracker<>(ctx, RoutingTable.class, null);
35 //routeChangeListener = rcl;
38 public Optional<RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String>> getRoutingTable() {
39 @SuppressWarnings("unchecked")
40 RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> tracked = tracker.getService();
42 if(tracked instanceof RoutingTableImpl){
43 if(routingTableImpl != tracked){
44 routingTableImpl= (RoutingTableImpl<?, ?>)tracked;
45 //routingTableImpl.setRouteChangeListener(routeChangeListener);
49 return Optional.fromNullable(tracked);
53 public void close() throws Exception {