Merge "Fixed deserialization of IdentityRefs in Restconf URI."
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / implementation / src / main / java / org / opendaylight / controller / sal / connector / remoterpc / RoutingTableProvider.java
1 package org.opendaylight.controller.sal.connector.remoterpc;
2
3 import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
4 import org.osgi.framework.BundleContext;
5 import org.osgi.util.tracker.ServiceTracker;
6
7 import com.google.common.base.Optional;
8
9 public class RoutingTableProvider implements AutoCloseable {
10
11     @SuppressWarnings("rawtypes")
12     final ServiceTracker<RoutingTable,RoutingTable> tracker;
13     
14     
15     public RoutingTableProvider(BundleContext ctx) {
16         @SuppressWarnings("rawtypes")
17         ServiceTracker<RoutingTable, RoutingTable> rawTracker = new ServiceTracker<>(ctx, RoutingTable.class, null);
18         tracker = rawTracker;
19         tracker.open();
20     }
21     
22     public Optional<RoutingTable<String, String>> getRoutingTable() {
23         @SuppressWarnings("unchecked")
24         RoutingTable<String,String> tracked = tracker.getService();
25         return Optional.fromNullable(tracked);
26     }
27
28     @Override
29     public void close() throws Exception {
30         tracker.close();
31     }
32 }