1 25 26 package org.objectweb.jonas.webapp.jonasadmin; 27 28 import java.net.URLEncoder ; 29 import java.util.ArrayList ; 30 import java.util.Collection ; 31 import java.util.Collections ; 32 import java.util.HashMap ; 33 import java.util.Iterator ; 34 import java.util.List ; 35 import java.util.StringTokenizer ; 36 37 import javax.management.MBeanAttributeInfo ; 38 import javax.management.MBeanInfo ; 39 import javax.management.MBeanOperationInfo ; 40 import javax.management.MalformedObjectNameException ; 41 import javax.management.ObjectName ; 42 import javax.servlet.http.HttpServletRequest ; 43 44 import org.allesta.wsabi.j2ee.Handler; 45 import org.allesta.wsabi.j2ee.PortComponent; 46 import org.allesta.wsabi.j2ee.WebServiceDescription; 47 import org.allesta.wsabi.j2ee.provider.GenericDomainCapableProvider; 48 import org.allesta.wsabi.j2ee.provider.jonas.JonasProvider; 49 import org.apache.struts.Globals; 50 import org.apache.struts.action.ActionServlet; 51 import org.apache.struts.util.MessageResources; 52 import org.objectweb.jonas.jmx.CatalinaObjectName; 53 import org.objectweb.jonas.jmx.J2eeObjectName; 54 import org.objectweb.jonas.jmx.JonasManagementRepr; 55 import org.objectweb.jonas.jmx.JonasObjectName; 56 import org.objectweb.jonas.jmx.JoramObjectName; 57 import org.objectweb.jonas.webapp.jonasadmin.catalina.ConnectorItem; 58 import org.objectweb.jonas.webapp.jonasadmin.catalina.ConnectorItemByPort; 59 import org.objectweb.jonas.webapp.jonasadmin.common.BeanComparator; 60 import org.objectweb.jonas.webapp.jonasadmin.joramplatform.ItemDestination; 61 import org.objectweb.jonas.webapp.jonasadmin.logging.LoggerItem; 62 import org.objectweb.jonas.webapp.jonasadmin.mbean.J2eeMbeanItem; 63 import org.objectweb.jonas.webapp.jonasadmin.mbean.MbeanItem; 64 import org.objectweb.jonas.webapp.jonasadmin.mbean.OwnerMbeanItem; 65 import org.objectweb.jonas.webapp.jonasadmin.service.container.ContainerItem; 66 import org.objectweb.jonas.webapp.jonasadmin.service.container.ContainerItemByFile; 67 import org.objectweb.jonas.webapp.jonasadmin.service.container.WebAppItem; 68 import org.objectweb.jonas.webapp.jonasadmin.service.container.WebAppItemByPathContext; 69 import org.objectweb.jonas.webapp.jonasadmin.service.ejb.EjbItem; 70 import org.objectweb.jonas.webapp.jonasadmin.service.ejb.EjbItemByNameComparator; 71 import org.objectweb.jonas.webapp.jonasadmin.service.resource.ResourceItem; 72 import org.objectweb.jonas.webapp.jonasadmin.service.resource.ResourceItemByFile; 73 import org.objectweb.jonas.webapp.taglib.TreeBuilder; 74 import org.objectweb.jonas.webapp.taglib.TreeControl; 75 import org.objectweb.jonas.webapp.taglib.TreeControlNode; 76 77 85 public class JonasTreeBuilder implements TreeBuilder { 86 87 89 91 100 public void buildTree(TreeControl treeControl, ActionServlet servlet 101 , HttpServletRequest request) { 102 try { 103 TreeControlNode rootNode = treeControl.getRoot(); 104 MessageResources resources = (MessageResources) servlet.getServletContext(). 105 getAttribute(Globals.MESSAGES_KEY); 106 getDomain(rootNode, resources, request); 107 } 108 catch (Throwable t) { 109 t.printStackTrace(System.out); 110 } 111 } 112 113 115 124 protected void getDomain(TreeControlNode p_RootNode, MessageResources p_Resources 125 , HttpServletRequest p_Request) 126 throws Exception { 127 WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou. 129 SESSION_NAME); 130 String sDomain = oWhere.getCurrentDomain().toString(); String sDomainName = oWhere.getCurrentDomainName(); String sNodeLabel = p_Resources.getMessage("treenode.jonas.domain") + " ( " + sDomainName 133 + " )"; 134 TreeControlNode domainNode = new TreeControlNode("domain", "icon/domain_jonas.gif" 135 , sNodeLabel, "EditDomain.do?select=" + URLEncoder.encode(sDomain, "UTF-8"), "content", true); 136 p_RootNode.addChild(domainNode); 137 if (JonasAdminJmx.hasMBeanName(JonasObjectName.discoveryService()) && isMaster()) { 139 getDomainDeploy(domainNode, p_Resources, p_Request); 140 } 141 getServer(domainNode, p_Resources, p_Request, sDomainName); 142 getJoramPlatform(domainNode, p_Resources, p_Request); 143 getMBeans(domainNode, p_Resources); 144 } 145 146 150 protected boolean isMaster() { 151 ObjectName oObjectName = JonasObjectName.discoveryService(); 152 Boolean result = (Boolean ) JonasManagementRepr.getAttribute(oObjectName, "IsDiscoveryMaster"); 153 return result.booleanValue(); 154 } 155 156 166 protected void getDomainDeploy(TreeControlNode p_DomainNode, MessageResources p_Resources 167 , HttpServletRequest p_Request) 168 throws Exception { 169 170 TreeControlNode nodeDeployments = new TreeControlNode(p_DomainNode.getName() 171 + WhereAreYou.NODE_SEPARATOR + "deployments", "icon/deployDomainManage.gif" 172 , p_Resources.getMessage("treenode.jonas.server.deployments"), null, "content", true); 173 174 p_DomainNode.addChild(0, nodeDeployments); 175 if (JonasAdminJmx.hasMBeanName(JonasObjectName.earService()) == true) { 176 getDomainDeploymentEar(nodeDeployments, p_Resources); 177 } 178 if (JonasAdminJmx.hasMBeanName(JonasObjectName.ejbService()) == true) { 179 getDomainDeploymentEjb(nodeDeployments, p_Resources); 180 } 181 if (JonasAdminJmx.hasMBeanName(JonasObjectName.webContainerService()) == true) { 182 getDomainDeploymentWebAppli(nodeDeployments, p_Resources); 183 } 184 if (JonasAdminJmx.hasMBeanName(JonasObjectName.resourceService()) == true) { 185 getDomainDeploymentRar(nodeDeployments, p_Resources); 186 } 187 } 188 189 197 protected void getDomainDeploymentEar(TreeControlNode p_NodeDeployments, MessageResources p_Resources) 198 throws Exception { 199 TreeControlNode oNode = new TreeControlNode(p_NodeDeployments.getName() 201 + WhereAreYou.NODE_SEPARATOR + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_EAR, "icon/deployDomain_ear.gif" 202 , p_Resources.getMessage("treenode.jonas.server.deployments." 203 + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_EAR) 204 , "EditDomainDeploy.do?type=" + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_EAR, "content", false); 205 p_NodeDeployments.addChild(oNode); 206 } 207 208 216 protected void getDomainDeploymentEjb(TreeControlNode p_NodeDeployments, MessageResources p_Resources) 217 throws Exception { 218 TreeControlNode oNode = new TreeControlNode(p_NodeDeployments.getName() 220 + WhereAreYou.NODE_SEPARATOR + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_JAR, "icon/deployDomain_jar.gif" 221 , p_Resources.getMessage("treenode.jonas.server.deployments." 222 + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_JAR) 223 , "EditDomainDeploy.do?type=" + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_JAR, "content", false); 224 p_NodeDeployments.addChild(oNode); 225 226 } 229 230 238 protected void getDomainDeploymentWebAppli(TreeControlNode p_NodeDeployments 239 , MessageResources p_Resources) 240 throws Exception { 241 TreeControlNode oNode = new TreeControlNode(p_NodeDeployments.getName() 243 + WhereAreYou.NODE_SEPARATOR + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_WAR, "icon/deployDomain_war.gif" 244 , p_Resources.getMessage("treenode.jonas.server.deployments." 245 + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_WAR) 246 , "EditDomainDeploy.do?type=" + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_WAR, "content", false); 247 p_NodeDeployments.addChild(oNode); 248 } 249 250 258 protected void getDomainDeploymentRar(TreeControlNode p_NodeDeployments, MessageResources p_Resources) 259 throws Exception { 260 TreeControlNode oNode = new TreeControlNode(p_NodeDeployments.getName() 262 + WhereAreYou.NODE_SEPARATOR + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_RAR, "icon/deployDomain_rar.gif" 263 , p_Resources.getMessage("treenode.jonas.server.deployments." 264 + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_RAR) 265 , "EditDomainDeploy.do?type=" + WhereAreYou.DOMAIN_DEPLOYMENT_STRING_RAR, "content", false); 266 p_NodeDeployments.addChild(oNode); 267 } 268 269 278 protected void getServer(TreeControlNode p_DomainNode, MessageResources p_Resources 279 , HttpServletRequest p_Request, String p_DomainName) 280 throws Exception { 281 288 WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou. 289 SESSION_NAME); 290 String sServer = oWhere.getCurrentJonasServer().toString(); 291 String sServerName = oWhere.getCurrentJonasServerName(); 292 String sNodeLabel = p_Resources.getMessage("treenode.jonas.server") + " ( " + sServerName + " )"; 293 TreeControlNode serverNode = new TreeControlNode(p_DomainNode.getName() 294 + WhereAreYou.NODE_SEPARATOR + sServerName, "icon/BalJonasTree.gif", sNodeLabel 295 , "EditJonasServer.do?select=" + URLEncoder.encode(sServer, "UTF-8"), "content", true); 296 p_DomainNode.addChild(serverNode); 297 getMonitoring(serverNode, p_Resources); 299 getLogging(serverNode, p_Resources, p_Request); 300 getProtocols(serverNode, p_Resources, p_Request); 301 getServices(serverNode, p_Resources, p_Request, p_DomainName, sServerName); 302 getDeployments(serverNode, p_Resources); 303 getResources(serverNode, p_Resources); 304 getSecurity(serverNode, p_Resources, p_Request); 305 } 306 307 316 protected void getMonitoring(TreeControlNode p_ServerNode, MessageResources p_Resources) 317 throws Exception { 318 TreeControlNode node = new TreeControlNode(p_ServerNode.getName() 320 + WhereAreYou.NODE_SEPARATOR + "monitoring", "icon/monitoring.gif" 321 , p_Resources.getMessage("treenode.jonas.server.monitoring"), "EditMonitoring.do" 322 , "content", false); 323 p_ServerNode.addChild(node); 324 } 325 326 335 protected void getLogging(TreeControlNode p_ServerNode, MessageResources p_Resources 336 , HttpServletRequest p_Request) 337 throws Exception { 338 TreeControlNode node = new TreeControlNode(p_ServerNode.getName() 340 + WhereAreYou.NODE_SEPARATOR + "logging", "icon/loggers.gif" 341 , p_Resources.getMessage("treenode.jonas.server.logging"), "ListLoggers.do", "content", false); 342 p_ServerNode.addChild(node); 343 getLoggers(node, p_Resources, p_Request); 345 } 346 347 356 public void getLoggers(TreeControlNode p_LoggingNode, MessageResources p_Resources 357 , HttpServletRequest p_Request) 358 throws Exception { 359 WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou. 361 SESSION_NAME); 362 ArrayList al = JonasAdminJmx.getLoggers(p_Resources, oWhere, true); 364 LoggerItem oLog; 366 String sIcon = "icon/loggers.gif"; 367 String rootNodeName = p_LoggingNode.getName(); 368 String nodeName; 369 for (int i = 0; i < al.size(); i++) { 370 oLog = (LoggerItem) al.get(i); 371 if (LoggerItem.LOGGER_JONAS.equals(oLog.getType())) { 372 sIcon = "icon/logger_jonas.gif"; 373 nodeName = rootNodeName + WhereAreYou.NODE_SEPARATOR + LoggerItem.LOGGER_JONAS; 374 } else { 375 sIcon = "icon/logger_http.gif"; 376 nodeName = rootNodeName 377 + WhereAreYou.NODE_SEPARATOR 378 + oLog.getType() 379 + WhereAreYou.NODE_SEPARATOR 380 + oLog.getContainerName(); 381 } 382 TreeControlNode node = new TreeControlNode(nodeName, sIcon 384 , oLog.getName() 385 , oLog.getForward() 386 , "content", false); 387 p_LoggingNode.addChild(node); 388 } 389 } 390 391 399 protected void getServices(TreeControlNode p_ServerNode, MessageResources p_Resources 400 , HttpServletRequest p_Request, String p_DomainName, String p_ServerName) 401 throws Exception { 402 TreeControlNode nodeAllServices = new TreeControlNode(p_ServerNode.getName() 404 + WhereAreYou.NODE_SEPARATOR + "services", "icon/services.gif" 405 , p_Resources.getMessage("treenode.jonas.server.services"), "ListServices.do" 406 , "content", true); 407 p_ServerNode.addChild(nodeAllServices); 408 409 if (JonasAdminJmx.hasMBeanName(JonasObjectName.earService()) == true) { 411 getServiceApp(nodeAllServices, p_Resources, p_DomainName, p_ServerName); 412 } 413 if (JonasAdminJmx.hasMBeanName(JonasObjectName.ejbService()) == true) { 414 getServiceEjbContainer(nodeAllServices, p_Resources, p_DomainName, p_ServerName); 415 } 416 if (JonasAdminJmx.hasMBeanName(JonasObjectName.webContainerService()) == true) { 417 getServiceWeb(nodeAllServices, p_Resources, p_Request, p_DomainName, p_ServerName); 418 } 419 if (JonasAdminJmx.hasMBeanName(JonasObjectName.databaseService()) == true) { 420 getServiceDatabase(nodeAllServices, p_Resources, p_DomainName, p_ServerName); 421 } 422 if (JonasAdminJmx.hasMBeanName(JonasObjectName.resourceService()) == true) { 423 getServiceResourceAdapter(nodeAllServices, p_Resources, p_DomainName, p_ServerName); 424 } 425 if (JonasAdminJmx.hasMBeanName(JonasObjectName.transactionService()) == true) { 426 getServiceTransaction(nodeAllServices, p_Resources, p_DomainName, p_ServerName); 427 } 428 if (JonasAdminJmx.hasMBeanName(JonasObjectName.jmsService()) == true) { 429 getServiceJms(nodeAllServices, p_Resources, p_DomainName, p_ServerName); 430 } 431 if (JonasAdminJmx.hasMBeanName(JonasObjectName.mailService()) == true) { 432 getServiceMail(nodeAllServices, p_Resources, p_Request, p_DomainName, p_ServerName); 433 } 434 if (JonasAdminJmx.hasMBeanName(JonasObjectName.securityService()) == true) { 435 getServiceSecurity(nodeAllServices, p_Resources, p_DomainName, p_ServerName); 436 } 437 if (JonasAdminJmx.hasMBeanName(JonasObjectName.discoveryService()) == true) { 438 getServiceDiscovery(nodeAllServices, p_Resources, p_DomainName, p_ServerName); 439 } 440 if (JonasAdminJmx.hasMBeanName(JonasObjectName.wsService()) == true) { 441 getServiceWebService(nodeAllServices, p_Resources, p_Request, p_DomainName, p_ServerName); 442 } 443 } 444 445 453 protected void getServiceApp(TreeControlNode p_NodeServices, MessageResources p_Resources, String p_DomainName, String p_ServerName) 454 throws Exception { 455 TreeControlNode nodeService = new TreeControlNode(p_NodeServices.getName() 457 + WhereAreYou.NODE_SEPARATOR + "ear", "icon/service_application.gif" 458 , p_Resources.getMessage("treenode.jonas.server.services.ear") 459 , "ListAppContainers.do" 460 , "content", false); 461 p_NodeServices.addChild(nodeService); 462 463 getAppContainers(nodeService, p_Resources, p_DomainName, p_ServerName); 465 } 466 467 475 public void getAppContainers(TreeControlNode p_NodeParent, MessageResources p_Resources, String p_DomainName, String p_ServerName) 476 throws Exception { 477 String sPath; 478 String sFile; 479 String sNodeName; 480 String sName; 481 ArrayList al = new ArrayList (); 482 483 ObjectName ons = J2eeObjectName.J2EEApplications(p_DomainName, p_ServerName); 485 Iterator itNames = JonasManagementRepr.queryNames(ons).iterator(); 486 while (itNames.hasNext()) { 487 ObjectName it_on = (ObjectName ) itNames.next(); 488 sPath = (String ) JonasManagementRepr.getAttribute(it_on, "earUrl").toString(); 489 sFile = JonasAdminJmx.extractFilename(sPath); 490 sNodeName = p_NodeParent.getName() + WhereAreYou.NODE_SEPARATOR + sFile; 491 sName = it_on.getKeyProperty("name"); 492 if (sFile != null) { 493 al.add(new ContainerItem(sFile, sPath, sNodeName, it_on.toString(), sName)); 494 } 495 } 496 Collections.sort(al, new ContainerItemByFile()); 498 ContainerItem oItem; 500 for (int i = 0; i < al.size(); i++) { 501 oItem = (ContainerItem) al.get(i); 502 TreeControlNode node = new TreeControlNode(oItem.getNodeName(), "icon/ear.gif" 503 , oItem.getFile(), "EditEar.do?select=" + oItem.getObjectName(), "content", false); 504 p_NodeParent.addChild(node); 505 } 506 } 507 508 517 protected void getServiceEjbContainer(TreeControlNode p_NodeServices 518 , MessageResources p_Resources, String p_DomainName, String p_ServerName) 519 throws Exception { 520 TreeControlNode nodeService = new TreeControlNode(p_NodeServices.getName() 522 + WhereAreYou.NODE_SEPARATOR + "ejbContainers", "icon/service_ejb.gif" 523 , p_Resources.getMessage("treenode.jonas.server.services.ejbContainers") 524 , "ListContainers.do" 525 , "content", false); 526 p_NodeServices.addChild(nodeService); 527 getContainers(nodeService, p_Resources, p_DomainName, p_ServerName); 529 } 530 531 539 public void getContainers(TreeControlNode p_NodeParent, MessageResources p_Resources, String p_DomainName, String p_ServerName) 540 throws Exception { 541 String sPath; 542 String sFile; 543 String sName; 544 String sNodeName; 545 ObjectName onContainer; 546 ArrayList al = new ArrayList (); 547 548 Iterator itNames = JonasManagementRepr.queryNames(J2eeObjectName.getEJBModules(p_DomainName, p_ServerName)).iterator(); 550 while (itNames.hasNext()) { 551 ObjectName it_on = (ObjectName ) itNames.next(); 552 sPath = (String ) JonasManagementRepr.getAttribute(it_on, "fileName"); 553 sFile = JonasAdminJmx.extractFilename(sPath); 554 sNodeName = p_NodeParent.getName() + WhereAreYou.NODE_SEPARATOR + sFile; 555 sName = it_on.getKeyProperty("name"); 556 if (sFile != null) { 557 al.add(new ContainerItem(sFile, sPath, sNodeName, it_on.toString(), sName)); 558 } 559 } 560 561 Collections.sort(al, new ContainerItemByFile()); 563 ContainerItem oItem; 565 for (int i = 0; i < al.size(); i++) { 566 oItem = (ContainerItem) al.get(i); 567 TreeControlNode node = new TreeControlNode(oItem.getNodeName(), "icon/jar.gif" 568 , oItem.getFile(), "EditContainer.do?select=" + oItem.getObjectName(), "content", false); 569 p_NodeParent.addChild(node); 570 getEjbs(node, p_Resources, oItem.getPath(), p_DomainName, p_ServerName, oItem.getName()); 572 } 573 } 574 575 584 protected void getEjbs(TreeControlNode p_NodeParent, MessageResources p_Resources 585 , String p_Filename, String p_DomainName, String p_ServerName, String p_moduleName) 586 throws Exception { 587 Iterator itNames; 589 ObjectName on; 590 ArrayList al = new ArrayList (); 591 592 on = J2eeObjectName.getEntityBeans(p_DomainName, p_moduleName, p_ServerName); 593 594 itNames = JonasAdminJmx.getListMbean(on).iterator(); 595 while (itNames.hasNext()) { 596 al.add(new EjbItem((ObjectName ) itNames.next())); 597 } 598 on = J2eeObjectName.getStatefulSessionBeans(p_DomainName, p_moduleName, p_ServerName); 599 itNames = JonasAdminJmx.getListMbean(on).iterator(); 600 while (itNames.hasNext()) { 601 al.add(new EjbItem((ObjectName ) itNames.next())); 602 } 603 on = J2eeObjectName.getStatelessSessionBeans(p_DomainName, p_moduleName, p_ServerName); 604 itNames = JonasAdminJmx.getListMbean(on).iterator(); 605 while (itNames.hasNext()) { 606 al.add(new EjbItem((ObjectName ) itNames.next())); 607 } 608 on = J2eeObjectName.getMessageDrivenBeans(p_DomainName, p_moduleName, p_ServerName); 609 itNames = JonasAdminJmx.getListMbean(on).iterator(); 610 while (itNames.hasNext()) { 611 al.add(new EjbItem((ObjectName ) itNames.next())); 612 } 613 614 Collections.sort(al, new EjbItemByNameComparator()); 616 617 String sNodeName; 619 String sAction; 620 TreeControlNode nodeEjb; 621 EjbItem oEjb; 622 for (int i = 0; i < al.size(); i++) { 623 oEjb = (EjbItem) al.get(i); 624 sNodeName = p_NodeParent.getName() + WhereAreYou.NODE_SEPARATOR + oEjb.getName(); 625 sAction = "EditEjb" + oEjb.getTypeString() + ".do?select=" + oEjb.getObjectName(); 626 nodeEjb = new TreeControlNode(sNodeName, "icon/bean.gif", oEjb.getName(), sAction 628 , "content", false); 629 p_NodeParent.addChild(nodeEjb); 630 } 631 } 632 633 642 protected void getServiceDatabase(TreeControlNode pNodeServices, MessageResources pResources, String pDomainName, String pServerName) 643 throws Exception { 644 TreeControlNode nodeService = new TreeControlNode(pNodeServices.getName() 646 + WhereAreYou.NODE_SEPARATOR + "database", "icon/service_database.gif" 647 , pResources.getMessage("treenode.jonas.server.services.database"), "ListDatabases.do" 648 , "content", false); 649 pNodeServices.addChild(nodeService); 650 getDatasources(nodeService, pResources, pDomainName, pServerName); 652 } 653 654 664 public void getDatasources(TreeControlNode pNodeParent, MessageResources pResources, String pDomainName, String pServerName) 665 throws Exception { 666 667 ArrayList al = JonasAdminJmx.getDatasourceFilesDeployed(pDomainName, pServerName); 668 for (int i = 0; i < al.size(); i++) { 670 TreeControlNode node = new TreeControlNode(pNodeParent.getName() 671 + WhereAreYou.NODE_SEPARATOR + al.get(i).toString(), "icon/Datasource.gif" 672 , al.get(i).toString(), "EditDatasource.do?name=" + al.get(i), "content", false); 673 pNodeParent.addChild(node); 674 } 675 } 676 677 688 protected void getServiceWeb(TreeControlNode pNodeServices, MessageResources pResources 689 , HttpServletRequest pRequest, String pDomainName, String pServerName) 690 throws Exception { 691 TreeControlNode nodeService = new TreeControlNode(pNodeServices.getName() 693 + WhereAreYou.NODE_SEPARATOR + "web", "icon/service_web.gif" 694 , pResources.getMessage("treenode.jonas.server.services.web"), "ListWebContainers.do" 695 , "content", false); 696 pNodeServices.addChild(nodeService); 697 getWebContainers(nodeService, pResources, pRequest); 699 } 700 701 710 public void getWebContainers(TreeControlNode p_NodeParent, MessageResources p_Resources 711 , HttpServletRequest p_Request) 712 throws Exception { 713 WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou. 714 SESSION_NAME); 715 716 ArrayList al = new ArrayList (); 717 if (oWhere.isCatalinaServer() == true) { 719 Iterator itOns = JonasAdminJmx.getListMbean(J2eeObjectName.getWebModules(oWhere. 721 getCurrentCatalinaDomainName())).iterator(); 722 while (itOns.hasNext()) { 723 al.add(new WebAppItem((ObjectName ) itOns.next())); 724 } 725 } 726 else if (oWhere.isJettyServer() == true) { 728 ObjectName on; 729 String sPathContext; 730 HashMap hWebAppItems = new HashMap (); 731 732 Iterator itOnContexts = JonasAdminJmx.getListMbean(JettyObjectName.jettyContexts()). 734 iterator(); 735 while (itOnContexts.hasNext()) { 736 on = (ObjectName ) itOnContexts.next(); 737 sPathContext = on.getKeyProperty("context"); 738 if (sPathContext != null) { 739 if (!hWebAppItems.containsKey(sPathContext) && on.getKeyProperty("WebApplicationContext") != null && 740 on.getKeyProperty("WebApplicationHandler") == null && on.getKeyProperty("config") == null) { 741 hWebAppItems.put(sPathContext, new WebAppItem(sPathContext, on.toString())); 742 } 743 } 744 } 745 al.addAll(hWebAppItems.values()); 747 } 748 Collections.sort(al, new WebAppItemByPathContext()); 750 WebAppItem oItem; 752 for (int i = 0; i < al.size(); i++) { 753 oItem = (WebAppItem) al.get(i); 754 TreeControlNode node = new TreeControlNode(p_NodeParent.getName() 755 + WhereAreYou.NODE_SEPARATOR + oItem.getObjectName(), "icon/war.gif" 756 , oItem.getLabelPathContext(), "EditWebApp.do?on=" + oItem.getObjectName() 757 , "content", false); 758 p_NodeParent.addChild(node); 759 } 760 } 761 762 771 protected void getServiceTransaction(TreeControlNode p_NodeServices 772 , MessageResources p_Resources, String p_DomainName, String p_ServerName) 773 throws Exception { 774 TreeControlNode nodeService = new TreeControlNode(p_NodeServices.getName() 776 + WhereAreYou.NODE_SEPARATOR + "transaction", "icon/service_transaction.gif" 777 , p_Resources.getMessage("treenode.jonas.server.services.transaction") 778 , "EditJtmService.do", "content", false); 779 p_NodeServices.addChild(nodeService); 780 } 781 782 791 protected void getServiceDiscovery(TreeControlNode p_NodeServices, MessageResources p_Resources, String p_DomainName, String p_ServerName) 792 throws Exception { 793 TreeControlNode nodeService = new TreeControlNode(p_NodeServices.getName() 795 + WhereAreYou.NODE_SEPARATOR + "Discovery", "icon/service_transaction.gif" 796 , p_Resources.getMessage("treenode.jonas.server.services.discovery") 797 , "EditServiceDiscovery.do", "content", false); 798 p_NodeServices.addChild(nodeService); 799 } 800 801 817 public void getServiceWebService(TreeControlNode p_NodeServices, 818 MessageResources p_Resources, HttpServletRequest request, String p_DomainName, 819 String p_ServerName) throws Exception { 820 String nodeName = p_NodeServices.getName() + WhereAreYou.NODE_SEPARATOR + "WebService"; 821 TreeControlNode nodeService = null; 822 nodeService = p_NodeServices.getTree().findNode(nodeName); 824 if (nodeService != null) { 825 nodeService.remove(); 826 } 827 nodeService = new TreeControlNode( 829 nodeName, 830 "icon/war.gif", 831 p_Resources 832 .getMessage("treenode.jonas.server.services.webservices"), 833 "ListWebService.do", "content", true); 834 p_NodeServices.addChild(nodeService); 835 getWebServiceDetails(nodeService, p_Resources, request); 836 837 } 838 850 public void getWebServiceDetails(TreeControlNode p_webServicesNode, 851 MessageResources p_Resources, HttpServletRequest p_Request) 852 throws Exception { 853 WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute( 855 WhereAreYou.SESSION_NAME); 856 857 String sServerName = oWhere.getCurrentJonasServerName(); 859 Collection al = new ArrayList (); 861 GenericDomainCapableProvider jProvider = new JonasProvider(); 862 jProvider.initialize(sServerName, null); 863 al = jProvider.getWebServiceDescription(); 864 865 TreeControlNode node; 867 WebServiceDescription oWebServiceDescription = null; 868 String sLabel; 869 Iterator it = al.iterator(); 870 while (it.hasNext()) { 871 oWebServiceDescription = (WebServiceDescription) it.next(); 872 node = new TreeControlNode(p_webServicesNode.getName() 873 + WhereAreYou.NODE_SEPARATOR 874 + oWebServiceDescription.getId(), "icon/war.gif", 875 oWebServiceDescription.getId(), 876 "WebServiceDetails.do?select=" 877 + oWebServiceDescription.getId(), "content", false); 878 p_webServicesNode.addChild(node); 879 getPortComponents(oWebServiceDescription, node, p_Resources); 880 } 881 } 882 883 895 private void getPortComponents(WebServiceDescription wsd, 896 TreeControlNode p_webServiceNode, MessageResources p_Resources) 897 throws Exception { 898 899 String sLabel; 900 TreeControlNode node = null; 902 for (int i = 0; i < wsd.getPortComponentCount(); i++) { 903 PortComponent pc = wsd.getPortComponent(i); 904 node = new TreeControlNode(p_webServiceNode.getName() 905 + WhereAreYou.NODE_SEPARATOR + pc.getId(), "icon/war.gif", 906 pc.getId(), "PortComponentsDetails.do?pcselect=" 907 + pc.getId() + "&wsdselect=" + wsd.getId(), 908 "content", false); 909 p_webServiceNode.addChild(node); 910 getPortComponentHandler(wsd, pc, node, p_Resources); 911 } 912 913 } 914 915 927 private void getPortComponentHandler(WebServiceDescription wsd, 928 PortComponent pc, TreeControlNode p_portComponentNode, 929 MessageResources p_Resources) throws Exception { 930 TreeControlNode node = null; 932 for (int i = 0; i < pc.getHandlerCount(); i++) { 933 Handler handler = pc.getHandler(i); 934 node = new TreeControlNode( 935 p_portComponentNode.getName() + WhereAreYou.NODE_SEPARATOR 936 + handler.getId(), 937 "icon/war.gif", 938 handler.getId(), 939 "HandlersDetails.do?pcselect=" + pc.getId() + "&wsdselect=" 940 + wsd.getId() + "&handlerselect=" + handler.getId(), 941 "content", false); 942 p_portComponentNode.addChild(node); 943 } 944 945 } 946 947 955 protected void getServiceJms(TreeControlNode p_NodeServices, MessageResources p_Resources, String p_DomainName, String p_ServerName) 956 throws Exception { 957 TreeControlNode nodeService = new TreeControlNode(p_NodeServices.getName() 959 + WhereAreYou.NODE_SEPARATOR + "jms", "icon/service_jms.gif" 960 , p_Resources.getMessage("treenode.jonas.server.services.jms"), "EditJmsService.do" 961 , "content", false); 962 p_NodeServices.addChild(nodeService); 963 getJmsResources(nodeService, p_Resources); 965 } 966 967 975 public void getJmsResources(TreeControlNode p_NodeParent, MessageResources p_Resources) 976 throws Exception { 977 TreeControlNode node = new TreeControlNode(p_NodeParent.getName() 979 + WhereAreYou.NODE_SEPARATOR + "cf", "icon/jms_connector.gif" 980 , p_Resources.getMessage("treenode.jonas.server.services.jms.cf") 981 , "ListConnectionFactories.do", "content", false); 982 p_NodeParent.addChild(node); 983 getJmsConnectionFactories(node, p_Resources); 984 985 node = new TreeControlNode(p_NodeParent.getName() + WhereAreYou.NODE_SEPARATOR + "queue" 987 , "icon/jms_queue.gif" 988 , p_Resources.getMessage("treenode.jonas.server.services.jms.queues"), "ListQueues.do" 989 , "content", false); 990 p_NodeParent.addChild(node); 991 getJmsQueues(node, p_Resources); 992 993 node = new TreeControlNode(p_NodeParent.getName() + WhereAreYou.NODE_SEPARATOR + "topic" 995 , "icon/jms_topic.gif" 996 , p_Resources.getMessage("treenode.jonas.server.services.jms.topics"), "ListTopics.do" 997 , "content", false); 998 p_NodeParent.addChild(node); 999 getJmsTopics(node, p_Resources); 1000 } 1001 1002 1010 public void getJmsConnectionFactories(TreeControlNode p_NodeParent 1011 , MessageResources p_Resources) 1012 throws Exception { 1013 int nbConnFacts = 3; 1017 String cfNames[] = new String [3]; 1018 ObjectName jmsServMB = JonasObjectName.jmsService(); 1019 cfNames[0] = (String ) JonasManagementRepr.getAttribute(jmsServMB 1020 , "DefaultConnectionFactoryName"); 1021 cfNames[1] = (String ) JonasManagementRepr.getAttribute(jmsServMB 1022 , "DefaultTopicConnectionFactoryName"); 1023 cfNames[2] = (String ) JonasManagementRepr.getAttribute(jmsServMB 1024 , "DefaultQueueConnectionFactoryName"); 1025 TreeControlNode node; 1026 for (int i = 0; i < nbConnFacts; i++) { 1027 node = new TreeControlNode(p_NodeParent.getName() + WhereAreYou.NODE_SEPARATOR 1028 + cfNames[i], "icon/jms_connector.gif", cfNames[i] 1029 , "PresentConnectionFactory.do?name=" + cfNames[i], "content", false); 1030 p_NodeParent.addChild(node); 1031 } 1032 } 1033 1034 1042 public void getJmsQueues(TreeControlNode p_NodeParent, MessageResources p_Resources) 1043 throws Exception { 1044 Iterator itNames = ((java.util.Set ) JonasManagementRepr.getAttribute(JonasObjectName. 1046 jmsService(), "AllJmsQueueDestinationNames")).iterator(); 1047 while (itNames.hasNext()) { 1048 String sNodeName = (String ) itNames.next(); 1049 String sQueueName = sNodeName; 1050 TreeControlNode node = new TreeControlNode(p_NodeParent.getName() 1052 + WhereAreYou.NODE_SEPARATOR + sNodeName, "icon/jms_queue.gif", sQueueName 1053 , "PresentQueue.do?name=" + sQueueName, "content", false); 1054 p_NodeParent.addChild(node); 1055 } 1056 } 1057 1058 1066 public void getJmsTopics(TreeControlNode p_NodeParent, MessageResources p_Resources) 1067 throws Exception { 1068 Iterator itNames = ((java.util.Set ) JonasManagementRepr.getAttribute(JonasObjectName. 1070 jmsService(), "AllJmsTopicDestinationNames")).iterator(); 1071 while (itNames.hasNext()) { 1072 String sNodeName = (String ) itNames.next(); 1073 String sTopicName = sNodeName; 1074 TreeControlNode node = new TreeControlNode(p_NodeParent.getName() 1076 + WhereAreYou.NODE_SEPARATOR + sNodeName, "icon/jms_topic.gif", sTopicName 1077 , "PresentTopic.do?name=" + sTopicName, "content", false); 1078 p_NodeParent.addChild(node); 1079 } 1080 } 1081 1082 1091 protected void getServiceMail(TreeControlNode p_NodeServices, MessageResources p_Resources 1092 , HttpServletRequest p_Request, String p_DomainName, String p_ServerName) 1093 throws Exception { 1094 TreeControlNode nodeService = new TreeControlNode(p_NodeServices.getName() 1096 + WhereAreYou.NODE_SEPARATOR + "mail", "icon/service_mail.gif" 1097 , p_Resources.getMessage("treenode.jonas.server.services.mail"), "EditMailService.do" 1098 , "content", false); 1099 p_NodeServices.addChild(nodeService); 1100 getAllSessionMailFactories(nodeService, p_Resources, p_Request); 1102 getAllMimePartDSMailFactories(nodeService, p_Resources, p_Request); 1103 } 1104 1105 public void getAllSessionMailFactories(TreeControlNode p_NodeParent 1106 , MessageResources p_Resources, HttpServletRequest p_Request) 1107 throws Exception { 1108 TreeControlNode nodeSessionMailFactories = new TreeControlNode(p_NodeParent.getName() 1110 + WhereAreYou.NODE_SEPARATOR + "session", "icon/mail_session.gif" 1111 , p_Resources.getMessage("treenode.jonas.server.services.mail.session") 1112 , "ListSessionMailFactories.do", "content", false); 1113 p_NodeParent.addChild(nodeSessionMailFactories); 1114 getSessionMailFactories(nodeSessionMailFactories, p_Resources, p_Request); 1116 } 1117 1118 public void getAllMimePartDSMailFactories(TreeControlNode p_NodeParent 1119 , MessageResources p_Resources, HttpServletRequest p_Request) 1120 throws Exception { 1121 TreeControlNode nodeMimePartMailFactories = new TreeControlNode(p_NodeParent.getName() 1123 + WhereAreYou.NODE_SEPARATOR + "mimepart", "icon/mail_mime.gif" 1124 , p_Resources.getMessage("treenode.jonas.server.services.mail.mimepart") 1125 , "ListMimePartMailFactories.do", "content", false); 1126 p_NodeParent.addChild(nodeMimePartMailFactories); 1127 getMimePartMailFactories(nodeMimePartMailFactories, p_Resources, p_Request); 1129 } 1130 1131 protected void getSessionMailFactories(TreeControlNode p_NodeParent 1132 , MessageResources p_Resources, HttpServletRequest p_Request) 1133 throws Exception { 1134 String sPath; 1135 String sFile; 1136 String sNodeName; 1137 ArrayList al = new ArrayList (); 1138 1139 WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou. 1140 SESSION_NAME); 1141 1142 java.util.List deployedFactories = (java.util.List ) JonasAdminJmx. 1144 getSessionMailFactoriesDeployed(oWhere); 1145 Iterator itNames = deployedFactories.iterator(); 1146 while (itNames.hasNext()) { 1148 al.add(itNames.next().toString()); 1149 } 1150 Collections.sort(al); 1152 for (int i = 0; i < al.size(); i++) { 1154 TreeControlNode node = new TreeControlNode(p_NodeParent.getName() 1155 + WhereAreYou.NODE_SEPARATOR + al.get(i).toString(), "icon/mail_session.gif" 1156 , al.get(i).toString(), "EditSessionMailFactory.do?name=" + al.get(i).toString() 1157 , "content", false); 1158 p_NodeParent.addChild(node); 1159 } 1160 } 1161 1162 protected void getMimePartMailFactories(TreeControlNode p_NodeParent 1163 , MessageResources p_Resource, HttpServletRequest p_Request) 1164 throws Exception { 1165 String sPath; 1166 String sFile; 1167 String sNodeName; 1168 ArrayList al = new ArrayList (); 1169 1170 WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou. 1171 SESSION_NAME); 1172 1173 Iterator itNames = ((java.util.List ) JonasAdminJmx.getMimeMailPartFactoriesDeployed(oWhere)). 1175 iterator(); 1176 while (itNames.hasNext()) { 1177 al.add(itNames.next().toString()); 1178 } 1179 Collections.sort(al); 1181 for (int i = 0; i < al.size(); i++) { 1183 TreeControlNode node = new TreeControlNode(p_NodeParent.getName() 1184 + WhereAreYou.NODE_SEPARATOR + al.get(i).toString(), "icon/mail_mime.gif" 1185 , al.get(i).toString(), "EditMimePartMailFactory.do?name=" + al.get(i).toString() 1186 , "content", false); 1187 p_NodeParent.addChild(node); 1188 } 1189 } 1190 1191 1199 protected void getServiceResourceAdapter(TreeControlNode p_NodeServices 1200 , MessageResources p_Resources, String p_DomainName, String p_ServerName) 1201 throws Exception { 1202 TreeControlNode nodeService = new TreeControlNode(p_NodeServices.getName() 1204 + WhereAreYou.NODE_SEPARATOR + "resourceAdapter", "icon/service_resource.gif" 1205 , p_Resources.getMessage("treenode.jonas.server.services.resource") 1206 , "ListResourceAdapters.do", "content", false); 1207 p_NodeServices.addChild(nodeService); 1208 getResourceAdapters(nodeService, p_Resources, p_DomainName, p_ServerName); 1210 } 1211 1212 1222 public void getResourceAdapters(TreeControlNode p_NodeParent, MessageResources p_Resources, 1223 String p_DomainName, String p_ServerName) 1224 throws Exception { 1225 String sPath; 1226 String sFile; 1227 String sNodeName; 1228 String sName; 1229 ObjectName on; 1230 ArrayList al = new ArrayList (); 1231 1232 ObjectName ons = J2eeObjectName.getResourceAdapters(p_DomainName, p_ServerName); 1234 Iterator itNames = JonasManagementRepr.queryNames(ons).iterator(); 1235 while (itNames.hasNext()) { 1236 ObjectName it_on = (ObjectName ) itNames.next(); 1237 sPath = (String ) JonasManagementRepr.getAttribute(it_on, "fileName"); 1238 sFile = JonasAdminJmx.extractFilename(sPath); 1239 sNodeName = p_NodeParent.getName() + WhereAreYou.NODE_SEPARATOR + sFile; 1240 sName = it_on.getKeyProperty("name"); 1241 if (sFile != null) { 1242 al.add(new ResourceItem(sFile, sPath, sNodeName, it_on.toString(), sName)); 1243 } 1244 } 1245 Collections.sort(al, new ResourceItemByFile()); 1247 ResourceItem oItem; 1249 for (int i = 0; i < al.size(); i++) { 1250 oItem = (ResourceItem) al.get(i); 1251 TreeControlNode node = new TreeControlNode(oItem.getNodeName(), "icon/ear.gif" 1252 , oItem.getFile(), "EditResourceAdapter.do?select=" + oItem.getObjectName(), "content", false); 1253 p_NodeParent.addChild(node); 1254 } 1255 1275 } 1276 1277 1286 protected void getServiceSecurity(TreeControlNode p_NodeServices, MessageResources p_Resources, String p_DomainName, String p_ServerName) 1287 throws Exception { 1288 TreeControlNode nodeService = new TreeControlNode(p_NodeServices.getName() 1290 + WhereAreYou.NODE_SEPARATOR + "security", "icon/service_security.gif" 1291 , p_Resources.getMessage("treenode.jonas.server.services.security") 1292 , "EditServiceSecurity.do", "content", false); 1293 p_NodeServices.addChild(nodeService); 1294 } 1295 1296 1303 protected void getDeployments(TreeControlNode p_ServerNode, MessageResources p_Resources) 1304 throws Exception { 1305 TreeControlNode nodeDeployments = new TreeControlNode(p_ServerNode.getName() 1307 + WhereAreYou.NODE_SEPARATOR + "deployments", "icon/deploy.gif" 1308 , p_Resources.getMessage("treenode.jonas.server.deployments"), null, "content", true); 1309 p_ServerNode.addChild(nodeDeployments); 1310 1311 if (JonasAdminJmx.hasMBeanName(JonasObjectName.earService()) == true) { 1313 getDeploymentEar(nodeDeployments, p_Resources); 1314 } 1315 if (JonasAdminJmx.hasMBeanName(JonasObjectName.ejbService()) == true) { 1316 getDeploymentEjb(nodeDeployments, p_Resources); 1317 } 1318 if (JonasAdminJmx.hasMBeanName(JonasObjectName.webContainerService()) == true) { 1319 getDeploymentWebAppli(nodeDeployments, p_Resources); 1320 } 1321 if (JonasAdminJmx.hasMBeanName(JonasObjectName.resourceService()) == true) { 1322 getDeploymentRar(nodeDeployments, p_Resources); 1323 } 1324 } 1325 1326 1334 protected void getDeploymentEar(TreeControlNode p_NodeDeployments, MessageResources p_Resources) 1335 throws Exception { 1336 TreeControlNode oNode = new TreeControlNode(p_NodeDeployments.getName() 1338 + WhereAreYou.NODE_SEPARATOR + WhereAreYou.DEPLOYMENT_STRING_EAR, "icon/deploy_ear.gif" 1339 , p_Resources.getMessage("treenode.jonas.server.deployments." 1340 + WhereAreYou.DEPLOYMENT_STRING_EAR) 1341 , "EditDeploy.do?type=" + WhereAreYou.DEPLOYMENT_STRING_EAR, "content", false); 1342 p_NodeDeployments.addChild(oNode); 1343 } 1344 1345 1353 protected void getDeploymentEjb(TreeControlNode p_NodeDeployments, MessageResources p_Resources) 1354 throws Exception { 1355 TreeControlNode oNode = new TreeControlNode(p_NodeDeployments.getName() 1357 + WhereAreYou.NODE_SEPARATOR + WhereAreYou.DEPLOYMENT_STRING_JAR, "icon/deploy_jar.gif" 1358 , p_Resources.getMessage("treenode.jonas.server.deployments." 1359 + WhereAreYou.DEPLOYMENT_STRING_JAR) 1360 , "EditDeploy.do?type=" + WhereAreYou.DEPLOYMENT_STRING_JAR, "content", false); 1361 p_NodeDeployments.addChild(oNode); 1362 1363 } 1366 1367 1375 protected void getDeploymentEjbFiles(TreeControlNode p_NodeParent, MessageResources p_Resources) 1376 throws Exception { 1377 String sFile; 1378 Iterator it = JonasAdminJmx.getJarFilesDeployable().iterator(); 1379 while (it.hasNext()) { 1380 sFile = it.next().toString(); 1381 TreeControlNode oNode = new TreeControlNode(p_NodeParent.getName() 1383 + WhereAreYou.NODE_SEPARATOR + sFile, "icon/JonasQuestion.gif", sFile, null 1384 , "content", false); 1385 p_NodeParent.addChild(oNode); 1386 } 1387 1388 } 1389 1390 1398 protected void getDeploymentWebAppli(TreeControlNode p_NodeDeployments 1399 , MessageResources p_Resources) 1400 throws Exception { 1401 TreeControlNode oNode = new TreeControlNode(p_NodeDeployments.getName() 1403 + WhereAreYou.NODE_SEPARATOR + WhereAreYou.DEPLOYMENT_STRING_WAR, "icon/deploy_war.gif" 1404 , p_Resources.getMessage("treenode.jonas.server.deployments." 1405 + WhereAreYou.DEPLOYMENT_STRING_WAR) 1406 , "EditDeploy.do?type=" + WhereAreYou.DEPLOYMENT_STRING_WAR, "content", false); 1407 p_NodeDeployments.addChild(oNode); 1408 } 1409 1410 1418 protected void getDeploymentRar(TreeControlNode p_NodeDeployments, MessageResources p_Resources) 1419 throws Exception { 1420 TreeControlNode oNode = new TreeControlNode(p_NodeDeployments.getName() 1422 + WhereAreYou.NODE_SEPARATOR + WhereAreYou.DEPLOYMENT_STRING_RAR, "icon/deploy_rar.gif" 1423 , p_Resources.getMessage("treenode.jonas.server.deployments." 1424 + WhereAreYou.DEPLOYMENT_STRING_RAR) 1425 , "EditDeploy.do?type=" + WhereAreYou.DEPLOYMENT_STRING_RAR, "content", false); 1426 p_NodeDeployments.addChild(oNode); 1427 } 1428 1429 1436 protected void getResources(TreeControlNode p_ServerNode, MessageResources p_Resources) 1437 throws Exception { 1438 TreeControlNode nodeDeployments = new TreeControlNode(p_ServerNode.getName() 1440 + WhereAreYou.NODE_SEPARATOR + "resources", "icon/resources.gif" 1441 , p_Resources.getMessage("treenode.jonas.server.resources"), null, "content", true); 1442 p_ServerNode.addChild(nodeDeployments); 1443 1444 if (JonasAdminJmx.hasMBeanName(JonasObjectName.databaseService()) == true) { 1447 getResourceDatabase(nodeDeployments, p_Resources); 1448 } 1449 if (JonasAdminJmx.hasMBeanName(JonasObjectName.jmsService()) == true) { 1451 getJmsResource(nodeDeployments, p_Resources); 1452 } 1453 if (JonasAdminJmx.hasMBeanName(JonasObjectName.mailService()) == true) { 1455 getMailResource(nodeDeployments, p_Resources); 1456 } 1457 } 1458 1459 1466 protected void getMailResource(TreeControlNode p_ServerNode, MessageResources p_Resources) 1467 throws Exception { 1468 TreeControlNode nodeDeployments = new TreeControlNode(p_ServerNode.getName() 1470 + WhereAreYou.NODE_SEPARATOR + "mail", "icon/mail.gif" 1471 , p_Resources.getMessage("treenode.jonas.server.resources.mail") 1472 , "EditDeploy.do?type=" + WhereAreYou.DEPLOYMENT_STRING_MAILFACTORY, "content", false); 1473 p_ServerNode.addChild(nodeDeployments); 1474 } 1475 1476 1483 protected void getJmsResource(TreeControlNode p_ServerNode, MessageResources p_Resources) 1484 throws Exception { 1485 TreeControlNode nodeDeployments = new TreeControlNode(p_ServerNode.getName() 1487 + WhereAreYou.NODE_SEPARATOR + "jms", "icon/jms.gif" 1488 , p_Resources.getMessage("treenode.jonas.server.resources.jms"), "ListJmsResources.do" 1489 , "content", false); 1490 p_ServerNode.addChild(nodeDeployments); 1491 } 1492 1493 1500 protected void getResourceDatabase(TreeControlNode p_ServerNode, MessageResources p_Resources) 1501 throws Exception { 1502 TreeControlNode nodeDeployments = new TreeControlNode(p_ServerNode.getName() 1504 + WhereAreYou.NODE_SEPARATOR + "database", "icon/Database.gif" 1505 , p_Resources.getMessage("treenode.jonas.server.resources.database") 1506 , "EditDeploy.do?type=" + WhereAreYou.DEPLOYMENT_STRING_DATASOURCE, "content", false); 1507 p_ServerNode.addChild(nodeDeployments); 1508 } 1509 1510 1518 protected void getSecurity(TreeControlNode p_ServerNode, MessageResources p_Resources 1519 , HttpServletRequest p_Request) 1520 throws Exception { 1521 boolean bJonasSecurityService = JonasAdminJmx.hasMBeanName(JonasObjectName.securityService()); 1523 WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou. 1525 SESSION_NAME); 1526 boolean bCatalinaRealm = false; 1527 if (oWhere.isCatalinaServer() == true) { 1528 bCatalinaRealm = JonasAdminJmx.hasMBeanName(CatalinaObjectName.catalinaRealm(oWhere. 1529 getCurrentCatalinaServiceName())); 1530 } 1531 if ((bJonasSecurityService == true) || (bCatalinaRealm == true)) { 1533 String sAction = null; 1535 if (bJonasSecurityService == true) { 1536 sAction = "ListRealms.do?realm=all"; 1537 } 1538 else if (bCatalinaRealm == true) { 1539 sAction = "EditSecurityCatalinaRealm.do"; 1540 } 1541 TreeControlNode nodeSecurity = new TreeControlNode(p_ServerNode.getName() 1543 + WhereAreYou.NODE_SEPARATOR + "security", "icon/security.gif" 1544 , p_Resources.getMessage("treenode.jonas.server.security"), sAction, "content", false); 1545 p_ServerNode.addChild(nodeSecurity); 1546 if (bJonasSecurityService == true) { 1548 getSecurityFactories(nodeSecurity, p_Resources); 1549 } 1550 } 1551 } 1552 1553 1562 protected void getSecurityCatalinaRealm(TreeControlNode p_SecurityNode 1563 , MessageResources p_Resources, HttpServletRequest p_Request) 1564 throws Exception { 1565 1566 TreeControlNode oNode = new TreeControlNode(p_SecurityNode.getName() 1568 + WhereAreYou.NODE_SEPARATOR + "catalina.realm", "icon/security.gif" 1569 , p_Resources.getMessage("treenode.jonas.server.security.catalina.realm"), null 1570 , "content", false); 1571 p_SecurityNode.addChild(oNode); 1572 } 1573 1574 1581 public void getSecurityFactories(TreeControlNode p_SecurityNode, MessageResources p_Resources) 1582 throws Exception { 1583 ArrayList al = null; 1584 String sName = null; 1585 TreeControlNode nodeSecurityFactories = null; 1586 TreeControlNode nodeSecurityFactory = null; 1587 1588 al = JonasAdminJmx.getSecurityMemoryFactories(); 1590 if (al.size() > 0) { 1591 nodeSecurityFactories = new TreeControlNode(p_SecurityNode.getName() 1593 + WhereAreYou.NODE_SEPARATOR + "factory.memory", "icon/security_memory.gif" 1594 , p_Resources.getMessage("treenode.jonas.server.security.factory.memory") 1595 , "ListRealms.do?realm=memory", "content", false); 1596 p_SecurityNode.addChild(nodeSecurityFactories); 1597 for (int i = 0; i < al.size(); i++) { 1599 sName = al.get(i).toString(); 1600 nodeSecurityFactory = new TreeControlNode(nodeSecurityFactories.getName() 1602 + WhereAreYou.NODE_SEPARATOR + sName, "icon/security_memory.gif", sName 1603 , "EditMemoryRealm.do?resource=" + sName, "content", false); 1604 nodeSecurityFactories.addChild(nodeSecurityFactory); 1605 } 1608 } 1609 al = JonasAdminJmx.getSecurityDatasourceFactories(); 1611 if (al.size() > 0) { 1612 nodeSecurityFactories = new TreeControlNode(p_SecurityNode.getName() 1614 + WhereAreYou.NODE_SEPARATOR + "factory.datasource", "icon/security_database.gif" 1615 , p_Resources.getMessage("treenode.jonas.server.security.factory.datasource") 1616 , "ListRealms.do?realm=datasource", "content", false); 1617 p_SecurityNode.addChild(nodeSecurityFactories); 1618 for (int i = 0; i < al.size(); i++) { 1620 sName = al.get(i).toString(); 1621 nodeSecurityFactory = new TreeControlNode(nodeSecurityFactories.getName() 1623 + WhereAreYou.NODE_SEPARATOR + sName, "icon/security_database.gif", sName 1624 , "EditDatasourceRealm.do?resource=" + sName, "content", false); 1625 nodeSecurityFactories.addChild(nodeSecurityFactory); 1626 } 1627 } 1628 al = JonasAdminJmx.getSecurityLdapFactories(); 1630 if (al.size() > 0) { 1631 nodeSecurityFactories = new TreeControlNode(p_SecurityNode.getName() 1633 + WhereAreYou.NODE_SEPARATOR + "factory.ldap", "icon/security_ldap.gif" 1634 , p_Resources.getMessage("treenode.jonas.server.security.factory.ldap") 1635 , "ListRealms.do?realm=ldap", "content", false); 1636 p_SecurityNode.addChild(nodeSecurityFactories); 1637 for (int i = 0; i < al.size(); i++) { 1639 sName = al.get(i).toString(); 1640 nodeSecurityFactory = new TreeControlNode(nodeSecurityFactories.getName() 1642 + WhereAreYou.NODE_SEPARATOR + sName, "icon/security_ldap.gif", sName 1643 , "EditLdapRealm.do?resource=" + sName, "content", false); 1644 nodeSecurityFactories.addChild(nodeSecurityFactory); 1645 } 1646 } 1647 } 1648 1649 1657 protected void getSecurityMemoryFactory(TreeControlNode p_SecurityMemoryNode 1658 , MessageResources p_Resources, String p_ResourceFactory) 1659 throws Exception { 1660 TreeControlNode node = null; 1661 node = new TreeControlNode(p_SecurityMemoryNode.getName() + WhereAreYou.NODE_SEPARATOR 1663 + "users", "icon/security_memory.gif" 1664 , p_Resources.getMessage("treenode.jonas.server.security.factory.memory.users") 1665 , "EditMemoryRealmUsers.do?resource=" + p_ResourceFactory, "content", false); 1666 p_SecurityMemoryNode.addChild(node); 1667 node = new TreeControlNode(p_SecurityMemoryNode.getName() + WhereAreYou.NODE_SEPARATOR 1669 + "groups", "icon/security_memory.gif" 1670 , p_Resources.getMessage("treenode.jonas.server.security.factory.memory.groups") 1671 , "EditMemoryRealmGroups.do?resource=" + p_ResourceFactory, "content", false); 1672 p_SecurityMemoryNode.addChild(node); 1673 node = new TreeControlNode(p_SecurityMemoryNode.getName() + WhereAreYou.NODE_SEPARATOR 1675 + "roles", "icon/security_memory.gif" 1676 , p_Resources.getMessage("treenode.jonas.server.security.factory.memory.roles") 1677 , "EditMemoryRealmRoles.do?resource=" + p_ResourceFactory, "content", false); 1678 p_SecurityMemoryNode.addChild(node); 1679 } 1680 1681 1690 protected void getProtocols(TreeControlNode p_ServerNode, MessageResources p_Resources 1691 , HttpServletRequest p_Request) 1692 throws Exception { 1693 if (JonasAdminJmx.hasMBeanName(CatalinaObjectName.catalinaServer()) == true) { 1695 getCatalinaProtocols(p_ServerNode, p_Resources, p_Request); 1696 } 1697 } 1698 1699 1708 protected void getCatalinaProtocols(TreeControlNode p_ServerNode, MessageResources p_Resources 1709 , HttpServletRequest p_Request) 1710 throws Exception { 1711 TreeControlNode catalinaNode = new TreeControlNode(p_ServerNode.getName() 1713 + WhereAreYou.NODE_SEPARATOR + "protocols", "icon/protocol.gif" 1714 , p_Resources.getMessage("treenode.jonas.server.protocols") 1715 , "ListCatalinaConnectors.do", "content", false); 1716 p_ServerNode.addChild(catalinaNode); 1717 getCatalinaConnector(catalinaNode, p_Resources, p_Request); 1719 } 1720 1721 1730 protected void getCatalinaConnector(TreeControlNode p_CatalinaServerNode 1731 , MessageResources p_Resources, HttpServletRequest p_Request) 1732 throws Exception { 1733 1734 TreeControlNode connectorNode = new TreeControlNode(p_CatalinaServerNode.getName() 1736 + WhereAreYou.NODE_SEPARATOR + "connectors", "icon/connectors.gif" 1737 , p_Resources.getMessage("treenode.jonas.server.protocols.connectors") 1738 , "ListCatalinaConnectors.do", "content", false); 1739 p_CatalinaServerNode.addChild(connectorNode); 1740 1741 getCatalinaDetailConnectors(connectorNode, p_Resources, p_Request); 1742 1743 } 1744 1745 1754 public void getCatalinaDetailConnectors(TreeControlNode p_ConnectorNode 1755 , MessageResources p_Resources, HttpServletRequest p_Request) 1756 throws Exception { 1757 1758 WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou. 1760 SESSION_NAME); 1761 1762 String sDomain = oWhere.getCurrentCatalinaDomainName(); 1764 ArrayList al = new ArrayList (); 1766 Iterator it = JonasAdminJmx.getListMBeanName(CatalinaObjectName.catalinaConnectors(sDomain)). 1767 iterator(); 1768 while (it.hasNext()) { 1769 al.add(new ConnectorItem(new ObjectName (it.next().toString()) 1770 , oWhere.getApplicationServerPort())); 1771 } 1772 Collections.sort(al, new ConnectorItemByPort()); 1774 TreeControlNode node; 1776 ConnectorItem oConnector; 1777 String sLabel; 1778 for (int i = 0; i < al.size(); i++) { 1779 oConnector = (ConnectorItem) al.get(i); 1780 node = new TreeControlNode(p_ConnectorNode.getName() + WhereAreYou.NODE_SEPARATOR 1781 + sDomain + WhereAreYou.NODE_SEPARATOR + oConnector.getPort(), "icon/connector.gif" 1782 , oConnector.getLabel() 1783 , "EditCatalinaConnector.do?select=" + oConnector.getObjectName(), "content", false); 1784 p_ConnectorNode.addChild(node); 1785 } 1786 } 1787 1788 1796 public void getJoramPlatform(TreeControlNode pDomainNode, 1797 MessageResources pResources, HttpServletRequest p_Request) 1798 throws Exception { 1799 1800 ObjectName joramPlatformON = JoramObjectName.joramPlatform(); 1801 if (!JonasAdminJmx.hasMBeanName(joramPlatformON)) { 1802 return; 1803 } 1804 1805 TreeControlNode platformNode = 1807 new TreeControlNode(pDomainNode.getName() 1808 + WhereAreYou.NODE_SEPARATOR 1809 + "joramplatform", 1810 "icon/service_jms.gif", 1811 pResources.getMessage("treenode.joramplatform"), 1812 "EditJoramPlatform.do", 1813 "content", 1814 false); 1815 1816 pDomainNode.addChild(platformNode); 1818 1819 getJoramResources(platformNode, joramPlatformON, pResources, p_Request); 1820 } 1821 1822 public void getJoramResources(TreeControlNode platformNode, ObjectName joramPlatformON, 1823 MessageResources pResources, HttpServletRequest p_Request) throws Exception { 1824 1825 if (joramPlatformON == null) { 1826 joramPlatformON = JoramObjectName.joramPlatform(); 1827 } 1828 Integer localServerId = (Integer ) JonasManagementRepr.getAttribute(joramPlatformON, "LocalServerId"); 1829 String localId = localServerId.toString(); 1830 TreeControlNode localServerNode = 1831 new TreeControlNode(platformNode.getName() 1832 + WhereAreYou.NODE_SEPARATOR 1833 + "joramlocalserver", 1834 "icon/service_jms.gif", 1835 pResources.getMessage("treenode.joramplatform.joramlocalserver") + " (" + localId + ")", 1836 "EditJoramServer.do?id=" + localId, 1837 "content", 1838 false); 1839 1840 platformNode.addChild(localServerNode); 1841 p_Request.getSession().setAttribute("localId", localId); 1842 1843 ObjectName joramAdminON = JoramObjectName.joramAdmin(); 1845 List globalDestList = (List ) JonasManagementRepr.getAttribute(joramAdminON, "Destinations"); 1846 HashMap map = null; 1849 if (globalDestList != null && !globalDestList.isEmpty()) { 1850 map = new HashMap (); 1851 Iterator it = globalDestList.iterator(); 1852 while (it.hasNext()) { 1853 ItemDestination destinationItem = getDestinationItem((String ) it.next()); 1854 String serverId = destinationItem.getServerId(); 1855 if (!map.containsKey(serverId)) { 1856 ArrayList destList = new ArrayList (); 1857 map.put(serverId, destList); 1858 } 1859 if (destinationItem.getType().equals("queue")) { 1860 ((ArrayList ) map.get(serverId)).add(0, destinationItem); 1862 } else if (destinationItem.getType().equals("topic")) { 1863 ((ArrayList ) map.get(serverId)).add(destinationItem); 1865 } 1866 } 1867 } 1868 1869 ArrayList localDestList = (ArrayList ) map.get(localId); 1871 for (int i = 0; i < localDestList.size(); i++) { 1872 ItemDestination item = (ItemDestination) localDestList.get(i); 1873 if (item.getOn() == null) { 1874 continue; 1875 } 1876 String name = item.getName(); 1877 String type = item.getType(); 1878 TreeControlNode destinationNode = null; 1879 if (type.equals("queue")) { 1880 destinationNode = new TreeControlNode(localServerNode.getName() 1881 + WhereAreYou.NODE_SEPARATOR 1882 + "joramqueue" + name, 1883 "icon/jms_queue.gif", 1884 pResources.getMessage("treenode.joramplatform.queue") + " (" + name + ")", 1885 "EditJoramQueue.do?name=" + name + "&id=" + localId, 1886 "content", 1887 false); 1888 } else if (type.equals("topic")) { 1889 destinationNode = new TreeControlNode(localServerNode.getName() 1890 + WhereAreYou.NODE_SEPARATOR 1891 + "joramtopic" + name, 1892 "icon/jms_topic.gif", 1893 pResources.getMessage("treenode.joramplatform.topic") + " (" + name + ")", 1894 "EditJoramTopic.do?name=" + name + "&id=" + localId, 1895 "content", 1896 false); 1897 } 1898 if (destinationNode != null) { 1899 localServerNode.addChild(destinationNode); 1900 } 1901 } 1902 1903 List list = (List ) JonasManagementRepr.getAttribute(joramPlatformON, "ServersIds"); 1905 if (list != null) { 1906 Iterator it = list.iterator(); 1907 Integer serverId; 1908 String id; 1909 TreeControlNode remoteServerNode; 1910 while (it.hasNext()) { 1911 serverId = (Integer ) it.next(); 1912 id = serverId.toString(); 1913 String joramremoteserver = null; 1914 if (!id.equals(localId)) { 1915 joramremoteserver = "joramremoteserver" + id; 1916 remoteServerNode = 1917 new TreeControlNode(platformNode.getName() + WhereAreYou.NODE_SEPARATOR + joramremoteserver, 1918 "icon/service_jms.gif", 1919 pResources.getMessage("treenode.joramplatform.joramremoteserver") + " (" + id + ")", 1920 "EditJoramServer.do?id=" + id, 1921 "content", 1922 false); 1923 1924 platformNode.addChild(remoteServerNode); 1925 1926 ArrayList remoteDestList = (ArrayList ) map.get(id); 1928 if (remoteDestList == null) { 1929 continue; 1930 } 1931 for (int i = 0; i < remoteDestList.size(); i++) { 1932 ItemDestination item = (ItemDestination) remoteDestList.get(i); 1933 if (item.getOn() == null) { 1934 continue; 1935 } 1936 String name = item.getName(); 1937 String type = item.getType(); 1938 TreeControlNode destinationNode = null; 1939 if (type.equals("queue")) { 1940 destinationNode = new TreeControlNode(remoteServerNode.getName() 1941 + WhereAreYou.NODE_SEPARATOR 1942 + "joramqueue" + name, 1943 "icon/jms_queue.gif", 1944 pResources.getMessage("treenode.joramplatform.queue") + " (" + name + ")", 1945 "EditJoramQueue.do?name=" + name + "&id=" + id, 1946 "content", 1947 false); 1948 } else if (type.equals("topic")) { 1949 destinationNode = new TreeControlNode(remoteServerNode.getName() 1950 + WhereAreYou.NODE_SEPARATOR 1951 + "joramtopic" + name, 1952 "icon/jms_topic.gif", 1953 pResources.getMessage("treenode.joramplatform.topic") + " (" + name + ")", 1954 "EditJoramTopic.do?name=" + name + "&id=" + id, 1955 "content", 1956 false); 1957 } 1958 if (destinationNode != null) { 1959 remoteServerNode.addChild(destinationNode); 1960 } 1961 } 1962 } 1963 } 1964 } 1965 } 1966 1974 public void getMBeans(TreeControlNode domainNode, MessageResources resources) 1975 throws Exception { 1976 1977 TreeControlNode nodeMBeans = new TreeControlNode(domainNode.getName() 1978 + WhereAreYou.NODE_SEPARATOR 1979 + "mbeans" 1980 , "icon/mbeans.gif" 1981 , resources.getMessage("treenode.allmbeans") 1982 , "ListMBeans.do", "content", false); 1983 domainNode.addChild(nodeMBeans); 1984 1985 ArrayList [] als = JonasAdminJmx.getFamiliesMbeansLists(); 1986 if (als[MbeanItem.FAMILY_J2EE].size() > 0) { 1987 getJ2eeMBeans(nodeMBeans, resources, als[MbeanItem.FAMILY_J2EE]); 1988 } 1989 if (als[MbeanItem.FAMILY_OWNER].size() > 0) { 1990 getOwnerMBeans(nodeMBeans, resources, als[MbeanItem.FAMILY_OWNER]); 1991 } 1992 if (als[MbeanItem.FAMILY_UNKNOWN].size() > 0) { 1993 getUnknownMBeans(nodeMBeans, resources, als[MbeanItem.FAMILY_UNKNOWN]); 1994 } 1995 } 1996 1997 2006 public void getOwnerMBeans(TreeControlNode p_ParentNode, MessageResources p_Resources 2007 , ArrayList p_List) 2008 throws Exception { 2009 2010 TreeControlNode nodeMBeans = new TreeControlNode(p_ParentNode.getName() 2011 + WhereAreYou.NODE_SEPARATOR 2012 + "owner" 2013 , "icon/mbeans.gif" 2014 , p_Resources.getMessage("treenode.mbeans.owner") 2015 , "ListOwnerMBeans.do", "content", false); 2016 p_ParentNode.addChild(nodeMBeans); 2017 Collections.sort(p_List, new BeanComparator(new String [] { 2019 "domain", "type", "objectName"})); 2020 2021 String sLastDomain = ""; 2023 String sLastType = ""; 2024 TreeControlNode nodeMBean = null; 2025 TreeControlNode nodeDomain = null; 2026 TreeControlNode nodeType = null; 2027 TreeControlNode nodeParent = null; 2028 OwnerMbeanItem oItem; 2029 2030 Iterator it = p_List.iterator(); 2031 while (it.hasNext()) { 2032 oItem = (OwnerMbeanItem) it.next(); 2033 2034 nodeParent = nodeMBeans; 2035 if (oItem.getDomain() != null) { 2036 if (oItem.getDomain().equals(sLastDomain) == false) { 2038 sLastDomain = oItem.getDomain(); 2039 nodeDomain = new TreeControlNode(nodeParent.getName() 2040 + WhereAreYou.NODE_SEPARATOR + oItem.getDomain(), "icon/mbeandomain.gif" 2041 , oItem.getDomain(), null, "content", false); 2042 nodeMBeans.addChild(nodeDomain); 2043 } 2044 nodeParent = nodeDomain; 2045 2046 if (oItem.getType() != null) { 2047 if (oItem.getType().equals(sLastType) == false) { 2049 sLastType = oItem.getType(); 2050 nodeType = new TreeControlNode(nodeParent.getName() 2051 + WhereAreYou.NODE_SEPARATOR + oItem.getType(), "icon/mbeantype.gif" 2052 , oItem.getType(), null, "content", false); 2053 nodeDomain.addChild(nodeType); 2054 } 2055 nodeParent = nodeType; 2056 } 2057 } 2058 2059 nodeMBean = new TreeControlNode(p_ParentNode.getName() 2061 + WhereAreYou.NODE_SEPARATOR 2062 + oItem.getObjectName() 2063 , "icon/mbean.gif" 2064 , oItem.getObjectName() 2065 , "ListMBeanDetails.do?select=" + URLEncoder.encode(oItem.getObjectName(), "UTF-8") 2066 , "content", false); 2067 nodeParent.addChild(nodeMBean); 2068 2069 } 2070 } 2071 2072 2081 public void getJ2eeMBeans(TreeControlNode p_ParentNode, MessageResources p_Resources 2082 , ArrayList p_List) 2083 throws Exception { 2084 2085 TreeControlNode nodeMBeans = new TreeControlNode(p_ParentNode.getName() 2086 + WhereAreYou.NODE_SEPARATOR 2087 + "j2ee" 2088 , "icon/mbeans.gif" 2089 , p_Resources.getMessage("treenode.mbeans.j2ee") 2090 , "ListJ2eeMBeans.do", "content", false); 2091 p_ParentNode.addChild(nodeMBeans); 2092 Collections.sort(p_List, new BeanComparator(new String [] { 2094 "domain", "j2eeType", "name", "objectName"})); 2095 2096 J2eeMbeanItem oItem; 2098 String sLastDomain = ""; 2099 String sLastType = ""; 2100 TreeControlNode nodeMBean = null; 2101 TreeControlNode nodeDomain = null; 2102 TreeControlNode nodeType = null; 2103 TreeControlNode nodeParent = null; 2104 2105 Iterator it = p_List.iterator(); 2106 while (it.hasNext()) { 2107 oItem = (J2eeMbeanItem) it.next(); 2108 2109 nodeParent = nodeMBeans; 2110 if (oItem.getDomain() != null) { 2111 if (oItem.getDomain().equals(sLastDomain) == false) { 2113 sLastDomain = oItem.getDomain(); 2114 nodeDomain = new TreeControlNode(nodeParent.getName() 2115 + WhereAreYou.NODE_SEPARATOR + oItem.getDomain(), "icon/mbeandomain.gif" 2116 , oItem.getDomain(), null, "content", false); 2117 nodeMBeans.addChild(nodeDomain); 2118 } 2119 nodeParent = nodeDomain; 2120 } 2121 if (oItem.getJ2eeType() != null) { 2122 if (oItem.getJ2eeType().equals(sLastType) == false) { 2124 sLastType = oItem.getJ2eeType(); 2125 nodeType = new TreeControlNode(nodeParent.getName() 2126 + WhereAreYou.NODE_SEPARATOR + oItem.getJ2eeType(), "icon/mbeantype.gif" 2127 , oItem.getJ2eeType(), null, "content", false); 2128 nodeDomain.addChild(nodeType); 2129 } 2130 nodeParent = nodeType; 2131 } 2132 2133 nodeMBean = new TreeControlNode(p_ParentNode.getName() 2135 + WhereAreYou.NODE_SEPARATOR 2136 + oItem.getObjectName() 2137 , "icon/mbean.gif" 2138 , oItem.getObjectName() 2139 , "ListMBeanDetails.do?select=" + URLEncoder.encode(oItem.getObjectName(), "UTF-8") 2140 , "content", false); 2141 nodeParent.addChild(nodeMBean); 2142 2143 } 2144 } 2145 2146 2155 public void getUnknownMBeans(TreeControlNode p_ParentNode, MessageResources p_Resources 2156 , ArrayList p_List) 2157 throws Exception { 2158 2159 TreeControlNode nodeMBeans = new TreeControlNode(p_ParentNode.getName() 2160 + WhereAreYou.NODE_SEPARATOR 2161 + "unknown" 2162 , "icon/mbeans.gif" 2163 , p_Resources.getMessage("treenode.mbeans.unknown") 2164 , "ListUnknownMBeans.do", "content", false); 2165 p_ParentNode.addChild(nodeMBeans); 2166 Collections.sort(p_List, new BeanComparator(new String [] { 2168 "domain", "objectName"})); 2169 2170 MbeanItem oItem; 2172 String sLastDomain = ""; 2173 TreeControlNode nodeMBean = null; 2174 TreeControlNode nodeDomain = null; 2175 TreeControlNode nodeType = null; 2176 TreeControlNode nodeParent = null; 2177 2178 Iterator it = p_List.iterator(); 2179 while (it.hasNext()) { 2180 oItem = (MbeanItem) it.next(); 2181 2182 nodeParent = nodeMBeans; 2183 if (oItem.getDomain() != null) { 2184 if (oItem.getDomain().equals(sLastDomain) == false) { 2186 sLastDomain = oItem.getDomain(); 2187 nodeDomain = new TreeControlNode(nodeParent.getName() 2188 + WhereAreYou.NODE_SEPARATOR + oItem.getDomain(), "icon/mbeandomain.gif" 2189 , oItem.getDomain(), null, "content", false); 2190 nodeMBeans.addChild(nodeDomain); 2191 } 2192 nodeParent = nodeDomain; 2193 2194 } 2195 2196 nodeMBean = new TreeControlNode(p_ParentNode.getName() 2198 + WhereAreYou.NODE_SEPARATOR 2199 + oItem.getObjectName() 2200 , "icon/mbean.gif" 2201 , oItem.getObjectName() 2202 , "ListMBeanDetails.do?select=" + URLEncoder.encode(oItem.getObjectName(), "UTF-8") 2203 , "content", false); 2204 nodeParent.addChild(nodeMBean); 2205 2206 } 2207 } 2208 2209 2217 protected void getMBeanInfo(TreeControlNode nodeMBean, ObjectName onMBean 2218 , MessageResources resources) 2219 throws Exception { 2220 MBeanInfo oMBeanInfo = JonasManagementRepr.getMBeanInfo(onMBean); 2222 MBeanAttributeInfo [] aoMBeanAttributeInfo = oMBeanInfo.getAttributes(); 2224 if (aoMBeanAttributeInfo.length > 0) { 2225 TreeControlNode nodeAttributes = new TreeControlNode("Attributes" 2227 + WhereAreYou.NODE_SEPARATOR + onMBean.toString(), "icon/JonasQuestion.gif" 2228 , resources.getMessage("treenode.allmbeans.attributes"), null, "content", false); 2229 nodeMBean.addChild(nodeAttributes); 2230 for (int i = 0; i < aoMBeanAttributeInfo.length; i++) { 2232 TreeControlNode nodeAttr = new TreeControlNode(String.valueOf(i) 2233 + WhereAreYou.NODE_SEPARATOR + onMBean.toString() + WhereAreYou.NODE_SEPARATOR 2234 + aoMBeanAttributeInfo[i].getName(), "icon/property.gif" 2235 , aoMBeanAttributeInfo[i].getName(), null, "content", false); 2236 nodeAttributes.addChild(nodeAttr); 2237 } 2238 } 2239 MBeanOperationInfo [] aoMBeanOperationInfo = oMBeanInfo.getOperations(); 2241 if (aoMBeanOperationInfo.length > 0) { 2242 TreeControlNode nodeOperations = new TreeControlNode("Operations" 2244 + WhereAreYou.NODE_SEPARATOR + onMBean.toString(), "icon/JonasQuestion.gif" 2245 , resources.getMessage("treenode.allmbeans.operations"), null, "content", false); 2246 nodeMBean.addChild(nodeOperations); 2247 for (int i = 0; i < aoMBeanOperationInfo.length; i++) { 2249 TreeControlNode nodeOpe = new TreeControlNode(String.valueOf(i) 2250 + WhereAreYou.NODE_SEPARATOR + onMBean.toString() + WhereAreYou.NODE_SEPARATOR 2251 + aoMBeanOperationInfo[i].getName(), "icon/action.gif" 2252 , aoMBeanOperationInfo[i].getName(), null, "content", false); 2253 nodeOperations.addChild(nodeOpe); 2254 } 2255 } 2256 } 2257 2258 2265 public ItemDestination getDestinationItem(String joramAdminDestination) throws MalformedObjectNameException { 2266 ItemDestination destinationItem = new ItemDestination(); 2267 ObjectName destinationON = null; 2268 StringTokenizer st = new StringTokenizer (joramAdminDestination, ","); 2269 String type = null; 2270 String name = null; 2271 String id = null; 2272 String serverId = null; 2273 while (st.hasMoreTokens()) { 2274 String couple = st.nextToken().trim(); 2276 int index = couple.indexOf("="); 2277 String key = couple.substring(0, index); 2278 String value = couple.substring(index+1, couple.length()); 2279 if (key.equals("type")) { 2280 type = value; 2281 destinationItem.setType(type); 2282 } 2283 if (key.equals("name")) { 2284 name = value; 2285 destinationItem.setName(name); 2286 } 2287 if (key.equals("id")) { 2288 id = value; 2289 destinationItem.setId(id); 2290 int indexBefore = id.indexOf("#"); 2291 int indexAfter = id.indexOf(".", indexBefore); 2292 serverId = id.substring(indexBefore + 1, indexAfter); 2293 destinationItem.setServerId(serverId); 2294 } 2295 if (name != null && type != null) { 2296 if (type.equals("topic")) { 2297 destinationON = JoramObjectName.joramTopic(name); 2298 } else if (type.equals("queue")) { 2299 destinationON = JoramObjectName.joramQueue(name); 2300 } 2301 if (JonasAdminJmx.hasMBeanName(destinationON)) { 2302 destinationItem.setOn(destinationON); 2303 } 2304 } 2305 } 2306 return destinationItem; 2307 } 2308 2309} 2310 | Popular Tags |