Search in sources :

Example 1 with Topo2OverlayCache

use of org.onosproject.ui.impl.topo.Topo2OverlayCache 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

IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 ServiceNotFoundException (org.onlab.osgi.ServiceNotFoundException)1 UiExtensionService (org.onosproject.ui.UiExtensionService)1 UiMessageHandler (org.onosproject.ui.UiMessageHandler)1 UiMessageHandlerFactory (org.onosproject.ui.UiMessageHandlerFactory)1 Topo2OverlayCache (org.onosproject.ui.impl.topo.Topo2OverlayCache)1