blob: b9b5e8cff99f3acb6ff664a6f697f287e08bfcda [file] [log] [blame]
Simon Hunted804d52016-03-30 09:51:40 -07001/*
2 * Copyright 2016 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.ui.impl.topo.model;
18
Simon Huntf679c4e2016-04-01 17:02:24 -070019import org.onosproject.ui.impl.topo.UiTopoSession;
Simon Hunted804d52016-03-30 09:51:40 -070020import org.slf4j.Logger;
21import org.slf4j.LoggerFactory;
22
23/**
24 * A lazily-initialized Singleton that creates and maintains the UI-model
25 * of the network topology.
26 */
27public final class UiSharedTopologyModel {
28
29 private static final Logger log =
30 LoggerFactory.getLogger(UiSharedTopologyModel.class);
31
Simon Hunted804d52016-03-30 09:51:40 -070032
33 private UiSharedTopologyModel() {
34 // TODO: set up core model listeners and build the state of the model
35 }
36
Simon Huntf679c4e2016-04-01 17:02:24 -070037 // TODO: Note to Thomas (or others)..
38 // Don't we have a common pattern for adding/removing listeners and
39 // invoking them when things happen?
40
41
42 /**
43 * Registers a UI topology session with the topology model.
44 *
45 * @param session the session to register
46 */
47 public void register(UiTopoSession session) {
48 log.info("Registering topology session {}", session);
49 // TODO: register the session
Simon Hunted804d52016-03-30 09:51:40 -070050 }
51
Simon Huntf679c4e2016-04-01 17:02:24 -070052 /**
53 * Unregisters a UI topology session from the topology model.
54 *
55 * @param session the session to unregister
56 */
57 public void unregister(UiTopoSession session) {
58 log.info("Unregistering topology session {}", session);
59 // TODO: unregister the session
60 }
61
62 /**
63 * Bill Pugh Singleton pattern. INSTANCE won't be instantiated until the
64 * LazyHolder class is loaded via a call to the instance() method below.
65 */
66 private static class LazyHolder {
67 private static final UiSharedTopologyModel INSTANCE =
68 new UiSharedTopologyModel();
Simon Hunted804d52016-03-30 09:51:40 -070069 }
70
71 /**
72 * Returns a reference to the Singleton UI network topology model.
73 *
74 * @return the singleton topology model
75 */
Simon Huntf679c4e2016-04-01 17:02:24 -070076 public static UiSharedTopologyModel instance() {
77 return LazyHolder.INSTANCE;
Simon Hunted804d52016-03-30 09:51:40 -070078 }
79}