KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > JonasTreeBuilder


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: JonasTreeBuilder.java,v 1.70 2005/07/25 22:51:11 vivekl Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin;
27
28 import java.net.URLEncoder JavaDoc;
29 import java.util.ArrayList JavaDoc;
30 import java.util.Collection JavaDoc;
31 import java.util.Collections JavaDoc;
32 import java.util.HashMap JavaDoc;
33 import java.util.Iterator JavaDoc;
34 import java.util.List JavaDoc;
35 import java.util.StringTokenizer JavaDoc;
36
37 import javax.management.MBeanAttributeInfo JavaDoc;
38 import javax.management.MBeanInfo JavaDoc;
39 import javax.management.MBeanOperationInfo JavaDoc;
40 import javax.management.MalformedObjectNameException JavaDoc;
41 import javax.management.ObjectName JavaDoc;
42 import javax.servlet.http.HttpServletRequest JavaDoc;
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 /**
78  * Implementation of <code>TreeBuilder</code> that adds the nodes required
79  * for administering the Jonas server.
80  *
81  * @author Michel-Ange ANTON (initial developer)
82  * @author Adriana Danes : add nodes for JMS service
83  * @author Florent Benoit (changes for struts 1.2.2)
84  */

85 public class JonasTreeBuilder implements TreeBuilder {
86
87 // ----------------------------------------------------- Instance Variables
88

89 // ---------------------------------------------------- TreeBuilder Methods
90

91     /**
92      * Add the required nodes to the specified <code>treeControl</code>
93      * instance.
94      *
95      * @param treeControl The <code>TreeControl</code> to which we should
96      * add our nodes
97      * @param servlet The controller servlet for the admin application
98      * @param request The servlet request we are processing
99      */

100     public void buildTree(TreeControl treeControl, ActionServlet servlet
101         , HttpServletRequest JavaDoc 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 JavaDoc t) {
109             t.printStackTrace(System.out);
110         }
111     }
112
113 // ------------------------------------------------------ Protected Methods
114

115     /**
116      * Append nodes for the current domain.
117      *
118      * @param p_RootNode Root node for the tree control
119      * @param p_Resources The MessageResources for our localized messages
120      * @param p_Request The servlet request we are processing
121      *
122      * @exception Exception if an exception occurs building the tree
123      */

124     protected void getDomain(TreeControlNode p_RootNode, MessageResources p_Resources
125         , HttpServletRequest JavaDoc p_Request)
126         throws Exception JavaDoc {
127         // Add domain node
128
WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou.
129             SESSION_NAME);
130         String JavaDoc sDomain = oWhere.getCurrentDomain().toString();// OBJECT_NAME
131
String JavaDoc sDomainName = oWhere.getCurrentDomainName();// value of the 'name' key property
132
String JavaDoc 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         // Add children
138
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     /**
147      * Returns if the current server (with discovery running) is a master server.
148      * @return if the current server is a master server.
149      */

150     protected boolean isMaster() {
151         ObjectName JavaDoc oObjectName = JonasObjectName.discoveryService();
152         Boolean JavaDoc result = (Boolean JavaDoc) JonasManagementRepr.getAttribute(oObjectName, "IsDiscoveryMaster");
153         return result.booleanValue();
154     }
155     
156     /**
157      * Append nodes for domain management deployment.
158      *
159      * @param p_DomainNode Domain node for the tree control
160      * @param p_Resources The MessageResources for our localized messages
161      * @param p_Request The servlet request we are processing
162      * @param p_DomainName The name of the domain.
163      *
164      * @throws Exception if an exception occurs building the tree
165      */

166     protected void getDomainDeploy(TreeControlNode p_DomainNode, MessageResources p_Resources
167             , HttpServletRequest JavaDoc p_Request)
168             throws Exception JavaDoc {
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     /**
190      * Append node for Ear deployment using domain management.
191      *
192      * @param p_NodeDeployments Deployment node for the tree control
193      * @param p_Resources The MessageResources for our localized messages
194      *
195      * @exception Exception if an exception occurs building the tree
196      */

197     protected void getDomainDeploymentEar(TreeControlNode p_NodeDeployments, MessageResources p_Resources)
198         throws Exception JavaDoc {
199         // Add node
200
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     /**
209      * Append node for Ejb deployment using domain management.
210      *
211      * @param p_NodeDeployments Deployment node for the tree control
212      * @param p_Resources The MessageResources for our localized messages
213      *
214      * @exception Exception if an exception occurs building the tree
215      */

216     protected void getDomainDeploymentEjb(TreeControlNode p_NodeDeployments, MessageResources p_Resources)
217         throws Exception JavaDoc {
218         // Add node
219
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         // Add list files
227
//getDeploymentJarFiles(oNode, p_Resources);
228
}
229
230     /**
231      * Append node for Web deployment using domain management.
232      *
233      * @param p_NodeDeployments Deployment node for the tree control
234      * @param p_Resources The MessageResources for our localized messages
235      *
236      * @exception Exception if an exception occurs building the tree
237      */

238     protected void getDomainDeploymentWebAppli(TreeControlNode p_NodeDeployments
239         , MessageResources p_Resources)
240         throws Exception JavaDoc {
241         // Add node
242
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     /**
251      * Append node for Rar deployment using domain management.
252      *
253      * @param p_NodeDeployments Deployment node for the tree control
254      * @param p_Resources The MessageResources for our localized messages
255      *
256      * @exception Exception if an exception occurs building the tree
257      */

258     protected void getDomainDeploymentRar(TreeControlNode p_NodeDeployments, MessageResources p_Resources)
259         throws Exception JavaDoc {
260         // Add node
261
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     /**
270      * Append nodes for a defined Jonas server.
271      *
272      * @param p_DomainNode Domain node for the tree control
273      * @param p_Resources The MessageResources for our localized messages
274      * @param p_Request The servlet request we are processing
275      *
276      * @exception Exception if an exception occurs building the tree
277      */

278     protected void getServer(TreeControlNode p_DomainNode, MessageResources p_Resources
279         , HttpServletRequest JavaDoc p_Request, String JavaDoc p_DomainName)
280         throws Exception JavaDoc {
281         // Add server node
282
/* Implem note
283          * -----------
284          * Currently we have only one server in the domain, it's id being registered
285          * in helper class WhereAreYou. This will change with in the next version
286          * with full Domain support. We'll have to query for all the J2EEServer MBeans.
287          */

288         WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou.
289             SESSION_NAME);
290         String JavaDoc sServer = oWhere.getCurrentJonasServer().toString();
291         String JavaDoc sServerName = oWhere.getCurrentJonasServerName();
292         String JavaDoc 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         // Add children
298
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     /**
308      * Append nodes for Monitoring.
309      *
310      * @param p_ServerNode Server node for the tree control
311      * @param p_Resources The MessageResources for our localized messages
312      * messages
313      *
314      * @exception Exception if an exception occurs building the tree
315      */

316     protected void getMonitoring(TreeControlNode p_ServerNode, MessageResources p_Resources)
317         throws Exception JavaDoc {
318         // Monitoring server Service node
319
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     /**
327      * Append nodes for Logging.
328      *
329      * @param p_ServerNode Server node for the tree control
330      * @param p_Resources The MessageResources for our localized messages
331      * @param p_Request The servlet request we are processing
332      *
333      * @exception Exception if an exception occurs building the tree
334      */

335     protected void getLogging(TreeControlNode p_ServerNode, MessageResources p_Resources
336         , HttpServletRequest JavaDoc p_Request)
337         throws Exception JavaDoc {
338         // Logging server Service node
339
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         // Add all loggers
344
getLoggers(node, p_Resources, p_Request);
345     }
346
347     /**
348      * Append nodes for each logger.
349      *
350      * @param p_LoggingNode Server node for the tree control
351      * @param p_Resources The MessageResources for our localized messages
352      * @param p_Request The servlet request we are processing
353      *
354      * @exception Exception if an exception occurs building the tree
355      */

356     public void getLoggers(TreeControlNode p_LoggingNode, MessageResources p_Resources
357         , HttpServletRequest JavaDoc p_Request)
358         throws Exception JavaDoc {
359         // Get WhereAreYou instance in session
360
WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou.
361             SESSION_NAME);
362         // Get list of loggers with Action name
363
ArrayList JavaDoc al = JonasAdminJmx.getLoggers(p_Resources, oWhere, true);
364         // Build the node of each logger
365
LoggerItem oLog;
366         String JavaDoc sIcon = "icon/loggers.gif";
367         String JavaDoc rootNodeName = p_LoggingNode.getName();
368         String JavaDoc 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 /*if (LoggerItem.LOGGER_CATALINA_ACCESS.equals(oLog.getType()) == true)*/ {
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             // Add a logger node
383
TreeControlNode node = new TreeControlNode(nodeName, sIcon
384                 , oLog.getName()
385                 , oLog.getForward()
386                 , "content", false);
387             p_LoggingNode.addChild(node);
388         }
389     }
390
391     /**
392      * Append nodes for all defined services for the specified server.
393      *
394      * @param p_ServerNode Server node for the tree control
395      * @param p_Resources The MessageResources for our localized messages
396      * @param p_Request The servlet request we are processing
397      * @exception Exception if an exception occurs building the tree
398      */

399     protected void getServices(TreeControlNode p_ServerNode, MessageResources p_Resources
400         , HttpServletRequest JavaDoc p_Request, String JavaDoc p_DomainName, String JavaDoc p_ServerName)
401         throws Exception JavaDoc {
402         // Services node
403
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         // Detail Service node
410
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     /**
446      * Append node for Ear service for the JOnAS services.
447      *
448      * @param p_NodeServices Services node for the tree control
449      * @param p_Resources The MessageResources for our localized messages
450      *
451      * @exception Exception if an exception occurs building the tree
452      */

453     protected void getServiceApp(TreeControlNode p_NodeServices, MessageResources p_Resources, String JavaDoc p_DomainName, String JavaDoc p_ServerName)
454         throws Exception JavaDoc {
455         // Add Service node
456
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         // Add App Containers nodes
464
getAppContainers(nodeService, p_Resources, p_DomainName, p_ServerName);
465     }
466
467     /**
468      * Append node for all App Containers.
469      *
470      * @param p_NodeParent Server node for the tree control
471      * @param p_Resources The MessageResources for our localized messages
472      *
473      * @exception Exception if an exception occurs building the tree
474      */

475     public void getAppContainers(TreeControlNode p_NodeParent, MessageResources p_Resources, String JavaDoc p_DomainName, String JavaDoc p_ServerName)
476         throws Exception JavaDoc {
477         String JavaDoc sPath;
478         String JavaDoc sFile;
479         String JavaDoc sNodeName;
480         String JavaDoc sName;
481         ArrayList JavaDoc al = new ArrayList JavaDoc();
482
483         // Get Container List
484
ObjectName JavaDoc ons = J2eeObjectName.J2EEApplications(p_DomainName, p_ServerName);
485         Iterator JavaDoc itNames = JonasManagementRepr.queryNames(ons).iterator();
486         while (itNames.hasNext()) {
487             ObjectName JavaDoc it_on = (ObjectName JavaDoc) itNames.next();
488             sPath = (String JavaDoc) 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         // Sort list
497
Collections.sort(al, new ContainerItemByFile());
498         // Build nodes
499
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     /**
509      * Append node for EJBContainer service for the JOnAS services.
510      *
511      * @param p_NodeServices Services node for the tree control
512      * @param p_Resources The MessageResources for our localized messages
513      * messages
514      *
515      * @exception Exception if an exception occurs building the tree
516      */

517     protected void getServiceEjbContainer(TreeControlNode p_NodeServices
518         , MessageResources p_Resources, String JavaDoc p_DomainName, String JavaDoc p_ServerName)
519         throws Exception JavaDoc {
520         // Add Service node
521
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         // Add Containers nodes
528
getContainers(nodeService, p_Resources, p_DomainName, p_ServerName);
529     }
530
531     /**
532      * Append node for all Containers.
533      *
534      * @param p_NodeParent Server node for the tree control
535      * @param p_Resources The MessageResources for our localized messages
536      *
537      * @exception Exception if an exception occurs building the tree
538      */

539     public void getContainers(TreeControlNode p_NodeParent, MessageResources p_Resources, String JavaDoc p_DomainName, String JavaDoc p_ServerName)
540         throws Exception JavaDoc {
541         String JavaDoc sPath;
542         String JavaDoc sFile;
543         String JavaDoc sName;
544         String JavaDoc sNodeName;
545         ObjectName JavaDoc onContainer;
546         ArrayList JavaDoc al = new ArrayList JavaDoc();
547
548         // Get Container List
549
Iterator JavaDoc itNames = JonasManagementRepr.queryNames(J2eeObjectName.getEJBModules(p_DomainName, p_ServerName)).iterator();
550         while (itNames.hasNext()) {
551             ObjectName JavaDoc it_on = (ObjectName JavaDoc) itNames.next();
552             sPath = (String JavaDoc) 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         // Sort list
562
Collections.sort(al, new ContainerItemByFile());
563         // Build nodes
564
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             // Add ejb node
571
getEjbs(node, p_Resources, oItem.getPath(), p_DomainName, p_ServerName, oItem.getName());
572         }
573     }
574
575     /**
576      * Append node for all Ejbs for a Container.
577      *
578      * @param p_NodeParent Server node for the tree control
579      * @param p_Resources The MessageResources for our localized messages
580      * @param p_Filename Filename of container
581      *
582      * @exception Exception if an exception occurs building the tree
583      */

584     protected void getEjbs(TreeControlNode p_NodeParent, MessageResources p_Resources
585         , String JavaDoc p_Filename, String JavaDoc p_DomainName, String JavaDoc p_ServerName, String JavaDoc p_moduleName)
586         throws Exception JavaDoc {
587         //String sName;
588
Iterator JavaDoc itNames;
589         ObjectName JavaDoc on;
590         ArrayList JavaDoc al = new ArrayList JavaDoc();
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 JavaDoc) 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 JavaDoc) 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 JavaDoc) 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 JavaDoc) itNames.next()));
612         }
613
614         // Sort by name
615
Collections.sort(al, new EjbItemByNameComparator());
616
617         // Add all node Ejb
618
String JavaDoc sNodeName;
619         String JavaDoc 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             // Add node Ejb
627
nodeEjb = new TreeControlNode(sNodeName, "icon/bean.gif", oEjb.getName(), sAction
628                 , "content", false);
629             p_NodeParent.addChild(nodeEjb);
630         }
631     }
632
633     /**
634      * Append node for Database service for the JOnAS services.
635      *
636      * @param pNodeServices Services node for the tree control
637      * @param pResources The MessageResources for our localized messages
638      * @param pDomainName The name of the current management domain
639      * @param pServerName The name of the currently managed JOnAS server
640      * @exception Exception if an exception occurs building the tree
641      */

642     protected void getServiceDatabase(TreeControlNode pNodeServices, MessageResources pResources, String JavaDoc pDomainName, String JavaDoc pServerName)
643         throws Exception JavaDoc {
644         // Add Service node
645
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         // Add Datasources nodes
651
getDatasources(nodeService, pResources, pDomainName, pServerName);
652     }
653
654     /**
655      * Append node for all deployed Datasources.
656      *
657      * @param pNodeParent Server node for the tree control
658      * @param pResources The MessageResources for our localized messages
659      * @param pDomainName The name of the current management domain
660      * @param pServerName The name of the currently managed JOnAS server
661      *
662      * @exception Exception if an exception occurs building the tree
663      */

664     public void getDatasources(TreeControlNode pNodeParent, MessageResources pResources, String JavaDoc pDomainName, String JavaDoc pServerName)
665         throws Exception JavaDoc {
666
667         ArrayList JavaDoc al = JonasAdminJmx.getDatasourceFilesDeployed(pDomainName, pServerName);
668         // Build nodes
669
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     /**
678      * Append node for Web service for the JOnAS services.
679      *
680      * @param pNodeServices Services node for the tree control
681      * @param pResources The MessageResources for our localized messages
682      * @param pRequest The servlet request we are processing
683      * @param pDomainName The name of the current management domain
684      * @param pServerName The name of the currently managed JOnAS server
685      *
686      * @exception Exception if an exception occurs building the tree
687      */

688     protected void getServiceWeb(TreeControlNode pNodeServices, MessageResources pResources
689         , HttpServletRequest JavaDoc pRequest, String JavaDoc pDomainName, String JavaDoc pServerName)
690         throws Exception JavaDoc {
691         // Add Service node
692
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         // Add Web Containers nodes
698
getWebContainers(nodeService, pResources, pRequest);
699     }
700
701     /**
702      * Append node for all Web Containers.
703      *
704      * @param p_NodeParent Server node for the tree control
705      * @param p_Resources The MessageResources for our localized messages
706      * @param p_Request The servlet request we are processing
707      *
708      * @exception Exception if an exception occurs building the tree
709      */

710     public void getWebContainers(TreeControlNode p_NodeParent, MessageResources p_Resources
711         , HttpServletRequest JavaDoc p_Request)
712         throws Exception JavaDoc {
713         WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou.
714             SESSION_NAME);
715
716         ArrayList JavaDoc al = new ArrayList JavaDoc();
717         // Detect Catalina items present
718
if (oWhere.isCatalinaServer() == true) {
719             // Get the list of WebModule
720
Iterator JavaDoc itOns = JonasAdminJmx.getListMbean(J2eeObjectName.getWebModules(oWhere.
721                 getCurrentCatalinaDomainName())).iterator();
722             while (itOns.hasNext()) {
723                 al.add(new WebAppItem((ObjectName JavaDoc) itOns.next()));
724             }
725         }
726         // Detect Jetty items present
727
else if (oWhere.isJettyServer() == true) {
728             ObjectName JavaDoc on;
729             String JavaDoc sPathContext;
730             HashMap JavaDoc hWebAppItems = new HashMap JavaDoc();
731
732             // Get the list of Jetty contexts
733
Iterator JavaDoc itOnContexts = JonasAdminJmx.getListMbean(JettyObjectName.jettyContexts()).
734                 iterator();
735             while (itOnContexts.hasNext()) {
736                 on = (ObjectName JavaDoc) 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             // Prepare to display
746
al.addAll(hWebAppItems.values());
747         }
748         // Sort list
749
Collections.sort(al, new WebAppItemByPathContext());
750         // Build nodes
751
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     /**
763      * Append node for Transaction service for the JOnAS services.
764      *
765      * @param p_NodeServices Services node for the tree control
766      * @param p_Resources The MessageResources for our localized messages
767      * messages
768      *
769      * @exception Exception if an exception occurs building the tree
770      */

771     protected void getServiceTransaction(TreeControlNode p_NodeServices
772         , MessageResources p_Resources, String JavaDoc p_DomainName, String JavaDoc p_ServerName)
773         throws Exception JavaDoc {
774         // Add Service node
775
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     /**
783      * Append node for discovery service for the JOnAS services.
784      *
785      * @param p_NodeServices Services node for the tree control
786      * @param p_Resources The MessageResources for our localized messages
787      * messages
788      *
789      * @exception Exception if an exception occurs building the tree
790      */

791     protected void getServiceDiscovery(TreeControlNode p_NodeServices, MessageResources p_Resources, String JavaDoc p_DomainName, String JavaDoc p_ServerName)
792         throws Exception JavaDoc {
793         // Add Service node
794
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     /**
802      * Append node for WebService (ws) service for the JOnAS services.
803      *
804      * @param p_NodeServices
805      * Services node for the tree control
806      * @param p_Resources
807      * The MessageResources for our localized messages
808      * @param request
809      * The HTTP request object currently in use.
810      * @param p_DomainName
811      * The domain name for the instance
812      * @param p_ServerName
813      * The server name for the instance being monitored
814      * @exception Exception
815      * if an exception occurs building the tree
816      */

817      public void getServiceWebService(TreeControlNode p_NodeServices,
818             MessageResources p_Resources, HttpServletRequest JavaDoc request, String JavaDoc p_DomainName,
819             String JavaDoc p_ServerName) throws Exception JavaDoc {
820         String JavaDoc nodeName = p_NodeServices.getName() + WhereAreYou.NODE_SEPARATOR + "WebService";
821         TreeControlNode nodeService = null;
822         // Rebuild the webservice tree.
823
nodeService = p_NodeServices.getTree().findNode(nodeName);
824         if (nodeService != null) {
825             nodeService.remove();
826         }
827             // (Re)Add Web Service node
828
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     /**
839      * Append Web Service names for web services node in tree.
840      *
841      * @param p_WebServicesNode
842      * Web Services node for the tree control
843      * @param p_Resources
844      * The MessageResources for our localized messages
845      * @param p_Request
846      * The servlet request we are processing
847      * @exception Exception
848      * if an exception occurs building the tree
849      */

850     public void getWebServiceDetails(TreeControlNode p_webServicesNode,
851             MessageResources p_Resources, HttpServletRequest JavaDoc p_Request)
852             throws Exception JavaDoc {
853         // Get WhereAreYou
854
WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(
855                 WhereAreYou.SESSION_NAME);
856
857         // Get the server name
858
String JavaDoc sServerName = oWhere.getCurrentJonasServerName();
859         // Get the list of webservice descriptions from mbean server.
860
Collection JavaDoc al = new ArrayList JavaDoc();
861         GenericDomainCapableProvider jProvider = new JonasProvider();
862         jProvider.initialize(sServerName, null);
863         al = jProvider.getWebServiceDescription();
864
865         // Build the nodes
866
TreeControlNode node;
867         WebServiceDescription oWebServiceDescription = null;
868         String JavaDoc sLabel;
869         Iterator JavaDoc 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     /**
884      * Append port component names for a web service node in tree.
885      *
886      * @param wsd
887      * Web Service Description for current web service.
888      * @param p_WebServicesNode
889      * Connector node for the tree control
890      * @param p_Resources
891      * The MessageResources for our localized messages
892      * @exception Exception
893      * if an exception occurs building the tree
894      */

895     private void getPortComponents(WebServiceDescription wsd,
896             TreeControlNode p_webServiceNode, MessageResources p_Resources)
897             throws Exception JavaDoc {
898
899         String JavaDoc sLabel;
900         // Build the nodes
901
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     /**
916      * Append handler names for port component node in tree.
917      *
918      * @param wsd
919      * Web Service Description for current web service.
920      * @param pc
921      * Port Component for current web service.
922      * @param p_portComponentNode
923      * Port component node for the tree control
924      * @param p_Resources
925      * The MessageResources for our localized messages
926      */

927     private void getPortComponentHandler(WebServiceDescription wsd,
928             PortComponent pc, TreeControlNode p_portComponentNode,
929             MessageResources p_Resources) throws Exception JavaDoc {
930         // Build the nodes
931
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     /**
948      * Append node for Jms service for the JOnAS services.
949      *
950      * @param p_NodeServices Services node for the tree control
951      * @param p_Resources The MessageResources for our localized messages
952      *
953      * @exception Exception if an exception occurs building the tree
954      */

955     protected void getServiceJms(TreeControlNode p_NodeServices, MessageResources p_Resources, String JavaDoc p_DomainName, String JavaDoc p_ServerName)
956         throws Exception JavaDoc {
957         // Add Service node
958
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         // Add JMS administred objects (resources)
964
getJmsResources(nodeService, p_Resources);
965     }
966
967     /**
968      * Append 3 subnodes for the JMS resource types + subnodes for all the ressources
969      *
970      * @param p_NodeParent JMS service node
971      * @param p_Resources The MessageResources for our localized messages
972      *
973      * @exception Exception if an exception occurs building the tree
974      */

975     public void getJmsResources(TreeControlNode p_NodeParent, MessageResources p_Resources)
976         throws Exception JavaDoc {
977         // Add node for Connection Factories
978
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         // Add node for Queues
986
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         // Add node for Topics
994
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    /**
1003     * Append subnodes for ConnectionFactory resources
1004     *
1005     * @param p_NodeParent CFs subnode
1006     * @param p_Resources The MessageResources for our localized messages
1007     *
1008     * @exception Exception if an exception occurs building the tree
1009     */

1010    public void getJmsConnectionFactories(TreeControlNode p_NodeParent
1011        , MessageResources p_Resources)
1012        throws Exception JavaDoc {
1013        // Get the 3 connection factories created by default:
1014
// - default ConnectionFactory , default Topic ConnectionFactory, default Queue ConnectionFactory,
1015
// This corresponds to the current implementation of the JMS service ..... ???
1016
int nbConnFacts = 3;
1017        String JavaDoc cfNames[] = new String JavaDoc[3];
1018        ObjectName JavaDoc jmsServMB = JonasObjectName.jmsService();
1019        cfNames[0] = (String JavaDoc) JonasManagementRepr.getAttribute(jmsServMB
1020            , "DefaultConnectionFactoryName");
1021        cfNames[1] = (String JavaDoc) JonasManagementRepr.getAttribute(jmsServMB
1022            , "DefaultTopicConnectionFactoryName");
1023        cfNames[2] = (String JavaDoc) 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    /**
1035     * Append subnodes node for Queue destinations
1036     *
1037     * @param p_NodeParent Queue subnode
1038     * @param p_Resources The MessageResources for our localized messages
1039     *
1040     * @exception Exception if an exception occurs building the tree
1041     */

1042    public void getJmsQueues(TreeControlNode p_NodeParent, MessageResources p_Resources)
1043        throws Exception JavaDoc {
1044        // Get queues list
1045
Iterator JavaDoc itNames = ((java.util.Set JavaDoc) JonasManagementRepr.getAttribute(JonasObjectName.
1046            jmsService(), "AllJmsQueueDestinationNames")).iterator();
1047        while (itNames.hasNext()) {
1048            String JavaDoc sNodeName = (String JavaDoc) itNames.next();
1049            String JavaDoc sQueueName = sNodeName;
1050            // Add node for each queue
1051
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    /**
1059     * Append subnodes node for Topic destinations
1060     *
1061     * @param p_NodeParent Topic subnode
1062     * @param p_Resources The MessageResources for our localized messages
1063     *
1064     * @exception Exception if an exception occurs building the tree
1065     */

1066    public void getJmsTopics(TreeControlNode p_NodeParent, MessageResources p_Resources)
1067        throws Exception JavaDoc {
1068        // Get topics list
1069
Iterator JavaDoc itNames = ((java.util.Set JavaDoc) JonasManagementRepr.getAttribute(JonasObjectName.
1070            jmsService(), "AllJmsTopicDestinationNames")).iterator();
1071        while (itNames.hasNext()) {
1072            String JavaDoc sNodeName = (String JavaDoc) itNames.next();
1073            String JavaDoc sTopicName = sNodeName;
1074            // Add node for each topic
1075
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    /**
1083     * Append node for Mail service for the JOnAS services.
1084     *
1085     * @param p_NodeServices Services node for the tree control
1086     * @param p_Resources The MessageResources for our localized messages
1087     * messages
1088     *
1089     * @exception Exception if an exception occurs building the tree
1090     */

1091    protected void getServiceMail(TreeControlNode p_NodeServices, MessageResources p_Resources
1092        , HttpServletRequest JavaDoc p_Request, String JavaDoc p_DomainName, String JavaDoc p_ServerName)
1093        throws Exception JavaDoc {
1094        // Add Service node
1095
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        // Add nodes for MailFactories
1101
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 JavaDoc p_Request)
1107        throws Exception JavaDoc {
1108        // Add parent node for all the Session Mail Factories
1109
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        // Add a node for each Session Mail Factory
1115
getSessionMailFactories(nodeSessionMailFactories, p_Resources, p_Request);
1116    }
1117
1118    public void getAllMimePartDSMailFactories(TreeControlNode p_NodeParent
1119        , MessageResources p_Resources, HttpServletRequest JavaDoc p_Request)
1120        throws Exception JavaDoc {
1121        // Add parent node for all the Session Mail Factories
1122
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        // Add a node for each Session Mail Factory
1128
getMimePartMailFactories(nodeMimePartMailFactories, p_Resources, p_Request);
1129    }
1130
1131    protected void getSessionMailFactories(TreeControlNode p_NodeParent
1132        , MessageResources p_Resources, HttpServletRequest JavaDoc p_Request)
1133        throws Exception JavaDoc {
1134        String JavaDoc sPath;
1135        String JavaDoc sFile;
1136        String JavaDoc sNodeName;
1137        ArrayList JavaDoc al = new ArrayList JavaDoc();
1138
1139        WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou.
1140            SESSION_NAME);
1141
1142        // Get List
1143
java.util.List JavaDoc deployedFactories = (java.util.List JavaDoc) JonasAdminJmx.
1144            getSessionMailFactoriesDeployed(oWhere);
1145        Iterator JavaDoc itNames = deployedFactories.iterator();
1146        //Iterator itNames = ((java.util.List) JonasAdminJmx.getSessionMailFactoriesDeployed(oWhere)).iterator();
1147
while (itNames.hasNext()) {
1148            al.add(itNames.next().toString());
1149        }
1150        // Sort list
1151
Collections.sort(al);
1152        // Build nodes
1153
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 JavaDoc p_Request)
1164        throws Exception JavaDoc {
1165        String JavaDoc sPath;
1166        String JavaDoc sFile;
1167        String JavaDoc sNodeName;
1168        ArrayList JavaDoc al = new ArrayList JavaDoc();
1169
1170        WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou.
1171            SESSION_NAME);
1172
1173        // Get List
1174
Iterator JavaDoc itNames = ((java.util.List JavaDoc) JonasAdminJmx.getMimeMailPartFactoriesDeployed(oWhere)).
1175            iterator();
1176        while (itNames.hasNext()) {
1177            al.add(itNames.next().toString());
1178        }
1179        // Sort list
1180
Collections.sort(al);
1181        // Build nodes
1182
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    /**
1192     * Append node for Resource service for the JOnAS services.
1193     *
1194     * @param p_NodeServices Services node for the tree control
1195     * @param p_Resources The MessageResources for our localized messages
1196     *
1197     * @exception Exception if an exception occurs building the tree
1198     */

1199    protected void getServiceResourceAdapter(TreeControlNode p_NodeServices
1200        , MessageResources p_Resources, String JavaDoc p_DomainName, String JavaDoc p_ServerName)
1201        throws Exception JavaDoc {
1202        // Add Service node
1203
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        // Add Containers nodes
1209
getResourceAdapters(nodeService, p_Resources, p_DomainName, p_ServerName);
1210    }
1211
1212    /**
1213     * Append node for all Resource Adapters.
1214     *
1215     * @param p_NodeParent Server node for the tree control
1216     * @param p_Resources The MessageResources for our localized messages
1217     * @param pDomainName The name of the current management domain
1218     * @param pServerName The name of the currently managed JOnAS server
1219     *
1220     * @exception Exception if an exception occurs building the tree
1221     */

1222    public void getResourceAdapters(TreeControlNode p_NodeParent, MessageResources p_Resources,
1223            String JavaDoc p_DomainName, String JavaDoc p_ServerName)
1224        throws Exception JavaDoc {
1225        String JavaDoc sPath;
1226        String JavaDoc sFile;
1227        String JavaDoc sNodeName;
1228        String JavaDoc sName;
1229        ObjectName JavaDoc on;
1230        ArrayList JavaDoc al = new ArrayList JavaDoc();
1231
1232        // Get Resource Adapters
1233
ObjectName JavaDoc ons = J2eeObjectName.getResourceAdapters(p_DomainName, p_ServerName);
1234        Iterator JavaDoc itNames = JonasManagementRepr.queryNames(ons).iterator();
1235        while (itNames.hasNext()) {
1236            ObjectName JavaDoc it_on = (ObjectName JavaDoc) itNames.next();
1237            sPath = (String JavaDoc) 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        // Sort list
1246
Collections.sort(al, new ResourceItemByFile());
1247        // Build nodes
1248
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/*
1256        // Get Container List
1257        ObjectName ons = J2eeObjectName.getResourceAdapterModules(p_DomainName, p_ServerName);
1258        Iterator itNames = JonasManagementRepr.queryNames(ons).iterator();
1259        while (itNames.hasNext()) {
1260            on = (ObjectName) itNames.next();
1261            al.add(on.getKeyProperty("name"));
1262        }
1263        // Sort list
1264        Collections.sort(al);
1265        // Build nodes
1266        for (int i = 0; i < al.size(); i++) {
1267            sName = al.get(i).toString();
1268            TreeControlNode node = new TreeControlNode(p_NodeParent.getName()
1269                + WhereAreYou.NODE_SEPARATOR + sName, "icon/resourceAdapter.gif"
1270                , JonasAdminJmx.extractFilename(sName)
1271                , "EditResourceAdapter.do?name=" + sName, "content", false);
1272            p_NodeParent.addChild(node);
1273        }
1274*/

1275    }
1276
1277    /**
1278     * Append node for Security service for the JOnAS services.
1279     *
1280     * @param p_NodeServices Services node for the tree control
1281     * @param p_Resources The MessageResources for our localized messages
1282     * messages
1283     *
1284     * @exception Exception if an exception occurs building the tree
1285     */

1286    protected void getServiceSecurity(TreeControlNode p_NodeServices, MessageResources p_Resources, String JavaDoc p_DomainName, String JavaDoc p_ServerName)
1287        throws Exception JavaDoc {
1288        // Add Service node
1289
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    /**
1297     * Append nodes for Deployments services for the specified server.
1298     *
1299     * @param p_ServerNode Server node for the tree control
1300     * @param p_Resources The MessageResources for our localized messages
1301     * @exception Exception if an exception occurs building the tree
1302     */

1303    protected void getDeployments(TreeControlNode p_ServerNode, MessageResources p_Resources)
1304        throws Exception JavaDoc {
1305        // Deployments node
1306
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        // Detail Service node
1312
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    /**
1327     * Append node for Ear deployment.
1328     *
1329     * @param p_NodeDeployments Deployment node for the tree control
1330     * @param p_Resources The MessageResources for our localized messages
1331     *
1332     * @exception Exception if an exception occurs building the tree
1333     */

1334    protected void getDeploymentEar(TreeControlNode p_NodeDeployments, MessageResources p_Resources)
1335        throws Exception JavaDoc {
1336        // Add node
1337
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    /**
1346     * Append node for Ejb deployment.
1347     *
1348     * @param p_NodeDeployments Deployment node for the tree control
1349     * @param p_Resources The MessageResources for our localized messages
1350     *
1351     * @exception Exception if an exception occurs building the tree
1352     */

1353    protected void getDeploymentEjb(TreeControlNode p_NodeDeployments, MessageResources p_Resources)
1354        throws Exception JavaDoc {
1355        // Add node
1356
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        // Add list files
1364
//getDeploymentJarFiles(oNode, p_Resources);
1365
}
1366
1367    /**
1368     * Append node for Ejb Files deployment.
1369     *
1370     * @param p_NodeParent Deployment node for the tree control
1371     * @param p_Resources The MessageResources for our localized messages
1372     *
1373     * @exception Exception if an exception occurs building the tree
1374     */

1375    protected void getDeploymentEjbFiles(TreeControlNode p_NodeParent, MessageResources p_Resources)
1376        throws Exception JavaDoc {
1377        String JavaDoc sFile;
1378        Iterator JavaDoc it = JonasAdminJmx.getJarFilesDeployable().iterator();
1379        while (it.hasNext()) {
1380            sFile = it.next().toString();
1381            // Add node
1382
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    /**
1391     * Append node for Web deployment.
1392     *
1393     * @param p_NodeDeployments Deployment node for the tree control
1394     * @param p_Resources The MessageResources for our localized messages
1395     *
1396     * @exception Exception if an exception occurs building the tree
1397     */

1398    protected void getDeploymentWebAppli(TreeControlNode p_NodeDeployments
1399        , MessageResources p_Resources)
1400        throws Exception JavaDoc {
1401        // Add node
1402
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    /**
1411     * Append node for Rar deployment.
1412     *
1413     * @param p_NodeDeployments Deployment node for the tree control
1414     * @param p_Resources The MessageResources for our localized messages
1415     *
1416     * @exception Exception if an exception occurs building the tree
1417     */

1418    protected void getDeploymentRar(TreeControlNode p_NodeDeployments, MessageResources p_Resources)
1419        throws Exception JavaDoc {
1420        // Add node
1421
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    /**
1430     * Append nodes for Resources services for the specified server.
1431     *
1432     * @param p_ServerNode Server node for the tree control
1433     * @param p_Resources The MessageResources for our localized messages
1434     * @exception Exception if an exception occurs building the tree
1435     */

1436    protected void getResources(TreeControlNode p_ServerNode, MessageResources p_Resources)
1437        throws Exception JavaDoc {
1438        // Resources node
1439
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        // Detail Service node
1445
// - database resources
1446
if (JonasAdminJmx.hasMBeanName(JonasObjectName.databaseService()) == true) {
1447            getResourceDatabase(nodeDeployments, p_Resources);
1448        }
1449        // - jms resources
1450
if (JonasAdminJmx.hasMBeanName(JonasObjectName.jmsService()) == true) {
1451            getJmsResource(nodeDeployments, p_Resources);
1452        }
1453        // - mail resources
1454
if (JonasAdminJmx.hasMBeanName(JonasObjectName.mailService()) == true) {
1455            getMailResource(nodeDeployments, p_Resources);
1456        }
1457    }
1458
1459    /**
1460     * Append nodes for Mail Resources for the specified server.
1461     *
1462     * @param p_ServerNode Server node for the tree control
1463     * @param p_Resources The MessageResources for our localized messages
1464     * @exception Exception if an exception occurs building the tree
1465     */

1466    protected void getMailResource(TreeControlNode p_ServerNode, MessageResources p_Resources)
1467        throws Exception JavaDoc {
1468        // Mail resources node
1469
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    /**
1477     * Append nodes for Jms Resource for the specified server.
1478     *
1479     * @param p_ServerNode Server node for the tree control
1480     * @param p_Resources The MessageResources for our localized messages
1481     * @exception Exception if an exception occurs building the tree
1482     */

1483    protected void getJmsResource(TreeControlNode p_ServerNode, MessageResources p_Resources)
1484        throws Exception JavaDoc {
1485        // Jms resources node
1486
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    /**
1494     * Append nodes for Database Resource for the specified server.
1495     *
1496     * @param p_ServerNode Server node for the tree control
1497     * @param p_Resources The MessageResources for our localized messages
1498     * @exception Exception if an exception occurs building the tree
1499     */

1500    protected void getResourceDatabase(TreeControlNode p_ServerNode, MessageResources p_Resources)
1501        throws Exception JavaDoc {
1502        // Database Resources node
1503
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    /**
1511     * Append nodes for Security for the specified server.
1512     *
1513     * @param p_ServerNode Server node for the tree control
1514     * @param p_Resources The MessageResources for our localized messages
1515     * @param p_Request The servlet request we are processing
1516     * @exception Exception if an exception occurs building the tree
1517     */

1518    protected void getSecurity(TreeControlNode p_ServerNode, MessageResources p_Resources
1519        , HttpServletRequest JavaDoc p_Request)
1520        throws Exception JavaDoc {
1521        // Detect JOnAS item presents
1522
boolean bJonasSecurityService = JonasAdminJmx.hasMBeanName(JonasObjectName.securityService());
1523        // Detect Catalina items present
1524
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        // Add nodes
1532
if ((bJonasSecurityService == true) || (bCatalinaRealm == true)) {
1533            // Active action
1534
String JavaDoc sAction = null;
1535            if (bJonasSecurityService == true) {
1536                sAction = "ListRealms.do?realm=all";
1537            }
1538            else if (bCatalinaRealm == true) {
1539                sAction = "EditSecurityCatalinaRealm.do";
1540            }
1541            // Security node
1542
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            // Detail Security node for JOnAS service
1547
if (bJonasSecurityService == true) {
1548                getSecurityFactories(nodeSecurity, p_Resources);
1549            }
1550        }
1551    }
1552
1553    /**
1554     * Append node for the Security catalina realm
1555     *
1556     * @param p_SecurityNode Catalina Server node for the tree control
1557     * @param p_Resources The MessageResources for our localized messages
1558     * @param p_Request The servlet request we are processing
1559     *
1560     * @exception Exception if an exception occurs building the tree
1561     */

1562    protected void getSecurityCatalinaRealm(TreeControlNode p_SecurityNode
1563        , MessageResources p_Resources, HttpServletRequest JavaDoc p_Request)
1564        throws Exception JavaDoc {
1565
1566        // Add node
1567
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    /**
1575     * Append nodes for Security factories for the specified server.
1576     *
1577     * @param p_SecurityNode Security node for the tree control
1578     * @param p_Resources The MessageResources for our localized messages
1579     * @exception Exception if an exception occurs building the tree
1580     */

1581    public void getSecurityFactories(TreeControlNode p_SecurityNode, MessageResources p_Resources)
1582        throws Exception JavaDoc {
1583        ArrayList JavaDoc al = null;
1584        String JavaDoc sName = null;
1585        TreeControlNode nodeSecurityFactories = null;
1586        TreeControlNode nodeSecurityFactory = null;
1587
1588        // Security Memory factories
1589
al = JonasAdminJmx.getSecurityMemoryFactories();
1590        if (al.size() > 0) {
1591            // Security factories node
1592
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            // List Security factories
1598
for (int i = 0; i < al.size(); i++) {
1599                sName = al.get(i).toString();
1600                // Security factory node
1601
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                // Add detail to memory security node
1606
//getSecurityMemoryFactory(nodeSecurityFactory, p_Resources, sName);
1607
}
1608        }
1609        // Security Datasource factories
1610
al = JonasAdminJmx.getSecurityDatasourceFactories();
1611        if (al.size() > 0) {
1612            // Security factories node
1613
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            // List Security factories
1619
for (int i = 0; i < al.size(); i++) {
1620                sName = al.get(i).toString();
1621                // Security factory node
1622
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        // Security Ldap factories
1629
al = JonasAdminJmx.getSecurityLdapFactories();
1630        if (al.size() > 0) {
1631            // Security factories node
1632
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            // List Security factories
1638
for (int i = 0; i < al.size(); i++) {
1639                sName = al.get(i).toString();
1640                // Security factory node
1641
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    /**
1650     * Append nodes for Memory Security Factory for the specified server.
1651     *
1652     * @param p_SecurityMemoryNode Server node for the tree control
1653     * @param p_Resources The MessageResources for our localized messages
1654     * @param p_ResourceFactory The name of resource
1655     * @exception Exception if an exception occurs building the tree
1656     */

1657    protected void getSecurityMemoryFactory(TreeControlNode p_SecurityMemoryNode
1658        , MessageResources p_Resources, String JavaDoc p_ResourceFactory)
1659        throws Exception JavaDoc {
1660        TreeControlNode node = null;
1661        // Users node
1662
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        // Groups node
1668
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        // Roles node
1674
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    /**
1682     * Append nodes for the Servlet server
1683     *
1684     * @param p_ServerNode Server node for the tree control
1685     * @param p_Resources The MessageResources for our localized messages
1686     * @param p_Request The servlet request we are processing
1687     *
1688     * @exception Exception if an exception occurs building the tree
1689     */

1690    protected void getProtocols(TreeControlNode p_ServerNode, MessageResources p_Resources
1691        , HttpServletRequest JavaDoc p_Request)
1692        throws Exception JavaDoc {
1693        // Catalina server
1694
if (JonasAdminJmx.hasMBeanName(CatalinaObjectName.catalinaServer()) == true) {
1695            getCatalinaProtocols(p_ServerNode, p_Resources, p_Request);
1696        }
1697    }
1698
1699    /**
1700     * Append nodes for the Catalina server
1701     *
1702     * @param p_ServerNode Server node for the tree control
1703     * @param p_Resources The MessageResources for our localized messages
1704     * @param p_Request The servlet request we are processing
1705     *
1706     * @exception Exception if an exception occurs building the tree
1707     */

1708    protected void getCatalinaProtocols(TreeControlNode p_ServerNode, MessageResources p_Resources
1709        , HttpServletRequest JavaDoc p_Request)
1710        throws Exception JavaDoc {
1711        // Add Catalina server node
1712
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        // Add Connectors nodes
1718
getCatalinaConnector(catalinaNode, p_Resources, p_Request);
1719    }
1720
1721    /**
1722     * Append node for the Connector catalina server
1723     *
1724     * @param p_CatalinaServerNode Catalina Server node for the tree control
1725     * @param p_Resources The MessageResources for our localized messages
1726     * @param p_Request The servlet request we are processing
1727     *
1728     * @exception Exception if an exception occurs building the tree
1729     */

1730    protected void getCatalinaConnector(TreeControlNode p_CatalinaServerNode
1731        , MessageResources p_Resources, HttpServletRequest JavaDoc p_Request)
1732        throws Exception JavaDoc {
1733
1734        // Add Connector node
1735
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    /**
1746     * Append nodes for all the Connectors catalina server
1747     *
1748     * @param p_ConnectorNode Connector node for the tree control
1749     * @param p_Resources The MessageResources for our localized messages
1750     * @param p_Request The servlet request we are processing
1751     *
1752     * @exception Exception if an exception occurs building the tree
1753     */

1754    public void getCatalinaDetailConnectors(TreeControlNode p_ConnectorNode
1755        , MessageResources p_Resources, HttpServletRequest JavaDoc p_Request)
1756        throws Exception JavaDoc {
1757
1758        // Get WhereAreYou
1759
WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou.
1760            SESSION_NAME);
1761
1762        // Get the domain name
1763
String JavaDoc sDomain = oWhere.getCurrentCatalinaDomainName();
1764        // Get the list of connectors
1765
ArrayList JavaDoc al = new ArrayList JavaDoc();
1766        Iterator JavaDoc it = JonasAdminJmx.getListMBeanName(CatalinaObjectName.catalinaConnectors(sDomain)).
1767            iterator();
1768        while (it.hasNext()) {
1769            al.add(new ConnectorItem(new ObjectName JavaDoc(it.next().toString())
1770                , oWhere.getApplicationServerPort()));
1771        }
1772        // Sort
1773
Collections.sort(al, new ConnectorItemByPort());
1774        // Build the nodes
1775
TreeControlNode node;
1776        ConnectorItem oConnector;
1777        String JavaDoc 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    /**
1789     * Append nodes for a defined JORAM platform.
1790     *
1791     * @param pDomainNode Domain node for the tree control
1792     * @param pResources The MessageResources for our localized messages
1793     *
1794     * @exception Exception If an exception occurs when building the tree.
1795     */

1796    public void getJoramPlatform(TreeControlNode pDomainNode,
1797                                    MessageResources pResources, HttpServletRequest JavaDoc p_Request)
1798        throws Exception JavaDoc {
1799
1800        ObjectName JavaDoc joramPlatformON = JoramObjectName.joramPlatform();
1801        if (!JonasAdminJmx.hasMBeanName(joramPlatformON)) {
1802            return;
1803        }
1804
1805        // Joram platform present, create node for it
1806
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        // Create node for the local server (Joram server to which the admin client is connected)
1817
pDomainNode.addChild(platformNode);
1818
1819        getJoramResources(platformNode, joramPlatformON, pResources, p_Request);
1820    }
1821
1822    public void getJoramResources(TreeControlNode platformNode, ObjectName JavaDoc joramPlatformON,
1823            MessageResources pResources, HttpServletRequest JavaDoc p_Request) throws Exception JavaDoc {
1824
1825        if (joramPlatformON == null) {
1826            joramPlatformON = JoramObjectName.joramPlatform();
1827        }
1828        Integer JavaDoc localServerId = (Integer JavaDoc) JonasManagementRepr.getAttribute(joramPlatformON, "LocalServerId");
1829        String JavaDoc 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        // Get all the destinations
1844
ObjectName JavaDoc joramAdminON = JoramObjectName.joramAdmin();
1845        List JavaDoc globalDestList = (List JavaDoc) JonasManagementRepr.getAttribute(joramAdminON, "Destinations");
1846        // Create a map with one entry per server, each entry points to an
1847
// ArrayList of ItemDestination objects
1848
HashMap JavaDoc map = null;
1849        if (globalDestList != null && !globalDestList.isEmpty()) {
1850            map = new HashMap JavaDoc();
1851            Iterator JavaDoc it = globalDestList.iterator();
1852            while (it.hasNext()) {
1853                ItemDestination destinationItem = getDestinationItem((String JavaDoc) it.next());
1854                String JavaDoc serverId = destinationItem.getServerId();
1855                if (!map.containsKey(serverId)) {
1856                    ArrayList JavaDoc destList = new ArrayList JavaDoc();
1857                    map.put(serverId, destList);
1858                }
1859                if (destinationItem.getType().equals("queue")) {
1860                    // insert in head
1861
((ArrayList JavaDoc) map.get(serverId)).add(0, destinationItem);
1862                } else if (destinationItem.getType().equals("topic")) {
1863                    // append
1864
((ArrayList JavaDoc) map.get(serverId)).add(destinationItem);
1865                }
1866            }
1867        }
1868
1869        // Add sub-nodes for destinations belonging to the current server
1870
ArrayList JavaDoc localDestList = (ArrayList JavaDoc) 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 JavaDoc name = item.getName();
1877            String JavaDoc 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        // If Joram is disributed, create nodes for the 'remote' servers
1904
List JavaDoc list = (List JavaDoc) JonasManagementRepr.getAttribute(joramPlatformON, "ServersIds");
1905        if (list != null) {
1906            Iterator JavaDoc it = list.iterator();
1907            Integer JavaDoc serverId;
1908            String JavaDoc id;
1909            TreeControlNode remoteServerNode;
1910            while (it.hasNext()) {
1911                serverId = (Integer JavaDoc) it.next();
1912                id = serverId.toString();
1913                String JavaDoc 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                    // Add sub-nodes for destinations belonging to the remote server
1927
ArrayList JavaDoc remoteDestList = (ArrayList JavaDoc) 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 JavaDoc name = item.getName();
1937                        String JavaDoc 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    /**
1967     * Append nodes for all defined MBeans.
1968     *
1969     * @param rootNode Root node for the tree control
1970     * @param resources The MessageResources for our localized messages
1971     *
1972     * @exception Exception if an exception occurs building the tree
1973     */

1974    public void getMBeans(TreeControlNode domainNode, MessageResources resources)
1975        throws Exception JavaDoc {
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 JavaDoc[] 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    /**
1998     * Append nodes for all defined Owner MBeans.
1999     *
2000     * @param p_ParentNode Parent node for the tree control
2001     * @param p_Resources The MessageResources for our localized messages
2002     * @param p_List The list of Mbeans
2003     *
2004     * @exception Exception if an exception occurs building the tree
2005     */

2006    public void getOwnerMBeans(TreeControlNode p_ParentNode, MessageResources p_Resources
2007        , ArrayList JavaDoc p_List)
2008        throws Exception JavaDoc {
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        // Sort list
2018
Collections.sort(p_List, new BeanComparator(new String JavaDoc[] {
2019            "domain", "type", "objectName"}));
2020
2021        // Detail MBean node
2022
String JavaDoc sLastDomain = "";
2023        String JavaDoc sLastType = "";
2024        TreeControlNode nodeMBean = null;
2025        TreeControlNode nodeDomain = null;
2026        TreeControlNode nodeType = null;
2027        TreeControlNode nodeParent = null;
2028        OwnerMbeanItem oItem;
2029
2030        Iterator JavaDoc it = p_List.iterator();
2031        while (it.hasNext()) {
2032            oItem = (OwnerMbeanItem) it.next();
2033
2034            nodeParent = nodeMBeans;
2035            if (oItem.getDomain() != null) {
2036                // Domain node
2037
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                    // Type node
2048
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            // Mbean node
2060
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    /**
2073     * Append nodes for all defined J2EE MBeans.
2074     *
2075     * @param p_ParentNode Parent node for the tree control
2076     * @param p_Resources The MessageResources for our localized messages
2077     * @param p_List The list of Mbeans
2078     *
2079     * @exception Exception if an exception occurs building the tree
2080     */

2081    public void getJ2eeMBeans(TreeControlNode p_ParentNode, MessageResources p_Resources
2082        , ArrayList JavaDoc p_List)
2083        throws Exception JavaDoc {
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        // Sort list
2093
Collections.sort(p_List, new BeanComparator(new String JavaDoc[] {
2094            "domain", "j2eeType", "name", "objectName"}));
2095
2096        // Detail MBean node
2097
J2eeMbeanItem oItem;
2098        String JavaDoc sLastDomain = "";
2099        String JavaDoc sLastType = "";
2100        TreeControlNode nodeMBean = null;
2101        TreeControlNode nodeDomain = null;
2102        TreeControlNode nodeType = null;
2103        TreeControlNode nodeParent = null;
2104
2105        Iterator JavaDoc it = p_List.iterator();
2106        while (it.hasNext()) {
2107            oItem = (J2eeMbeanItem) it.next();
2108
2109            nodeParent = nodeMBeans;
2110            if (oItem.getDomain() != null) {
2111                // Domain node
2112
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                // Type node
2123
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            // Mbean node
2134
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    /**
2147     * Append nodes for all defined Unknown MBeans.
2148     *
2149     * @param p_ParentNode Parent node for the tree control
2150     * @param p_Resources The MessageResources for our localized messages
2151     * @param p_List The list of Mbeans
2152     *
2153     * @exception Exception if an exception occurs building the tree
2154     */

2155    public void getUnknownMBeans(TreeControlNode p_ParentNode, MessageResources p_Resources
2156        , ArrayList JavaDoc p_List)
2157        throws Exception JavaDoc {
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        // Sort list
2167
Collections.sort(p_List, new BeanComparator(new String JavaDoc[] {
2168            "domain", "objectName"}));
2169
2170        // Detail MBean node
2171
MbeanItem oItem;
2172        String JavaDoc sLastDomain = "";
2173        TreeControlNode nodeMBean = null;
2174        TreeControlNode nodeDomain = null;
2175        TreeControlNode nodeType = null;
2176        TreeControlNode nodeParent = null;
2177
2178        Iterator JavaDoc it = p_List.iterator();
2179        while (it.hasNext()) {
2180            oItem = (MbeanItem) it.next();
2181
2182            nodeParent = nodeMBeans;
2183            if (oItem.getDomain() != null) {
2184                // Domain node
2185
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            // Mbean node
2197
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    /**
2210     * Append nodes Attributes and Operations for a defined MBean.
2211     *
2212     * @param nodeMBean The MBean node
2213     * @param onMBean The MBean Object name
2214     * @param resources Resource
2215     * @throws Exception
2216     */

2217    protected void getMBeanInfo(TreeControlNode nodeMBean, ObjectName JavaDoc onMBean
2218        , MessageResources resources)
2219        throws Exception JavaDoc {
2220        // Get all infos of a MBean
2221
MBeanInfo JavaDoc oMBeanInfo = JonasManagementRepr.getMBeanInfo(onMBean);
2222        // Get attributes infos
2223
MBeanAttributeInfo JavaDoc[] aoMBeanAttributeInfo = oMBeanInfo.getAttributes();
2224        if (aoMBeanAttributeInfo.length > 0) {
2225            // Append attributes node
2226
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            // Loop to append each attribute node
2231
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        // Get operations infos
2240
MBeanOperationInfo JavaDoc[] aoMBeanOperationInfo = oMBeanInfo.getOperations();
2241        if (aoMBeanOperationInfo.length > 0) {
2242            // Append operations node
2243
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            // Loop to append each operation node
2248
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    /**
2259     * Create a ItemDestination object from a String structured as follows:
2260     * type=queue/topic, name=destName, id=#x.y.z
2261     * @param joramAdminDestination String containing destination description
2262     * @return ItemDestination containing name, type, id and ObjectName of the MBean associated to the corresponding destination
2263     * @throws MalformedObjectNameException
2264     */

2265    public ItemDestination getDestinationItem(String JavaDoc joramAdminDestination) throws MalformedObjectNameException JavaDoc {
2266        ItemDestination destinationItem = new ItemDestination();
2267        ObjectName JavaDoc destinationON = null;
2268        StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(joramAdminDestination, ",");
2269        String JavaDoc type = null;
2270        String JavaDoc name = null;
2271        String JavaDoc id = null;
2272        String JavaDoc serverId = null;
2273        while (st.hasMoreTokens()) {
2274            // A couple has the following structure: key=value
2275
String JavaDoc couple = st.nextToken().trim();
2276            int index = couple.indexOf("=");
2277            String JavaDoc key = couple.substring(0, index);
2278            String JavaDoc 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