Simon Hunt

GUI -- Rename UIMessageHandlerTwo => UIMessageHandler. Also, make bindHandlers() private.

Change-Id: Id36e220c1285b88b8b4db0e106ef063bd8b9bfd1
...@@ -31,7 +31,7 @@ import org.onosproject.ui.RequestHandler; ...@@ -31,7 +31,7 @@ import org.onosproject.ui.RequestHandler;
31 import org.onosproject.ui.UiConnection; 31 import org.onosproject.ui.UiConnection;
32 import org.onosproject.ui.UiExtension; 32 import org.onosproject.ui.UiExtension;
33 import org.onosproject.ui.UiExtensionService; 33 import org.onosproject.ui.UiExtensionService;
34 -import org.onosproject.ui.UiMessageHandlerTwo; 34 +import org.onosproject.ui.UiMessageHandler;
35 import org.onosproject.ui.UiView; 35 import org.onosproject.ui.UiView;
36 36
37 import java.util.Collection; 37 import java.util.Collection;
...@@ -97,13 +97,13 @@ public class IntentPerfUi { ...@@ -97,13 +97,13 @@ public class IntentPerfUi {
97 } 97 }
98 98
99 // Creates and returns session specific message handler. 99 // Creates and returns session specific message handler.
100 - private Collection<UiMessageHandlerTwo> newHandlers() { 100 + private Collection<UiMessageHandler> newHandlers() {
101 return ImmutableList.of(new StreamingControl()); 101 return ImmutableList.of(new StreamingControl());
102 } 102 }
103 103
104 104
105 // UI Message handlers for turning on/off reporting to a session. 105 // UI Message handlers for turning on/off reporting to a session.
106 - private class StreamingControl extends UiMessageHandlerTwo { 106 + private class StreamingControl extends UiMessageHandler {
107 107
108 private boolean streamingEnabled = false; 108 private boolean streamingEnabled = false;
109 109
......
...@@ -22,14 +22,14 @@ import com.fasterxml.jackson.databind.node.ObjectNode; ...@@ -22,14 +22,14 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
22 * Abstraction of an entity that handles a specific request from the 22 * Abstraction of an entity that handles a specific request from the
23 * user interface client. 23 * user interface client.
24 * 24 *
25 - * @see UiMessageHandlerTwo 25 + * @see UiMessageHandler
26 */ 26 */
27 public abstract class RequestHandler { 27 public abstract class RequestHandler {
28 28
29 protected static final ObjectMapper MAPPER = new ObjectMapper(); 29 protected static final ObjectMapper MAPPER = new ObjectMapper();
30 30
31 private final String eventType; 31 private final String eventType;
32 - private UiMessageHandlerTwo parent; 32 + private UiMessageHandler parent;
33 33
34 34
35 public RequestHandler(String eventType) { 35 public RequestHandler(String eventType) {
...@@ -37,7 +37,7 @@ public abstract class RequestHandler { ...@@ -37,7 +37,7 @@ public abstract class RequestHandler {
37 } 37 }
38 38
39 // package private 39 // package private
40 - void setParent(UiMessageHandlerTwo parent) { 40 + void setParent(UiMessageHandler parent) {
41 this.parent = parent; 41 this.parent = parent;
42 } 42 }
43 43
......
...@@ -44,7 +44,7 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -44,7 +44,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
44 * } 44 * }
45 * </pre> 45 * </pre>
46 */ 46 */
47 -public abstract class UiMessageHandlerTwo { 47 +public abstract class UiMessageHandler {
48 48
49 private final Map<String, RequestHandler> handlerMap = new HashMap<>(); 49 private final Map<String, RequestHandler> handlerMap = new HashMap<>();
50 50
...@@ -56,20 +56,6 @@ public abstract class UiMessageHandlerTwo { ...@@ -56,20 +56,6 @@ public abstract class UiMessageHandlerTwo {
56 */ 56 */
57 protected final ObjectMapper mapper = new ObjectMapper(); 57 protected final ObjectMapper mapper = new ObjectMapper();
58 58
59 - /**
60 - * Binds the handlers returned from {@link #getHandlers()} to this
61 - * instance.
62 - */
63 - void bindHandlers() {
64 - Collection<RequestHandler> handlers = getHandlers();
65 - checkNotNull(handlers, "Handlers cannot be null");
66 - checkArgument(!handlers.isEmpty(), "Handlers cannot be empty");
67 -
68 - for (RequestHandler h : handlers) {
69 - h.setParent(this);
70 - handlerMap.put(h.eventType(), h);
71 - }
72 - }
73 59
74 /** 60 /**
75 * Subclasses must return the collection of handlers for the 61 * Subclasses must return the collection of handlers for the
...@@ -115,6 +101,17 @@ public abstract class UiMessageHandlerTwo { ...@@ -115,6 +101,17 @@ public abstract class UiMessageHandlerTwo {
115 } 101 }
116 } 102 }
117 103
104 + private void bindHandlers() {
105 + Collection<RequestHandler> handlers = getHandlers();
106 + checkNotNull(handlers, "Handlers cannot be null");
107 + checkArgument(!handlers.isEmpty(), "Handlers cannot be empty");
108 +
109 + for (RequestHandler h : handlers) {
110 + h.setParent(this);
111 + handlerMap.put(h.eventType(), h);
112 + }
113 + }
114 +
118 /** 115 /**
119 * Initializes the handler with the user interface connection and 116 * Initializes the handler with the user interface connection and
120 * service directory context. 117 * service directory context.
......
...@@ -28,6 +28,6 @@ public interface UiMessageHandlerFactory { ...@@ -28,6 +28,6 @@ public interface UiMessageHandlerFactory {
28 * 28 *
29 * @return collection of new handlers 29 * @return collection of new handlers
30 */ 30 */
31 - Collection<UiMessageHandlerTwo> newHandlers(); 31 + Collection<UiMessageHandler> newHandlers();
32 32
33 } 33 }
......
...@@ -23,7 +23,7 @@ import org.onosproject.app.ApplicationState; ...@@ -23,7 +23,7 @@ import org.onosproject.app.ApplicationState;
23 import org.onosproject.core.Application; 23 import org.onosproject.core.Application;
24 import org.onosproject.core.ApplicationId; 24 import org.onosproject.core.ApplicationId;
25 import org.onosproject.ui.RequestHandler; 25 import org.onosproject.ui.RequestHandler;
26 -import org.onosproject.ui.UiMessageHandlerTwo; 26 +import org.onosproject.ui.UiMessageHandler;
27 import org.onosproject.ui.table.AbstractTableRow; 27 import org.onosproject.ui.table.AbstractTableRow;
28 import org.onosproject.ui.table.RowComparator; 28 import org.onosproject.ui.table.RowComparator;
29 import org.onosproject.ui.table.TableRow; 29 import org.onosproject.ui.table.TableRow;
...@@ -39,7 +39,7 @@ import static org.onosproject.app.ApplicationState.ACTIVE; ...@@ -39,7 +39,7 @@ import static org.onosproject.app.ApplicationState.ACTIVE;
39 /** 39 /**
40 * Message handler for application view related messages. 40 * Message handler for application view related messages.
41 */ 41 */
42 -public class ApplicationViewMessageHandler extends UiMessageHandlerTwo { 42 +public class ApplicationViewMessageHandler extends UiMessageHandler {
43 43
44 private static final String APP_DATA_REQ = "appDataRequest"; 44 private static final String APP_DATA_REQ = "appDataRequest";
45 private static final String APP_MGMT_REQ = "appManagementRequest"; 45 private static final String APP_MGMT_REQ = "appManagementRequest";
......
...@@ -24,7 +24,7 @@ import org.onosproject.cluster.ClusterService; ...@@ -24,7 +24,7 @@ import org.onosproject.cluster.ClusterService;
24 import org.onosproject.cluster.ControllerNode; 24 import org.onosproject.cluster.ControllerNode;
25 import org.onosproject.cluster.NodeId; 25 import org.onosproject.cluster.NodeId;
26 import org.onosproject.ui.RequestHandler; 26 import org.onosproject.ui.RequestHandler;
27 -import org.onosproject.ui.UiMessageHandlerTwo; 27 +import org.onosproject.ui.UiMessageHandler;
28 import org.onosproject.ui.table.AbstractTableRow; 28 import org.onosproject.ui.table.AbstractTableRow;
29 import org.onosproject.ui.table.RowComparator; 29 import org.onosproject.ui.table.RowComparator;
30 import org.onosproject.ui.table.TableRow; 30 import org.onosproject.ui.table.TableRow;
...@@ -39,7 +39,7 @@ import java.util.stream.Collectors; ...@@ -39,7 +39,7 @@ import java.util.stream.Collectors;
39 /** 39 /**
40 * Message handler for cluster view related messages. 40 * Message handler for cluster view related messages.
41 */ 41 */
42 -public class ClusterViewMessageHandler extends UiMessageHandlerTwo { 42 +public class ClusterViewMessageHandler extends UiMessageHandler {
43 43
44 private static final String CLUSTER_DATA_REQ = "clusterDataRequest"; 44 private static final String CLUSTER_DATA_REQ = "clusterDataRequest";
45 45
......
...@@ -28,7 +28,7 @@ import org.onosproject.net.Port; ...@@ -28,7 +28,7 @@ import org.onosproject.net.Port;
28 import org.onosproject.net.device.DeviceService; 28 import org.onosproject.net.device.DeviceService;
29 import org.onosproject.net.link.LinkService; 29 import org.onosproject.net.link.LinkService;
30 import org.onosproject.ui.RequestHandler; 30 import org.onosproject.ui.RequestHandler;
31 -import org.onosproject.ui.UiMessageHandlerTwo; 31 +import org.onosproject.ui.UiMessageHandler;
32 import org.onosproject.ui.table.AbstractTableRow; 32 import org.onosproject.ui.table.AbstractTableRow;
33 import org.onosproject.ui.table.RowComparator; 33 import org.onosproject.ui.table.RowComparator;
34 import org.onosproject.ui.table.TableRow; 34 import org.onosproject.ui.table.TableRow;
...@@ -44,7 +44,7 @@ import java.util.Set; ...@@ -44,7 +44,7 @@ import java.util.Set;
44 /** 44 /**
45 * Message handler for device view related messages. 45 * Message handler for device view related messages.
46 */ 46 */
47 -public class DeviceViewMessageHandler extends UiMessageHandlerTwo { 47 +public class DeviceViewMessageHandler extends UiMessageHandler {
48 48
49 private static final String DEV_DATA_REQ = "deviceDataRequest"; 49 private static final String DEV_DATA_REQ = "deviceDataRequest";
50 private static final String DEV_DETAIL_REQ = "deviceDetailRequest"; 50 private static final String DEV_DETAIL_REQ = "deviceDetailRequest";
......
...@@ -27,7 +27,7 @@ import org.onosproject.net.flow.TrafficTreatment; ...@@ -27,7 +27,7 @@ import org.onosproject.net.flow.TrafficTreatment;
27 import org.onosproject.net.flow.criteria.Criterion; 27 import org.onosproject.net.flow.criteria.Criterion;
28 import org.onosproject.net.flow.instructions.Instruction; 28 import org.onosproject.net.flow.instructions.Instruction;
29 import org.onosproject.ui.RequestHandler; 29 import org.onosproject.ui.RequestHandler;
30 -import org.onosproject.ui.UiMessageHandlerTwo; 30 +import org.onosproject.ui.UiMessageHandler;
31 import org.onosproject.ui.table.AbstractTableRow; 31 import org.onosproject.ui.table.AbstractTableRow;
32 import org.onosproject.ui.table.RowComparator; 32 import org.onosproject.ui.table.RowComparator;
33 import org.onosproject.ui.table.TableRow; 33 import org.onosproject.ui.table.TableRow;
...@@ -43,7 +43,7 @@ import java.util.Set; ...@@ -43,7 +43,7 @@ import java.util.Set;
43 /** 43 /**
44 * Message handler for flow view related messages. 44 * Message handler for flow view related messages.
45 */ 45 */
46 -public class FlowViewMessageHandler extends UiMessageHandlerTwo { 46 +public class FlowViewMessageHandler extends UiMessageHandler {
47 47
48 private static final String FLOW_DATA_REQ = "flowDataRequest"; 48 private static final String FLOW_DATA_REQ = "flowDataRequest";
49 49
......
...@@ -22,7 +22,7 @@ import org.onosproject.net.Host; ...@@ -22,7 +22,7 @@ import org.onosproject.net.Host;
22 import org.onosproject.net.HostLocation; 22 import org.onosproject.net.HostLocation;
23 import org.onosproject.net.host.HostService; 23 import org.onosproject.net.host.HostService;
24 import org.onosproject.ui.RequestHandler; 24 import org.onosproject.ui.RequestHandler;
25 -import org.onosproject.ui.UiMessageHandlerTwo; 25 +import org.onosproject.ui.UiMessageHandler;
26 import org.onosproject.ui.table.AbstractTableRow; 26 import org.onosproject.ui.table.AbstractTableRow;
27 import org.onosproject.ui.table.RowComparator; 27 import org.onosproject.ui.table.RowComparator;
28 import org.onosproject.ui.table.TableRow; 28 import org.onosproject.ui.table.TableRow;
...@@ -38,7 +38,7 @@ import static com.google.common.base.Strings.isNullOrEmpty; ...@@ -38,7 +38,7 @@ import static com.google.common.base.Strings.isNullOrEmpty;
38 /** 38 /**
39 * Message handler for host view related messages. 39 * Message handler for host view related messages.
40 */ 40 */
41 -public class HostViewMessageHandler extends UiMessageHandlerTwo { 41 +public class HostViewMessageHandler extends UiMessageHandler {
42 42
43 private static final String HOST_DATA_REQ = "hostDataRequest"; 43 private static final String HOST_DATA_REQ = "hostDataRequest";
44 44
......
...@@ -32,7 +32,7 @@ import org.onosproject.net.intent.PathIntent; ...@@ -32,7 +32,7 @@ import org.onosproject.net.intent.PathIntent;
32 import org.onosproject.net.intent.PointToPointIntent; 32 import org.onosproject.net.intent.PointToPointIntent;
33 import org.onosproject.net.intent.SinglePointToMultiPointIntent; 33 import org.onosproject.net.intent.SinglePointToMultiPointIntent;
34 import org.onosproject.ui.RequestHandler; 34 import org.onosproject.ui.RequestHandler;
35 -import org.onosproject.ui.UiMessageHandlerTwo; 35 +import org.onosproject.ui.UiMessageHandler;
36 import org.onosproject.ui.table.AbstractTableRow; 36 import org.onosproject.ui.table.AbstractTableRow;
37 import org.onosproject.ui.table.RowComparator; 37 import org.onosproject.ui.table.RowComparator;
38 import org.onosproject.ui.table.TableRow; 38 import org.onosproject.ui.table.TableRow;
...@@ -47,7 +47,7 @@ import java.util.Set; ...@@ -47,7 +47,7 @@ import java.util.Set;
47 /** 47 /**
48 * Message handler for intent view related messages. 48 * Message handler for intent view related messages.
49 */ 49 */
50 -public class IntentViewMessageHandler extends UiMessageHandlerTwo { 50 +public class IntentViewMessageHandler extends UiMessageHandler {
51 51
52 private static final String INTENT_DATA_REQ = "intentDataRequest"; 52 private static final String INTENT_DATA_REQ = "intentDataRequest";
53 53
......
...@@ -24,7 +24,7 @@ import org.onosproject.net.Link; ...@@ -24,7 +24,7 @@ import org.onosproject.net.Link;
24 import org.onosproject.net.LinkKey; 24 import org.onosproject.net.LinkKey;
25 import org.onosproject.net.link.LinkService; 25 import org.onosproject.net.link.LinkService;
26 import org.onosproject.ui.RequestHandler; 26 import org.onosproject.ui.RequestHandler;
27 -import org.onosproject.ui.UiMessageHandlerTwo; 27 +import org.onosproject.ui.UiMessageHandler;
28 import org.onosproject.ui.impl.TopologyViewMessageHandlerBase.BiLink; 28 import org.onosproject.ui.impl.TopologyViewMessageHandlerBase.BiLink;
29 import org.onosproject.ui.table.AbstractTableRow; 29 import org.onosproject.ui.table.AbstractTableRow;
30 import org.onosproject.ui.table.RowComparator; 30 import org.onosproject.ui.table.RowComparator;
...@@ -42,7 +42,7 @@ import static org.onosproject.ui.impl.TopologyViewMessageHandlerBase.addLink; ...@@ -42,7 +42,7 @@ import static org.onosproject.ui.impl.TopologyViewMessageHandlerBase.addLink;
42 /** 42 /**
43 * Message handler for link view related messages. 43 * Message handler for link view related messages.
44 */ 44 */
45 -public class LinkViewMessageHandler extends UiMessageHandlerTwo { 45 +public class LinkViewMessageHandler extends UiMessageHandler {
46 46
47 private static final String LINK_DATA_REQ = "linkDataRequest"; 47 private static final String LINK_DATA_REQ = "linkDataRequest";
48 48
......
...@@ -65,7 +65,7 @@ import org.onosproject.net.topology.Topology; ...@@ -65,7 +65,7 @@ import org.onosproject.net.topology.Topology;
65 import org.onosproject.net.topology.TopologyService; 65 import org.onosproject.net.topology.TopologyService;
66 import org.onosproject.ui.JsonUtils; 66 import org.onosproject.ui.JsonUtils;
67 import org.onosproject.ui.UiConnection; 67 import org.onosproject.ui.UiConnection;
68 -import org.onosproject.ui.UiMessageHandlerTwo; 68 +import org.onosproject.ui.UiMessageHandler;
69 import org.slf4j.Logger; 69 import org.slf4j.Logger;
70 import org.slf4j.LoggerFactory; 70 import org.slf4j.LoggerFactory;
71 71
...@@ -101,7 +101,7 @@ import static org.onosproject.net.link.LinkEvent.Type.LINK_REMOVED; ...@@ -101,7 +101,7 @@ import static org.onosproject.net.link.LinkEvent.Type.LINK_REMOVED;
101 /** 101 /**
102 * Facility for creating messages bound for the topology viewer. 102 * Facility for creating messages bound for the topology viewer.
103 */ 103 */
104 -public abstract class TopologyViewMessageHandlerBase extends UiMessageHandlerTwo { 104 +public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
105 105
106 protected static final Logger log = 106 protected static final Logger log =
107 LoggerFactory.getLogger(TopologyViewMessageHandlerBase.class); 107 LoggerFactory.getLogger(TopologyViewMessageHandlerBase.class);
......
...@@ -25,7 +25,7 @@ import org.onosproject.cluster.ControllerNode; ...@@ -25,7 +25,7 @@ import org.onosproject.cluster.ControllerNode;
25 import org.onosproject.ui.UiConnection; 25 import org.onosproject.ui.UiConnection;
26 import org.onosproject.ui.UiExtensionService; 26 import org.onosproject.ui.UiExtensionService;
27 import org.onosproject.ui.UiMessageHandlerFactory; 27 import org.onosproject.ui.UiMessageHandlerFactory;
28 -import org.onosproject.ui.UiMessageHandlerTwo; 28 +import org.onosproject.ui.UiMessageHandler;
29 import org.slf4j.Logger; 29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory; 30 import org.slf4j.LoggerFactory;
31 31
...@@ -56,7 +56,7 @@ public class UiWebSocket ...@@ -56,7 +56,7 @@ public class UiWebSocket
56 56
57 private long lastActive = System.currentTimeMillis(); 57 private long lastActive = System.currentTimeMillis();
58 58
59 - private Map<String, UiMessageHandlerTwo> handlers; 59 + private Map<String, UiMessageHandler> handlers;
60 60
61 /** 61 /**
62 * Creates a new web-socket for serving data to GUI. 62 * Creates a new web-socket for serving data to GUI.
...@@ -123,7 +123,7 @@ public class UiWebSocket ...@@ -123,7 +123,7 @@ public class UiWebSocket
123 try { 123 try {
124 ObjectNode message = (ObjectNode) mapper.reader().readTree(data); 124 ObjectNode message = (ObjectNode) mapper.reader().readTree(data);
125 String type = message.path("event").asText("unknown"); 125 String type = message.path("event").asText("unknown");
126 - UiMessageHandlerTwo handler = handlers.get(type); 126 + UiMessageHandler handler = handlers.get(type);
127 if (handler != null) { 127 if (handler != null) {
128 handler.process(message); 128 handler.process(message);
129 } else { 129 } else {
......