BUG-509: remove unused code
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / implementation / src / main / java / org / opendaylight / controller / sal / connector / remoterpc / RoutingTableProvider.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. 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
9 package org.opendaylight.controller.sal.connector.remoterpc;
10
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;
19
20 public class RoutingTableProvider implements AutoCloseable {
21
22     @SuppressWarnings("rawtypes")
23     final ServiceTracker<RoutingTable,RoutingTable> tracker;
24
25     private RoutingTableImpl routingTableImpl = null;
26
27     //final private RouteChangeListener routeChangeListener;
28     
29     
30     public RoutingTableProvider(BundleContext ctx){//,RouteChangeListener rcl) {
31         @SuppressWarnings("rawtypes")
32         ServiceTracker<RoutingTable, RoutingTable> rawTracker = new ServiceTracker<>(ctx, RoutingTable.class, null);
33         tracker = rawTracker;
34         tracker.open();
35
36         //routeChangeListener = rcl;
37     }
38     
39     public Optional<RoutingTable<RpcRouter.RouteIdentifier, String>> getRoutingTable() {
40         @SuppressWarnings("unchecked")
41         RoutingTable<RpcRouter.RouteIdentifier,String> tracked = tracker.getService();
42
43         if(tracked instanceof RoutingTableImpl){
44             if(routingTableImpl != tracked){
45              routingTableImpl= (RoutingTableImpl)tracked;
46              //routingTableImpl.setRouteChangeListener(routeChangeListener);
47             }
48         }
49
50         return Optional.fromNullable(tracked);
51     }
52
53     @Override
54     public void close() throws Exception {
55         tracker.close();
56     }
57 }