⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tomcattreebuilder.java

📁 精通tomcat书籍原代码,希望大家共同学习
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        Iterator hostNames =
            Lists.getHosts(mBServer, serviceName).iterator();
        while (hostNames.hasNext()) {
            String hostName = (String) hostNames.next();
            ObjectName objectName = new ObjectName(hostName);
            String nodeLabel =
                resources.getMessage(locale, 
                    "server.service.treeBuilder.host") + " (" +
                    objectName.getKeyProperty("host") + ")";
            TreeControlNode hostNode =
                new TreeControlNode(hostName,
                                    "Host.gif",
                                    nodeLabel,
                                    "EditHost.do?select=" +
                                    URLEncoder.encode(hostName,URL_ENCODING) +
                                    "&nodeLabel=" +
                                    URLEncoder.encode(nodeLabel,URL_ENCODING),
                                    "content",
                                    false, domain);
            serviceNode.addChild(hostNode);
            getContexts(hostNode, hostName);            
            getRealms(hostNode, hostName);
            getValves(hostNode, hostName);
        }

    }    

    
    /**
     * Append nodes for all defined contexts for the specified host.
     *
     * @param hostNode Host node for the tree control
     * @param hostName Object name of the parent host
     * @param resources The MessageResources for our localized messages
     *  messages
     *
     * @exception Exception if an exception occurs building the tree
     */
    public void getContexts(TreeControlNode hostNode, String hostName) 
        throws Exception {
        
        String domain = hostNode.getDomain();
        Iterator contextNames =
            Lists.getContexts(mBServer, hostName).iterator();
        while (contextNames.hasNext()) {
            String contextName = (String) contextNames.next();
            ObjectName objectName = new ObjectName(contextName);
            String name = objectName.getKeyProperty("name");
            name = name.substring(2);
            int i = name.indexOf("/");
            String path = name.substring(i);
            String nodeLabel =
                resources.getMessage(locale, 
                    "server.service.treeBuilder.context") + " (" + path + ")";
            TreeControlNode contextNode =
                new TreeControlNode(contextName,
                                    "Context.gif",
                                    nodeLabel,
                                    "EditContext.do?select=" +
                                    URLEncoder.encode(contextName,URL_ENCODING) +
                                    "&nodeLabel=" +
                                    URLEncoder.encode(nodeLabel,URL_ENCODING),
                                    "content",
                                    false, domain);
            hostNode.addChild(contextNode);
            getResources(contextNode, contextName);
            getRealms(contextNode, contextName);
            getValves(contextNode, contextName);
        }
    }
    
    /**
     * Append nodes for any defined realms for the specified container.
     *
     * @param containerNode Container node for the tree control
     * @param containerName Object name of the parent container
     *
     * @exception Exception if an exception occurs building the tree
     */
    public void getRealms(TreeControlNode containerNode,
                          String containerName) throws Exception {

        String domain = containerNode.getDomain();
        Iterator realmNames =
            Lists.getRealms(mBServer, containerName).iterator();
        while (realmNames.hasNext()) {
            String realmName = (String) realmNames.next();
	    ObjectName objectName = new ObjectName(realmName);
            // Create tree nodes for non JAASRealm only
            try {
                mBServer.getAttribute(objectName, "validate");
            } catch (AttributeNotFoundException e) {
                String nodeLabel = resources.getMessage(locale, 
                    "server.service.treeBuilder.realmFor", 
                    containerNode.getLabel());
	        TreeControlNode realmNode =
		    new TreeControlNode(realmName,
                                    "Realm.gif",
                                    nodeLabel,
                                    "EditRealm.do?select=" +
                                    URLEncoder.encode(realmName,URL_ENCODING) +
                                    "&nodeLabel=" +
                                    URLEncoder.encode(nodeLabel,URL_ENCODING),
                                    "content",
                                    false, domain);
                containerNode.addChild(realmNode);
            }
        }
        
    }   
        
    
    /**
     * Append nodes for any define resources for the specified Context.
     *
     * @param containerNode Container node for the tree control
     * @param containerName Object name of the parent container
     * @param resources The MessageResources for our localized messages
     *  messages
     */
    public void getResources(TreeControlNode containerNode, String containerName) 
        throws Exception {

        String domain = containerNode.getDomain();
        ObjectName oname = new ObjectName(containerName);
        String type = oname.getKeyProperty("type");
        if (type == null) {
            type = oname.getKeyProperty("j2eeType");
            if (type.equals("WebModule")) {
                type = "Context";
            } else {
                type = "";
            }
        }
        String path = "";
        String host = "";
        String name = oname.getKeyProperty("name");
        if ((name != null) && (name.length() > 0)) {
            // context resource
            name = name.substring(2);
            int i = name.indexOf("/");
            host = name.substring(0,i);
            path = name.substring(i);
        }     
        TreeControlNode subtree = new TreeControlNode
            ("Context Resource Administration " + containerName,
             "folder_16_pad.gif",
             resources.getMessage(locale, "resources.treeBuilder.subtreeNode"),
             null,
             "content",
             true, domain);        
        containerNode.addChild(subtree);
        TreeControlNode datasources = new TreeControlNode
            ("Context Data Sources " + containerName,
            "Datasource.gif",
            resources.getMessage(locale, "resources.treeBuilder.datasources"),
            "resources/listDataSources.do?resourcetype=" + 
                URLEncoder.encode(type,URL_ENCODING) + "&path=" +
                URLEncoder.encode(path,URL_ENCODING) + "&host=" + 
                URLEncoder.encode(host,URL_ENCODING) + "&domain=" + 
                URLEncoder.encode(domain,URL_ENCODING) + "&forward=" +
                URLEncoder.encode("DataSources List Setup",URL_ENCODING),
            "content",
            false, domain);
        TreeControlNode mailsessions = new TreeControlNode
            ("Context Mail Sessions " + containerName,
            "Mailsession.gif",
            resources.getMessage(locale, "resources.treeBuilder.mailsessions"),
            "resources/listMailSessions.do?resourcetype=" + 
                URLEncoder.encode(type,URL_ENCODING) + "&path=" +
                URLEncoder.encode(path,URL_ENCODING) + "&host=" + 
                URLEncoder.encode(host,URL_ENCODING) + "&domain=" + 
                URLEncoder.encode(domain,URL_ENCODING) + "&forward=" +
                URLEncoder.encode("MailSessions List Setup",URL_ENCODING),
            "content",
            false, domain);
        TreeControlNode resourcelinks = new TreeControlNode
            ("Resource Links " + containerName,
            "ResourceLink.gif",
            resources.getMessage(locale, "resources.treeBuilder.resourcelinks"),
            "resources/listResourceLinks.do?resourcetype=" + 
                URLEncoder.encode(type,URL_ENCODING) + "&path=" +
                URLEncoder.encode(path,URL_ENCODING) + "&host=" + 
                URLEncoder.encode(host,URL_ENCODING) + "&domain=" + 
                URLEncoder.encode(domain,URL_ENCODING) + "&forward=" +
                URLEncoder.encode("ResourceLinks List Setup",URL_ENCODING),
            "content",
            false, domain);
        TreeControlNode envs = new TreeControlNode
            ("Context Environment Entries "+ containerName,
            "EnvironmentEntries.gif",
            resources.getMessage(locale, "resources.env.entries"),
            "resources/listEnvEntries.do?resourcetype=" + 
                URLEncoder.encode(type,URL_ENCODING) + "&path=" +
                URLEncoder.encode(path,URL_ENCODING) + "&host=" + 
                URLEncoder.encode(host,URL_ENCODING) + "&domain=" + 
                URLEncoder.encode(domain,URL_ENCODING) + "&forward=" +
                URLEncoder.encode("EnvEntries List Setup",URL_ENCODING),
            "content",
            false, domain);
        subtree.addChild(datasources);
        subtree.addChild(mailsessions);
        subtree.addChild(resourcelinks);
        subtree.addChild(envs);
    }
    
    
   /**
     * Append nodes for any defined valves for the specified container.
     *
     * @param containerNode Container node for the tree control
     * @param containerName Object name of the parent container
     *
     * @exception Exception if an exception occurs building the tree
     */
    public void getValves(TreeControlNode containerNode,
                          String containerName) throws Exception {

        String domain = containerNode.getDomain();
        Iterator valveNames =
                Lists.getValves(mBServer, containerName).iterator();        
        while (valveNames.hasNext()) {
            String valveName = (String) valveNames.next();
            ObjectName objectName = new ObjectName(valveName);
            String nodeLabel = "Valve for " + containerNode.getLabel();
            TreeControlNode valveNode =
                new TreeControlNode(valveName,
                                    "Valve.gif",
                                    nodeLabel,
                                    "EditValve.do?select=" +
                                    URLEncoder.encode(valveName,URL_ENCODING) +
                                    "&nodeLabel=" +
                                    URLEncoder.encode(nodeLabel,URL_ENCODING) +
                                    "&parent=" +
                                    URLEncoder.encode(containerName,URL_ENCODING),
                                    "content",
                                    false, domain);
            containerNode.addChild(valveNode);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -