Update the REST shortest-path computation backend to use the in-memory
topology, so the result is consistent with the shortest-path computation
as done by the rest of the system.
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
index debb5b1..cb1e678 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
@@ -74,6 +74,13 @@
     }
 
     /**
+     * Get the network topology.
+     *
+     * @return the network topology.
+     */
+    protected Topology getTopology() { return this.topology; }
+
+    /**
      * Run the thread.
      */
     @Override
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
index c974e9e..c22b916 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
@@ -714,6 +714,15 @@
     }
 
     /**
+     * Get the network topology.
+     *
+     * @return the network topology.
+     */
+    public Topology getTopology() {
+	return flowEventHandler.getTopology();
+    }
+
+    /**
      * Reconcile a flow.
      *
      * @param flowObj the flow that needs to be reconciliated.
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/IFlowService.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/IFlowService.java
index 1f8cd5b..8d362d1 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/IFlowService.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/IFlowService.java
@@ -4,6 +4,7 @@
 
 import net.floodlightcontroller.core.module.IFloodlightService;
 import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
+import net.onrc.onos.ofcontroller.topology.Topology;
 import net.onrc.onos.ofcontroller.util.CallerId;
 import net.onrc.onos.ofcontroller.util.DataPathEndpoints;
 import net.onrc.onos.ofcontroller.util.FlowId;
@@ -112,4 +113,11 @@
      * @return the added shortest-path flow on success, otherwise null.
      */
     FlowPath addAndMaintainShortestPathFlow(FlowPath flowPath);
+
+    /**
+     * Get the network topology.
+     *
+     * @return the network topology.
+     */
+    Topology getTopology();
 }
diff --git a/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java b/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java
index b340996..0d33b27 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java
@@ -1,5 +1,6 @@
 package net.onrc.onos.ofcontroller.topology.web;
 
+import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
 import net.onrc.onos.ofcontroller.topology.ITopologyNetService;
 import net.onrc.onos.ofcontroller.topology.TopologyManager;
 import net.onrc.onos.ofcontroller.util.DataPath;
@@ -18,11 +19,22 @@
 
     @Get("json")
     public DataPath retrieve() {
-        ITopologyNetService topologyNetService = new TopologyManager("");
+	// Get the services that are needed for the computation
+	ITopologyNetService topologyNetService =
+	    (ITopologyNetService)getContext().getAttributes().
+	    get(ITopologyNetService.class.getCanonicalName());
+	IFlowService flowService =
+	    (IFlowService)getContext().getAttributes().
+	    get(IFlowService.class.getCanonicalName());
+
 	if (topologyNetService == null) {
 	    log.debug("Topology Net Service not found");
 	    return null;
 	}
+	if (flowService == null) {
+	    log.debug("Flow Service not found");
+	    return null;
+	}
         
         String srcDpidStr = (String) getRequestAttributes().get("src-dpid");
         String srcPortStr = (String) getRequestAttributes().get("src-port");
@@ -37,7 +49,8 @@
 	Port dstPort = new Port(Short.parseShort(dstPortStr));
         
 	DataPath result =
-	    topologyNetService.getDatabaseShortestPath(
+	    topologyNetService.getTopologyShortestPath(
+		flowService.getTopology(),
 		new SwitchPort(srcDpid, srcPort),
 		new SwitchPort(dstDpid, dstPort));
 	if (result != null) {