Package org.apache.geronimo.console.util

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


        Set setEnt = kernel.listGBeans(new org.apache.geronimo.gbean.AbstractNameQuery(null, query));
        Iterator iterator = setEnt.iterator();

        while (iterator.hasNext()) {
            AbstractName gb = (AbstractName) iterator.next();
            StringTree ejbModule = new StringTree(gb.getNameProperty("name"));

            if (gb.getNameProperty("J2EEApplication") == null
                    || gb.getNameProperty("J2EEApplication").equals("null")) {
                StringTree treeEnt = (StringTree) entApp.get("EJBModule");
                treeEnt.addChild(ejbModule);
            } else {
                StringTree treeEnt = (StringTree) entApp.get(gb
                        .getNameProperty("J2EEApplication"));
                treeEnt = treeEnt.findNode("EJBModule");
                treeEnt.addChild(ejbModule);
            }
            Map queryEnt = new HashMap();
            StringTree entityBean = new StringTree("EntityBeans");
            ejbModule.addChild(entityBean);
            queryEnt.put("j2eeType", "EntityBean");
            queryEnt.put("EJBModule", gb.getNameProperty("name"));
            queryEnt.put("J2EEApplication", gb
                    .getNameProperty("J2EEApplication"));
            Set setEntBean = kernel
                    .listGBeans(new org.apache.geronimo.gbean.AbstractNameQuery(
                            null, queryEnt));

            Iterator iterEntBean = setEntBean.iterator();

            while (iterEntBean.hasNext()) {
                AbstractName gbEntBean = (AbstractName) iterEntBean.next();
                StringTree beanNode = new StringTree(gbEntBean
                        .getNameProperty("name"));
                entityBean.addChild(beanNode);
                Context jndi = (Context) kernel.getAttribute(gbEntBean,
                        "componentContext");
                buildContext(beanNode, jndi, "java:comp");
            }

            queryEnt = new HashMap();
            StringTree sessionBean = new StringTree("SessionBeans");
            ejbModule.addChild(sessionBean);
            queryEnt.put("j2eeType", "StatelessSessionBean");
            queryEnt.put("EJBModule", gb.getNameProperty("name"));
            queryEnt.put("J2EEApplication", gb
                    .getNameProperty("J2EEApplication"));
            Set setSessionBean = kernel
                    .listGBeans(new org.apache.geronimo.gbean.AbstractNameQuery(
                            null, queryEnt));

            Iterator iterSessionBean = setSessionBean.iterator();

            while (iterSessionBean.hasNext()) {
                AbstractName gbSessionBean = (AbstractName) iterSessionBean
                        .next();
                StringTree beanNode = new StringTree(gbSessionBean
                        .getNameProperty("name"));
                sessionBean.addChild(beanNode);
                Context jndi = (Context) kernel.getAttribute(gbSessionBean,
                        "componentContext");
                buildContext(beanNode, jndi, "java:comp");
            }

            queryEnt = new HashMap();
            queryEnt.put("j2eeType", "StatefullSessionBean");
            queryEnt.put("EJBModule", gb.getNameProperty("name"));
            queryEnt.put("J2EEApplication", gb
                    .getNameProperty("J2EEApplication"));
            setSessionBean = kernel
                    .listGBeans(new org.apache.geronimo.gbean.AbstractNameQuery(
                            null, queryEnt));

            iterSessionBean = setSessionBean.iterator();

            while (iterSessionBean.hasNext()) {
                AbstractName gbSessionBean = (AbstractName) iterSessionBean
                        .next();
                StringTree beanNode = new StringTree(gbSessionBean
                        .getNameProperty("name"));
                sessionBean.addChild(beanNode);
                Context jndi = (Context) kernel.getAttribute(gbSessionBean,
                        "componentContext");
                buildContext(beanNode, jndi, "java:comp");
View Full Code Here


        Iterator iterator = setEnt.iterator();

        while (iterator.hasNext()) {

            AbstractName gb = (AbstractName) iterator.next();
            StringTree webModule = new StringTree(gb.getNameProperty("name"));

            if (gb.getNameProperty("J2EEApplication") == null
                    || gb.getNameProperty("J2EEApplication").equals("null")) {
                StringTree treeEnt = (StringTree) entApp.get("WebModule");
                treeEnt.addChild(webModule);
            } else {
                StringTree treeEnt = (StringTree) entApp.get(gb
                        .getNameProperty("J2EEApplication"));
                treeEnt = treeEnt.findNode("WebModule");
                treeEnt.addChild(webModule);
            }

            Map map = (Map) kernel.getAttribute(gb, "componentContext");
            String[] servlets = (String[]) kernel.getAttribute(gb, "servlets");

            StringTree servletsNode = null;
            StringTree jspNode = null;

            for (int i = 0; i < servlets.length; i++) {
                String servlet = servlets[i];
                servlet = servlet.substring(servlet.indexOf("name=") + 5);
                if (servlet.indexOf(",") != -1)
                    servlet = servlet.substring(0, servlet.indexOf(","));
                if (!servlet.equals("jsp") && servlet.startsWith("jsp.")) {
                    if (servletsNode == null) {
                        servletsNode = new StringTree("Servlets");
                        webModule.addChild(servletsNode);
                    }
                    if (jspNode == null) {
                        jspNode = new StringTree("JSP");
                        servletsNode.addChild(jspNode);
                    }
                    jspNode.addChild(new StringTree(servlet.substring(4)));
                } else if (!servlet.equals("jsp")) {
                    if (servletsNode == null) {
                        servletsNode = new StringTree("Servlets");
                        webModule.addChild(servletsNode);
                    }
                    servletsNode.addChild(new StringTree(servlet));
                }
            }
            Iterator contexts = map.keySet().iterator();
            while (contexts.hasNext())
                webModule.addChild(new StringTree("java:comp/" + contexts.next()));
        }
    }
View Full Code Here

        while (iterator.hasNext()) {
            AbstractName gb = (AbstractName) iterator.next();
            String resourceModule = gb.getNameProperty("name");
            if (gb.getNameProperty("J2EEApplication") == null
                    || gb.getNameProperty("J2EEApplication").equals("null")) {
                StringTree treeEnt = (StringTree) entApp
                        .get("ResourceAdapterModule");
                treeEnt.addChild(new StringTree(resourceModule));
            } else {
                StringTree treeEnt = (StringTree) entApp.get(gb
                        .getNameProperty("J2EEApplication"));
                treeEnt = treeEnt.findNode("ResourceAdapterModule");
                treeEnt.addChild(new StringTree(resourceModule));
            }
        }
    }
View Full Code Here

        while (iterator.hasNext()) {
            AbstractName gb = (AbstractName) iterator.next();
            String appClienteModule = gb.getNameProperty("name");
            if (gb.getNameProperty("J2EEApplication") == null
                    || gb.getNameProperty("J2EEApplication").equals("null")) {
                StringTree treeEnt = (StringTree) entApp.get("AppClientModule");
                treeEnt.addChild(new StringTree(appClienteModule));
            } else {
                StringTree treeEnt = (StringTree) entApp.get(gb
                        .getNameProperty("J2EEApplication"));
                treeEnt = treeEnt.findNode("AppClientModule");
                treeEnt.addChild(new StringTree(appClienteModule));
            }
        }
    }
View Full Code Here

                Object obj = ctx.lookup(pair.getName());
                if (obj instanceof Context) {
                    buildContext(node, (Context) obj, nodeCurr + "/"
                            + pair.getName());
                } else {
                    node.addChild(new StringTree(nodeCurr + "/" + pair.getName()));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
View Full Code Here

                    .next();
            Object obj = context.lookup(pair.getName());
            if (obj instanceof Context) {
                buildGlobal(tree, (Context) obj, parent + pair.getName());
            } else {
                tree.addChild(new StringTree(parent + pair.getName()));
            }
        }
    }
View Full Code Here

    public List getContextTree() throws Exception {
        List arryList = new ArrayList();
        Hashtable entApp = new Hashtable();

        StringTree treeGlobal = new StringTree("Global Context");
        arryList.add(treeGlobal);
        buildGlobal(treeGlobal,
                org.apache.xbean.naming.global.GlobalContextManager
                        .getGlobalContext(), "");

        StringTree tree = new StringTree("Enterprise Applications");
        arryList.add(tree);

        StringTree treeMod = new StringTree("EJBModule");
        entApp.put("EJBModule", treeMod);
        arryList.add(treeMod);

        treeMod = new StringTree("WebModule");
        entApp.put("WebModule", treeMod);
        arryList.add(treeMod);

        treeMod = new StringTree("ResourceAdapterModule");
        entApp.put("ResourceAdapterModule", treeMod);
        arryList.add(treeMod);

        treeMod = new StringTree("AppClientModule");
        entApp.put("AppClientModule", treeMod);
        arryList.add(treeMod);

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

        Set setEnt = kernel
                .listGBeans(new org.apache.geronimo.gbean.AbstractNameQuery(
                        null,
                        Collections.EMPTY_MAP,
                        org.apache.geronimo.j2ee.management.impl.J2EEApplicationImpl.class
                                .getName()));
        Iterator iterator = setEnt.iterator();
        while (iterator.hasNext()) {
            org.apache.geronimo.gbean.AbstractName gb = (org.apache.geronimo.gbean.AbstractName) iterator
                    .next();
            StringTree curr = new StringTree(gb.getNameProperty("name"));
            tree.addChild(curr);
            entApp.put(gb.getNameProperty("name"), curr);

            StringTree temp = new StringTree("EJBModule");
            curr.addChild(temp);

            temp = new StringTree("WebModule");
            curr.addChild(temp);

            temp = new StringTree("ResourceAdapterModule");
            curr.addChild(temp);

            temp = new StringTree("AppClientModule");
            curr.addChild(temp);
        }

        buildEJBModule(kernel, arryList, entApp);
        buildWebModule(kernel, arryList, entApp);
View Full Code Here

            return "[]";

        StringBuffer stb = new StringBuffer();
        stb.append("[");
        for (int i = 0; i < list.size(); i++) {
            StringTree node = (StringTree) list.get(i);
            if (i != 0)
                stb.append(",");
            stb.append(node.toJSONObject("" + i));
        }
        stb.append("]");
        return stb.toString();
    }
View Full Code Here

    }

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

    }

    public static ArrayList getTrees(RenderRequest request) {

        ArrayList arryList = new ArrayList();
        StringTree treeEAR = new StringTree("Enterprise Applications");
        arryList.add(treeEAR);

        StringTree treeEJB = new StringTree("EJBModule");
        arryList.add(treeEJB);

        StringTree treeWeb = new StringTree("WebModule");
        arryList.add(treeWeb);

        StringTree treeRAR = new StringTree("ResourceAdapterModule");
        arryList.add(treeRAR);

        StringTree treeCLI = new StringTree("AppClientModule");
        arryList.add(treeCLI);

        StringTree treeSys = new StringTree("System Module");
        arryList.add(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) {
                StringTree curr = new StringTree(info.getConfigID().toString());
                ;
                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()) {
                    StringTree nodeEJB = new StringTree("EJBModule");
                    curr.addChild(nodeEJB);

                    StringTree nodeWeb = new StringTree("WebModule");
                    curr.addChild(nodeWeb);

                    StringTree nodeRAR = new StringTree("ResourceAdapterModule");
                    curr.addChild(nodeRAR);

                    StringTree nodeCLI = new StringTree("AppClientModule");
                    curr.addChild(nodeCLI);

                    Map query = new HashMap();
                    query.put("j2eeType", "EJBModule");
                    query.put("J2EEApplication", info.getConfigID().toString());
                    Set setEnt = kernel
                            .listGBeans(new org.apache.geronimo.gbean.AbstractNameQuery(
                                    null, query));
                    Iterator iterator = setEnt.iterator();
                    while (iterator.hasNext()) {
                        AbstractName gb = (AbstractName) iterator.next();
                        StringTree subCurr = new StringTree(info.getConfigID()
                                .getGroupId()
                                + "/"
                                + info.getConfigID().getArtifactId()
                                + "_"
                                + gb.getNameProperty("name")
                                + "/"
                                + info.getConfigID().getVersion()
                                + "/"
                                + info.getConfigID().getType());
                        nodeEJB.addChild(subCurr);
                        addDependencies(subCurr, configManager
                                .getConfiguration(gb.getArtifact()));
                    }

                    Map query1 = new HashMap();
                    query1.put("j2eeType", "ResourceAdapterModule");
                    query1
                            .put("J2EEApplication", info.getConfigID()
                                    .toString());
                    Set setEnt1 = kernel
                            .listGBeans(new org.apache.geronimo.gbean.AbstractNameQuery(
                                    null, query1));

                    Iterator iterator1 = setEnt1.iterator();
                    while (iterator1.hasNext()) {
                        AbstractName gb = (AbstractName) iterator1.next();
                        StringTree subCurr = new StringTree(info.getConfigID()
                                .getGroupId()
                                + "/"
                                + info.getConfigID().getArtifactId()
                                + "_"
                                + gb.getNameProperty("name")
                                + "/"
                                + info.getConfigID().getVersion()
                                + "/"
                                + info.getConfigID().getType());
                        nodeRAR.addChild(subCurr);
                        addDependencies(subCurr, configManager
                                .getConfiguration(gb.getArtifact()));
                    }

                    for (int i = 0; i < conf.getChildren().size(); i++) {
                        Configuration config = ((Configuration) conf
                                .getChildren().get(i));
                        StringTree subCurr = new StringTree(config
                                .getAbstractName().toString());
                        nodeWeb.addChild(subCurr);
                        addDependencies(subCurr, config);
                    }

                    for (Iterator iter = conf.getOwnedConfigurations()
                            .iterator(); iter.hasNext();) {
                        Artifact name = (Artifact) iter.next();
                        StringTree subCurr = new StringTree(name.toString());
                        nodeCLI.addChild(subCurr);
                        addDependencies(subCurr, configManager
                                .getConfiguration(name));
                    }

                }

            }

        }

        StringTree treeRepo = new StringTree("Repository");
        arryList.add(treeRepo);

        ListableRepository[] repos = PortletManager.getCurrentServer(request)
                .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(fileName);
            }

        }

        return arryList;
View Full Code Here

TOP

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

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.