Search in sources :

Example 1 with UiMessageHandlerFactory

use of org.onosproject.ui.UiMessageHandlerFactory in project onos by opennetworkinglab.

the class UiExtensionManager method createCoreExtension.

private UiExtension createCoreExtension() {
    List<LionBundle> lionBundles = generateBundles(LION_BASE, LION_TAGS);
    navLion = lionBundles.stream().filter(f -> f.id().equals("core.fw.Nav")).findFirst().get();
    List<UiView> coreViews = of(mkView(PLATFORM, "app", "nav_apps"), mkView(PLATFORM, "settings", "nav_settings"), mkView(PLATFORM, "cluster", "nav_cluster"), mkView(PLATFORM, "processor", "nav_processors"), mkView(PLATFORM, "partition", "nav_partitions"), mkView(NETWORK, "topo", "nav_topo"), // mkView(NETWORK, "topo2", "nav_topo2"),
    mkView(NETWORK, "device", "nav_devs"), new UiViewHidden("flow"), new UiViewHidden("port"), new UiViewHidden("group"), new UiViewHidden("meter"), new UiViewHidden("pipeconf"), mkView(NETWORK, "link", "nav_links"), mkView(NETWORK, "host", "nav_hosts"), mkView(NETWORK, "intent", "nav_intents"));
    UiMessageHandlerFactory messageHandlerFactory = () -> ImmutableList.of(new UserPreferencesMessageHandler(), new TopologyViewMessageHandler(), new Topo2ViewMessageHandler(), new Topo2TrafficMessageHandler(), new MapSelectorMessageHandler(), new DeviceViewMessageHandler(), new LinkViewMessageHandler(), new HostViewMessageHandler(), new FlowViewMessageHandler(), new PortViewMessageHandler(), new GroupViewMessageHandler(), new MeterViewMessageHandler(), new IntentViewMessageHandler(), new ApplicationViewMessageHandler(), new SettingsViewMessageHandler(), new ClusterViewMessageHandler(), new ProcessorViewMessageHandler(), new PartitionViewMessageHandler(), new PipeconfViewMessageHandler());
    UiTopoOverlayFactory topoOverlayFactory = () -> ImmutableList.of(new TrafficOverlay(), new ProtectedIntentOverlay());
    UiTopo2OverlayFactory topo2OverlayFactory = () -> ImmutableList.of(new Traffic2Overlay());
    UiTopoMapFactory topoMapFactory = () -> ImmutableList.of(new UiTopoMap("australia", "Australia", "*australia", 1.0), new UiTopoMap("americas", "North, Central and South America", "*americas", 0.7), new UiTopoMap("n_america", "North America", "*n_america", 0.9), new UiTopoMap("s_america", "South America", "*s_america", 0.9), new UiTopoMap("usa", "United States", "*continental_us", 1.3), new UiTopoMap("bayareaGEO", "Bay Area, California", "*bayarea", 1.0), new UiTopoMap("europe", "Europe", "*europe", 10.0), new UiTopoMap("italy", "Italy", "*italy", 0.8), new UiTopoMap("uk", "United Kingdom and Ireland", "*uk", 2.0), new UiTopoMap("japan", "Japan", "*japan", 0.8), new UiTopoMap("s_korea", "South Korea", "*s_korea", 0.75), new UiTopoMap("taiwan", "Taiwan", "*taiwan", 0.7), new UiTopoMap("africa", "Africa", "*africa", 0.7), new UiTopoMap("oceania", "Oceania", "*oceania", 0.7), new UiTopoMap("asia", "Asia", "*asia", 0.7));
    return new UiExtension.Builder(CL, coreViews).lionBundles(lionBundles).messageHandlerFactory(messageHandlerFactory).topoOverlayFactory(topoOverlayFactory).topo2OverlayFactory(topo2OverlayFactory).topoMapFactory(topoMapFactory).resourcePath(CORE).ui2().build();
}
Also used : ConsistentMap(org.onosproject.store.service.ConsistentMap) UiTokenService(org.onosproject.ui.UiTokenService) UiTopoMapFactory(org.onosproject.ui.UiTopoMapFactory) LoggerFactory(org.slf4j.LoggerFactory) UiTopo2OverlayFactory(org.onosproject.ui.UiTopo2OverlayFactory) UiView(org.onosproject.ui.UiView) Topo2ViewMessageHandler(org.onosproject.ui.impl.topo.Topo2ViewMessageHandler) LongNode(com.fasterxml.jackson.databind.node.LongNode) UiMessageHandlerFactory(org.onosproject.ui.UiMessageHandlerFactory) SecureRandom(java.security.SecureRandom) NullNode(com.fasterxml.jackson.databind.node.NullNode) LionUtils(org.onosproject.ui.lion.LionUtils) StorageService(org.onosproject.store.service.StorageService) Traffic2Overlay(org.onosproject.ui.impl.topo.Traffic2Overlay) Locale(java.util.Locale) Map(java.util.Map) UI_WRITE(org.onosproject.security.AppPermission.Type.UI_WRITE) JsonNode(com.fasterxml.jackson.databind.JsonNode) BigInteger(java.math.BigInteger) TRAFFIC_REFRESH_MS(org.onosproject.ui.impl.OsgiPropertyConstants.TRAFFIC_REFRESH_MS) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) MastershipService(org.onosproject.mastership.MastershipService) Topo2TrafficMessageHandler(org.onosproject.ui.impl.topo.Topo2TrafficMessageHandler) LionBundle(org.onosproject.ui.lion.LionBundle) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableList.of(com.google.common.collect.ImmutableList.of) UiGlyphFactory(org.onosproject.ui.UiGlyphFactory) Serializer(org.onosproject.store.service.Serializer) NETWORK(org.onosproject.ui.UiView.Category.NETWORK) ImmutableSet(com.google.common.collect.ImmutableSet) UiSessionToken(org.onosproject.ui.UiSessionToken) ImmutableMap(com.google.common.collect.ImmutableMap) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) TextNode(com.fasterxml.jackson.databind.node.TextNode) Executors(java.util.concurrent.Executors) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) TRAFFIC_REFRESH_MS_DEFAULT(org.onosproject.ui.impl.OsgiPropertyConstants.TRAFFIC_REFRESH_MS_DEFAULT) List(java.util.List) UI_READ(org.onosproject.security.AppPermission.Type.UI_READ) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) UiSharedTopologyModel(org.onosproject.ui.impl.topo.model.UiSharedTopologyModel) AbstractTopoMonitor(org.onosproject.ui.topo.AbstractTopoMonitor) UiExtension(org.onosproject.ui.UiExtension) Dictionary(java.util.Dictionary) GLYPH_READ(org.onosproject.security.AppPermission.Type.GLYPH_READ) UiTopoMap(org.onosproject.ui.UiTopoMap) UiViewHidden(org.onosproject.ui.UiViewHidden) IntNode(com.fasterxml.jackson.databind.node.IntNode) Tools(org.onlab.util.Tools) UiTopoOverlayFactory(org.onosproject.ui.UiTopoOverlayFactory) UiExtensionService(org.onosproject.ui.UiExtensionService) ComponentContext(org.osgi.service.component.ComponentContext) AppGuard.checkPermission(org.onosproject.security.AppGuard.checkPermission) GLYPH_WRITE(org.onosproject.security.AppPermission.Type.GLYPH_WRITE) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) MapEventListener(org.onosproject.store.service.MapEventListener) LinkedHashMap(java.util.LinkedHashMap) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) UiTopoHighlighterFactory(org.onosproject.ui.UiTopoHighlighterFactory) UiGlyph(org.onosproject.ui.UiGlyph) Activate(org.osgi.service.component.annotations.Activate) ExecutorService(java.util.concurrent.ExecutorService) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) Logger(org.slf4j.Logger) PLATFORM(org.onosproject.ui.UiView.Category.PLATFORM) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) UiPreferencesService(org.onosproject.ui.UiPreferencesService) BundleStitcher.generateBundles(org.onosproject.ui.impl.lion.BundleStitcher.generateBundles) Maps(com.google.common.collect.Maps) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) DoubleNode(com.fasterxml.jackson.databind.node.DoubleNode) MapEvent(org.onosproject.store.service.MapEvent) Modified(org.osgi.service.component.annotations.Modified) BooleanNode(com.fasterxml.jackson.databind.node.BooleanNode) ShortNode(com.fasterxml.jackson.databind.node.ShortNode) Reference(org.osgi.service.component.annotations.Reference) UiMessageHandlerFactory(org.onosproject.ui.UiMessageHandlerFactory) Topo2ViewMessageHandler(org.onosproject.ui.impl.topo.Topo2ViewMessageHandler) UiView(org.onosproject.ui.UiView) UiTopoMap(org.onosproject.ui.UiTopoMap) Traffic2Overlay(org.onosproject.ui.impl.topo.Traffic2Overlay) UiTopoOverlayFactory(org.onosproject.ui.UiTopoOverlayFactory) UiTopo2OverlayFactory(org.onosproject.ui.UiTopo2OverlayFactory) Topo2TrafficMessageHandler(org.onosproject.ui.impl.topo.Topo2TrafficMessageHandler) LionBundle(org.onosproject.ui.lion.LionBundle) UiTopoMapFactory(org.onosproject.ui.UiTopoMapFactory) UiViewHidden(org.onosproject.ui.UiViewHidden)

Example 2 with UiMessageHandlerFactory

use of org.onosproject.ui.UiMessageHandlerFactory in project onos by opennetworkinglab.

the class UiWebSocket method createHandlersAndOverlays.

// Creates new message handlers.
private synchronized void createHandlersAndOverlays() {
    log.debug("Creating handlers and overlays...");
    handlers = new HashMap<>();
    overlayCache = new TopoOverlayCache();
    overlay2Cache = new Topo2OverlayCache();
    Map<Class<?>, UiMessageHandler> handlerInstances = new HashMap<>();
    UiExtensionService service = directory.get(UiExtensionService.class);
    lionBundleMap = generateLionMap(service);
    service.getExtensions().forEach(ext -> {
        UiMessageHandlerFactory factory = ext.messageHandlerFactory();
        if (factory != null) {
            factory.newHandlers().forEach(handler -> {
                try {
                    handler.init(this, directory);
                    injectLionBundles(handler, lionBundleMap);
                    handler.messageTypes().forEach(type -> handlers.put(type, handler));
                    handlerInstances.put(handler.getClass(), handler);
                } catch (Exception e) {
                    log.warn("Unable to setup handler {} due to", handler, e);
                }
            });
        }
        registerOverlays(ext);
    });
    handlerCrossConnects(handlerInstances);
    overlay2Cache.switchOverlay(null, Traffic2Overlay.OVERLAY_ID);
    log.debug("#handlers = {}, #overlays = Topo: {}, Topo2: {}", handlers.size(), overlayCache.size(), overlay2Cache.size());
}
Also used : UiMessageHandlerFactory(org.onosproject.ui.UiMessageHandlerFactory) UiMessageHandler(org.onosproject.ui.UiMessageHandler) Topo2OverlayCache(org.onosproject.ui.impl.topo.Topo2OverlayCache) HashMap(java.util.HashMap) UiExtensionService(org.onosproject.ui.UiExtensionService) ServiceNotFoundException(org.onlab.osgi.ServiceNotFoundException) IOException(java.io.IOException)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 BooleanNode (com.fasterxml.jackson.databind.node.BooleanNode)1 DoubleNode (com.fasterxml.jackson.databind.node.DoubleNode)1 IntNode (com.fasterxml.jackson.databind.node.IntNode)1 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)1 LongNode (com.fasterxml.jackson.databind.node.LongNode)1 NullNode (com.fasterxml.jackson.databind.node.NullNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ShortNode (com.fasterxml.jackson.databind.node.ShortNode)1 TextNode (com.fasterxml.jackson.databind.node.TextNode)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.of (com.google.common.collect.ImmutableList.of)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 IOException (java.io.IOException)1 BigInteger (java.math.BigInteger)1