Converted UiSharedTopologyModel to be a @Service.
Change-Id: Idc8df1b9c0a52db01ac545567dacc0e1c770f84a
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/UiTopoSession.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/UiTopoSession.java
index fbc7fa42..70698ec 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/UiTopoSession.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/UiTopoSession.java
@@ -18,6 +18,8 @@
import org.onosproject.ui.UiTopoLayoutService;
import org.onosproject.ui.impl.UiWebSocket;
+import org.onosproject.ui.impl.topo.model.UiModelEvent;
+import org.onosproject.ui.impl.topo.model.UiModelListener;
import org.onosproject.ui.impl.topo.model.UiSharedTopologyModel;
import org.onosproject.ui.model.topo.UiTopoLayout;
import org.slf4j.Logger;
@@ -26,14 +28,14 @@
/**
* Coordinates with the {@link UiTopoLayoutService} to access
* {@link UiTopoLayout}s, and with the {@link UiSharedTopologyModel} which
- * maintains a local model of the network entities,
- * tailored specifically for displaying on the UI.
+ * maintains a local model of the network entities, tailored specifically
+ * for displaying on the UI.
* <p>
* Note that an instance of this class will be created for each
* {@link UiWebSocket} connection, and will contain
* the state of how the topology is laid out for the logged-in user.
*/
-public class UiTopoSession {
+public class UiTopoSession implements UiModelListener {
private final Logger log = LoggerFactory.getLogger(getClass());
private final UiWebSocket webSocket;
@@ -50,11 +52,12 @@
* Creates a new topology session for the specified web socket connection.
*
* @param webSocket web socket
+ * @param model share topology model
*/
- public UiTopoSession(UiWebSocket webSocket) {
+ public UiTopoSession(UiWebSocket webSocket, UiSharedTopologyModel model) {
this.webSocket = webSocket;
this.username = webSocket.userName();
- this.sharedModel = UiSharedTopologyModel.instance();
+ this.sharedModel = model;
}
/**
@@ -87,4 +90,10 @@
public String toString() {
return String.format("{UiTopoSession for user <%s>}", username);
}
+
+ @Override
+ public void event(UiModelEvent event) {
+ log.info("Event received: {}", event);
+ // TODO: handle model events from the cache...
+ }
}