Initial cut for UI topo model implementation.
- also moved existing classes down a package (to util).
Change-Id: Ie6c99ff10a3f4255795217a93f7028b5d8717d21
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java b/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java
index 29c4992..729aeeb 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java
@@ -63,7 +63,7 @@
import org.onosproject.ui.JsonUtils;
import org.onosproject.ui.UiConnection;
import org.onosproject.ui.UiMessageHandler;
-import org.onosproject.ui.impl.topo.ServicesBundle;
+import org.onosproject.ui.impl.topo.util.ServicesBundle;
import org.onosproject.ui.topo.PropertyPanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/TrafficMonitor.java b/web/gui/src/main/java/org/onosproject/ui/impl/TrafficMonitor.java
index 1de86de..164f1f4 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/TrafficMonitor.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/TrafficMonitor.java
@@ -37,12 +37,12 @@
import org.onosproject.net.intent.OpticalPathIntent;
import org.onosproject.net.intent.PathIntent;
import org.onosproject.net.statistic.Load;
-import org.onosproject.ui.impl.topo.IntentSelection;
-import org.onosproject.ui.impl.topo.ServicesBundle;
-import org.onosproject.ui.impl.topo.TopoIntentFilter;
-import org.onosproject.ui.impl.topo.TrafficLink;
-import org.onosproject.ui.impl.topo.TrafficLink.StatsType;
-import org.onosproject.ui.impl.topo.TrafficLinkMap;
+import org.onosproject.ui.impl.topo.util.IntentSelection;
+import org.onosproject.ui.impl.topo.util.ServicesBundle;
+import org.onosproject.ui.impl.topo.util.TopoIntentFilter;
+import org.onosproject.ui.impl.topo.util.TrafficLink;
+import org.onosproject.ui.impl.topo.util.TrafficLink.StatsType;
+import org.onosproject.ui.impl.topo.util.TrafficLinkMap;
import org.onosproject.ui.topo.DeviceHighlight;
import org.onosproject.ui.topo.Highlights;
import org.onosproject.ui.topo.Highlights.Amount;
@@ -66,7 +66,9 @@
import java.util.TimerTask;
import static org.onosproject.net.DefaultEdgeLink.createEdgeLink;
-import static org.onosproject.ui.impl.TrafficMonitor.Mode.*;
+import static org.onosproject.ui.impl.TrafficMonitor.Mode.IDLE;
+import static org.onosproject.ui.impl.TrafficMonitor.Mode.RELATED_INTENTS;
+import static org.onosproject.ui.impl.TrafficMonitor.Mode.SELECTED_INTENT;
/**
* Encapsulates the behavior of monitoring specific traffic patterns.
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TrafficLinkMap.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/TrafficLinkMap.java
deleted file mode 100644
index 081964f..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TrafficLinkMap.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.onosproject.ui.impl.topo;
-
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-import org.onosproject.ui.topo.BiLinkMap;
-
-/**
- * Collection of {@link TrafficLink}s.
- */
-public class TrafficLinkMap extends BiLinkMap<TrafficLink> {
-
- @Override
- public TrafficLink create(LinkKey key, Link link) {
- return new TrafficLink(key, link);
- }
-}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java
new file mode 100644
index 0000000..1e1374a
--- /dev/null
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.ui.impl.topo.model;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A lazily-initialized Singleton that creates and maintains the UI-model
+ * of the network topology.
+ */
+public final class UiSharedTopologyModel {
+
+ private static final Logger log =
+ LoggerFactory.getLogger(UiSharedTopologyModel.class);
+
+ private static UiSharedTopologyModel singleton = null;
+
+ private UiSharedTopologyModel() {
+ // TODO: set up core model listeners and build the state of the model
+ }
+
+ public void register(UiTopoLayout layout) {
+ log.info("Registering topology layout {}", layout);
+ // TODO: register the view
+ }
+
+ public void unregister(UiTopoLayout layout) {
+ log.info("Unregistering topology layout {}", layout);
+ // TODO: unregister the view
+ }
+
+ /**
+ * Returns a reference to the Singleton UI network topology model.
+ *
+ * @return the singleton topology model
+ */
+ public static synchronized UiSharedTopologyModel instance() {
+ if (singleton == null) {
+ log.info("Instantiating Singleton.");
+ singleton = new UiSharedTopologyModel();
+ }
+ return singleton;
+ }
+}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiTopoLayout.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiTopoLayout.java
new file mode 100644
index 0000000..b71b81e
--- /dev/null
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiTopoLayout.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.ui.impl.topo.model;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Base class for modeling the Topology View layout.
+ * <p>
+ * Note that an instance of this class will be created for each
+ * {@link org.onosproject.ui.impl.UiWebSocket} connection, and will contain
+ * the state of how the topology is laid out for the logged-in user.
+ */
+public class UiTopoLayout {
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ private final String username;
+ private final UiSharedTopologyModel sharedModel;
+
+ private boolean registered = false;
+
+ /**
+ * Creates a new topology layout.
+ */
+ public UiTopoLayout(String username) {
+ this.username = username;
+ this.sharedModel = UiSharedTopologyModel.instance();
+ }
+
+ /**
+ * Initializes the layout; registering with the shared model.
+ */
+ public void init() {
+ if (!registered) {
+ sharedModel.register(this);
+ registered = true;
+ } else {
+ log.warn("already registered");
+ }
+ }
+
+ /**
+ * Destroys the layout; unregistering from the shared model.
+ */
+ public void destroy() {
+ if (!registered) {
+ sharedModel.unregister(this);
+ } else {
+ log.warn("already unregistered");
+ }
+ }
+
+ @Override
+ public String toString() {
+ return String.format("{UiTopoLayout for user <%s>}", username);
+ }
+}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/package-info.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/package-info.java
new file mode 100644
index 0000000..b0cbf54
--- /dev/null
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Server-side modeling of the Topology View.
+ */
+package org.onosproject.ui.impl.topo.model;
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/package-info.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/package-info.java
index 07f4802..8bb50f5 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/package-info.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/package-info.java
@@ -15,6 +15,6 @@
*/
/**
- * Topology resources for the ONOS GUI.
+ * Topology View server-side support.
*/
package org.onosproject.ui.impl.topo;
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/IntentSelection.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/IntentSelection.java
similarity index 85%
rename from web/gui/src/main/java/org/onosproject/ui/impl/topo/IntentSelection.java
rename to web/gui/src/main/java/org/onosproject/ui/impl/topo/util/IntentSelection.java
index 151e613..04724df 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/IntentSelection.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/IntentSelection.java
@@ -1,21 +1,20 @@
/*
- * Copyright 2015 Open Networking Laboratory
+ * Copyright 2016 Open Networking Laboratory
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
-package org.onosproject.ui.impl.topo;
+package org.onosproject.ui.impl.topo.util;
import org.onosproject.net.intent.Intent;
import org.onosproject.ui.topo.NodeSelection;
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/ServicesBundle.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/ServicesBundle.java
similarity index 84%
rename from web/gui/src/main/java/org/onosproject/ui/impl/topo/ServicesBundle.java
rename to web/gui/src/main/java/org/onosproject/ui/impl/topo/util/ServicesBundle.java
index bcc4ad8..d78c01a 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/ServicesBundle.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/ServicesBundle.java
@@ -1,21 +1,20 @@
/*
- * Copyright 2015 Open Networking Laboratory
+ * Copyright 2016 Open Networking Laboratory
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
-package org.onosproject.ui.impl.topo;
+package org.onosproject.ui.impl.topo.util;
import org.onosproject.incubator.net.PortStatisticsService;
import org.onosproject.net.device.DeviceService;
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoIntentFilter.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TopoIntentFilter.java
similarity index 94%
rename from web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoIntentFilter.java
rename to web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TopoIntentFilter.java
index 12b9ce9..c99453c 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TopoIntentFilter.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TopoIntentFilter.java
@@ -1,19 +1,19 @@
/*
- * Copyright 2014-2015 Open Networking Laboratory
+ * Copyright 2016 Open Networking Laboratory
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
-package org.onosproject.ui.impl.topo;
+package org.onosproject.ui.impl.topo.util;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Device;
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TrafficLink.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TrafficLink.java
similarity index 89%
rename from web/gui/src/main/java/org/onosproject/ui/impl/topo/TrafficLink.java
rename to web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TrafficLink.java
index a0e1662..3fd4099 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/TrafficLink.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TrafficLink.java
@@ -1,21 +1,20 @@
/*
- * Copyright 2015 Open Networking Laboratory
+ * Copyright 2016 Open Networking Laboratory
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
-package org.onosproject.ui.impl.topo;
+package org.onosproject.ui.impl.topo.util;
import org.onosproject.net.Link;
import org.onosproject.net.LinkKey;
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TrafficLinkMap.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TrafficLinkMap.java
new file mode 100644
index 0000000..e4c79e9
--- /dev/null
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TrafficLinkMap.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.ui.impl.topo.util;
+
+import org.onosproject.net.Link;
+import org.onosproject.net.LinkKey;
+import org.onosproject.ui.topo.BiLinkMap;
+
+/**
+ * Collection of {@link TrafficLink}s.
+ */
+public class TrafficLinkMap extends BiLinkMap<TrafficLink> {
+
+ @Override
+ public TrafficLink create(LinkKey key, Link link) {
+ return new TrafficLink(key, link);
+ }
+}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/package-info.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/package-info.java
new file mode 100644
index 0000000..80be5eb
--- /dev/null
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Topology resources for the ONOS GUI.
+ */
+package org.onosproject.ui.impl.topo.util;