Package org.apache.geronimo.console.util

Examples of org.apache.geronimo.console.util.TreeEntry


        return tree;
    }

    public List<TreeEntry> getDeployments(DeploymentInfo[] deploymentInfos) {
        List<TreeEntry> deployments = new ArrayList<TreeEntry>();
        TreeEntry deploymentsEntry = null;
        for (DeploymentInfo deployment : deploymentInfos) {
            deploymentsEntry = new TreeEntry();
            deploymentsEntry.setName(deployment.getEjbName());
            deploymentsEntry.setValues(new String[]{
                    deployment.getContainer().getContainerID().toString(),
                    deployment.getDeploymentID().toString()});
            deploymentsEntry.setChildren(new ArrayList<TreeEntry>());
            deployments.add(deploymentsEntry);
        }
        return deployments;
    }
View Full Code Here


        Container container = null;
        ContainerSystemInfo systemInfo = configuration.containerSystem;
        Map<ContainerType, TreeEntry> containerMap = new TreeMap<ContainerType, TreeEntry>();
        List<ContainerInfo> containerInfos = systemInfo.containers;
        ContainerInfo containerInfo = null;
        TreeEntry containerTypesEntry, containersEntry, deploymentsEntry = null;
        Tree tree = new Tree("name", "name");
        List<TreeEntry> entries = new ArrayList<TreeEntry>();
        for (int i = 0; i < containerInfos.size(); i++) {

            containerInfo = containerInfos.get(i);
            container = containerSystem.getContainer(containerInfo.id);
            List<TreeEntry> containers = null;
            if (containerMap.get(container.getContainerType()) != null) {
                containerTypesEntry = containerMap.get(container.getContainerType());
                containers = containerTypesEntry.getChildren();
            } else {
                containerTypesEntry = new TreeEntry();
                containerTypesEntry.setName(resolveContainerTypes(container.getContainerType()));
                containerTypesEntry.setValues(new String[]{containerTypesEntry.getName()});
                containers = new ArrayList<TreeEntry>();
                containerTypesEntry.setChildren(containers);
                containerMap.put(container.getContainerType(),containerTypesEntry);
                entries.add(containerTypesEntry);
            }
            containersEntry = new TreeEntry();
            containersEntry.setName(containerInfo.id);
            containersEntry.setValues(new String[]{containerInfo.id});

            DeploymentInfo[] deployments = container.deployments();
            containersEntry.setChildren(getDeployments(deployments));
View Full Code Here

        return tree;
    }

    public List<TreeEntry> getDeployments(DeploymentInfo[] deploymentInfos) {
        List<TreeEntry> deployments = new ArrayList<TreeEntry>();
        TreeEntry deploymentsEntry = null;
        for (DeploymentInfo deployment : deploymentInfos) {
            deploymentsEntry = new TreeEntry();
            deploymentsEntry.setName(deployment.getEjbName());
            deploymentsEntry.setValues(new String[]{
                    deployment.getContainer().getContainerID().toString(),
                    deployment.getDeploymentID().toString()});
            deploymentsEntry.setChildren(new ArrayList<TreeEntry>());
            deployments.add(deploymentsEntry);
        }
        return deployments;
    }
View Full Code Here

        return this.printClassLoaders();
    }

    public TreeEntry inverseTree(ClassLoader classloader) {
        TreeEntry node = nodeHash.get(classloader.toString());
        if (null != node)
            return node;
        node = new TreeEntry(classloader.toString(), "root");
        node = addClasses(node, classloader);
        nodeHash.put(node.getName(), node);

        if (classloader instanceof MultiParentClassLoader) {
            MultiParentClassLoader mpclassloader = (MultiParentClassLoader) classloader;
            ClassLoader[] parents = mpclassloader.getParents();
            if (null != parents && 0 < parents.length) {
                for (int i = 0; i < parents.length; i++) {
                    TreeEntry parentNode = inverseTree(parents[i]);
                    node.addChild(parentNode);
                }
            }
        } else if (classloader.getParent() != null) {
            TreeEntry parentNode = inverseTree(classloader.getParent());
            node.addChild(parentNode);
        }

        return node;
    }
View Full Code Here

        return node;
    }

    public TreeEntry updateTree(ClassLoader classloader) {

        TreeEntry node = nodeHash.get(classloader.toString());
        if (null != node)
            return node;

        node = new TreeEntry(classloader.toString(), NORMAL_TYPE);
        node = addClasses(node, classloader);
        nodeHash.put(node.getName(), node);

        if (classloader instanceof MultiParentClassLoader) {
            MultiParentClassLoader mpclassloader = (MultiParentClassLoader) classloader;
            ClassLoader[] parents = mpclassloader.getParents();
            if (null != parents && 0 < parents.length) {
                for (int i = 0; i < parents.length; i++) {
                    TreeEntry parentNode = updateTree(parents[i]);
                    parentNode.addChild(node);
                }
            }
        } else if (classloader.getParent() != null) {
            TreeEntry parentNode = updateTree(classloader.getParent());
            parentNode.addChild(node);
        } else {
            node.setType("root");
        }

        return node;
View Full Code Here

                classes.toArray(result);
            }

            CLASSES_VECTOR_FIELD.setAccessible(false);

            TreeEntry classNames = new TreeEntry("Classes", NORMAL_TYPE);
            TreeEntry interfaceNames = new TreeEntry("Interfaces", NORMAL_TYPE);
            node.addChild(classNames);
            node.addChild(interfaceNames);

            for (int i = 0; i < result.length; i++) {
                if (result[i].isInterface())
                    interfaceNames.addChild(new TreeEntry(result[i].toString(), NORMAL_TYPE));
                else
                    classNames.addChild(new TreeEntry(result[i].toString(), NORMAL_TYPE));
            }
            if (classNames.getChildren().size() < 1)
                classNames.addChild(new TreeEntry(NO_CHILD, NORMAL_TYPE));
            if (interfaceNames.getChildren().size() < 1)
                interfaceNames.addChild(new TreeEntry(NO_CHILD, NORMAL_TYPE));
            return node;
        } catch (Exception e) {
            return node;
        }
    }
View Full Code Here

    private static final Logger logger = LoggerFactory.getLogger(DependencyViewHelper.class);

    public static void addDependencies(TreeEntry curr, Configuration conf) {
        if (curr == null || conf == null)
            return;
        TreeEntry dep = new TreeEntry("dependencies", NOT_LEAF_TYPE);
        curr.addChild(dep);
        for (Iterator iterator = conf.getDependencies().iterator(); iterator.hasNext();) {
            dep.addChild(new TreeEntry(iterator.next().toString(), NORMAL_TYPE));
        }
        for (Iterator iterator = conf.getServiceParents().iterator(); iterator.hasNext();) {
            Configuration config = (Configuration) iterator.next();
            dep.addChild(new TreeEntry(config.getId().toString(), NORMAL_TYPE));
        }
    }
View Full Code Here

        StringBuilder sb = new StringBuilder(512);

        sb.append("{label:\"name\",identifier:\"id\",items:[");
        Iterator<TreeEntry> list = allNodes.iterator();
        while (list.hasNext()) {
            TreeEntry curr = list.next();
            sb.append("{name:\"").append(curr.getName())
            .append("\",id:\"").append(curr.getId())
            .append("\",type:\"").append(curr.getType())
            .append("\",children:[");

            Iterator<TreeEntry> children = curr.getChildren().iterator();
            // the first child is Classes and the second one is Interfaces
            printClasses(sb, children.next());
            sb.append(",");
            printClasses(sb, children.next());
            while (children.hasNext()) {
                TreeEntry child = children.next();
                sb.append(",{_reference:\"").append(child.getId()).append("\"}");
            }
            if (list.hasNext())
                sb.append("]},");
            else
                sb.append("]}");
View Full Code Here

        sb.append("{name:\"").append(classes.getName())
        .append("\",id:\"").append(classes.getId())
        .append("\",children:[");
        Iterator<TreeEntry> children = classes.getChildren().iterator();
        while (children.hasNext()) {
            TreeEntry child = children.next();
            sb.append("{name:\"").append(child.getName())
            .append("\",id:\"").append(child.getId())
            .append("\"}");
            if (children.hasNext())
                sb.append(",");
        }
        sb.append("]}");
View Full Code Here

    @RemoteMethod
    public static Tree getTrees(HttpSession session) {
        Tree dependencyTree = new Tree(null, "name");

        TreeEntry treeEAR = new TreeEntry("Enterprise Applications", NOT_LEAF_TYPE);
        dependencyTree.addItem(treeEAR);

        TreeEntry treeEJB = new TreeEntry("EJBModule", NOT_LEAF_TYPE);
        dependencyTree.addItem(treeEJB);

        TreeEntry treeWeb = new TreeEntry("WebModule", NOT_LEAF_TYPE);
        dependencyTree.addItem(treeWeb);

        TreeEntry treeRAR = new TreeEntry("ResourceAdapterModule", NOT_LEAF_TYPE);
        dependencyTree.addItem(treeRAR);

        TreeEntry treeCLI = new TreeEntry("AppClientModule", NOT_LEAF_TYPE);
        dependencyTree.addItem(treeCLI);

        TreeEntry treeSys = new TreeEntry("System Module", NOT_LEAF_TYPE);
        dependencyTree.addItem(treeSys);

        org.apache.geronimo.kernel.Kernel kernel = org.apache.geronimo.kernel.KernelRegistry.getSingleKernel();

        ConfigurationManager configManager = ConfigurationUtil.getConfigurationManager(kernel);

        List infos = configManager.listConfigurations();
        for (Iterator infoIterator = infos.iterator(); infoIterator.hasNext();) {
            ConfigurationInfo info = (ConfigurationInfo) infoIterator.next();
            Configuration conf = configManager.getConfiguration(info.getConfigID());
            if (conf != null) {
                TreeEntry curr = new TreeEntry(info.getConfigID().toString(), NORMAL_TYPE);
                switch (info.getType().getValue()) {
                case 0:// EAR
                {
                    treeEAR.addChild(curr);
                    break;
                }
                case 1:// EJB
                {
                    treeEJB.addChild(curr);
                    break;
                }
                case 2:// CAR
                {
                    treeCLI.addChild(curr);
                    break;
                }

                case 3:// RAR
                {
                    treeRAR.addChild(curr);
                    break;
                }
                case 4:// WAR
                {
                    treeWeb.addChild(curr);
                    break;
                }
                case 5:// SERVICE
                {
                    treeSys.addChild(curr);
                    break;
                }
                }

                addDependencies(curr, conf);

                if (info.getType().getValue() == ConfigurationModuleType.EAR.getValue()) {
                    TreeEntry nodeEJB = new TreeEntry("EJBModule", NOT_LEAF_TYPE);
                    curr.addChild(nodeEJB);

                    TreeEntry nodeWeb = new TreeEntry("WebModule", NOT_LEAF_TYPE);
                    curr.addChild(nodeWeb);

                    TreeEntry nodeRAR = new TreeEntry("ResourceAdapterModule", NOT_LEAF_TYPE);
                    curr.addChild(nodeRAR);

                    TreeEntry nodeCLI = new TreeEntry("AppClientModule", NOT_LEAF_TYPE);
                    curr.addChild(nodeCLI);

                    Map<String, String> query = new HashMap<String, String>();
                    query.put("j2eeType", "EJBModule");
                    query.put("J2EEApplication", info.getConfigID().toString());
                    Set<AbstractName> setEnt = kernel.listGBeans(new AbstractNameQuery(null, query));
                    for (AbstractName gb : setEnt) {
                        TreeEntry subCurr = new TreeEntry(info.getConfigID().getGroupId() + "/"
                                + info.getConfigID().getArtifactId() + "_" + gb.getNameProperty("name") + "/"
                                + info.getConfigID().getVersion() + "/" + info.getConfigID().getType(), NORMAL_TYPE);
                        nodeEJB.addChild(subCurr);
                        addDependencies(subCurr, configManager.getConfiguration(gb.getArtifact()));
                    }

                    Map<String, String> query1 = new HashMap<String, String>();
                    query1.put("j2eeType", "ResourceAdapterModule");
                    query1.put("J2EEApplication", info.getConfigID().toString());
                    Set<AbstractName> setEnt1 = kernel.listGBeans(new AbstractNameQuery(null, query1));

                    for (AbstractName gb : setEnt1) {
                        TreeEntry subCurr = new TreeEntry(info.getConfigID().getGroupId() + "/"
                                + info.getConfigID().getArtifactId() + "_" + gb.getNameProperty("name") + "/"
                                + info.getConfigID().getVersion() + "/" + info.getConfigID().getType(), NORMAL_TYPE);
                        nodeRAR.addChild(subCurr);
                        addDependencies(subCurr, configManager.getConfiguration(gb.getArtifact()));
                    }

                    for (Configuration config : conf.getChildren()) {
                        TreeEntry subCurr = new TreeEntry(config.getAbstractName().toString(), NORMAL_TYPE);
                        nodeWeb.addChild(subCurr);
                        addDependencies(subCurr, config);
                    }

                    for (Artifact name : conf.getOwnedConfigurations()) {
                        TreeEntry subCurr = new TreeEntry(name.toString(), NORMAL_TYPE);
                        nodeCLI.addChild(subCurr);
                        addDependencies(subCurr, configManager.getConfiguration(name));
                    }

                }

            }

        }

        TreeEntry treeRepo = new TreeEntry("Repository", NORMAL_TYPE);
        dependencyTree.addItem(treeRepo);
        J2EEServer server = (J2EEServer) session.getAttribute(DependencyViewPortlet.Server_Key);
        if (null == server) {
            logger.error("can not find expected J2EEServer object");
            treeRepo.addChild(new TreeEntry("Not found the content of repository", NORMAL_TYPE));// Ignore the error at client
            return dependencyTree;
        }
        session.removeAttribute(DependencyViewPortlet.Server_Key);
        ListableRepository[] repos = server.getRepositories();
        for (int i = 0; i < repos.length; i++) {
            ListableRepository repo = repos[i];
            final SortedSet artifacts = repo.list();
            for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
                String fileName = iterator.next().toString();
                treeRepo.addChild(new TreeEntry(fileName, NORMAL_TYPE));
            }
        }
        check_no_child(dependencyTree.getItems());
        return dependencyTree;
    }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.console.util.TreeEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.