mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-17 10:21:52 +02:00
GUI -- Rename UIMessageHandlerTwo => UIMessageHandler. Also, make bindHandlers() private.
Change-Id: Id36e220c1285b88b8b4db0e106ef063bd8b9bfd1
This commit is contained in:
parent
8ea1f51324
commit
a0ddb02bd6
@ -31,7 +31,7 @@ import org.onosproject.ui.RequestHandler;
|
||||
import org.onosproject.ui.UiConnection;
|
||||
import org.onosproject.ui.UiExtension;
|
||||
import org.onosproject.ui.UiExtensionService;
|
||||
import org.onosproject.ui.UiMessageHandlerTwo;
|
||||
import org.onosproject.ui.UiMessageHandler;
|
||||
import org.onosproject.ui.UiView;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -97,13 +97,13 @@ public class IntentPerfUi {
|
||||
}
|
||||
|
||||
// Creates and returns session specific message handler.
|
||||
private Collection<UiMessageHandlerTwo> newHandlers() {
|
||||
private Collection<UiMessageHandler> newHandlers() {
|
||||
return ImmutableList.of(new StreamingControl());
|
||||
}
|
||||
|
||||
|
||||
// UI Message handlers for turning on/off reporting to a session.
|
||||
private class StreamingControl extends UiMessageHandlerTwo {
|
||||
private class StreamingControl extends UiMessageHandler {
|
||||
|
||||
private boolean streamingEnabled = false;
|
||||
|
||||
|
@ -22,14 +22,14 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
* Abstraction of an entity that handles a specific request from the
|
||||
* user interface client.
|
||||
*
|
||||
* @see UiMessageHandlerTwo
|
||||
* @see UiMessageHandler
|
||||
*/
|
||||
public abstract class RequestHandler {
|
||||
|
||||
protected static final ObjectMapper MAPPER = new ObjectMapper();
|
||||
|
||||
private final String eventType;
|
||||
private UiMessageHandlerTwo parent;
|
||||
private UiMessageHandler parent;
|
||||
|
||||
|
||||
public RequestHandler(String eventType) {
|
||||
@ -37,7 +37,7 @@ public abstract class RequestHandler {
|
||||
}
|
||||
|
||||
// package private
|
||||
void setParent(UiMessageHandlerTwo parent) {
|
||||
void setParent(UiMessageHandler parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public abstract class UiMessageHandlerTwo {
|
||||
public abstract class UiMessageHandler {
|
||||
|
||||
private final Map<String, RequestHandler> handlerMap = new HashMap<>();
|
||||
|
||||
@ -56,20 +56,6 @@ public abstract class UiMessageHandlerTwo {
|
||||
*/
|
||||
protected final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
/**
|
||||
* Binds the handlers returned from {@link #getHandlers()} to this
|
||||
* instance.
|
||||
*/
|
||||
void bindHandlers() {
|
||||
Collection<RequestHandler> handlers = getHandlers();
|
||||
checkNotNull(handlers, "Handlers cannot be null");
|
||||
checkArgument(!handlers.isEmpty(), "Handlers cannot be empty");
|
||||
|
||||
for (RequestHandler h : handlers) {
|
||||
h.setParent(this);
|
||||
handlerMap.put(h.eventType(), h);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses must return the collection of handlers for the
|
||||
@ -115,6 +101,17 @@ public abstract class UiMessageHandlerTwo {
|
||||
}
|
||||
}
|
||||
|
||||
private void bindHandlers() {
|
||||
Collection<RequestHandler> handlers = getHandlers();
|
||||
checkNotNull(handlers, "Handlers cannot be null");
|
||||
checkArgument(!handlers.isEmpty(), "Handlers cannot be empty");
|
||||
|
||||
for (RequestHandler h : handlers) {
|
||||
h.setParent(this);
|
||||
handlerMap.put(h.eventType(), h);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the handler with the user interface connection and
|
||||
* service directory context.
|
@ -28,6 +28,6 @@ public interface UiMessageHandlerFactory {
|
||||
*
|
||||
* @return collection of new handlers
|
||||
*/
|
||||
Collection<UiMessageHandlerTwo> newHandlers();
|
||||
Collection<UiMessageHandler> newHandlers();
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import org.onosproject.app.ApplicationState;
|
||||
import org.onosproject.core.Application;
|
||||
import org.onosproject.core.ApplicationId;
|
||||
import org.onosproject.ui.RequestHandler;
|
||||
import org.onosproject.ui.UiMessageHandlerTwo;
|
||||
import org.onosproject.ui.UiMessageHandler;
|
||||
import org.onosproject.ui.table.AbstractTableRow;
|
||||
import org.onosproject.ui.table.RowComparator;
|
||||
import org.onosproject.ui.table.TableRow;
|
||||
@ -39,7 +39,7 @@ import static org.onosproject.app.ApplicationState.ACTIVE;
|
||||
/**
|
||||
* Message handler for application view related messages.
|
||||
*/
|
||||
public class ApplicationViewMessageHandler extends UiMessageHandlerTwo {
|
||||
public class ApplicationViewMessageHandler extends UiMessageHandler {
|
||||
|
||||
private static final String APP_DATA_REQ = "appDataRequest";
|
||||
private static final String APP_MGMT_REQ = "appManagementRequest";
|
||||
|
@ -24,7 +24,7 @@ import org.onosproject.cluster.ClusterService;
|
||||
import org.onosproject.cluster.ControllerNode;
|
||||
import org.onosproject.cluster.NodeId;
|
||||
import org.onosproject.ui.RequestHandler;
|
||||
import org.onosproject.ui.UiMessageHandlerTwo;
|
||||
import org.onosproject.ui.UiMessageHandler;
|
||||
import org.onosproject.ui.table.AbstractTableRow;
|
||||
import org.onosproject.ui.table.RowComparator;
|
||||
import org.onosproject.ui.table.TableRow;
|
||||
@ -39,7 +39,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* Message handler for cluster view related messages.
|
||||
*/
|
||||
public class ClusterViewMessageHandler extends UiMessageHandlerTwo {
|
||||
public class ClusterViewMessageHandler extends UiMessageHandler {
|
||||
|
||||
private static final String CLUSTER_DATA_REQ = "clusterDataRequest";
|
||||
|
||||
|
@ -28,7 +28,7 @@ import org.onosproject.net.Port;
|
||||
import org.onosproject.net.device.DeviceService;
|
||||
import org.onosproject.net.link.LinkService;
|
||||
import org.onosproject.ui.RequestHandler;
|
||||
import org.onosproject.ui.UiMessageHandlerTwo;
|
||||
import org.onosproject.ui.UiMessageHandler;
|
||||
import org.onosproject.ui.table.AbstractTableRow;
|
||||
import org.onosproject.ui.table.RowComparator;
|
||||
import org.onosproject.ui.table.TableRow;
|
||||
@ -44,7 +44,7 @@ import java.util.Set;
|
||||
/**
|
||||
* Message handler for device view related messages.
|
||||
*/
|
||||
public class DeviceViewMessageHandler extends UiMessageHandlerTwo {
|
||||
public class DeviceViewMessageHandler extends UiMessageHandler {
|
||||
|
||||
private static final String DEV_DATA_REQ = "deviceDataRequest";
|
||||
private static final String DEV_DETAIL_REQ = "deviceDetailRequest";
|
||||
|
@ -27,7 +27,7 @@ import org.onosproject.net.flow.TrafficTreatment;
|
||||
import org.onosproject.net.flow.criteria.Criterion;
|
||||
import org.onosproject.net.flow.instructions.Instruction;
|
||||
import org.onosproject.ui.RequestHandler;
|
||||
import org.onosproject.ui.UiMessageHandlerTwo;
|
||||
import org.onosproject.ui.UiMessageHandler;
|
||||
import org.onosproject.ui.table.AbstractTableRow;
|
||||
import org.onosproject.ui.table.RowComparator;
|
||||
import org.onosproject.ui.table.TableRow;
|
||||
@ -43,7 +43,7 @@ import java.util.Set;
|
||||
/**
|
||||
* Message handler for flow view related messages.
|
||||
*/
|
||||
public class FlowViewMessageHandler extends UiMessageHandlerTwo {
|
||||
public class FlowViewMessageHandler extends UiMessageHandler {
|
||||
|
||||
private static final String FLOW_DATA_REQ = "flowDataRequest";
|
||||
|
||||
|
@ -22,7 +22,7 @@ import org.onosproject.net.Host;
|
||||
import org.onosproject.net.HostLocation;
|
||||
import org.onosproject.net.host.HostService;
|
||||
import org.onosproject.ui.RequestHandler;
|
||||
import org.onosproject.ui.UiMessageHandlerTwo;
|
||||
import org.onosproject.ui.UiMessageHandler;
|
||||
import org.onosproject.ui.table.AbstractTableRow;
|
||||
import org.onosproject.ui.table.RowComparator;
|
||||
import org.onosproject.ui.table.TableRow;
|
||||
@ -38,7 +38,7 @@ import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
/**
|
||||
* Message handler for host view related messages.
|
||||
*/
|
||||
public class HostViewMessageHandler extends UiMessageHandlerTwo {
|
||||
public class HostViewMessageHandler extends UiMessageHandler {
|
||||
|
||||
private static final String HOST_DATA_REQ = "hostDataRequest";
|
||||
|
||||
|
@ -32,7 +32,7 @@ import org.onosproject.net.intent.PathIntent;
|
||||
import org.onosproject.net.intent.PointToPointIntent;
|
||||
import org.onosproject.net.intent.SinglePointToMultiPointIntent;
|
||||
import org.onosproject.ui.RequestHandler;
|
||||
import org.onosproject.ui.UiMessageHandlerTwo;
|
||||
import org.onosproject.ui.UiMessageHandler;
|
||||
import org.onosproject.ui.table.AbstractTableRow;
|
||||
import org.onosproject.ui.table.RowComparator;
|
||||
import org.onosproject.ui.table.TableRow;
|
||||
@ -47,7 +47,7 @@ import java.util.Set;
|
||||
/**
|
||||
* Message handler for intent view related messages.
|
||||
*/
|
||||
public class IntentViewMessageHandler extends UiMessageHandlerTwo {
|
||||
public class IntentViewMessageHandler extends UiMessageHandler {
|
||||
|
||||
private static final String INTENT_DATA_REQ = "intentDataRequest";
|
||||
|
||||
|
@ -24,7 +24,7 @@ import org.onosproject.net.Link;
|
||||
import org.onosproject.net.LinkKey;
|
||||
import org.onosproject.net.link.LinkService;
|
||||
import org.onosproject.ui.RequestHandler;
|
||||
import org.onosproject.ui.UiMessageHandlerTwo;
|
||||
import org.onosproject.ui.UiMessageHandler;
|
||||
import org.onosproject.ui.impl.TopologyViewMessageHandlerBase.BiLink;
|
||||
import org.onosproject.ui.table.AbstractTableRow;
|
||||
import org.onosproject.ui.table.RowComparator;
|
||||
@ -42,7 +42,7 @@ import static org.onosproject.ui.impl.TopologyViewMessageHandlerBase.addLink;
|
||||
/**
|
||||
* Message handler for link view related messages.
|
||||
*/
|
||||
public class LinkViewMessageHandler extends UiMessageHandlerTwo {
|
||||
public class LinkViewMessageHandler extends UiMessageHandler {
|
||||
|
||||
private static final String LINK_DATA_REQ = "linkDataRequest";
|
||||
|
||||
|
@ -65,7 +65,7 @@ import org.onosproject.net.topology.Topology;
|
||||
import org.onosproject.net.topology.TopologyService;
|
||||
import org.onosproject.ui.JsonUtils;
|
||||
import org.onosproject.ui.UiConnection;
|
||||
import org.onosproject.ui.UiMessageHandlerTwo;
|
||||
import org.onosproject.ui.UiMessageHandler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -101,7 +101,7 @@ import static org.onosproject.net.link.LinkEvent.Type.LINK_REMOVED;
|
||||
/**
|
||||
* Facility for creating messages bound for the topology viewer.
|
||||
*/
|
||||
public abstract class TopologyViewMessageHandlerBase extends UiMessageHandlerTwo {
|
||||
public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
|
||||
|
||||
protected static final Logger log =
|
||||
LoggerFactory.getLogger(TopologyViewMessageHandlerBase.class);
|
||||
|
@ -25,7 +25,7 @@ import org.onosproject.cluster.ControllerNode;
|
||||
import org.onosproject.ui.UiConnection;
|
||||
import org.onosproject.ui.UiExtensionService;
|
||||
import org.onosproject.ui.UiMessageHandlerFactory;
|
||||
import org.onosproject.ui.UiMessageHandlerTwo;
|
||||
import org.onosproject.ui.UiMessageHandler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -56,7 +56,7 @@ public class UiWebSocket
|
||||
|
||||
private long lastActive = System.currentTimeMillis();
|
||||
|
||||
private Map<String, UiMessageHandlerTwo> handlers;
|
||||
private Map<String, UiMessageHandler> handlers;
|
||||
|
||||
/**
|
||||
* Creates a new web-socket for serving data to GUI.
|
||||
@ -123,7 +123,7 @@ public class UiWebSocket
|
||||
try {
|
||||
ObjectNode message = (ObjectNode) mapper.reader().readTree(data);
|
||||
String type = message.path("event").asText("unknown");
|
||||
UiMessageHandlerTwo handler = handlers.get(type);
|
||||
UiMessageHandler handler = handlers.get(type);
|
||||
if (handler != null) {
|
||||
handler.process(message);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user