Search in sources :

Example 1 with ManagedBeanDomain

use of com.haulmont.cuba.web.jmx.entity.ManagedBeanDomain in project cuba by cuba-platform.

the class ManagedBeanInfoDatasource method loadTree.

@Override
protected Tree<ManagedBeanInfo> loadTree(Map<String, Object> params) {
    String tag = getLoggingTag("TDS");
    StopWatch sw = new Slf4JStopWatch(tag, LoggerFactory.getLogger(UIPerformanceLogger.class));
    List<Node<ManagedBeanInfo>> nodes = new ArrayList<>();
    if (jmxInstance != null) {
        List<ManagedBeanDomain> domains = jmxControlAPI.getDomains(jmxInstance);
        Map<String, Node<ManagedBeanInfo>> domainMap = new HashMap<>();
        for (ManagedBeanDomain mbd : domains) {
            ManagedBeanInfo dummy = metadata.create(ManagedBeanInfo.class);
            dummy.setDomain(mbd.getName());
            Node<ManagedBeanInfo> node = new Node<>(dummy);
            domainMap.put(mbd.getName(), node);
            nodes.add(node);
        }
        List<ManagedBeanInfo> list = loadManagedBeans(params);
        for (ManagedBeanInfo mbi : list) {
            if (mbi != null) {
                if (domainMap.containsKey(mbi.getDomain())) {
                    domainMap.get(mbi.getDomain()).addChild(new Node<>(mbi));
                }
            }
        }
        // remove root nodes that might have left without children after filtering
        for (Node<ManagedBeanInfo> rootNode : new ArrayList<>(nodes)) {
            if (rootNode.getChildren().isEmpty()) {
                nodes.remove(rootNode);
            }
        }
    }
    sw.stop();
    return new Tree<>(nodes);
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) UIPerformanceLogger(com.haulmont.cuba.gui.logging.UIPerformanceLogger) Node(com.haulmont.bali.datastruct.Node) ManagedBeanInfo(com.haulmont.cuba.web.jmx.entity.ManagedBeanInfo) ManagedBeanDomain(com.haulmont.cuba.web.jmx.entity.ManagedBeanDomain) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch) Tree(com.haulmont.bali.datastruct.Tree)

Aggregations

Node (com.haulmont.bali.datastruct.Node)1 Tree (com.haulmont.bali.datastruct.Tree)1 UIPerformanceLogger (com.haulmont.cuba.gui.logging.UIPerformanceLogger)1 ManagedBeanDomain (com.haulmont.cuba.web.jmx.entity.ManagedBeanDomain)1 ManagedBeanInfo (com.haulmont.cuba.web.jmx.entity.ManagedBeanInfo)1 StopWatch (org.perf4j.StopWatch)1 Slf4JStopWatch (org.perf4j.slf4j.Slf4JStopWatch)1