0001: /**
0002: * JOnAS: Java(TM) Open Application Server
0003: * Copyright (C) 1999-2004 Bull S.A.
0004: * Contact: jonas-team@objectweb.org
0005: *
0006: * This library is free software; you can redistribute it and/or
0007: * modify it under the terms of the GNU Lesser General Public
0008: * License as published by the Free Software Foundation; either
0009: * version 2.1 of the License, or any later version.
0010: *
0011: * This library is distributed in the hope that it will be useful,
0012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0014: * Lesser General Public License for more details.
0015: *
0016: * You should have received a copy of the GNU Lesser General Public
0017: * License along with this library; if not, write to the Free Software
0018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
0019: * USA
0020: *
0021: * --------------------------------------------------------------------------
0022: * $Id: JonasTreeBuilder.java 10139 2007-04-02 15:16:44Z danesa $
0023: * --------------------------------------------------------------------------
0024: */package org.objectweb.jonas.webapp.jonasadmin;
0025:
0026: import java.net.URLEncoder;
0027: import java.util.ArrayList;
0028: import java.util.Collection;
0029: import java.util.Collections;
0030: import java.util.HashMap;
0031: import java.util.Iterator;
0032: import java.util.List;
0033: import java.util.Set;
0034: import java.util.StringTokenizer;
0035:
0036: import javax.management.MBeanAttributeInfo;
0037: import javax.management.MBeanInfo;
0038: import javax.management.MBeanOperationInfo;
0039: import javax.management.MalformedObjectNameException;
0040: import javax.management.ObjectName;
0041: import javax.servlet.http.HttpServletRequest;
0042:
0043: import org.allesta.wsabi.j2ee.Handler;
0044: import org.allesta.wsabi.j2ee.PortComponent;
0045: import org.allesta.wsabi.j2ee.WebServiceDescription;
0046: import org.allesta.wsabi.j2ee.provider.GenericDomainCapableProvider;
0047: import org.allesta.wsabi.j2ee.provider.jonas.JonasProvider;
0048: import org.apache.struts.Globals;
0049: import org.apache.struts.action.ActionServlet;
0050: import org.apache.struts.util.MessageResources;
0051: import org.objectweb.jonas.jmx.CatalinaObjectName;
0052: import org.objectweb.jonas.jmx.J2eeObjectName;
0053: import org.objectweb.jonas.jmx.JonasManagementRepr;
0054: import org.objectweb.jonas.jmx.JonasObjectName;
0055: import org.objectweb.jonas.jmx.JoramObjectName;
0056: import org.objectweb.jonas.webapp.jonasadmin.catalina.ConnectorItem;
0057: import org.objectweb.jonas.webapp.jonasadmin.catalina.ConnectorItemByPort;
0058: import org.objectweb.jonas.webapp.jonasadmin.common.BeanComparator;
0059: import org.objectweb.jonas.webapp.jonasadmin.joramplatform.ItemDestination;
0060: import org.objectweb.jonas.webapp.jonasadmin.logging.LoggerItem;
0061: import org.objectweb.jonas.webapp.jonasadmin.mbean.J2eeMbeanItem;
0062: import org.objectweb.jonas.webapp.jonasadmin.mbean.MbeanItem;
0063: import org.objectweb.jonas.webapp.jonasadmin.mbean.OwnerMbeanItem;
0064: import org.objectweb.jonas.webapp.jonasadmin.service.container.ContainerItem;
0065: import org.objectweb.jonas.webapp.jonasadmin.service.container.ContainerItemByFile;
0066: import org.objectweb.jonas.webapp.jonasadmin.service.container.WebAppItem;
0067: import org.objectweb.jonas.webapp.jonasadmin.service.container.WebAppItemByPathContext;
0068: import org.objectweb.jonas.webapp.jonasadmin.service.ejb.EjbItem;
0069: import org.objectweb.jonas.webapp.jonasadmin.service.ejb.EjbItemByNameComparator;
0070: import org.objectweb.jonas.webapp.jonasadmin.service.resource.ResourceItem;
0071: import org.objectweb.jonas.webapp.jonasadmin.service.resource.ResourceItemByFile;
0072: import org.objectweb.jonas.webapp.jonasadmin.jonasmqconnect.util.MqObjectNames;
0073: import org.objectweb.jonas.webapp.taglib.TreeBuilder;
0074: import org.objectweb.jonas.webapp.taglib.TreeControl;
0075: import org.objectweb.jonas.webapp.taglib.TreeControlNode;
0076:
0077: /**
0078: * Implementation of <code>TreeBuilder</code> that adds the nodes required
0079: * for administering the Jonas server.
0080: *
0081: * @author Michel-Ange ANTON (initial developer)
0082: * @author Adriana Danes : add nodes for JMS service
0083: * @author Florent Benoit (changes for struts 1.2.2)
0084: */
0085: public class JonasTreeBuilder implements TreeBuilder {
0086:
0087: // ----------------------------------------------------- Instance Variables
0088:
0089: // ---------------------------------------------------- TreeBuilder Methods
0090: /**
0091: * Add the required nodes to the specified <code>treeControl</code>
0092: * instance.
0093: *
0094: * @param treeControl The <code>TreeControl</code> to which we should
0095: * add our nodes
0096: * @param servlet The controller servlet for the admin application
0097: * @param request The servlet request we are processing
0098: */
0099: public void buildTree(TreeControl treeControl,
0100: ActionServlet servlet, HttpServletRequest request) {
0101: try {
0102: TreeControlNode rootNode = treeControl.getRoot();
0103: MessageResources resources = (MessageResources) servlet
0104: .getServletContext().getAttribute(
0105: Globals.MESSAGES_KEY);
0106: getDomain(rootNode, resources, request);
0107: } catch (Throwable t) {
0108: t.printStackTrace(System.out);
0109: }
0110: }
0111:
0112: // ------------------------------------------------------ Protected Methods
0113:
0114: /**
0115: * Append nodes for the current domain.
0116: *
0117: * @param p_RootNode Root node for the tree control
0118: * @param p_Resources The MessageResources for our localized messages
0119: * @param p_Request The servlet request we are processing
0120: *
0121: * @exception Exception if an exception occurs building the tree
0122: */
0123: protected void getDomain(TreeControlNode p_RootNode,
0124: MessageResources p_Resources, HttpServletRequest p_Request)
0125: throws Exception {
0126: // Add domain node
0127: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
0128: .getAttribute(WhereAreYou.SESSION_NAME);
0129: //String sDomain = oWhere.getCurrentDomain().toString();// OBJECT_NAME
0130: String sDomainName = oWhere.getCurrentDomainName();// value of the 'name' key property
0131: String sServerName = oWhere.getCurrentJonasServerName();
0132:
0133: String sNodeLabel = p_Resources
0134: .getMessage("treenode.jonas.domain")
0135: + " ( " + sDomainName + " )";
0136: TreeControlNode domainNode = new TreeControlNode("domain",
0137: "icon/domain_jonas.gif", sNodeLabel,
0138: "EditDomain.do?select="
0139: + URLEncoder.encode(sDomainName, "UTF-8"),
0140: "content", true);
0141: p_RootNode.addChild(domainNode);
0142:
0143: // Add children
0144: if (JonasAdminJmx.hasMBeanName(JonasObjectName
0145: .discoveryService(), sServerName)
0146: && isMaster(p_Request, sServerName)) {
0147: getMonitoring(domainNode, p_Resources, p_Request,
0148: sDomainName, sServerName);
0149: getDomainDeploy(domainNode, p_Resources, p_Request);
0150: }
0151: getServer(domainNode, p_Resources, p_Request, sDomainName,
0152: sServerName);
0153: getJoramPlatform(domainNode, sServerName, p_Resources,
0154: p_Request);
0155: getMBeans(domainNode, p_Resources, p_Request);
0156: }
0157:
0158: /**
0159: * Returns if the current server (with discovery running) is a master server.
0160: * @return if the current server is a master server.
0161: */
0162: protected boolean isMaster(HttpServletRequest p_Request,
0163: String serverName) {
0164: ObjectName oObjectName = JonasObjectName.discoveryService();
0165: Boolean result = (Boolean) JonasManagementRepr.getAttribute(
0166: oObjectName, "IsDiscoveryMaster", serverName);
0167: return result.booleanValue();
0168: }
0169:
0170: /**
0171: * Append nodes for domain management deployment.
0172: *
0173: * @param p_DomainNode Domain node for the tree control
0174: * @param p_Resources The MessageResources for our localized messages
0175: * @param p_Request The servlet request we are processing
0176: * @param p_DomainName The name of the domain.
0177: *
0178: * @throws Exception if an exception occurs building the tree
0179: */
0180: protected void getDomainDeploy(TreeControlNode p_DomainNode,
0181: MessageResources p_Resources, HttpServletRequest p_Request)
0182: throws Exception {
0183:
0184: TreeControlNode nodeDeployments = new TreeControlNode(
0185: p_DomainNode.getName() + WhereAreYou.NODE_SEPARATOR
0186: + "deployments",
0187: "icon/deployDomainManage.gif",
0188: p_Resources
0189: .getMessage("treenode.jonas.server.deployments"),
0190: null, "content", true);
0191: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
0192: .getAttribute(WhereAreYou.SESSION_NAME);
0193: String serverName = oWhere.getCurrentJonasServerName();
0194: p_DomainNode.addChild(1, nodeDeployments);
0195: if (JonasAdminJmx.hasMBeanName(JonasObjectName.earService(),
0196: serverName) == true) {
0197: getDomainDeploymentEar(nodeDeployments, p_Resources);
0198: }
0199: if (JonasAdminJmx.hasMBeanName(JonasObjectName.ejbService(),
0200: serverName) == true) {
0201: getDomainDeploymentEjb(nodeDeployments, p_Resources);
0202: }
0203: if (JonasAdminJmx.hasMBeanName(JonasObjectName
0204: .webContainerService(), serverName) == true) {
0205: getDomainDeploymentWebAppli(nodeDeployments, p_Resources);
0206: }
0207: if (JonasAdminJmx.hasMBeanName(JonasObjectName
0208: .resourceService(), serverName) == true) {
0209: getDomainDeploymentRar(nodeDeployments, p_Resources);
0210: }
0211: }
0212:
0213: /**
0214: * Append node for Ear deployment using domain management.
0215: *
0216: * @param p_NodeDeployments Deployment node for the tree control
0217: * @param p_Resources The MessageResources for our localized messages
0218: *
0219: * @exception Exception if an exception occurs building the tree
0220: */
0221: protected void getDomainDeploymentEar(
0222: TreeControlNode p_NodeDeployments,
0223: MessageResources p_Resources) throws Exception {
0224: // Add node
0225: TreeControlNode oNode = new TreeControlNode(
0226: p_NodeDeployments.getName()
0227: + WhereAreYou.NODE_SEPARATOR
0228: + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_EAR,
0229: "icon/deployDomain_ear.gif",
0230: p_Resources
0231: .getMessage("treenode.jonas.server.deployments."
0232: + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_EAR),
0233: "EditDomainDeploy.do?type="
0234: + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_EAR,
0235: "content", false);
0236: p_NodeDeployments.addChild(oNode);
0237: }
0238:
0239: /**
0240: * Append node for Ejb deployment using domain management.
0241: *
0242: * @param p_NodeDeployments Deployment node for the tree control
0243: * @param p_Resources The MessageResources for our localized messages
0244: *
0245: * @exception Exception if an exception occurs building the tree
0246: */
0247: protected void getDomainDeploymentEjb(
0248: TreeControlNode p_NodeDeployments,
0249: MessageResources p_Resources) throws Exception {
0250: // Add node
0251: TreeControlNode oNode = new TreeControlNode(
0252: p_NodeDeployments.getName()
0253: + WhereAreYou.NODE_SEPARATOR
0254: + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_JAR,
0255: "icon/deployDomain_jar.gif",
0256: p_Resources
0257: .getMessage("treenode.jonas.server.deployments."
0258: + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_JAR),
0259: "EditDomainDeploy.do?type="
0260: + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_JAR,
0261: "content", false);
0262: p_NodeDeployments.addChild(oNode);
0263:
0264: // Add list files
0265: //getDeploymentJarFiles(oNode, p_Resources);
0266: }
0267:
0268: /**
0269: * Append node for Web deployment using domain management.
0270: *
0271: * @param p_NodeDeployments Deployment node for the tree control
0272: * @param p_Resources The MessageResources for our localized messages
0273: *
0274: * @exception Exception if an exception occurs building the tree
0275: */
0276: protected void getDomainDeploymentWebAppli(
0277: TreeControlNode p_NodeDeployments,
0278: MessageResources p_Resources) throws Exception {
0279: // Add node
0280: TreeControlNode oNode = new TreeControlNode(
0281: p_NodeDeployments.getName()
0282: + WhereAreYou.NODE_SEPARATOR
0283: + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_WAR,
0284: "icon/deployDomain_war.gif",
0285: p_Resources
0286: .getMessage("treenode.jonas.server.deployments."
0287: + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_WAR),
0288: "EditDomainDeploy.do?type="
0289: + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_WAR,
0290: "content", false);
0291: p_NodeDeployments.addChild(oNode);
0292: }
0293:
0294: /**
0295: * Append node for Rar deployment using domain management.
0296: *
0297: * @param p_NodeDeployments Deployment node for the tree control
0298: * @param p_Resources The MessageResources for our localized messages
0299: *
0300: * @exception Exception if an exception occurs building the tree
0301: */
0302: protected void getDomainDeploymentRar(
0303: TreeControlNode p_NodeDeployments,
0304: MessageResources p_Resources) throws Exception {
0305: // Add node
0306: TreeControlNode oNode = new TreeControlNode(
0307: p_NodeDeployments.getName()
0308: + WhereAreYou.NODE_SEPARATOR
0309: + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_RAR,
0310: "icon/deployDomain_rar.gif",
0311: p_Resources
0312: .getMessage("treenode.jonas.server.deployments."
0313: + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_RAR),
0314: "EditDomainDeploy.do?type="
0315: + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_RAR,
0316: "content", false);
0317: p_NodeDeployments.addChild(oNode);
0318: }
0319:
0320: /**
0321: * Append nodes for a defined Jonas server.
0322: *
0323: * @param p_DomainNode Domain node for the tree control
0324: * @param p_Resources The MessageResources for our localized messages
0325: * @param p_Request The servlet request we are processing
0326: *
0327: * @exception Exception if an exception occurs building the tree
0328: */
0329: protected void getServer(TreeControlNode p_DomainNode,
0330: MessageResources p_Resources, HttpServletRequest p_Request,
0331: String p_DomainName, String p_ServerName) throws Exception {
0332: // Add server node
0333: /* Implem note
0334: * -----------
0335: * Currently we have only one server in the domain, it's id being registered
0336: * in helper class WhereAreYou. This will change with in the next version
0337: * with full Domain support. We'll have to query for all the J2EEServer MBeans.
0338: */
0339: String sServerName = p_ServerName;
0340: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
0341: .getAttribute(WhereAreYou.SESSION_NAME);
0342: String sServer = oWhere.getCurrentJonasServer().toString();
0343: String sNodeLabel = p_Resources
0344: .getMessage("treenode.jonas.server")
0345: + " ( " + sServerName + " )";
0346: TreeControlNode serverNode = new TreeControlNode(p_DomainNode
0347: .getName()
0348: + WhereAreYou.NODE_SEPARATOR + sServerName,
0349: "icon/BalJonasTree.gif", sNodeLabel,
0350: "EditJonasServer.do?select="
0351: + URLEncoder.encode(sServer, "UTF-8"),
0352: "content", true);
0353: p_DomainNode.addChild(serverNode);
0354: // Add children
0355: getServerMonitoring(serverNode, p_Resources);
0356: getLogging(serverNode, p_Resources, p_Request);
0357: getProtocols(serverNode, p_Resources, p_Request);
0358: getServices(serverNode, p_Resources, p_Request, p_DomainName,
0359: sServerName);
0360: getDeployments(serverNode, p_Resources, p_Request);
0361: getResources(serverNode, p_Resources, p_Request);
0362: getSecurity(serverNode, p_Resources, p_Request);
0363: // Add node for MQ connector support
0364: getJonasMqConnectorPlatform(serverNode, sServerName,
0365: p_Resources, p_Request);
0366: }
0367:
0368: /**
0369: * Append nodes for Monitoring.
0370: *
0371: * @param p_ServerNode Server node for the tree control
0372: * @param p_Resources The MessageResources for our localized messages
0373: * messages
0374: *
0375: * @exception Exception if an exception occurs building the tree
0376: */
0377: protected void getServerMonitoring(TreeControlNode p_ServerNode,
0378: MessageResources p_Resources) throws Exception {
0379: // Monitoring server Service node
0380: TreeControlNode node = new TreeControlNode(
0381: p_ServerNode.getName() + WhereAreYou.NODE_SEPARATOR
0382: + "monitoring",
0383: "icon/monitoring.gif",
0384: p_Resources
0385: .getMessage("treenode.jonas.server.monitoring"),
0386: "EditMonitoring.do", "content", false);
0387: p_ServerNode.addChild(node);
0388: }
0389:
0390: /**
0391: * Append nodes for Logging.
0392: *
0393: * @param p_ServerNode Server node for the tree control
0394: * @param p_Resources The MessageResources for our localized messages
0395: * @param p_Request The servlet request we are processing
0396: *
0397: * @exception Exception if an exception occurs building the tree
0398: */
0399: protected void getLogging(TreeControlNode p_ServerNode,
0400: MessageResources p_Resources, HttpServletRequest p_Request)
0401: throws Exception {
0402: // Logging server Service node
0403: TreeControlNode node = new TreeControlNode(p_ServerNode
0404: .getName()
0405: + WhereAreYou.NODE_SEPARATOR + "logging",
0406: "icon/loggers.gif", p_Resources
0407: .getMessage("treenode.jonas.server.logging"),
0408: "ListLoggers.do", "content", false);
0409: p_ServerNode.addChild(node);
0410: // Add all loggers
0411: getLoggers(node, p_Resources, p_Request);
0412: }
0413:
0414: /**
0415: * Append nodes for each logger.
0416: *
0417: * @param p_LoggingNode Server node for the tree control
0418: * @param p_Resources The MessageResources for our localized messages
0419: * @param p_Request The servlet request we are processing
0420: *
0421: * @exception Exception if an exception occurs building the tree
0422: */
0423: public void getLoggers(TreeControlNode p_LoggingNode,
0424: MessageResources p_Resources, HttpServletRequest p_Request)
0425: throws Exception {
0426: // Get WhereAreYou instance in session
0427: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
0428: .getAttribute(WhereAreYou.SESSION_NAME);
0429: // Get list of loggers with Action name
0430: ArrayList al = JonasAdminJmx.getLoggers(p_Resources, oWhere,
0431: true);
0432: // Build the node of each logger
0433: LoggerItem oLog;
0434: String sIcon = "icon/loggers.gif";
0435: String rootNodeName = p_LoggingNode.getName();
0436: String nodeName;
0437: for (int i = 0; i < al.size(); i++) {
0438: oLog = (LoggerItem) al.get(i);
0439: if (LoggerItem.LOGGER_JONAS.equals(oLog.getType())) {
0440: sIcon = "icon/logger_jonas.gif";
0441: nodeName = rootNodeName + WhereAreYou.NODE_SEPARATOR
0442: + LoggerItem.LOGGER_JONAS;
0443: } else /*if (LoggerItem.LOGGER_CATALINA_ACCESS.equals(oLog.getType()) == true)*/{
0444: sIcon = "icon/logger_http.gif";
0445: nodeName = rootNodeName + WhereAreYou.NODE_SEPARATOR
0446: + oLog.getType() + WhereAreYou.NODE_SEPARATOR
0447: + oLog.getContainerName();
0448: }
0449: // Add a logger node
0450: TreeControlNode node = new TreeControlNode(nodeName, sIcon,
0451: oLog.getName(), oLog.getForward(), "content", false);
0452: p_LoggingNode.addChild(node);
0453: }
0454: }
0455:
0456: /**
0457: * Append nodes for all defined services for the specified server.
0458: *
0459: * @param p_ServerNode Server node for the tree control
0460: * @param p_Resources The MessageResources for our localized messages
0461: * @param p_Request The servlet request we are processing
0462: * @exception Exception if an exception occurs building the tree
0463: */
0464: protected void getServices(TreeControlNode p_ServerNode,
0465: MessageResources p_Resources, HttpServletRequest p_Request,
0466: String p_DomainName, String p_ServerName) throws Exception {
0467: // Services node
0468: TreeControlNode nodeAllServices = new TreeControlNode(
0469: p_ServerNode.getName() + WhereAreYou.NODE_SEPARATOR
0470: + "services", "icon/services.gif", p_Resources
0471: .getMessage("treenode.jonas.server.services"),
0472: "ListServices.do", "content", false);
0473: p_ServerNode.addChild(nodeAllServices);
0474: String serverName = p_ServerName;
0475: // Detail Service node
0476: if (JonasAdminJmx.hasMBeanName(JonasObjectName.earService(),
0477: serverName)) {
0478: getServiceApp(nodeAllServices, p_Resources, p_DomainName,
0479: p_ServerName);
0480: }
0481: if (JonasAdminJmx.hasMBeanName(JonasObjectName.ejbService(),
0482: serverName)) {
0483: getServiceEjbContainer(nodeAllServices, p_Resources,
0484: p_DomainName, p_ServerName);
0485: }
0486: if (JonasAdminJmx.hasMBeanName(JonasObjectName
0487: .webContainerService(), serverName)) {
0488: getServiceWeb(nodeAllServices, p_Resources, p_Request,
0489: p_DomainName, p_ServerName);
0490: }
0491: if (JonasAdminJmx.hasMBeanName(JonasObjectName
0492: .databaseService(), serverName)) {
0493: getServiceDatabase(nodeAllServices, p_Resources,
0494: p_DomainName, p_ServerName);
0495: }
0496: if (JonasAdminJmx.hasMBeanName(JonasObjectName
0497: .resourceService(), serverName)) {
0498: getServiceResourceAdapter(nodeAllServices, p_Resources,
0499: p_DomainName, p_ServerName);
0500: }
0501: if (JonasAdminJmx.hasMBeanName(JonasObjectName
0502: .transactionService(), serverName)) {
0503: getServiceTransaction(nodeAllServices, p_Resources,
0504: p_DomainName, p_ServerName);
0505: }
0506: if (JonasAdminJmx.hasMBeanName(JonasObjectName.jmsService(),
0507: serverName)) {
0508: getServiceJms(nodeAllServices, p_Resources, p_DomainName,
0509: p_ServerName);
0510: }
0511: if (JonasAdminJmx.hasMBeanName(JonasObjectName.mailService(),
0512: serverName)) {
0513: getServiceMail(nodeAllServices, p_Resources, p_Request,
0514: p_DomainName, p_ServerName);
0515: }
0516: if (JonasAdminJmx.hasMBeanName(JonasObjectName
0517: .securityService(), serverName)) {
0518: getServiceSecurity(nodeAllServices, p_Resources,
0519: p_DomainName, p_ServerName);
0520: }
0521: if (JonasAdminJmx.hasMBeanName(JonasObjectName
0522: .discoveryService(), serverName)) {
0523: getServiceDiscovery(nodeAllServices, p_Resources,
0524: p_DomainName, p_ServerName);
0525: }
0526: if (JonasAdminJmx.hasMBeanName(JonasObjectName.wsService(),
0527: serverName)) {
0528: getServiceWebService(nodeAllServices, p_Resources,
0529: p_Request, p_DomainName, p_ServerName);
0530: }
0531: }
0532:
0533: /**
0534: * Append node for Ear service for the JOnAS services.
0535: *
0536: * @param p_NodeServices Services node for the tree control
0537: * @param p_Resources The MessageResources for our localized messages
0538: *
0539: * @exception Exception if an exception occurs building the tree
0540: */
0541: protected void getServiceApp(TreeControlNode p_NodeServices,
0542: MessageResources p_Resources, String p_DomainName,
0543: String p_ServerName) throws Exception {
0544: // Add Service node
0545: TreeControlNode nodeService = new TreeControlNode(
0546: p_NodeServices.getName() + WhereAreYou.NODE_SEPARATOR
0547: + "ear",
0548: "icon/service_application.gif",
0549: p_Resources
0550: .getMessage("treenode.jonas.server.services.ear"),
0551: "ListAppContainers.do", "content", false);
0552: p_NodeServices.addChild(nodeService);
0553:
0554: // Add App Containers nodes
0555: getAppContainers(nodeService, p_Resources, p_DomainName,
0556: p_ServerName);
0557: }
0558:
0559: /**
0560: * Append node for all App Containers.
0561: *
0562: * @param p_NodeParent Server node for the tree control
0563: * @param p_Resources The MessageResources for our localized messages
0564: *
0565: * @exception Exception if an exception occurs building the tree
0566: */
0567: public void getAppContainers(TreeControlNode p_NodeParent,
0568: MessageResources p_Resources, String p_DomainName,
0569: String p_ServerName) throws Exception {
0570: String sPath;
0571: String sFile;
0572: String sNodeName;
0573: String sName;
0574: ArrayList al = new ArrayList();
0575: String serverName = p_ServerName;
0576: // Get Container List
0577: ObjectName ons = J2eeObjectName.J2EEApplications(p_DomainName,
0578: p_ServerName);
0579: Iterator itNames = JonasManagementRepr.queryNames(ons,
0580: serverName).iterator();
0581: while (itNames.hasNext()) {
0582: ObjectName it_on = (ObjectName) itNames.next();
0583: sPath = (String) JonasManagementRepr.getAttribute(it_on,
0584: "earUrl", serverName).toString();
0585: sFile = JonasAdminJmx.extractFilename(sPath);
0586: sNodeName = p_NodeParent.getName()
0587: + WhereAreYou.NODE_SEPARATOR + sFile;
0588: sName = it_on.getKeyProperty("name");
0589: if (sFile != null) {
0590: al.add(new ContainerItem(sFile, sPath, sNodeName, it_on
0591: .toString(), sName));
0592: }
0593: }
0594: // Sort list
0595: Collections.sort(al, new ContainerItemByFile());
0596: // Build nodes
0597: ContainerItem oItem;
0598: for (int i = 0; i < al.size(); i++) {
0599: oItem = (ContainerItem) al.get(i);
0600: TreeControlNode node = new TreeControlNode(oItem
0601: .getNodeName(), "icon/ear.gif", oItem.getFile(),
0602: "EditEar.do?select=" + oItem.getObjectName(),
0603: "content", false);
0604: p_NodeParent.addChild(node);
0605: }
0606: }
0607:
0608: /**
0609: * Append node for EJBContainer service for the JOnAS services.
0610: *
0611: * @param p_NodeServices Services node for the tree control
0612: * @param p_Resources The MessageResources for our localized messages
0613: * messages
0614: *
0615: * @exception Exception if an exception occurs building the tree
0616: */
0617: protected void getServiceEjbContainer(
0618: TreeControlNode p_NodeServices,
0619: MessageResources p_Resources, String p_DomainName,
0620: String p_ServerName) throws Exception {
0621: // Add Service node
0622: TreeControlNode nodeService = new TreeControlNode(
0623: p_NodeServices.getName() + WhereAreYou.NODE_SEPARATOR
0624: + "ejbContainers",
0625: "icon/service_ejb.gif",
0626: p_Resources
0627: .getMessage("treenode.jonas.server.services.ejbContainers"),
0628: "ListContainers.do", "content", false);
0629: p_NodeServices.addChild(nodeService);
0630: // Add Containers nodes
0631: getContainers(nodeService, p_Resources, p_DomainName,
0632: p_ServerName);
0633: }
0634:
0635: /**
0636: * Append node for all Containers.
0637: *
0638: * @param p_NodeParent Server node for the tree control
0639: * @param p_Resources The MessageResources for our localized messages
0640: *
0641: * @exception Exception if an exception occurs building the tree
0642: */
0643: public void getContainers(TreeControlNode p_NodeParent,
0644: MessageResources p_Resources, String p_DomainName,
0645: String p_ServerName) throws Exception {
0646: String sPath;
0647: String sFile;
0648: String sName;
0649: String sNodeName;
0650: ObjectName onContainer;
0651: ArrayList al = new ArrayList();
0652:
0653: // Get Container List
0654: Iterator itNames = JonasManagementRepr.queryNames(
0655: J2eeObjectName
0656: .getEJBModules(p_DomainName, p_ServerName),
0657: p_ServerName).iterator();
0658: while (itNames.hasNext()) {
0659: ObjectName it_on = (ObjectName) itNames.next();
0660: sPath = (String) JonasManagementRepr.getAttribute(it_on,
0661: "fileName", p_ServerName);
0662: sFile = JonasAdminJmx.extractFilename(sPath);
0663: sNodeName = p_NodeParent.getName()
0664: + WhereAreYou.NODE_SEPARATOR + sFile;
0665: sName = it_on.getKeyProperty("name");
0666: if (sFile != null) {
0667: al.add(new ContainerItem(sFile, sPath, sNodeName, it_on
0668: .toString(), sName));
0669: }
0670: }
0671:
0672: // Sort list
0673: Collections.sort(al, new ContainerItemByFile());
0674: // Build nodes
0675: ContainerItem oItem;
0676: for (int i = 0; i < al.size(); i++) {
0677: oItem = (ContainerItem) al.get(i);
0678: TreeControlNode node = new TreeControlNode(oItem
0679: .getNodeName(), "icon/jar.gif", oItem.getFile(),
0680: "EditContainer.do?select=" + oItem.getObjectName(),
0681: "content", false);
0682: p_NodeParent.addChild(node);
0683: // Add ejb node
0684: getEjbs(node, p_Resources, oItem.getPath(), p_DomainName,
0685: p_ServerName, oItem.getName());
0686: }
0687: }
0688:
0689: /**
0690: * Append node for all Ejbs for a Container.
0691: *
0692: * @param p_NodeParent Server node for the tree control
0693: * @param p_Resources The MessageResources for our localized messages
0694: * @param p_Filename Filename of container
0695: *
0696: * @exception Exception if an exception occurs building the tree
0697: */
0698: protected void getEjbs(TreeControlNode p_NodeParent,
0699: MessageResources p_Resources, String p_Filename,
0700: String p_DomainName, String p_ServerName,
0701: String p_moduleName) throws Exception {
0702: //String sName;
0703: Iterator itNames;
0704: ObjectName on;
0705: ArrayList al = new ArrayList();
0706:
0707: on = J2eeObjectName.getEntityBeans(p_DomainName, p_moduleName,
0708: p_ServerName);
0709:
0710: itNames = JonasAdminJmx.getListMbean(on, p_ServerName)
0711: .iterator();
0712: while (itNames.hasNext()) {
0713: al.add(new EjbItem((ObjectName) itNames.next(),
0714: p_ServerName));
0715: }
0716: on = J2eeObjectName.getStatefulSessionBeans(p_DomainName,
0717: p_moduleName, p_ServerName);
0718: itNames = JonasAdminJmx.getListMbean(on, p_ServerName)
0719: .iterator();
0720: while (itNames.hasNext()) {
0721: al.add(new EjbItem((ObjectName) itNames.next(),
0722: p_ServerName));
0723: }
0724: on = J2eeObjectName.getStatelessSessionBeans(p_DomainName,
0725: p_moduleName, p_ServerName);
0726: itNames = JonasAdminJmx.getListMbean(on, p_ServerName)
0727: .iterator();
0728: while (itNames.hasNext()) {
0729: al.add(new EjbItem((ObjectName) itNames.next(),
0730: p_ServerName));
0731: }
0732: on = J2eeObjectName.getMessageDrivenBeans(p_DomainName,
0733: p_moduleName, p_ServerName);
0734: itNames = JonasAdminJmx.getListMbean(on, p_ServerName)
0735: .iterator();
0736: while (itNames.hasNext()) {
0737: al.add(new EjbItem((ObjectName) itNames.next(),
0738: p_ServerName));
0739: }
0740:
0741: // Sort by name
0742: Collections.sort(al, new EjbItemByNameComparator());
0743:
0744: // Add all node Ejb
0745: String sNodeName;
0746: String sAction;
0747: TreeControlNode nodeEjb;
0748: EjbItem oEjb;
0749: for (int i = 0; i < al.size(); i++) {
0750: oEjb = (EjbItem) al.get(i);
0751: sNodeName = p_NodeParent.getName()
0752: + WhereAreYou.NODE_SEPARATOR + oEjb.getName();
0753: sAction = "EditEjb" + oEjb.getTypeString() + ".do?select="
0754: + oEjb.getObjectName();
0755: // Add node Ejb
0756: nodeEjb = new TreeControlNode(sNodeName, "icon/bean.gif",
0757: oEjb.getName(), sAction, "content", false);
0758: p_NodeParent.addChild(nodeEjb);
0759: }
0760: }
0761:
0762: /**
0763: * Append node for Database service for the JOnAS services.
0764: *
0765: * @param pNodeServices Services node for the tree control
0766: * @param pResources The MessageResources for our localized messages
0767: * @param pDomainName The name of the current management domain
0768: * @param pServerName The name of the currently managed JOnAS server
0769: * @exception Exception if an exception occurs building the tree
0770: */
0771: protected void getServiceDatabase(TreeControlNode pNodeServices,
0772: MessageResources pResources, String pDomainName,
0773: String pServerName) throws Exception {
0774: // Add Service node
0775: TreeControlNode nodeService = new TreeControlNode(
0776: pNodeServices.getName() + WhereAreYou.NODE_SEPARATOR
0777: + "database",
0778: "icon/service_database.gif",
0779: pResources
0780: .getMessage("treenode.jonas.server.services.database"),
0781: "ListDatabases.do", "content", false);
0782: pNodeServices.addChild(nodeService);
0783: // Add Datasources nodes
0784: getDatasources(nodeService, pResources, pDomainName,
0785: pServerName);
0786: }
0787:
0788: /**
0789: * Append node for all deployed Datasources.
0790: *
0791: * @param pNodeParent Server node for the tree control
0792: * @param pResources The MessageResources for our localized messages
0793: * @param pDomainName The name of the current management domain
0794: * @param pServerName The name of the currently managed JOnAS server
0795: *
0796: * @exception Exception if an exception occurs building the tree
0797: */
0798: public void getDatasources(TreeControlNode pNodeParent,
0799: MessageResources pResources, String pDomainName,
0800: String pServerName) throws Exception {
0801:
0802: ArrayList al = JonasAdminJmx.getDatasourceFilesDeployed(
0803: pDomainName, pServerName);
0804: // Build nodes
0805: for (int i = 0; i < al.size(); i++) {
0806: TreeControlNode node = new TreeControlNode(
0807: pNodeParent.getName() + WhereAreYou.NODE_SEPARATOR
0808: + al.get(i).toString(),
0809: "icon/Datasource.gif", al.get(i).toString(),
0810: "EditDatasource.do?name=" + al.get(i), "content",
0811: false);
0812: pNodeParent.addChild(node);
0813: }
0814: }
0815:
0816: /**
0817: * Append node for Web service for the JOnAS services.
0818: *
0819: * @param pNodeServices Services node for the tree control
0820: * @param pResources The MessageResources for our localized messages
0821: * @param pRequest The servlet request we are processing
0822: * @param pDomainName The name of the current management domain
0823: * @param pServerName The name of the currently managed JOnAS server
0824: *
0825: * @exception Exception if an exception occurs building the tree
0826: */
0827: protected void getServiceWeb(TreeControlNode pNodeServices,
0828: MessageResources pResources, HttpServletRequest pRequest,
0829: String pDomainName, String pServerName) throws Exception {
0830: // Add Service node
0831: TreeControlNode nodeService = new TreeControlNode(
0832: pNodeServices.getName() + WhereAreYou.NODE_SEPARATOR
0833: + "web",
0834: "icon/service_web.gif",
0835: pResources
0836: .getMessage("treenode.jonas.server.services.web"),
0837: "ListWebContainers.do", "content", false);
0838: pNodeServices.addChild(nodeService);
0839: // Add Web Containers nodes
0840: getWebContainers(nodeService, pResources, pRequest);
0841: }
0842:
0843: /**
0844: * Append node for all Web Containers.
0845: *
0846: * @param p_NodeParent Server node for the tree control
0847: * @param p_Resources The MessageResources for our localized messages
0848: * @param p_Request The servlet request we are processing
0849: *
0850: * @exception Exception if an exception occurs building the tree
0851: */
0852: public void getWebContainers(TreeControlNode p_NodeParent,
0853: MessageResources p_Resources, HttpServletRequest p_Request)
0854: throws Exception {
0855: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
0856: .getAttribute(WhereAreYou.SESSION_NAME);
0857: String serverName = oWhere.getCurrentJonasServerName();
0858: String domainName = oWhere.getCurrentDomainName();
0859: ArrayList al = new ArrayList();
0860: // Detect Catalina items present
0861: if (oWhere.isCatalinaServer()) {
0862: // Get the list of WebModule
0863: Iterator itOns = JonasAdminJmx.getListMbean(
0864: J2eeObjectName.getWebModules(oWhere
0865: .getCurrentCatalinaDomainName()),
0866: serverName).iterator();
0867: while (itOns.hasNext()) {
0868: al.add(new WebAppItem((ObjectName) itOns.next(), oWhere
0869: .getCurrentCatalinaDefaultHostName()));
0870: }
0871: }
0872: // Detect Jetty items present
0873: else if (oWhere.isJettyServer()) {
0874: ObjectName on;
0875: String sPathContext;
0876: HashMap hWebAppItems = new HashMap();
0877:
0878: // Get the list of Jetty contexts
0879: Iterator itOnContexts = JonasAdminJmx.getListMbean(
0880: JettyObjectName.jettyContexts(domainName),
0881: serverName).iterator();
0882: while (itOnContexts.hasNext()) {
0883: on = (ObjectName) itOnContexts.next();
0884: sPathContext = on.getKeyProperty("context");
0885: if (sPathContext != null) {
0886: if (!hWebAppItems.containsKey(sPathContext)
0887: && on
0888: .getKeyProperty("WebApplicationContext") != null
0889: && on
0890: .getKeyProperty("WebApplicationHandler") == null
0891: && on.getKeyProperty("config") == null) {
0892: hWebAppItems.put(sPathContext, new WebAppItem(
0893: sPathContext, on.toString()));
0894: }
0895: }
0896: }
0897: // Prepare to display
0898: al.addAll(hWebAppItems.values());
0899: }
0900: // Sort list
0901: Collections.sort(al, new WebAppItemByPathContext());
0902: // Build nodes
0903: WebAppItem oItem;
0904: for (int i = 0; i < al.size(); i++) {
0905: oItem = (WebAppItem) al.get(i);
0906: TreeControlNode node = new TreeControlNode(p_NodeParent
0907: .getName()
0908: + WhereAreYou.NODE_SEPARATOR
0909: + oItem.getObjectName(), "icon/war.gif", oItem
0910: .getLabelPathContext(), "EditWebApp.do?on="
0911: + oItem.getObjectName(), "content", false);
0912: p_NodeParent.addChild(node);
0913: }
0914: }
0915:
0916: /**
0917: * Append node for Transaction service for the JOnAS services.
0918: *
0919: * @param p_NodeServices Services node for the tree control
0920: * @param p_Resources The MessageResources for our localized messages
0921: * messages
0922: *
0923: * @exception Exception if an exception occurs building the tree
0924: */
0925: protected void getServiceTransaction(
0926: TreeControlNode p_NodeServices,
0927: MessageResources p_Resources, String p_DomainName,
0928: String p_ServerName) throws Exception {
0929: // Add Service node
0930: TreeControlNode nodeService = new TreeControlNode(
0931: p_NodeServices.getName() + WhereAreYou.NODE_SEPARATOR
0932: + "transaction",
0933: "icon/service_transaction.gif",
0934: p_Resources
0935: .getMessage("treenode.jonas.server.services.transaction"),
0936: "EditJtmService.do", "content", false);
0937: p_NodeServices.addChild(nodeService);
0938: }
0939:
0940: /**
0941: * Append node for discovery service for the JOnAS services.
0942: *
0943: * @param p_NodeServices Services node for the tree control
0944: * @param p_Resources The MessageResources for our localized messages
0945: * messages
0946: *
0947: * @exception Exception if an exception occurs building the tree
0948: */
0949: protected void getServiceDiscovery(TreeControlNode p_NodeServices,
0950: MessageResources p_Resources, String p_DomainName,
0951: String p_ServerName) throws Exception {
0952: // Add Service node
0953: TreeControlNode nodeService = new TreeControlNode(
0954: p_NodeServices.getName() + WhereAreYou.NODE_SEPARATOR
0955: + "discovery",
0956: "icon/service_transaction.gif",
0957: p_Resources
0958: .getMessage("treenode.jonas.server.services.discovery"),
0959: "EditServiceDiscovery.do", "content", false);
0960: p_NodeServices.addChild(nodeService);
0961: }
0962:
0963: /**
0964: * Append node for WebService (ws) service for the JOnAS services.
0965: *
0966: * @param p_NodeServices
0967: * Services node for the tree control
0968: * @param p_Resources
0969: * The MessageResources for our localized messages
0970: * @param request
0971: * The HTTP request object currently in use.
0972: * @param p_DomainName
0973: * The domain name for the instance
0974: * @param p_ServerName
0975: * The server name for the instance being monitored
0976: * @exception Exception
0977: * if an exception occurs building the tree
0978: */
0979: public void getServiceWebService(TreeControlNode p_NodeServices,
0980: MessageResources p_Resources, HttpServletRequest request,
0981: String p_DomainName, String p_ServerName) throws Exception {
0982: String nodeName = p_NodeServices.getName()
0983: + WhereAreYou.NODE_SEPARATOR + "WebService";
0984: TreeControlNode nodeService = null;
0985: // Rebuild the webservice tree.
0986: nodeService = p_NodeServices.getTree().findNode(nodeName);
0987: if (nodeService != null) {
0988: nodeService.remove();
0989: }
0990: // (Re)Add Web Service node
0991: nodeService = new TreeControlNode(
0992: nodeName,
0993: "icon/war.gif",
0994: p_Resources
0995: .getMessage("treenode.jonas.server.services.webservices"),
0996: "ListWebService.do", "content", false);
0997: p_NodeServices.addChild(nodeService);
0998: getWebServiceDetails(nodeService, p_Resources, request);
0999:
1000: }
1001:
1002: /**
1003: * Append Web Service names for web services node in tree.
1004: *
1005: * @param p_WebServicesNode
1006: * Web Services node for the tree control
1007: * @param p_Resources
1008: * The MessageResources for our localized messages
1009: * @param p_Request
1010: * The servlet request we are processing
1011: * @exception Exception
1012: * if an exception occurs building the tree
1013: */
1014: public void getWebServiceDetails(TreeControlNode p_webServicesNode,
1015: MessageResources p_Resources, HttpServletRequest p_Request)
1016: throws Exception {
1017: // Get WhereAreYou
1018: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
1019: .getAttribute(WhereAreYou.SESSION_NAME);
1020:
1021: // Get the server name
1022: String sServerName = oWhere.getCurrentJonasServerName();
1023: // Get the list of webservice descriptions from mbean server.
1024: Collection al = new ArrayList();
1025: GenericDomainCapableProvider jProvider = new JonasProvider();
1026: jProvider.initialize(sServerName, null);
1027: al = jProvider.getWebServiceDescription();
1028:
1029: // Build the nodes
1030: TreeControlNode node;
1031: WebServiceDescription oWebServiceDescription = null;
1032: String sLabel;
1033: Iterator it = al.iterator();
1034: while (it.hasNext()) {
1035: oWebServiceDescription = (WebServiceDescription) it.next();
1036: node = new TreeControlNode(p_webServicesNode.getName()
1037: + WhereAreYou.NODE_SEPARATOR
1038: + oWebServiceDescription.getId(), "icon/war.gif",
1039: oWebServiceDescription.getId(),
1040: "WebServiceDetails.do?select="
1041: + oWebServiceDescription.getId(),
1042: "content", false);
1043: p_webServicesNode.addChild(node);
1044: getPortComponents(oWebServiceDescription, node, p_Resources);
1045: }
1046: }
1047:
1048: /**
1049: * Append port component names for a web service node in tree.
1050: *
1051: * @param wsd
1052: * Web Service Description for current web service.
1053: * @param p_WebServicesNode
1054: * Connector node for the tree control
1055: * @param p_Resources
1056: * The MessageResources for our localized messages
1057: * @exception Exception
1058: * if an exception occurs building the tree
1059: */
1060: private void getPortComponents(WebServiceDescription wsd,
1061: TreeControlNode p_webServiceNode,
1062: MessageResources p_Resources) throws Exception {
1063:
1064: String sLabel;
1065: // Build the nodes
1066: TreeControlNode node = null;
1067: for (int i = 0; i < wsd.getPortComponentCount(); i++) {
1068: PortComponent pc = wsd.getPortComponent(i);
1069: node = new TreeControlNode(p_webServiceNode.getName()
1070: + WhereAreYou.NODE_SEPARATOR + pc.getId(),
1071: "icon/war.gif", pc.getId(),
1072: "PortComponentsDetails.do?pcselect=" + pc.getId()
1073: + "&wsdselect=" + wsd.getId(), "content",
1074: false);
1075: p_webServiceNode.addChild(node);
1076: getPortComponentHandler(wsd, pc, node, p_Resources);
1077: }
1078:
1079: }
1080:
1081: /**
1082: * Append handler names for port component node in tree.
1083: *
1084: * @param wsd
1085: * Web Service Description for current web service.
1086: * @param pc
1087: * Port Component for current web service.
1088: * @param p_portComponentNode
1089: * Port component node for the tree control
1090: * @param p_Resources
1091: * The MessageResources for our localized messages
1092: */
1093: private void getPortComponentHandler(WebServiceDescription wsd,
1094: PortComponent pc, TreeControlNode p_portComponentNode,
1095: MessageResources p_Resources) throws Exception {
1096: // Build the nodes
1097: TreeControlNode node = null;
1098: for (int i = 0; i < pc.getHandlerCount(); i++) {
1099: Handler handler = pc.getHandler(i);
1100: node = new TreeControlNode(p_portComponentNode.getName()
1101: + WhereAreYou.NODE_SEPARATOR + handler.getId(),
1102: "icon/war.gif", handler.getId(),
1103: "HandlersDetails.do?pcselect=" + pc.getId()
1104: + "&wsdselect=" + wsd.getId()
1105: + "&handlerselect=" + handler.getId(),
1106: "content", false);
1107: p_portComponentNode.addChild(node);
1108: }
1109:
1110: }
1111:
1112: /**
1113: * Append node for Jms service for the JOnAS services.
1114: *
1115: * @param p_NodeServices Services node for the tree control
1116: * @param p_Resources The MessageResources for our localized messages
1117: *
1118: * @exception Exception if an exception occurs building the tree
1119: */
1120: protected void getServiceJms(TreeControlNode p_NodeServices,
1121: MessageResources p_Resources, String p_DomainName,
1122: String p_ServerName) throws Exception {
1123: // Add Service node
1124: TreeControlNode nodeService = new TreeControlNode(
1125: p_NodeServices.getName() + WhereAreYou.NODE_SEPARATOR
1126: + "jms",
1127: "icon/service_jms.gif",
1128: p_Resources
1129: .getMessage("treenode.jonas.server.services.jms"),
1130: "EditJmsService.do", "content", false);
1131: p_NodeServices.addChild(nodeService);
1132: // Add JMS administred objects (resources)
1133: getJmsResources(nodeService, p_Resources, p_ServerName);
1134: }
1135:
1136: /**
1137: * Append 3 subnodes for the JMS resource types + subnodes for all the ressources
1138: *
1139: * @param p_NodeParent JMS service node
1140: * @param p_Resources The MessageResources for our localized messages
1141: *
1142: * @exception Exception if an exception occurs building the tree
1143: */
1144: public void getJmsResources(TreeControlNode p_NodeParent,
1145: MessageResources p_Resources, String p_ServerName)
1146: throws Exception {
1147: // Add node for Connection Factories
1148: TreeControlNode node = new TreeControlNode(
1149: p_NodeParent.getName() + WhereAreYou.NODE_SEPARATOR
1150: + "cf",
1151: "icon/jms_connector.gif",
1152: p_Resources
1153: .getMessage("treenode.jonas.server.services.jms.cf"),
1154: "ListConnectionFactories.do", "content", false);
1155: p_NodeParent.addChild(node);
1156: getJmsConnectionFactories(node, p_Resources, p_ServerName);
1157:
1158: // Add node for Queues
1159: node = new TreeControlNode(
1160: p_NodeParent.getName() + WhereAreYou.NODE_SEPARATOR
1161: + "queue",
1162: "icon/jms_queue.gif",
1163: p_Resources
1164: .getMessage("treenode.jonas.server.services.jms.queues"),
1165: "ListQueues.do", "content", false);
1166: p_NodeParent.addChild(node);
1167: getJmsQueues(node, p_Resources, p_ServerName);
1168:
1169: // Add node for Topics
1170: node = new TreeControlNode(
1171: p_NodeParent.getName() + WhereAreYou.NODE_SEPARATOR
1172: + "topic",
1173: "icon/jms_topic.gif",
1174: p_Resources
1175: .getMessage("treenode.jonas.server.services.jms.topics"),
1176: "ListTopics.do", "content", false);
1177: p_NodeParent.addChild(node);
1178: getJmsTopics(node, p_Resources, p_ServerName);
1179: }
1180:
1181: /**
1182: * Append subnodes for ConnectionFactory resources
1183: *
1184: * @param p_NodeParent CFs subnode
1185: * @param p_Resources The MessageResources for our localized messages
1186: *
1187: * @exception Exception if an exception occurs building the tree
1188: */
1189: public void getJmsConnectionFactories(TreeControlNode p_NodeParent,
1190: MessageResources p_Resources, String p_ServerName)
1191: throws Exception {
1192: // Get the 3 connection factories created by default:
1193: // - default ConnectionFactory , default Topic ConnectionFactory, default Queue ConnectionFactory,
1194: // This corresponds to the current implementation of the JMS service ..... ???
1195: int nbConnFacts = 3;
1196: String cfNames[] = new String[3];
1197: ObjectName jmsServMB = JonasObjectName.jmsService();
1198: cfNames[0] = (String) JonasManagementRepr
1199: .getAttribute(jmsServMB,
1200: "DefaultConnectionFactoryName", p_ServerName);
1201: cfNames[1] = (String) JonasManagementRepr.getAttribute(
1202: jmsServMB, "DefaultTopicConnectionFactoryName",
1203: p_ServerName);
1204: cfNames[2] = (String) JonasManagementRepr.getAttribute(
1205: jmsServMB, "DefaultQueueConnectionFactoryName",
1206: p_ServerName);
1207: TreeControlNode node;
1208: for (int i = 0; i < nbConnFacts; i++) {
1209: node = new TreeControlNode(p_NodeParent.getName()
1210: + WhereAreYou.NODE_SEPARATOR + cfNames[i],
1211: "icon/jms_connector.gif", cfNames[i],
1212: "PresentConnectionFactory.do?name=" + cfNames[i],
1213: "content", false);
1214: p_NodeParent.addChild(node);
1215: }
1216: }
1217:
1218: /**
1219: * Append subnodes node for Queue destinations
1220: *
1221: * @param p_NodeParent Queue subnode
1222: * @param p_Resources The MessageResources for our localized messages
1223: *
1224: * @exception Exception if an exception occurs building the tree
1225: */
1226: public void getJmsQueues(TreeControlNode p_NodeParent,
1227: MessageResources p_Resources, String p_ServerName)
1228: throws Exception {
1229: // Get queues list
1230: Iterator itNames = ((java.util.Set) JonasManagementRepr
1231: .getAttribute(JonasObjectName.jmsService(),
1232: "AllJmsQueueDestinationNames", p_ServerName))
1233: .iterator();
1234: while (itNames.hasNext()) {
1235: String sNodeName = (String) itNames.next();
1236: String sQueueName = sNodeName;
1237: // Add node for each queue
1238: TreeControlNode node = new TreeControlNode(p_NodeParent
1239: .getName()
1240: + WhereAreYou.NODE_SEPARATOR + sNodeName,
1241: "icon/jms_queue.gif", sQueueName,
1242: "PresentQueue.do?name=" + sQueueName, "content",
1243: false);
1244: p_NodeParent.addChild(node);
1245: }
1246: }
1247:
1248: /**
1249: * Append subnodes node for Topic destinations
1250: *
1251: * @param p_NodeParent Topic subnode
1252: * @param p_Resources The MessageResources for our localized messages
1253: *
1254: * @exception Exception if an exception occurs building the tree
1255: */
1256: public void getJmsTopics(TreeControlNode p_NodeParent,
1257: MessageResources p_Resources, String p_ServerName)
1258: throws Exception {
1259: // Get topics list
1260: Iterator itNames = ((java.util.Set) JonasManagementRepr
1261: .getAttribute(JonasObjectName.jmsService(),
1262: "AllJmsTopicDestinationNames", p_ServerName))
1263: .iterator();
1264: while (itNames.hasNext()) {
1265: String sNodeName = (String) itNames.next();
1266: String sTopicName = sNodeName;
1267: // Add node for each topic
1268: TreeControlNode node = new TreeControlNode(p_NodeParent
1269: .getName()
1270: + WhereAreYou.NODE_SEPARATOR + sNodeName,
1271: "icon/jms_topic.gif", sTopicName,
1272: "PresentTopic.do?name=" + sTopicName, "content",
1273: false);
1274: p_NodeParent.addChild(node);
1275: }
1276: }
1277:
1278: /**
1279: * Append node for Mail service for the JOnAS services.
1280: *
1281: * @param p_NodeServices Services node for the tree control
1282: * @param p_Resources The MessageResources for our localized messages
1283: * messages
1284: *
1285: * @exception Exception if an exception occurs building the tree
1286: */
1287: protected void getServiceMail(TreeControlNode p_NodeServices,
1288: MessageResources p_Resources, HttpServletRequest p_Request,
1289: String p_DomainName, String p_ServerName) throws Exception {
1290: // Add Service node
1291: TreeControlNode nodeService = new TreeControlNode(
1292: p_NodeServices.getName() + WhereAreYou.NODE_SEPARATOR
1293: + "mail",
1294: "icon/service_mail.gif",
1295: p_Resources
1296: .getMessage("treenode.jonas.server.services.mail"),
1297: "EditMailService.do", "content", false);
1298: p_NodeServices.addChild(nodeService);
1299: // Add nodes for MailFactories
1300: getAllSessionMailFactories(nodeService, p_Resources, p_Request);
1301: getAllMimePartDSMailFactories(nodeService, p_Resources,
1302: p_Request);
1303: }
1304:
1305: public void getAllSessionMailFactories(
1306: TreeControlNode p_NodeParent, MessageResources p_Resources,
1307: HttpServletRequest p_Request) throws Exception {
1308: // Add parent node for all the Session Mail Factories
1309: TreeControlNode nodeSessionMailFactories = new TreeControlNode(
1310: p_NodeParent.getName() + WhereAreYou.NODE_SEPARATOR
1311: + "session",
1312: "icon/mail_session.gif",
1313: p_Resources
1314: .getMessage("treenode.jonas.server.services.mail.session"),
1315: "ListSessionMailFactories.do", "content", false);
1316: p_NodeParent.addChild(nodeSessionMailFactories);
1317: // Add a node for each Session Mail Factory
1318: getSessionMailFactories(nodeSessionMailFactories, p_Resources,
1319: p_Request);
1320: }
1321:
1322: public void getAllMimePartDSMailFactories(
1323: TreeControlNode p_NodeParent, MessageResources p_Resources,
1324: HttpServletRequest p_Request) throws Exception {
1325: // Add parent node for all the Session Mail Factories
1326: TreeControlNode nodeMimePartMailFactories = new TreeControlNode(
1327: p_NodeParent.getName() + WhereAreYou.NODE_SEPARATOR
1328: + "mimepart",
1329: "icon/mail_mime.gif",
1330: p_Resources
1331: .getMessage("treenode.jonas.server.services.mail.mimepart"),
1332: "ListMimePartMailFactories.do", "content", false);
1333: p_NodeParent.addChild(nodeMimePartMailFactories);
1334: // Add a node for each Session Mail Factory
1335: getMimePartMailFactories(nodeMimePartMailFactories,
1336: p_Resources, p_Request);
1337: }
1338:
1339: protected void getSessionMailFactories(
1340: TreeControlNode p_NodeParent, MessageResources p_Resources,
1341: HttpServletRequest p_Request) throws Exception {
1342: String sPath;
1343: String sFile;
1344: String sNodeName;
1345: ArrayList al = new ArrayList();
1346:
1347: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
1348: .getAttribute(WhereAreYou.SESSION_NAME);
1349:
1350: // Get List
1351: java.util.List deployedFactories = (java.util.List) JonasAdminJmx
1352: .getSessionMailFactoriesDeployed(oWhere);
1353: Iterator itNames = deployedFactories.iterator();
1354: //Iterator itNames = ((java.util.List) JonasAdminJmx.getSessionMailFactoriesDeployed(oWhere)).iterator();
1355: while (itNames.hasNext()) {
1356: al.add(itNames.next().toString());
1357: }
1358: // Sort list
1359: Collections.sort(al);
1360: // Build nodes
1361: for (int i = 0; i < al.size(); i++) {
1362: TreeControlNode node = new TreeControlNode(
1363: p_NodeParent.getName() + WhereAreYou.NODE_SEPARATOR
1364: + al.get(i).toString(),
1365: "icon/mail_session.gif", al.get(i).toString(),
1366: "EditSessionMailFactory.do?name="
1367: + al.get(i).toString(), "content", false);
1368: p_NodeParent.addChild(node);
1369: }
1370: }
1371:
1372: protected void getMimePartMailFactories(
1373: TreeControlNode p_NodeParent, MessageResources p_Resource,
1374: HttpServletRequest p_Request) throws Exception {
1375: String sPath;
1376: String sFile;
1377: String sNodeName;
1378: ArrayList al = new ArrayList();
1379:
1380: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
1381: .getAttribute(WhereAreYou.SESSION_NAME);
1382:
1383: // Get List
1384: Iterator itNames = ((java.util.List) JonasAdminJmx
1385: .getMimeMailPartFactoriesDeployed(oWhere)).iterator();
1386: while (itNames.hasNext()) {
1387: al.add(itNames.next().toString());
1388: }
1389: // Sort list
1390: Collections.sort(al);
1391: // Build nodes
1392: for (int i = 0; i < al.size(); i++) {
1393: TreeControlNode node = new TreeControlNode(
1394: p_NodeParent.getName() + WhereAreYou.NODE_SEPARATOR
1395: + al.get(i).toString(),
1396: "icon/mail_mime.gif", al.get(i).toString(),
1397: "EditMimePartMailFactory.do?name="
1398: + al.get(i).toString(), "content", false);
1399: p_NodeParent.addChild(node);
1400: }
1401: }
1402:
1403: /**
1404: * Append node for Resource service for the JOnAS services.
1405: *
1406: * @param p_NodeServices Services node for the tree control
1407: * @param p_Resources The MessageResources for our localized messages
1408: *
1409: * @exception Exception if an exception occurs building the tree
1410: */
1411: protected void getServiceResourceAdapter(
1412: TreeControlNode p_NodeServices,
1413: MessageResources p_Resources, String p_DomainName,
1414: String p_ServerName) throws Exception {
1415: // Add Service node
1416: TreeControlNode nodeService = new TreeControlNode(
1417: p_NodeServices.getName() + WhereAreYou.NODE_SEPARATOR
1418: + "resourceAdapter",
1419: "icon/service_resource.gif",
1420: p_Resources
1421: .getMessage("treenode.jonas.server.services.resource"),
1422: "ListResourceAdapters.do", "content", false);
1423: p_NodeServices.addChild(nodeService);
1424: // Add Containers nodes
1425: getResourceAdapters(nodeService, p_Resources, p_DomainName,
1426: p_ServerName);
1427: }
1428:
1429: /**
1430: * Append node for all Resource Adapters.
1431: *
1432: * @param p_NodeParent Server node for the tree control
1433: * @param p_Resources The MessageResources for our localized messages
1434: * @param pDomainName The name of the current management domain
1435: * @param pServerName The name of the currently managed JOnAS server
1436: *
1437: * @exception Exception if an exception occurs building the tree
1438: */
1439: public void getResourceAdapters(TreeControlNode p_NodeParent,
1440: MessageResources p_Resources, String p_DomainName,
1441: String p_ServerName) throws Exception {
1442: String sPath;
1443: String sFile;
1444: String sNodeName;
1445: String sName;
1446: ObjectName on;
1447: ArrayList al = new ArrayList();
1448:
1449: // Get Resource Adapters
1450: ObjectName ons = J2eeObjectName.getResourceAdapters(
1451: p_DomainName, p_ServerName);
1452: Iterator itNames = JonasManagementRepr.queryNames(ons,
1453: p_ServerName).iterator();
1454: while (itNames.hasNext()) {
1455: ObjectName it_on = (ObjectName) itNames.next();
1456: sPath = (String) JonasManagementRepr.getAttribute(it_on,
1457: "fileName", p_ServerName);
1458: sFile = JonasAdminJmx.extractFilename(sPath);
1459: sNodeName = p_NodeParent.getName()
1460: + WhereAreYou.NODE_SEPARATOR + sFile;
1461: sName = it_on.getKeyProperty("name");
1462: if (sFile != null) {
1463: al.add(new ResourceItem(sFile, sPath, sNodeName, it_on
1464: .toString(), sName));
1465: }
1466: }
1467: // Sort list
1468: Collections.sort(al, new ResourceItemByFile());
1469: // Build nodes
1470: ResourceItem oItem;
1471: for (int i = 0; i < al.size(); i++) {
1472: oItem = (ResourceItem) al.get(i);
1473: TreeControlNode node = new TreeControlNode(oItem
1474: .getNodeName(), "icon/ear.gif", oItem.getFile(),
1475: "EditResourceAdapter.do?select="
1476: + oItem.getObjectName(), "content", false);
1477: p_NodeParent.addChild(node);
1478: }
1479: /*
1480: // Get Container List
1481: ObjectName ons = J2eeObjectName.getResourceAdapterModules(p_DomainName, p_ServerName);
1482: Iterator itNames = JonasManagementRepr.queryNames(ons).iterator();
1483: while (itNames.hasNext()) {
1484: on = (ObjectName) itNames.next();
1485: al.add(on.getKeyProperty("name"));
1486: }
1487: // Sort list
1488: Collections.sort(al);
1489: // Build nodes
1490: for (int i = 0; i < al.size(); i++) {
1491: sName = al.get(i).toString();
1492: TreeControlNode node = new TreeControlNode(p_NodeParent.getName()
1493: + WhereAreYou.NODE_SEPARATOR + sName, "icon/resourceAdapter.gif"
1494: , JonasAdminJmx.extractFilename(sName)
1495: , "EditResourceAdapter.do?name=" + sName, "content", false);
1496: p_NodeParent.addChild(node);
1497: }
1498: */
1499: }
1500:
1501: /**
1502: * Append node for Security service for the JOnAS services.
1503: *
1504: * @param p_NodeServices Services node for the tree control
1505: * @param p_Resources The MessageResources for our localized messages
1506: * messages
1507: *
1508: * @exception Exception if an exception occurs building the tree
1509: */
1510: protected void getServiceSecurity(TreeControlNode p_NodeServices,
1511: MessageResources p_Resources, String p_DomainName,
1512: String p_ServerName) throws Exception {
1513: // Add Service node
1514: TreeControlNode nodeService = new TreeControlNode(
1515: p_NodeServices.getName() + WhereAreYou.NODE_SEPARATOR
1516: + "security",
1517: "icon/service_security.gif",
1518: p_Resources
1519: .getMessage("treenode.jonas.server.services.security"),
1520: "EditServiceSecurity.do", "content", false);
1521: p_NodeServices.addChild(nodeService);
1522: }
1523:
1524: /**
1525: * Append nodes for Deployments services for the specified server.
1526: *
1527: * @param p_ServerNode Server node for the tree control
1528: * @param p_Resources The MessageResources for our localized messages
1529: * @exception Exception if an exception occurs building the tree
1530: */
1531: protected void getDeployments(TreeControlNode p_ServerNode,
1532: MessageResources p_Resources, HttpServletRequest p_Request)
1533: throws Exception {
1534: // Deployments node
1535: TreeControlNode nodeDeployments = new TreeControlNode(
1536: p_ServerNode.getName() + WhereAreYou.NODE_SEPARATOR
1537: + "deployments",
1538: "icon/deploy.gif",
1539: p_Resources
1540: .getMessage("treenode.jonas.server.deployments"),
1541: null, "content", false);
1542: p_ServerNode.addChild(nodeDeployments);
1543: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
1544: .getAttribute(WhereAreYou.SESSION_NAME);
1545: String serverName = oWhere.getCurrentJonasServerName();
1546: // Detail Service node
1547: if (JonasAdminJmx.hasMBeanName(JonasObjectName.earService(),
1548: serverName)) {
1549: getDeploymentEar(nodeDeployments, p_Resources);
1550: }
1551: if (JonasAdminJmx.hasMBeanName(JonasObjectName.ejbService(),
1552: serverName)) {
1553: getDeploymentEjb(nodeDeployments, p_Resources);
1554: }
1555: if (JonasAdminJmx.hasMBeanName(JonasObjectName
1556: .webContainerService(), serverName)) {
1557: getDeploymentWebAppli(nodeDeployments, p_Resources);
1558: }
1559: if (JonasAdminJmx.hasMBeanName(JonasObjectName
1560: .resourceService(), serverName)) {
1561: getDeploymentRar(nodeDeployments, p_Resources);
1562: }
1563: }
1564:
1565: /**
1566: * Append node for Ear deployment.
1567: *
1568: * @param p_NodeDeployments Deployment node for the tree control
1569: * @param p_Resources The MessageResources for our localized messages
1570: *
1571: * @exception Exception if an exception occurs building the tree
1572: */
1573: protected void getDeploymentEar(TreeControlNode p_NodeDeployments,
1574: MessageResources p_Resources) throws Exception {
1575: // Add node
1576: TreeControlNode oNode = new TreeControlNode(
1577: p_NodeDeployments.getName()
1578: + WhereAreYou.NODE_SEPARATOR
1579: + WhereAreYou.DEPLOYMENT_STRING_EAR,
1580: "icon/deploy_ear.gif",
1581: p_Resources
1582: .getMessage("treenode.jonas.server.deployments."
1583: + WhereAreYou.DEPLOYMENT_STRING_EAR),
1584: "EditDeploy.do?type="
1585: + WhereAreYou.DEPLOYMENT_STRING_EAR, "content",
1586: false);
1587: p_NodeDeployments.addChild(oNode);
1588: }
1589:
1590: /**
1591: * Append node for Ejb deployment.
1592: *
1593: * @param p_NodeDeployments Deployment node for the tree control
1594: * @param p_Resources The MessageResources for our localized messages
1595: *
1596: * @exception Exception if an exception occurs building the tree
1597: */
1598: protected void getDeploymentEjb(TreeControlNode p_NodeDeployments,
1599: MessageResources p_Resources) throws Exception {
1600: // Add node
1601: TreeControlNode oNode = new TreeControlNode(
1602: p_NodeDeployments.getName()
1603: + WhereAreYou.NODE_SEPARATOR
1604: + WhereAreYou.DEPLOYMENT_STRING_JAR,
1605: "icon/deploy_jar.gif",
1606: p_Resources
1607: .getMessage("treenode.jonas.server.deployments."
1608: + WhereAreYou.DEPLOYMENT_STRING_JAR),
1609: "EditDeploy.do?type="
1610: + WhereAreYou.DEPLOYMENT_STRING_JAR, "content",
1611: false);
1612: p_NodeDeployments.addChild(oNode);
1613:
1614: // Add list files
1615: //getDeploymentJarFiles(oNode, p_Resources);
1616: }
1617:
1618: /**
1619: * Append node for Ejb Files deployment.
1620: *
1621: * @param p_NodeParent Deployment node for the tree control
1622: * @param p_Resources The MessageResources for our localized messages
1623: *
1624: * @exception Exception if an exception occurs building the tree
1625: */
1626: /*
1627: protected void getDeploymentEjbFiles(TreeControlNode p_NodeParent, MessageResources p_Resources)
1628: throws Exception {
1629: String sFile;
1630: Iterator it = JonasAdminJmx.getJarFilesDeployable().iterator();
1631: while (it.hasNext()) {
1632: sFile = it.next().toString();
1633: // Add node
1634: TreeControlNode oNode = new TreeControlNode(p_NodeParent.getName()
1635: + WhereAreYou.NODE_SEPARATOR + sFile, "icon/JonasQuestion.gif", sFile, null
1636: , "content", false);
1637: p_NodeParent.addChild(oNode);
1638: }
1639:
1640: }
1641: */
1642: /**
1643: * Append node for Web deployment.
1644: *
1645: * @param p_NodeDeployments Deployment node for the tree control
1646: * @param p_Resources The MessageResources for our localized messages
1647: *
1648: * @exception Exception if an exception occurs building the tree
1649: */
1650: protected void getDeploymentWebAppli(
1651: TreeControlNode p_NodeDeployments,
1652: MessageResources p_Resources) throws Exception {
1653: // Add node
1654: TreeControlNode oNode = new TreeControlNode(
1655: p_NodeDeployments.getName()
1656: + WhereAreYou.NODE_SEPARATOR
1657: + WhereAreYou.DEPLOYMENT_STRING_WAR,
1658: "icon/deploy_war.gif",
1659: p_Resources
1660: .getMessage("treenode.jonas.server.deployments."
1661: + WhereAreYou.DEPLOYMENT_STRING_WAR),
1662: "EditDeploy.do?type="
1663: + WhereAreYou.DEPLOYMENT_STRING_WAR, "content",
1664: false);
1665: p_NodeDeployments.addChild(oNode);
1666: }
1667:
1668: /**
1669: * Append node for Rar deployment.
1670: *
1671: * @param p_NodeDeployments Deployment node for the tree control
1672: * @param p_Resources The MessageResources for our localized messages
1673: *
1674: * @exception Exception if an exception occurs building the tree
1675: */
1676: protected void getDeploymentRar(TreeControlNode p_NodeDeployments,
1677: MessageResources p_Resources) throws Exception {
1678: // Add node
1679: TreeControlNode oNode = new TreeControlNode(
1680: p_NodeDeployments.getName()
1681: + WhereAreYou.NODE_SEPARATOR
1682: + WhereAreYou.DEPLOYMENT_STRING_RAR,
1683: "icon/deploy_rar.gif",
1684: p_Resources
1685: .getMessage("treenode.jonas.server.deployments."
1686: + WhereAreYou.DEPLOYMENT_STRING_RAR),
1687: "EditDeploy.do?type="
1688: + WhereAreYou.DEPLOYMENT_STRING_RAR, "content",
1689: false);
1690: p_NodeDeployments.addChild(oNode);
1691: }
1692:
1693: /**
1694: * Append nodes for Resources services for the specified server.
1695: *
1696: * @param p_ServerNode Server node for the tree control
1697: * @param p_Resources The MessageResources for our localized messages
1698: * @exception Exception if an exception occurs building the tree
1699: */
1700: protected void getResources(TreeControlNode p_ServerNode,
1701: MessageResources p_Resources, HttpServletRequest p_Request)
1702: throws Exception {
1703: // Resources node
1704: TreeControlNode nodeDeployments = new TreeControlNode(
1705: p_ServerNode.getName() + WhereAreYou.NODE_SEPARATOR
1706: + "resources", "icon/resources.gif",
1707: p_Resources
1708: .getMessage("treenode.jonas.server.resources"),
1709: null, "content", false);
1710: p_ServerNode.addChild(nodeDeployments);
1711:
1712: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
1713: .getAttribute(WhereAreYou.SESSION_NAME);
1714: String serverName = oWhere.getCurrentJonasServerName();
1715: // Detail Service node
1716: // - database resources
1717: if (JonasAdminJmx.hasMBeanName(JonasObjectName
1718: .databaseService(), serverName)) {
1719: getResourceDatabase(nodeDeployments, p_Resources);
1720: }
1721: // - jms resources
1722: if (JonasAdminJmx.hasMBeanName(JonasObjectName.jmsService(),
1723: serverName)) {
1724: getJmsResource(nodeDeployments, p_Resources);
1725: }
1726: // - mail resources
1727: if (JonasAdminJmx.hasMBeanName(JonasObjectName.mailService(),
1728: serverName)) {
1729: getMailResource(nodeDeployments, p_Resources);
1730: }
1731: }
1732:
1733: /**
1734: * Append nodes for Mail Resources for the specified server.
1735: *
1736: * @param p_ServerNode Server node for the tree control
1737: * @param p_Resources The MessageResources for our localized messages
1738: * @exception Exception if an exception occurs building the tree
1739: */
1740: protected void getMailResource(TreeControlNode p_ServerNode,
1741: MessageResources p_Resources) throws Exception {
1742: // Mail resources node
1743: TreeControlNode nodeDeployments = new TreeControlNode(
1744: p_ServerNode.getName() + WhereAreYou.NODE_SEPARATOR
1745: + "mail",
1746: "icon/mail.gif",
1747: p_Resources
1748: .getMessage("treenode.jonas.server.resources.mail"),
1749: "EditDeploy.do?type="
1750: + WhereAreYou.DEPLOYMENT_STRING_MAILFACTORY,
1751: "content", false);
1752: p_ServerNode.addChild(nodeDeployments);
1753: }
1754:
1755: /**
1756: * Append nodes for Jms Resource for the specified server.
1757: *
1758: * @param p_ServerNode Server node for the tree control
1759: * @param p_Resources The MessageResources for our localized messages
1760: * @exception Exception if an exception occurs building the tree
1761: */
1762: protected void getJmsResource(TreeControlNode p_ServerNode,
1763: MessageResources p_Resources) throws Exception {
1764: // Jms resources node
1765: TreeControlNode nodeDeployments = new TreeControlNode(
1766: p_ServerNode.getName() + WhereAreYou.NODE_SEPARATOR
1767: + "jms",
1768: "icon/jms.gif",
1769: p_Resources
1770: .getMessage("treenode.jonas.server.resources.jms"),
1771: "ListJmsResources.do", "content", false);
1772: p_ServerNode.addChild(nodeDeployments);
1773: }
1774:
1775: /**
1776: * Append nodes for Database Resource for the specified server.
1777: *
1778: * @param p_ServerNode Server node for the tree control
1779: * @param p_Resources The MessageResources for our localized messages
1780: * @exception Exception if an exception occurs building the tree
1781: */
1782: protected void getResourceDatabase(TreeControlNode p_ServerNode,
1783: MessageResources p_Resources) throws Exception {
1784: // Database Resources node
1785: TreeControlNode nodeDeployments = new TreeControlNode(
1786: p_ServerNode.getName() + WhereAreYou.NODE_SEPARATOR
1787: + "database",
1788: "icon/Database.gif",
1789: p_Resources
1790: .getMessage("treenode.jonas.server.resources.database"),
1791: "EditDeploy.do?type="
1792: + WhereAreYou.DEPLOYMENT_STRING_DATASOURCE,
1793: "content", false);
1794: p_ServerNode.addChild(nodeDeployments);
1795: }
1796:
1797: /**
1798: * Append nodes for Security for the specified server.
1799: *
1800: * @param p_ServerNode Server node for the tree control
1801: * @param p_Resources The MessageResources for our localized messages
1802: * @param p_Request The servlet request we are processing
1803: * @exception Exception if an exception occurs building the tree
1804: */
1805: protected void getSecurity(TreeControlNode p_ServerNode,
1806: MessageResources p_Resources, HttpServletRequest p_Request)
1807: throws Exception {
1808:
1809: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
1810: .getAttribute(WhereAreYou.SESSION_NAME);
1811: String serverName = oWhere.getCurrentJonasServerName();
1812: // Detect JOnAS item presents
1813: boolean bJonasSecurityService = JonasAdminJmx.hasMBeanName(
1814: JonasObjectName.securityService(), serverName);
1815: // Detect Catalina items present
1816: boolean bCatalinaRealm = false;
1817: if (oWhere.isCatalinaServer()) {
1818: bCatalinaRealm = JonasAdminJmx.hasMBeanName(
1819: CatalinaObjectName.catalinaRealm(oWhere
1820: .getCurrentCatalinaServiceName()),
1821: serverName);
1822: }
1823: // Add nodes
1824: if ((bJonasSecurityService) || (bCatalinaRealm)) {
1825: // Active action
1826: String sAction = null;
1827: if (bJonasSecurityService) {
1828: sAction = "ListRealms.do?realm=all";
1829: } else if (bCatalinaRealm) {
1830: sAction = "EditSecurityCatalinaRealm.do";
1831: }
1832: // Security node
1833: TreeControlNode nodeSecurity = new TreeControlNode(
1834: p_ServerNode.getName() + WhereAreYou.NODE_SEPARATOR
1835: + "security",
1836: "icon/security.gif",
1837: p_Resources
1838: .getMessage("treenode.jonas.server.security"),
1839: sAction, "content", false);
1840: p_ServerNode.addChild(nodeSecurity);
1841: // Detail Security node for JOnAS service
1842: if (bJonasSecurityService) {
1843: getSecurityFactories(nodeSecurity, p_Resources,
1844: p_Request);
1845: }
1846: }
1847: }
1848:
1849: /**
1850: * Append node for the Security catalina realm
1851: *
1852: * @param p_SecurityNode Catalina Server node for the tree control
1853: * @param p_Resources The MessageResources for our localized messages
1854: * @param p_Request The servlet request we are processing
1855: *
1856: * @exception Exception if an exception occurs building the tree
1857: */
1858: protected void getSecurityCatalinaRealm(
1859: TreeControlNode p_SecurityNode,
1860: MessageResources p_Resources, HttpServletRequest p_Request)
1861: throws Exception {
1862:
1863: // Add node
1864: TreeControlNode oNode = new TreeControlNode(
1865: p_SecurityNode.getName() + WhereAreYou.NODE_SEPARATOR
1866: + "catalina.realm",
1867: "icon/security.gif",
1868: p_Resources
1869: .getMessage("treenode.jonas.server.security.catalina.realm"),
1870: null, "content", false);
1871: p_SecurityNode.addChild(oNode);
1872: }
1873:
1874: /**
1875: * Append nodes for Security factories for the specified server.
1876: *
1877: * @param p_SecurityNode Security node for the tree control
1878: * @param p_Resources The MessageResources for our localized messages
1879: * @exception Exception if an exception occurs building the tree
1880: */
1881: public void getSecurityFactories(TreeControlNode p_SecurityNode,
1882: MessageResources p_Resources, HttpServletRequest p_Request)
1883: throws Exception {
1884: ArrayList al = null;
1885: String sName = null;
1886: TreeControlNode nodeSecurityFactories = null;
1887: TreeControlNode nodeSecurityFactory = null;
1888: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
1889: .getAttribute(WhereAreYou.SESSION_NAME);
1890: String serverName = oWhere.getCurrentJonasServerName();
1891: // Security Memory factories
1892: al = JonasAdminJmx.getSecurityMemoryFactories(serverName);
1893: if (al.size() > 0) {
1894: // Security factories node
1895: nodeSecurityFactories = new TreeControlNode(
1896: p_SecurityNode.getName()
1897: + WhereAreYou.NODE_SEPARATOR
1898: + "factory.memory",
1899: "icon/security_memory.gif",
1900: p_Resources
1901: .getMessage("treenode.jonas.server.security.factory.memory"),
1902: "ListRealms.do?realm=memory", "content", false);
1903: p_SecurityNode.addChild(nodeSecurityFactories);
1904: // List Security factories
1905: for (int i = 0; i < al.size(); i++) {
1906: sName = al.get(i).toString();
1907: // Security factory node
1908: nodeSecurityFactory = new TreeControlNode(
1909: nodeSecurityFactories.getName()
1910: + WhereAreYou.NODE_SEPARATOR + sName,
1911: "icon/security_memory.gif", sName,
1912: "EditMemoryRealm.do?resource=" + sName,
1913: "content", false);
1914: nodeSecurityFactories.addChild(nodeSecurityFactory);
1915: // Add detail to memory security node
1916: //getSecurityMemoryFactory(nodeSecurityFactory, p_Resources, sName);
1917: }
1918: }
1919: // Security Datasource factories
1920: al = JonasAdminJmx.getSecurityDatasourceFactories(serverName);
1921: if (al.size() > 0) {
1922: // Security factories node
1923: nodeSecurityFactories = new TreeControlNode(
1924: p_SecurityNode.getName()
1925: + WhereAreYou.NODE_SEPARATOR
1926: + "factory.datasource",
1927: "icon/security_database.gif",
1928: p_Resources
1929: .getMessage("treenode.jonas.server.security.factory.datasource"),
1930: "ListRealms.do?realm=datasource", "content", false);
1931: p_SecurityNode.addChild(nodeSecurityFactories);
1932: // List Security factories
1933: for (int i = 0; i < al.size(); i++) {
1934: sName = al.get(i).toString();
1935: // Security factory node
1936: nodeSecurityFactory = new TreeControlNode(
1937: nodeSecurityFactories.getName()
1938: + WhereAreYou.NODE_SEPARATOR + sName,
1939: "icon/security_database.gif", sName,
1940: "EditDatasourceRealm.do?resource=" + sName,
1941: "content", false);
1942: nodeSecurityFactories.addChild(nodeSecurityFactory);
1943: }
1944: }
1945: // Security Ldap factories
1946: al = JonasAdminJmx.getSecurityLdapFactories(serverName);
1947: if (al.size() > 0) {
1948: // Security factories node
1949: nodeSecurityFactories = new TreeControlNode(
1950: p_SecurityNode.getName()
1951: + WhereAreYou.NODE_SEPARATOR
1952: + "factory.ldap",
1953: "icon/security_ldap.gif",
1954: p_Resources
1955: .getMessage("treenode.jonas.server.security.factory.ldap"),
1956: "ListRealms.do?realm=ldap", "content", false);
1957: p_SecurityNode.addChild(nodeSecurityFactories);
1958: // List Security factories
1959: for (int i = 0; i < al.size(); i++) {
1960: sName = al.get(i).toString();
1961: // Security factory node
1962: nodeSecurityFactory = new TreeControlNode(
1963: nodeSecurityFactories.getName()
1964: + WhereAreYou.NODE_SEPARATOR + sName,
1965: "icon/security_ldap.gif", sName,
1966: "EditLdapRealm.do?resource=" + sName,
1967: "content", false);
1968: nodeSecurityFactories.addChild(nodeSecurityFactory);
1969: }
1970: }
1971: }
1972:
1973: /**
1974: * Append nodes for Memory Security Factory for the specified server.
1975: *
1976: * @param p_SecurityMemoryNode Server node for the tree control
1977: * @param p_Resources The MessageResources for our localized messages
1978: * @param p_ResourceFactory The name of resource
1979: * @exception Exception if an exception occurs building the tree
1980: */
1981: protected void getSecurityMemoryFactory(
1982: TreeControlNode p_SecurityMemoryNode,
1983: MessageResources p_Resources, String p_ResourceFactory)
1984: throws Exception {
1985: TreeControlNode node = null;
1986: // Users node
1987: node = new TreeControlNode(
1988: p_SecurityMemoryNode.getName()
1989: + WhereAreYou.NODE_SEPARATOR + "users",
1990: "icon/security_memory.gif",
1991: p_Resources
1992: .getMessage("treenode.jonas.server.security.factory.memory.users"),
1993: "EditMemoryRealmUsers.do?resource=" + p_ResourceFactory,
1994: "content", false);
1995: p_SecurityMemoryNode.addChild(node);
1996: // Groups node
1997: node = new TreeControlNode(
1998: p_SecurityMemoryNode.getName()
1999: + WhereAreYou.NODE_SEPARATOR + "groups",
2000: "icon/security_memory.gif",
2001: p_Resources
2002: .getMessage("treenode.jonas.server.security.factory.memory.groups"),
2003: "EditMemoryRealmGroups.do?resource="
2004: + p_ResourceFactory, "content", false);
2005: p_SecurityMemoryNode.addChild(node);
2006: // Roles node
2007: node = new TreeControlNode(
2008: p_SecurityMemoryNode.getName()
2009: + WhereAreYou.NODE_SEPARATOR + "roles",
2010: "icon/security_memory.gif",
2011: p_Resources
2012: .getMessage("treenode.jonas.server.security.factory.memory.roles"),
2013: "EditMemoryRealmRoles.do?resource=" + p_ResourceFactory,
2014: "content", false);
2015: p_SecurityMemoryNode.addChild(node);
2016: }
2017:
2018: /**
2019: * Append nodes for the Servlet server
2020: *
2021: * @param p_ServerNode Server node for the tree control
2022: * @param p_Resources The MessageResources for our localized messages
2023: * @param p_Request The servlet request we are processing
2024: *
2025: * @exception Exception if an exception occurs building the tree
2026: */
2027: protected void getProtocols(TreeControlNode p_ServerNode,
2028: MessageResources p_Resources, HttpServletRequest p_Request)
2029: throws Exception {
2030: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
2031: .getAttribute(WhereAreYou.SESSION_NAME);
2032: String serverName = oWhere.getCurrentJonasServerName();
2033: // Catalina server
2034: if (JonasAdminJmx.hasMBeanName(CatalinaObjectName
2035: .catalinaServer(), serverName)) {
2036: getCatalinaProtocols(p_ServerNode, p_Resources, p_Request);
2037: }
2038: }
2039:
2040: /**
2041: * Append nodes for the Catalina server
2042: *
2043: * @param p_ServerNode Server node for the tree control
2044: * @param p_Resources The MessageResources for our localized messages
2045: * @param p_Request The servlet request we are processing
2046: *
2047: * @exception Exception if an exception occurs building the tree
2048: */
2049: protected void getCatalinaProtocols(TreeControlNode p_ServerNode,
2050: MessageResources p_Resources, HttpServletRequest p_Request)
2051: throws Exception {
2052: // Add Catalina server node
2053: TreeControlNode catalinaNode = new TreeControlNode(p_ServerNode
2054: .getName()
2055: + WhereAreYou.NODE_SEPARATOR + "protocols",
2056: "icon/protocol.gif", p_Resources
2057: .getMessage("treenode.jonas.server.protocols"),
2058: "ListCatalinaConnectors.do", "content", false);
2059: p_ServerNode.addChild(catalinaNode);
2060: // Add Connectors nodes
2061: getCatalinaConnector(catalinaNode, p_Resources, p_Request);
2062: }
2063:
2064: /**
2065: * Append node for the Connector catalina server
2066: *
2067: * @param p_CatalinaServerNode Catalina Server node for the tree control
2068: * @param p_Resources The MessageResources for our localized messages
2069: * @param p_Request The servlet request we are processing
2070: *
2071: * @exception Exception if an exception occurs building the tree
2072: */
2073: protected void getCatalinaConnector(
2074: TreeControlNode p_CatalinaServerNode,
2075: MessageResources p_Resources, HttpServletRequest p_Request)
2076: throws Exception {
2077:
2078: // Add Connector node
2079: TreeControlNode connectorNode = new TreeControlNode(
2080: p_CatalinaServerNode.getName()
2081: + WhereAreYou.NODE_SEPARATOR + "connectors",
2082: "icon/connectors.gif",
2083: p_Resources
2084: .getMessage("treenode.jonas.server.protocols.connectors"),
2085: "ListCatalinaConnectors.do", "content", false);
2086: p_CatalinaServerNode.addChild(connectorNode);
2087:
2088: getCatalinaDetailConnectors(connectorNode, p_Resources,
2089: p_Request);
2090:
2091: }
2092:
2093: /**
2094: * Append nodes for all the Connectors catalina server
2095: *
2096: * @param p_ConnectorNode Connector node for the tree control
2097: * @param p_Resources The MessageResources for our localized messages
2098: * @param p_Request The servlet request we are processing
2099: *
2100: * @exception Exception if an exception occurs building the tree
2101: */
2102: public void getCatalinaDetailConnectors(
2103: TreeControlNode p_ConnectorNode,
2104: MessageResources p_Resources, HttpServletRequest p_Request)
2105: throws Exception {
2106:
2107: // Get WhereAreYou
2108: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
2109: .getAttribute(WhereAreYou.SESSION_NAME);
2110:
2111: String serverName = oWhere.getCurrentJonasServerName();
2112: // Get the domain name
2113: String sDomain = oWhere.getCurrentCatalinaDomainName();
2114: // Get the list of connectors
2115: ArrayList al = new ArrayList();
2116: Iterator it = JonasAdminJmx.getListMBeanName(
2117: CatalinaObjectName.catalinaConnectors(sDomain),
2118: serverName).iterator();
2119: while (it.hasNext()) {
2120: al.add(new ConnectorItem(new ObjectName(it.next()
2121: .toString()), oWhere.getApplicationServerPort(),
2122: serverName));
2123: }
2124: // Sort
2125: Collections.sort(al, new ConnectorItemByPort());
2126: // Build the nodes
2127: TreeControlNode node;
2128: ConnectorItem oConnector;
2129: String sLabel;
2130: for (int i = 0; i < al.size(); i++) {
2131: oConnector = (ConnectorItem) al.get(i);
2132: String nodeName = p_ConnectorNode.getName()
2133: + WhereAreYou.NODE_SEPARATOR + sDomain
2134: + WhereAreYou.NODE_SEPARATOR + oConnector.getPort();
2135: String address = oConnector.getAddress();
2136: if (address != null) {
2137: nodeName = nodeName + address;
2138: }
2139: node = new TreeControlNode(nodeName, "icon/connector.gif",
2140: oConnector.getLabel(),
2141: "EditCatalinaConnector.do?select="
2142: + oConnector.getObjectName(), "content",
2143: false);
2144: p_ConnectorNode.addChild(node);
2145: }
2146: }
2147:
2148: /**
2149: * Append node for JORAM platform management.
2150: *
2151: * @param pDomainNode Domain node for the tree control
2152: * @param jonasServerName the name of the JOnAS server to which the current JORAM server is connected
2153: * @param pResources The MessageResources for our localized messages
2154: * @param p_Request The servlet request we are processing
2155: *
2156: * @exception Exception If an exception occurs when building the tree.
2157: */
2158: public void getJoramPlatform(TreeControlNode pDomainNode,
2159: String jonasServerName, MessageResources pResources,
2160: HttpServletRequest p_Request) throws Exception {
2161:
2162: ObjectName joramPlatformON = JoramObjectName.joramPlatform();
2163: if (!JonasAdminJmx.hasMBeanName(joramPlatformON,
2164: jonasServerName)) {
2165: // No Joram to manage
2166: // reset localServerId in case we just switched management context
2167: // from a server which has Joram to this server which does not
2168: if (p_Request.getSession().getAttribute("localId") != null) {
2169: p_Request.getSession().setAttribute("localId", null);
2170: }
2171: return;
2172: }
2173: Set adapterOns = JonasManagementRepr.queryNames(JoramObjectName
2174: .joramAdapter(), jonasServerName);
2175: if (adapterOns.isEmpty()) {
2176: return;
2177: }
2178: ObjectName joramAdapterON = (ObjectName) adapterOns.iterator()
2179: .next();
2180:
2181: // Joram platform present, create node for it
2182: TreeControlNode platformNode = new TreeControlNode(pDomainNode
2183: .getName()
2184: + WhereAreYou.NODE_SEPARATOR + "joramplatform",
2185: "icon/service_jms.gif", pResources
2186: .getMessage("treenode.joramplatform"),
2187: "EditJoramPlatform.do", "content", false);
2188:
2189: // Create node for the local server (Joram server to which the admin client is connected)
2190: pDomainNode.addChild(platformNode);
2191:
2192: try {
2193: getJoramServers(platformNode, jonasServerName,
2194: joramPlatformON, pResources, p_Request);
2195: } catch (Exception e) {
2196: // TO DO
2197: }
2198: }
2199:
2200: /**
2201: * Append nodes for Joram server defined in tbe platform
2202: * @param platformNode Joram platform node
2203: * @param jonasServerName the name of the JOnAS server to which the current JORAM server is connected
2204: * @param joramPlatformON ObjectName of Joram Platform MBean
2205: * @param pResources The MessageResources for our localized messages
2206: * @param p_Request The servlet request we are processing
2207: * @throws Exception If an exception occurs when building the tree.
2208: */
2209: public void getJoramServers(TreeControlNode platformNode,
2210: String jonasServerName, ObjectName joramPlatformON,
2211: MessageResources pResources, HttpServletRequest p_Request)
2212: throws Exception {
2213:
2214: if (joramPlatformON == null) {
2215: joramPlatformON = JoramObjectName.joramPlatform();
2216: }
2217: ObjectName joramAdapterON = (ObjectName) (JonasManagementRepr
2218: .queryNames(JoramObjectName.joramAdapter(),
2219: jonasServerName)).iterator().next();
2220: boolean collocatedServer = true;
2221: Object attributeValue = null;
2222: if (JonasManagementRepr.isRegistered(joramAdapterON,
2223: jonasServerName)) {
2224: attributeValue = JonasManagementRepr
2225: .getAttribute(joramAdapterON, "CollocatedServer",
2226: jonasServerName);
2227: if (attributeValue != null) {
2228: collocatedServer = ((Boolean) attributeValue)
2229: .booleanValue();
2230: }
2231: }
2232: // get local Joram server
2233: String localId = null;
2234: attributeValue = JonasManagementRepr.getAttribute(
2235: joramPlatformON, "LocalServerId", jonasServerName);
2236: if (attributeValue != null) {
2237: Integer localIdInt = (Integer) attributeValue;
2238: localId = localIdInt.toString();
2239: }
2240: // Create the node for the currently managed JORAM server
2241: TreeControlNode currentServerNode = null;
2242: String nodeName = null;
2243: String icon = "icon/service_jms.gif";
2244: String label = null;
2245: String action = "EditJoramServer.do?id=" + localId;
2246: if (collocatedServer) {
2247: nodeName = platformNode.getName()
2248: + WhereAreYou.NODE_SEPARATOR + "joramlocalserver";
2249: label = pResources
2250: .getMessage("treenode.joramplatform.joramlocalserver")
2251: + " (" + localId + ")";
2252: } else {
2253: nodeName = platformNode.getName()
2254: + WhereAreYou.NODE_SEPARATOR + "joramcurrentserver";
2255: label = pResources
2256: .getMessage("treenode.joramplatform.joramcurrentserver")
2257: + " (" + localId + ")";
2258: }
2259: currentServerNode = new TreeControlNode(nodeName, icon, label,
2260: action, "content", false);
2261: platformNode.addChild(currentServerNode);
2262:
2263: // Add local server's resources
2264: getJoramResources(currentServerNode, jonasServerName, localId,
2265: pResources, p_Request);
2266:
2267: p_Request.getSession().setAttribute("localId", localId);
2268: p_Request.getSession().setAttribute("collocatedServer",
2269: new Boolean(collocatedServer));
2270:
2271: // get the other (remote) Joram servers
2272: List list = (List) JonasManagementRepr.getAttribute(
2273: joramPlatformON, "ServersIds", jonasServerName);
2274: if (list != null) {
2275: Iterator it = list.iterator();
2276: Integer serverId;
2277: String id;
2278: TreeControlNode remoteServerNode = null;
2279: while (it.hasNext()) {
2280: serverId = (Integer) it.next();
2281: id = serverId.toString();
2282: String joramremoteserver = null;
2283: if (!id.equals(localId)) {
2284: joramremoteserver = "joramremoteserver" + id;
2285: nodeName = platformNode.getName()
2286: + WhereAreYou.NODE_SEPARATOR
2287: + joramremoteserver;
2288: label = pResources
2289: .getMessage("treenode.joramplatform.joramremoteserver")
2290: + " (" + id + ")";
2291: action = "EditJoramServer.do?id=" + id;
2292: remoteServerNode = new TreeControlNode(nodeName,
2293: icon, label, action, "content", false);
2294: platformNode.addChild(remoteServerNode);
2295: // Add remote server's resources
2296: getJoramResources(remoteServerNode,
2297: jonasServerName, id, pResources, p_Request);
2298: }
2299: }
2300: }
2301: }
2302:
2303: /**
2304: * Append nodes for Joram DEstinations created in a Joram server
2305: * @param joramServerNode Joram server node
2306: * @param jonasServerName the name of the JOnAS server to which the current JORAM server is connected
2307: * @param serverId Joram server id
2308: * @param pResources The MessageResources for our localized messages
2309: * @param p_Request The servlet request we are processing
2310: * @throws Exception If an exception occurs when building the tree.
2311: */
2312: public void getJoramResources(TreeControlNode joramServerNode,
2313: String jonasServerName, String serverId,
2314: MessageResources pResources, HttpServletRequest p_Request)
2315: throws Exception {
2316:
2317: String joramServerNodeName = joramServerNode.getName();
2318:
2319: // Get all the destinations
2320: ObjectName joramAdminOn = JoramObjectName.joramAdmin();
2321: List destList = (List) JonasManagementRepr.getAttribute(
2322: joramAdminOn, "Destinations", jonasServerName);
2323: ArrayList destArray = new ArrayList();
2324: if (destList != null && !destList.isEmpty()) {
2325: Iterator it = destList.iterator();
2326: while (it.hasNext()) {
2327: ItemDestination destinationItem = getDestinationItem(
2328: (String) it.next(), jonasServerName);
2329: if (destinationItem.getServerId().equals(serverId)) {
2330: if (destinationItem.getType().equals("queue")) {
2331: // insert in head
2332: destArray.add(0, destinationItem);
2333: } else if (destinationItem.getType()
2334: .equals("topic")) {
2335: // append
2336: destArray.add(destinationItem);
2337: }
2338: }
2339: }
2340: }
2341: // Add sub-nodes for destinations belonging to the server
2342: for (int i = 0; i < destArray.size(); i++) {
2343: ItemDestination item = (ItemDestination) destArray.get(i);
2344: String name = item.getName();
2345: String type = item.getType();
2346: TreeControlNode destinationNode = null;
2347: String nodeName = null;
2348: String action = null;
2349: String icon = null;
2350: String label = null;
2351: if (type.equals("queue")) {
2352: nodeName = joramServerNodeName
2353: + WhereAreYou.NODE_SEPARATOR + "joramqueue"
2354: + name;
2355: icon = "icon/jms_queue.gif";
2356: label = pResources
2357: .getMessage("treenode.joramplatform.queue")
2358: + " (" + name + ")";
2359: action = "EditJoramQueue.do?name=" + name + "&id="
2360: + serverId;
2361: } else if (type.equals("topic")) {
2362: nodeName = joramServerNodeName
2363: + WhereAreYou.NODE_SEPARATOR + "joramtopic"
2364: + name;
2365: icon = "icon/jms_topic.gif";
2366: label = pResources
2367: .getMessage("treenode.joramplatform.topic")
2368: + " (" + name + ")";
2369: action = "EditJoramTopic.do?name=" + name + "&id="
2370: + serverId;
2371: }
2372: if (item.getOn() == null) {
2373: if (!item.isRegistered()) {
2374: Object[] asParam = { new Integer(serverId), name };
2375: String[] asSignature = { "int", "java.lang.String" };
2376: if (type.equals("queue")) {
2377: JonasManagementRepr.invoke(joramAdminOn,
2378: "createQueue", asParam, asSignature,
2379: jonasServerName);
2380: } else if (type.equals("topic")) {
2381: JonasManagementRepr.invoke(joramAdminOn,
2382: "createTopic", asParam, asSignature,
2383: jonasServerName);
2384: }
2385: } else {
2386: action = null;
2387: }
2388: }
2389: destinationNode = new TreeControlNode(nodeName, icon,
2390: label, action, "content", false);
2391: if (destinationNode != null) {
2392: joramServerNode.addChild(destinationNode);
2393: }
2394: }
2395: }
2396:
2397: /**
2398: * Append nodes for all defined MBeans.
2399: *
2400: * @param domainNode Root node for the tree control
2401: * @param resources The MessageResources for our localized messages
2402: *
2403: * @exception Exception if an exception occurs building the tree
2404: */
2405: public void getMBeans(TreeControlNode domainNode,
2406: MessageResources resources, HttpServletRequest p_Request)
2407: throws Exception {
2408: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
2409: .getAttribute(WhereAreYou.SESSION_NAME);
2410: String serverName = oWhere.getCurrentJonasServerName();
2411: TreeControlNode nodeMBeans = new TreeControlNode(domainNode
2412: .getName()
2413: + WhereAreYou.NODE_SEPARATOR + "mbeans",
2414: "icon/mbeans.gif", resources
2415: .getMessage("treenode.allmbeans"),
2416: "ListMBeans.do", "content", false);
2417: domainNode.addChild(nodeMBeans);
2418:
2419: ArrayList[] als = JonasAdminJmx
2420: .getFamiliesMbeansLists(serverName);
2421: if (als[MbeanItem.FAMILY_J2EE].size() > 0) {
2422: getJ2eeMBeans(nodeMBeans, resources,
2423: als[MbeanItem.FAMILY_J2EE]);
2424: }
2425: if (als[MbeanItem.FAMILY_OWNER].size() > 0) {
2426: getOwnerMBeans(nodeMBeans, resources,
2427: als[MbeanItem.FAMILY_OWNER]);
2428: }
2429: if (als[MbeanItem.FAMILY_UNKNOWN].size() > 0) {
2430: getUnknownMBeans(nodeMBeans, resources,
2431: als[MbeanItem.FAMILY_UNKNOWN]);
2432: }
2433: }
2434:
2435: /**
2436: * Append nodes for all defined Owner MBeans.
2437: *
2438: * @param p_ParentNode Parent node for the tree control
2439: * @param p_Resources The MessageResources for our localized messages
2440: * @param p_List The list of Mbeans
2441: *
2442: * @exception Exception if an exception occurs building the tree
2443: */
2444: public void getOwnerMBeans(TreeControlNode p_ParentNode,
2445: MessageResources p_Resources, ArrayList p_List)
2446: throws Exception {
2447:
2448: TreeControlNode nodeMBeans = new TreeControlNode(p_ParentNode
2449: .getName()
2450: + WhereAreYou.NODE_SEPARATOR + "owner",
2451: "icon/mbeans.gif", p_Resources
2452: .getMessage("treenode.mbeans.owner"),
2453: "ListOwnerMBeans.do", "content", false);
2454: p_ParentNode.addChild(nodeMBeans);
2455: // Sort list
2456: Collections.sort(p_List, new BeanComparator(new String[] {
2457: "domain", "type", "objectName" }));
2458:
2459: // Detail MBean node
2460: String sLastDomain = "";
2461: String sLastType = "";
2462: TreeControlNode nodeMBean = null;
2463: TreeControlNode nodeDomain = null;
2464: TreeControlNode nodeType = null;
2465: TreeControlNode nodeParent = null;
2466: OwnerMbeanItem oItem;
2467:
2468: Iterator it = p_List.iterator();
2469: while (it.hasNext()) {
2470: oItem = (OwnerMbeanItem) it.next();
2471:
2472: nodeParent = nodeMBeans;
2473: if (oItem.getDomain() != null) {
2474: // Domain node
2475: if (!oItem.getDomain().equals(sLastDomain)) {
2476: sLastDomain = oItem.getDomain();
2477: nodeDomain = new TreeControlNode(nodeParent
2478: .getName()
2479: + WhereAreYou.NODE_SEPARATOR
2480: + oItem.getDomain(),
2481: "icon/mbeandomain.gif", oItem.getDomain(),
2482: null, "content", false);
2483: nodeMBeans.addChild(nodeDomain);
2484: }
2485: nodeParent = nodeDomain;
2486:
2487: if (oItem.getType() != null) {
2488: // Type node
2489: if (!oItem.getType().equals(sLastType)) {
2490: sLastType = oItem.getType();
2491: nodeType = new TreeControlNode(nodeParent
2492: .getName()
2493: + WhereAreYou.NODE_SEPARATOR
2494: + oItem.getType(),
2495: "icon/mbeantype.gif", oItem.getType(),
2496: null, "content", false);
2497: nodeDomain.addChild(nodeType);
2498: }
2499: nodeParent = nodeType;
2500: }
2501: }
2502:
2503: // Mbean node
2504: nodeMBean = new TreeControlNode(p_ParentNode.getName()
2505: + WhereAreYou.NODE_SEPARATOR
2506: + oItem.getObjectName(), "icon/mbean.gif", oItem
2507: .getObjectName(),
2508: "ListMBeanDetails.do?select="
2509: + URLEncoder.encode(oItem.getObjectName(),
2510: "UTF-8"), "content", false);
2511: nodeParent.addChild(nodeMBean);
2512:
2513: }
2514: }
2515:
2516: /**
2517: * Append nodes for all defined J2EE MBeans.
2518: *
2519: * @param p_ParentNode Parent node for the tree control
2520: * @param p_Resources The MessageResources for our localized messages
2521: * @param p_List The list of Mbeans
2522: *
2523: * @exception Exception if an exception occurs building the tree
2524: */
2525: public void getJ2eeMBeans(TreeControlNode p_ParentNode,
2526: MessageResources p_Resources, ArrayList p_List)
2527: throws Exception {
2528:
2529: TreeControlNode nodeMBeans = new TreeControlNode(p_ParentNode
2530: .getName()
2531: + WhereAreYou.NODE_SEPARATOR + "j2ee",
2532: "icon/mbeans.gif", p_Resources
2533: .getMessage("treenode.mbeans.j2ee"),
2534: "ListJ2eeMBeans.do", "content", false);
2535: p_ParentNode.addChild(nodeMBeans);
2536: // Sort list
2537: Collections.sort(p_List, new BeanComparator(new String[] {
2538: "domain", "j2eeType", "name", "objectName" }));
2539:
2540: // Detail MBean node
2541: J2eeMbeanItem oItem;
2542: String sLastDomain = "";
2543: String sLastType = "";
2544: TreeControlNode nodeMBean = null;
2545: TreeControlNode nodeDomain = null;
2546: TreeControlNode nodeType = null;
2547: TreeControlNode nodeParent = null;
2548:
2549: Iterator it = p_List.iterator();
2550: while (it.hasNext()) {
2551: oItem = (J2eeMbeanItem) it.next();
2552:
2553: nodeParent = nodeMBeans;
2554: if (oItem.getDomain() != null) {
2555: // Domain node
2556: if (!oItem.getDomain().equals(sLastDomain)) {
2557: sLastDomain = oItem.getDomain();
2558: nodeDomain = new TreeControlNode(nodeParent
2559: .getName()
2560: + WhereAreYou.NODE_SEPARATOR
2561: + oItem.getDomain(),
2562: "icon/mbeandomain.gif", oItem.getDomain(),
2563: null, "content", false);
2564: nodeMBeans.addChild(nodeDomain);
2565: }
2566: nodeParent = nodeDomain;
2567: }
2568: if (oItem.getJ2eeType() != null) {
2569: // Type node
2570: if (!oItem.getJ2eeType().equals(sLastType)) {
2571: sLastType = oItem.getJ2eeType();
2572: nodeType = new TreeControlNode(nodeParent.getName()
2573: + WhereAreYou.NODE_SEPARATOR
2574: + oItem.getJ2eeType(),
2575: "icon/mbeantype.gif", oItem.getJ2eeType(),
2576: null, "content", false);
2577: nodeDomain.addChild(nodeType);
2578: }
2579: nodeParent = nodeType;
2580: }
2581:
2582: // Mbean node
2583: nodeMBean = new TreeControlNode(p_ParentNode.getName()
2584: + WhereAreYou.NODE_SEPARATOR
2585: + oItem.getObjectName(), "icon/mbean.gif", oItem
2586: .getObjectName(),
2587: "ListMBeanDetails.do?select="
2588: + URLEncoder.encode(oItem.getObjectName(),
2589: "UTF-8"), "content", false);
2590: nodeParent.addChild(nodeMBean);
2591:
2592: }
2593: }
2594:
2595: /**
2596: * Append nodes for all defined Unknown MBeans.
2597: *
2598: * @param p_ParentNode Parent node for the tree control
2599: * @param p_Resources The MessageResources for our localized messages
2600: * @param p_List The list of Mbeans
2601: *
2602: * @exception Exception if an exception occurs building the tree
2603: */
2604: public void getUnknownMBeans(TreeControlNode p_ParentNode,
2605: MessageResources p_Resources, ArrayList p_List)
2606: throws Exception {
2607:
2608: TreeControlNode nodeMBeans = new TreeControlNode(p_ParentNode
2609: .getName()
2610: + WhereAreYou.NODE_SEPARATOR + "unknown",
2611: "icon/mbeans.gif", p_Resources
2612: .getMessage("treenode.mbeans.unknown"),
2613: "ListUnknownMBeans.do", "content", false);
2614: p_ParentNode.addChild(nodeMBeans);
2615: // Sort list
2616: Collections.sort(p_List, new BeanComparator(new String[] {
2617: "domain", "objectName" }));
2618:
2619: // Detail MBean node
2620: MbeanItem oItem;
2621: String sLastDomain = "";
2622: TreeControlNode nodeMBean = null;
2623: TreeControlNode nodeDomain = null;
2624: TreeControlNode nodeType = null;
2625: TreeControlNode nodeParent = null;
2626:
2627: Iterator it = p_List.iterator();
2628: while (it.hasNext()) {
2629: oItem = (MbeanItem) it.next();
2630:
2631: nodeParent = nodeMBeans;
2632: if (oItem.getDomain() != null) {
2633: // Domain node
2634: if (!oItem.getDomain().equals(sLastDomain)) {
2635: sLastDomain = oItem.getDomain();
2636: nodeDomain = new TreeControlNode(nodeParent
2637: .getName()
2638: + WhereAreYou.NODE_SEPARATOR
2639: + oItem.getDomain(),
2640: "icon/mbeandomain.gif", oItem.getDomain(),
2641: null, "content", false);
2642: nodeMBeans.addChild(nodeDomain);
2643: }
2644: nodeParent = nodeDomain;
2645:
2646: }
2647:
2648: // Mbean node
2649: nodeMBean = new TreeControlNode(p_ParentNode.getName()
2650: + WhereAreYou.NODE_SEPARATOR
2651: + oItem.getObjectName(), "icon/mbean.gif", oItem
2652: .getObjectName(),
2653: "ListMBeanDetails.do?select="
2654: + URLEncoder.encode(oItem.getObjectName(),
2655: "UTF-8"), "content", false);
2656: nodeParent.addChild(nodeMBean);
2657:
2658: }
2659: }
2660:
2661: /**
2662: * Append nodes Attributes and Operations for a defined MBean.
2663: *
2664: * @param nodeMBean The MBean node
2665: * @param onMBean The MBean Object name
2666: * @param resources Resource
2667: * @throws Exception
2668: */
2669: protected void getMBeanInfo(TreeControlNode nodeMBean,
2670: ObjectName onMBean, MessageResources resources,
2671: HttpServletRequest p_Request) throws Exception {
2672: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
2673: .getAttribute(WhereAreYou.SESSION_NAME);
2674: String serverName = oWhere.getCurrentJonasServerName();
2675: // Get all infos of a MBean
2676: MBeanInfo oMBeanInfo = JonasManagementRepr.getMBeanInfo(
2677: onMBean, serverName);
2678: // Get attributes infos
2679: MBeanAttributeInfo[] aoMBeanAttributeInfo = oMBeanInfo
2680: .getAttributes();
2681: if (aoMBeanAttributeInfo.length > 0) {
2682: // Append attributes node
2683: TreeControlNode nodeAttributes = new TreeControlNode(
2684: "Attributes" + WhereAreYou.NODE_SEPARATOR
2685: + onMBean.toString(),
2686: "icon/JonasQuestion.gif",
2687: resources
2688: .getMessage("treenode.allmbeans.attributes"),
2689: null, "content", false);
2690: nodeMBean.addChild(nodeAttributes);
2691: // Loop to append each attribute node
2692: for (int i = 0; i < aoMBeanAttributeInfo.length; i++) {
2693: TreeControlNode nodeAttr = new TreeControlNode(String
2694: .valueOf(i)
2695: + WhereAreYou.NODE_SEPARATOR
2696: + onMBean.toString()
2697: + WhereAreYou.NODE_SEPARATOR
2698: + aoMBeanAttributeInfo[i].getName(),
2699: "icon/property.gif", aoMBeanAttributeInfo[i]
2700: .getName(), null, "content", false);
2701: nodeAttributes.addChild(nodeAttr);
2702: }
2703: }
2704: // Get operations infos
2705: MBeanOperationInfo[] aoMBeanOperationInfo = oMBeanInfo
2706: .getOperations();
2707: if (aoMBeanOperationInfo.length > 0) {
2708: // Append operations node
2709: TreeControlNode nodeOperations = new TreeControlNode(
2710: "Operations" + WhereAreYou.NODE_SEPARATOR
2711: + onMBean.toString(),
2712: "icon/JonasQuestion.gif",
2713: resources
2714: .getMessage("treenode.allmbeans.operations"),
2715: null, "content", false);
2716: nodeMBean.addChild(nodeOperations);
2717: // Loop to append each operation node
2718: for (int i = 0; i < aoMBeanOperationInfo.length; i++) {
2719: TreeControlNode nodeOpe = new TreeControlNode(String
2720: .valueOf(i)
2721: + WhereAreYou.NODE_SEPARATOR
2722: + onMBean.toString()
2723: + WhereAreYou.NODE_SEPARATOR
2724: + aoMBeanOperationInfo[i].getName(),
2725: "icon/action.gif", aoMBeanOperationInfo[i]
2726: .getName(), null, "content", false);
2727: nodeOperations.addChild(nodeOpe);
2728: }
2729: }
2730: }
2731:
2732: /**
2733: * Create a ItemDestination object from a String structured as follows:
2734: * type=queue/topic, name=destName, id=#x.y.z
2735: * @param joramAdminDestination String containing destination description
2736: * @param serverName the name of the JOnAS server to which the current JORAM server is connected
2737: * @return ItemDestination containing name, type, id and ObjectName of the MBean associated to the corresponding destination
2738: * @throws MalformedObjectNameException could not construct destination ObjectName
2739: */
2740: public ItemDestination getDestinationItem(
2741: String joramAdminDestination, String serverName)
2742: throws MalformedObjectNameException {
2743: ItemDestination destinationItem = new ItemDestination();
2744: ObjectName destinationOn = null;
2745: StringTokenizer st = new StringTokenizer(joramAdminDestination,
2746: ",");
2747: String type = null;
2748: String name = null;
2749: String id = null;
2750: String serverId = null;
2751: while (st.hasMoreTokens()) {
2752: // A couple has the following structure: key=value
2753: String couple = st.nextToken().trim();
2754: int index = couple.indexOf("=");
2755: String key = couple.substring(0, index);
2756: String value = couple.substring(index + 1, couple.length());
2757: if (key.equals("type")) {
2758: type = value;
2759: destinationItem.setType(type);
2760: }
2761: if (key.equals("name")) {
2762: name = value;
2763: destinationItem.setName(name);
2764: }
2765: if (key.equals("id")) {
2766: id = value;
2767: destinationItem.setId(id);
2768: int indexBefore = id.indexOf("#");
2769: int indexAfter = id.indexOf(".", indexBefore);
2770: serverId = id.substring(indexBefore + 1, indexAfter);
2771: destinationItem.setServerId(serverId);
2772: }
2773: }
2774: if (name != null && type != null && id != null) {
2775: if (type.equals("topic")) {
2776: destinationOn = JoramObjectName.joramTopic(name);
2777: } else if (type.equals("queue")) {
2778: destinationOn = JoramObjectName.joramQueue(name);
2779: }
2780: if (destinationOn != null
2781: && JonasAdminJmx.hasMBeanName(destinationOn,
2782: serverName)) {
2783: destinationItem.setRegistered(true);
2784: // exists a destination MBean with the given type and name, check the id
2785: String foundId = (String) JonasManagementRepr
2786: .getAttribute(destinationOn, "Name", serverName);
2787: if (id.equals(foundId)) {
2788: destinationItem.setOn(destinationOn);
2789: }
2790: }
2791: }
2792: return destinationItem;
2793: }
2794:
2795: /**
2796: * Append nodes for monitoring
2797: */
2798: protected void getMonitoring(TreeControlNode p_DomainNode,
2799: MessageResources p_Resources, HttpServletRequest p_Request,
2800: String domainName, String serverName) throws Exception {
2801:
2802: String domainNodeName = p_DomainNode.getName();
2803: TreeControlNode nodeMonitoring = new TreeControlNode(
2804: domainNodeName + WhereAreYou.NODE_SEPARATOR
2805: + "monitoring",
2806: "icon/monitoring.gif",
2807: p_Resources
2808: .getMessage("treenode.jonas.domain.monitoring"),
2809: null, "content", true);
2810:
2811: p_DomainNode.addChild(0, nodeMonitoring);
2812: getMonitoringNodeList(nodeMonitoring, p_Resources, p_Request,
2813: domainName, serverName);
2814: getMonitoringClusterList(nodeMonitoring, p_Resources,
2815: p_Request, domainName, serverName);
2816: //getClusterDaemonList(nodeMonitoring, p_Resources, p_Request, domainName);
2817: }
2818:
2819: /**
2820: * Append nodes for servers monitoring
2821: */
2822: protected void getMonitoringNodeList(TreeControlNode p_ParentNode,
2823: MessageResources p_Resources, HttpServletRequest p_Request,
2824: String domainName, String serverName) throws Exception {
2825: // server proxy
2826: Iterator itNames = JonasAdminJmx.getListMbean(
2827: new ObjectName(domainName + ":type=ServerProxy,*"),
2828: serverName).iterator();
2829: while (itNames.hasNext()) {
2830: ObjectName elem = (ObjectName) itNames.next();
2831: TreeControlNode node = new TreeControlNode(p_ParentNode
2832: .getName()
2833: + WhereAreYou.NODE_SEPARATOR
2834: + elem.getKeyProperty("name"),
2835: "icon/BalJonasTree.gif", elem
2836: .getKeyProperty("name"),
2837: "DisplayNodeInfo.do?node="
2838: + elem.getKeyProperty("name"), "content",
2839: true);
2840:
2841: p_ParentNode.addChild(node);
2842: }
2843: }
2844:
2845: /**
2846: * Append nodes for clusters monitoring
2847: */
2848: protected void getMonitoringClusterList(
2849: TreeControlNode p_ParentNode, MessageResources p_Resources,
2850: HttpServletRequest p_Request, String domainName,
2851: String serverName) throws Exception {
2852:
2853: String clusterType;
2854: String iconPath;
2855: String membersAttribute;
2856: String clusterActionPage;
2857: String memberActionPage;
2858:
2859: // tomcat cluster
2860: clusterType = "TomcatCluster";
2861: iconPath = "icon/domain_jonas.gif";
2862: membersAttribute = "Members";
2863: clusterActionPage = "TomcatClusterInfo.do?clust=";
2864: memberActionPage = "TomcatMemberInfo.do";
2865:
2866: displayClusterMembers(domainName, p_ParentNode, clusterType,
2867: iconPath, membersAttribute, clusterActionPage,
2868: memberActionPage, domainName, serverName);
2869:
2870: // loadbalancing cluster
2871: clusterType = "JkCluster";
2872: iconPath = "icon/domain_jonas.gif";
2873: membersAttribute = "Members";
2874: clusterActionPage = "JkClusterInfo.do?clust=";
2875: memberActionPage = "JkMemberInfo.do";
2876:
2877: displayClusterMembers(domainName, p_ParentNode, clusterType,
2878: iconPath, membersAttribute, clusterActionPage,
2879: memberActionPage, domainName, serverName);
2880:
2881: // CMI cluster
2882: clusterType = "CmiCluster";
2883: iconPath = "icon/domain_jonas.gif";
2884: membersAttribute = "Members";
2885: clusterActionPage = "CmiClusterInfo.do?clust=";
2886: memberActionPage = "CmiMemberInfo.do";
2887:
2888: displayClusterMembers(domainName, p_ParentNode, clusterType,
2889: iconPath, membersAttribute, clusterActionPage,
2890: memberActionPage, domainName, serverName);
2891:
2892: // EjbHa cluster
2893: clusterType = "EjbHaCluster";
2894: iconPath = "icon/domain_jonas.gif";
2895: membersAttribute = "Members";
2896: clusterActionPage = "EjbHaClusterInfo.do?clust=";
2897: memberActionPage = "EjbHaMemberInfo.do";
2898:
2899: displayClusterMembers(domainName, p_ParentNode, clusterType,
2900: iconPath, membersAttribute, clusterActionPage,
2901: memberActionPage, domainName, serverName);
2902:
2903: // Joram cluster
2904: clusterType = "JoramCluster";
2905: iconPath = "icon/domain_jonas.gif";
2906: membersAttribute = "Members";
2907: clusterActionPage = "JoramClusterInfo.do?clust=";
2908: memberActionPage = "JoramMemberInfo.do";
2909:
2910: displayClusterMembers(domainName, p_ParentNode, clusterType,
2911: iconPath, membersAttribute, clusterActionPage,
2912: memberActionPage, domainName, serverName);
2913:
2914: // Logical cluster
2915: clusterType = "LogicalCluster";
2916: iconPath = "icon/domain_jonas.gif";
2917: membersAttribute = "Members";
2918: clusterActionPage = "LogicalClusterInfo.do?clust=";
2919: memberActionPage = "LogicalMemberInfo.do";
2920:
2921: displayClusterMembers(domainName, p_ParentNode, clusterType,
2922: iconPath, membersAttribute, clusterActionPage,
2923: memberActionPage, domainName, serverName);
2924: }
2925:
2926: /**
2927: *
2928: * @param sDomainName
2929: * @param p_ParentNode
2930: * @param clusterType
2931: * @param iconPath
2932: * @param membersAttribute
2933: * @param clusterActionPage
2934: * @param memberActionPage
2935: */
2936: private void displayClusterMembers(String sDomainName,
2937: TreeControlNode p_ParentNode, String clusterType,
2938: String iconPath, String membersAttribute,
2939: String clusterActionPage, String memberActionPage,
2940: String domainName, String serverName) throws Exception {
2941: Iterator itNames = null;
2942:
2943: boolean isLogicalCluster = false;
2944: if (clusterType.equals("LogicalCluster")) {
2945: isLogicalCluster = true;
2946: }
2947: itNames = JonasAdminJmx.getListMbean(
2948: new ObjectName(sDomainName + ":type=" + clusterType
2949: + ",*"), serverName).iterator();
2950: while (itNames.hasNext()) {
2951: ObjectName on = (ObjectName) itNames.next();
2952: String clusterName = on.getKeyProperty("name");
2953: if (clusterName.equals(domainName)) {
2954: continue;
2955: }
2956: String clusterNodeName = clusterName + " - ("
2957: + on.getKeyProperty("type") + ")";
2958: // Cluster node
2959: TreeControlNode nodeCluster = new TreeControlNode(
2960: p_ParentNode.getName() + WhereAreYou.NODE_SEPARATOR
2961: + clusterNodeName, iconPath,
2962: clusterNodeName, clusterActionPage + clusterName,
2963: "content", true);
2964: p_ParentNode.addChild(nodeCluster);
2965:
2966: String[] members = null;
2967: members = (String[]) JonasManagementRepr.getAttribute(on,
2968: membersAttribute, serverName);
2969: String memberAction = null;
2970: if (members != null) {
2971: for (int i = 0; i < members.length; i++) {
2972: ObjectName onMember = new ObjectName(members[i]);
2973: String memberName = onMember.getKeyProperty("name");
2974: if ("LogicalCluster".equals(clusterType)) {
2975: memberAction = null;
2976: } else {
2977: memberAction = memberActionPage + "?member="
2978: + memberName + "&clust=" + clusterName;
2979: }
2980: // Members node
2981: TreeControlNode node = new TreeControlNode(
2982: nodeCluster.getName()
2983: + WhereAreYou.NODE_SEPARATOR
2984: + memberName,
2985: "icon/BalJonasTree.gif", memberName,
2986: memberAction, "content", true);
2987:
2988: nodeCluster.addChild(node);
2989: }
2990: }
2991: }
2992: }
2993:
2994: /**
2995: * Append nodes for cluster daemons
2996: */
2997: protected void getClusterDaemonList(TreeControlNode p_ParentNode,
2998: MessageResources p_Resources, HttpServletRequest p_Request,
2999: String domainName, String serverName) throws Exception {
3000:
3001: // clusterDaemon proxy
3002: Iterator itNames = JonasAdminJmx.getListMbean(
3003: new ObjectName(domainName
3004: + ":type=ClusterDaemonProxy,*"), serverName)
3005: .iterator();
3006: while (itNames.hasNext()) {
3007: ObjectName elem = (ObjectName) itNames.next();
3008: TreeControlNode node = new TreeControlNode(p_ParentNode
3009: .getName()
3010: + WhereAreYou.NODE_SEPARATOR
3011: + "ClusterDaemonProxy"
3012: + elem.getKeyProperty("name"),
3013: "icon/BalJonasGreen.gif", elem
3014: .getKeyProperty("name"),
3015: "DaemonProxyClusterInfo.do?node="
3016: + elem.getKeyProperty("name"), "content",
3017: true);
3018:
3019: p_ParentNode.addChild(node);
3020: }
3021: }
3022:
3023: // MQ Connector support
3024: //----------------------
3025: /**
3026: *
3027: */
3028: public void getJonasMqConnectorPlatform(
3029: TreeControlNode pServerNode, String sServerName,
3030: MessageResources pResources, HttpServletRequest p_Request)
3031: throws Exception {
3032: /*
3033: * retrieve the domain name
3034: */
3035: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
3036: .getAttribute(WhereAreYou.SESSION_NAME);
3037: String sDomainName = oWhere.getCurrentDomainName();
3038:
3039: TreeControlNode platformNode = new TreeControlNode(pServerNode
3040: .getName()
3041: + WhereAreYou.NODE_SEPARATOR + "jonasmqconnect",
3042: "icon/service_jms.gif", pResources
3043: .getMessage("treenode.joansmqconnect.name"),
3044: "JonasMqConnectPlatform.do", "content", false);
3045:
3046: pServerNode.addChild(platformNode);
3047:
3048: //ObjectName mqOnPattern = new ObjectName(sDomainName + ":type=JonasMQConnector,*");
3049: ObjectName[] mqOns = MqObjectNames.getConnectorsON(sDomainName,
3050: sServerName);
3051: for (int i = 0; i < mqOns.length; i++) {
3052: ObjectName on = (ObjectName) mqOns[i];
3053: String connectorName = on.getKeyProperty("name");
3054: TreeControlNode serverNode = new TreeControlNode(
3055: platformNode.getName() + WhereAreYou.NODE_SEPARATOR
3056: + "jonasmqconnector"
3057: + WhereAreYou.NODE_SEPARATOR
3058: + connectorName, "icon/jms_connector.gif",
3059: connectorName,
3060: "JonasMqConnect.do?operation=view&connector="
3061: + connectorName, "content", false);
3062: platformNode.addChild(serverNode);
3063: getJonasMqDestinations(serverNode, connectorName,
3064: sServerName, pResources, p_Request);
3065: }
3066: }
3067:
3068: /**
3069: *
3070: * Build the destination nodes
3071: */
3072: public void getJonasMqDestinations(TreeControlNode pMQNode,
3073: String connectorName, String sServerName,
3074: MessageResources pResources, HttpServletRequest p_Request)
3075: throws Exception {
3076:
3077: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
3078: .getAttribute(WhereAreYou.SESSION_NAME);
3079: String sDomainName = oWhere.getCurrentDomainName();
3080: //ObjectName mqDestPattern = new ObjectName(sDomainName + ":type=MQDestination,JonasMQConnector=" + connectorName+ ",*");
3081: //System.err.println("JOnASTreeBuilder querying " + mqDestPattern + " for server " + sServerName);
3082: ObjectName mqDestPattern = MqObjectNames.getDestinationsON(
3083: sDomainName, connectorName);
3084: Set destOns = JonasManagementRepr.queryNames(mqDestPattern,
3085: sServerName);
3086: for (Iterator i = destOns.iterator(); i.hasNext();) {
3087: ObjectName on = (ObjectName) i.next();
3088: String destName = on.getKeyProperty("name");
3089: boolean isTopic = ((Boolean) JonasManagementRepr
3090: .getAttribute(on, "IsTopic", sServerName))
3091: .booleanValue();
3092: TreeControlNode serverNode = new TreeControlNode(pMQNode
3093: .getName()
3094: + WhereAreYou.NODE_SEPARATOR
3095: + "destination"
3096: + WhereAreYou.NODE_SEPARATOR + destName, "icon/"
3097: + (isTopic ? "jms_topic.gif" : "jms_queue.gif"),
3098: destName,
3099: "JonasMqConnectDestinationEdit.do?operation=view&jndiName="
3100: + destName + "&connector=" + connectorName,
3101: "content", false);
3102: pMQNode.addChild(serverNode);
3103: }
3104: }
3105: }
|