Search in sources :

Example 21 with StopWatch

use of org.perf4j.StopWatch in project cuba by cuba-platform.

the class WindowManager method openFrame.

public Frame openFrame(Frame parentFrame, Component parent, @Nullable String id, WindowInfo windowInfo, Map<String, Object> params) {
    if (params == null) {
        params = Collections.emptyMap();
    }
    // Parameters can be useful later
    params = createParametersMap(windowInfo, params);
    String src = windowInfo.getTemplate();
    ComponentLoaderContext context = new ComponentLoaderContext(params);
    context.setDsContext(parentFrame.getDsContext());
    context.setFullFrameId(windowInfo.getId());
    context.setCurrentFrameId(windowInfo.getId());
    LayoutLoader loader = new LayoutLoader(context, AppConfig.getFactory(), LayoutLoaderConfig.getFrameLoaders());
    loader.setLocale(getLocale());
    loader.setMessagesPack(parentFrame.getMessagesPack());
    StopWatch loadDescriptorWatch = new Slf4JStopWatch(windowInfo.getId() + "#" + LifeCycle.LOAD, LoggerFactory.getLogger(UIPerformanceLogger.class));
    Frame component;
    String frameId = id != null ? id : windowInfo.getId();
    Pair<ComponentLoader, Element> loaderElementPair = loader.createFrameComponent(src, frameId, context.getParams());
    component = (Frame) loaderElementPair.getFirst().getResultComponent();
    if (parent != null) {
        showFrame(parent, component);
    } else {
        component.setFrame(parentFrame);
    }
    loaderElementPair.getFirst().loadComponent();
    if (component.getMessagesPack() == null) {
        component.setMessagesPack(parentFrame.getMessagesPack());
    }
    context.executeInjectTasks();
    context.setFrame(component);
    context.executePostWrapTasks();
    // init of frame
    context.executeInitTasks();
    context.executePostInitTasks();
    loadDescriptorWatch.stop();
    initDebugIds(component);
    userActionsLog.trace("Frame {} was opened", windowInfo.getId());
    return component;
}
Also used : LayoutLoader(com.haulmont.cuba.gui.xml.layout.LayoutLoader) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) UIPerformanceLogger(com.haulmont.cuba.gui.logging.UIPerformanceLogger) Element(org.dom4j.Element) ComponentLoaderContext(com.haulmont.cuba.gui.xml.layout.loaders.ComponentLoaderContext) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch) ComponentLoader(com.haulmont.cuba.gui.xml.layout.ComponentLoader)

Example 22 with StopWatch

use of org.perf4j.StopWatch in project cuba by cuba-platform.

the class WindowManager method createWindow.

protected Window createWindow(WindowInfo windowInfo, OpenType openType, Map<String, Object> params, LayoutLoaderConfig layoutConfig, boolean topLevel) {
    if (!topLevel) {
        checkPermission(windowInfo);
    }
    StopWatch loadDescriptorWatch = new Slf4JStopWatch(windowInfo.getId() + "#" + LifeCycle.LOAD, LoggerFactory.getLogger(UIPerformanceLogger.class));
    Element element = screenXmlLoader.load(windowInfo.getTemplate(), windowInfo.getId(), params);
    // try to load main screen class to resolve dynamic compilation dependencies issues
    preloadMainScreenClass(element);
    ComponentLoaderContext componentLoaderContext = new ComponentLoaderContext(params);
    componentLoaderContext.setFullFrameId(windowInfo.getId());
    componentLoaderContext.setCurrentFrameId(windowInfo.getId());
    ComponentLoader windowLoader = createLayout(windowInfo, element, componentLoaderContext, layoutConfig);
    Window clientSpecificWindow = (Window) windowLoader.getResultComponent();
    Window windowWrapper = wrapByCustomClass(clientSpecificWindow, element);
    screenViewsLoader.deployViews(element);
    DsContext dsContext = loadDsContext(element);
    initDatasources(clientSpecificWindow, dsContext, params);
    componentLoaderContext.setDsContext(dsContext);
    WindowContext windowContext = new WindowContextImpl(clientSpecificWindow, openType, params);
    clientSpecificWindow.setContext(windowContext);
    dsContext.setFrameContext(windowContext);
    // noinspection unchecked
    windowLoader.loadComponent();
    clientSpecificWindow.setWindowManager(this);
    loadDescriptorWatch.stop();
    initWrapperFrame(windowWrapper, componentLoaderContext, element, params);
    componentLoaderContext.setFrame(windowWrapper);
    componentLoaderContext.executePostInitTasks();
    if (configuration.getConfig(GlobalConfig.class).getTestMode()) {
        initDebugIds(clientSpecificWindow);
    }
    StopWatch uiPermissionsWatch = new Slf4JStopWatch(windowInfo.getId() + "#" + LifeCycle.UI_PERMISSIONS, LoggerFactory.getLogger(UIPerformanceLogger.class));
    // apply ui permissions
    WindowCreationHelper.applyUiPermissions(clientSpecificWindow);
    uiPermissionsWatch.stop();
    return windowWrapper;
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) UIPerformanceLogger(com.haulmont.cuba.gui.logging.UIPerformanceLogger) DsContext(com.haulmont.cuba.gui.data.DsContext) Element(org.dom4j.Element) ComponentLoaderContext(com.haulmont.cuba.gui.xml.layout.loaders.ComponentLoaderContext) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch) ComponentLoader(com.haulmont.cuba.gui.xml.layout.ComponentLoader)

Example 23 with StopWatch

use of org.perf4j.StopWatch in project cuba by cuba-platform.

the class WindowManager method openEditor.

public Window.Editor openEditor(WindowInfo windowInfo, Entity item, OpenType openType, Map<String, Object> params, Datasource parentDs) {
    if (params == null) {
        params = Collections.emptyMap();
    }
    checkCanOpenWindow(windowInfo, openType, params);
    Integer hashCode = getHash(windowInfo, params);
    String template = windowInfo.getTemplate();
    if (openType.getOpenMode() != OpenMode.DIALOG) {
        Window existingWindow = getWindow(hashCode);
        if (existingWindow != null) {
            params = createParametersMap(windowInfo, params);
            String caption = loadCaption(existingWindow, params);
            String description = loadDescription(existingWindow, params);
            showWindow(existingWindow, caption, description, openType, false);
            return (Window.Editor) existingWindow;
        }
    }
    params = createParametersMap(windowInfo, params);
    WindowParams.ITEM.set(params, item instanceof Datasource ? ((Datasource) item).getItem() : item);
    Window window;
    if (template != null) {
        window = createWindow(windowInfo, openType, params, LayoutLoaderConfig.getEditorLoaders(), false);
    } else {
        Class windowClass = windowInfo.getScreenClass();
        if (windowClass != null) {
            window = createWindow(windowInfo, params);
            if (!(window instanceof Window.Editor)) {
                throw new IllegalStateException(String.format("Class %s does't implement Window.Editor interface", windowClass));
            }
        } else {
            throw new IllegalStateException("Invalid WindowInfo: " + windowInfo);
        }
    }
    ((Window.Editor) window).setParentDs(parentDs);
    StopWatch setItemWatch = new Slf4JStopWatch(windowInfo.getId() + "#" + LifeCycle.SET_ITEM, LoggerFactory.getLogger(UIPerformanceLogger.class));
    ((Window.Editor) window).setItem(item);
    setItemWatch.stop();
    String caption = loadCaption(window, params);
    String description = loadDescription(window, params);
    showWindow(window, caption, description, openType, false);
    userActionsLog.trace("Editor {} was opened", windowInfo.getId());
    return (Window.Editor) window;
}
Also used : Datasource(com.haulmont.cuba.gui.data.Datasource) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) UIPerformanceLogger(com.haulmont.cuba.gui.logging.UIPerformanceLogger) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Example 24 with StopWatch

use of org.perf4j.StopWatch in project cuba by cuba-platform.

the class WindowManager method createWindow.

protected Window createWindow(WindowInfo windowInfo, Map<String, Object> params) {
    Window window;
    try {
        window = (Window) windowInfo.getScreenClass().newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
        throw new RuntimeException("Unable to instantiate window class", e);
    }
    window.setId(windowInfo.getId());
    window.setWindowManager(this);
    init(window, params);
    StopWatch uiPermissionsWatch = new Slf4JStopWatch(windowInfo.getId() + "#" + LifeCycle.UI_PERMISSIONS, LoggerFactory.getLogger(UIPerformanceLogger.class));
    // apply ui permissions
    WindowCreationHelper.applyUiPermissions(window);
    uiPermissionsWatch.stop();
    return window;
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) UIPerformanceLogger(com.haulmont.cuba.gui.logging.UIPerformanceLogger) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Example 25 with StopWatch

use of org.perf4j.StopWatch in project cuba by cuba-platform.

the class MenuCommand method execute.

public void execute() {
    StopWatch sw = new Slf4JStopWatch("MenuItem." + item.getId());
    command.run();
    sw.stop();
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Aggregations

StopWatch (org.perf4j.StopWatch)41 Slf4JStopWatch (org.perf4j.slf4j.Slf4JStopWatch)41 UIPerformanceLogger (com.haulmont.cuba.gui.logging.UIPerformanceLogger)17 Element (org.dom4j.Element)4 Transaction (com.haulmont.cuba.core.Transaction)3 Test (org.testng.annotations.Test)3 Node (com.haulmont.bali.datastruct.Node)2 MetaClass (com.haulmont.chile.core.model.MetaClass)2 AppFolder (com.haulmont.cuba.core.entity.AppFolder)2 ComponentLoader (com.haulmont.cuba.gui.xml.layout.ComponentLoader)2 ComponentLoaderContext (com.haulmont.cuba.gui.xml.layout.loaders.ComponentLoaderContext)2 SearchFolder (com.haulmont.cuba.security.entity.SearchFolder)2 Binding (groovy.lang.Binding)2 IOException (java.io.IOException)2 KryoException (com.esotericsoftware.kryo.KryoException)1 Pair (com.haulmont.bali.datastruct.Pair)1 Tree (com.haulmont.bali.datastruct.Tree)1 MetaModel (com.haulmont.chile.core.model.MetaModel)1 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 EntityManager (com.haulmont.cuba.core.EntityManager)1