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(