KickJava   Java API By Example, From Geeks To Geeks.

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


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: JonasAdminJmx.java,v 1.38 2005/04/19 13:01:41 danesa Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin;
27
28 import java.io.File JavaDoc;
29 import java.util.ArrayList JavaDoc;
30 import java.util.Collections JavaDoc;
31 import java.util.Iterator JavaDoc;
32 import java.util.List JavaDoc;
33 import java.util.Set JavaDoc;
34
35 import javax.management.MalformedObjectNameException JavaDoc;
36 import javax.management.ObjectName JavaDoc;
37 import javax.naming.Context JavaDoc;
38 import javax.naming.NameClassPair JavaDoc;
39 import javax.naming.NamingEnumeration JavaDoc;
40 import javax.naming.NamingException JavaDoc;
41 import javax.servlet.http.HttpServletRequest JavaDoc;
42
43 import org.apache.struts.util.MessageResources;
44 import org.objectweb.jonas.jmx.J2eeObjectName;
45 import org.objectweb.jonas.jmx.JonasManagementRepr;
46 import org.objectweb.jonas.jmx.JonasObjectName;
47 import org.objectweb.jonas.jmx.ManagementException;
48 import org.objectweb.jonas.mail.MailServiceImpl;
49 import org.objectweb.jonas.jmx.CatalinaObjectName;
50 import org.objectweb.jonas.webapp.jonasadmin.common.BeanComparator;
51 import org.objectweb.jonas.webapp.jonasadmin.logging.LoggerItem;
52 import org.objectweb.jonas.webapp.jonasadmin.mbean.MbeanItem;
53 import org.objectweb.jonas.webapp.jonasadmin.service.container.WebAppItem;
54
55 /**
56  * Helper class supporting manipulation of MBeans (accessing MBeans).
57  * @author Michel-Ange ANTON<p>
58  * Contributors: Adriana Danes
59  */

60 public class JonasAdminJmx {
61
62 // ----------------------------------------------------------- Constants
63

64     private static Object JavaDoc s_Synchro = new Object JavaDoc();
65
66 // ----------------------------------------------------------- Constructors
67

68     /**
69      * Protected constructor to prevent instantiation.
70      */

71     protected JonasAdminJmx() {
72     }
73
74 // --------------------------------------------------------- Public Methods
75

76     /**
77      * Replace any occurrence of the specified placeholder in the specified
78      * template string with the specified replacement value.
79      *
80      * @param template Pattern string possibly containing the placeholder
81      * @param placeholder Placeholder expression to be replaced
82      * @param value Replacement value for the placeholder
83      * @return A complete string
84      */

85     public static String JavaDoc replace(String JavaDoc template, String JavaDoc placeholder, String JavaDoc value) {
86         if (template == null) {
87             return (null);
88         }
89         if ((placeholder == null) || (value == null)) {
90             return (template);
91         }
92         String JavaDoc sRet = new String JavaDoc(template);
93         while (true) {
94             int index = sRet.indexOf(placeholder);
95             if (index < 0) {
96                 break;
97             }
98             StringBuffer JavaDoc temp = new StringBuffer JavaDoc(sRet.substring(0, index));
99             temp.append(value);
100             temp.append(sRet.substring(index + placeholder.length()));
101             sRet = temp.toString();
102         }
103         return (sRet);
104
105     }
106
107     /**
108      * Return the ObjectName corresponding to the J2EEDomain managed object registered in the
109      * current MBeanServer. Normally, we should have only one.
110      * @return an ObjectName which corresponds to the first J2EEDomain ObjectName pattern
111      */

112     public static ObjectName JavaDoc getJ2eeDomainObjectName() {
113         // Lookup for the first J2EEDomain managed object in the current MBeanServer
114
ObjectName JavaDoc onDomains = J2eeObjectName.J2EEDomains();
115         return getFirstMbean(onDomains);
116     }
117
118     /**
119      * Return the ObjectName corresponding to the J2EEServer managed object registered in the
120      * current MBeanServer and belonging to a domain.
121      * We should have one ObjectName corresponding to the current JOnAS server instance.
122      * @param p_DomainName The name of the management domain.
123      * @return an ObjectName which corresponds to a J2EEServer ObjectName pattern
124      * (having <code>j2eeType</code> key property equal to <code>J2EEServer</code>)
125      */

126     public static ObjectName JavaDoc getJ2eeServerObjectName(String JavaDoc p_DomainName) {
127         // Lookup for a J2EEServer managed object in the current MBeanServer
128
ObjectName JavaDoc pattern_server_on = J2eeObjectName.J2EEServers(p_DomainName);
129         ObjectName JavaDoc server_on = null;
130         Iterator JavaDoc it = JonasManagementRepr.queryNames(pattern_server_on).iterator();
131         if (it.hasNext()) {
132             // Got one J2EEServer managed object ; normally should not be more than one
133
server_on = (ObjectName JavaDoc) it.next();
134         }
135         return server_on;
136     }
137
138     /**
139      * Return the ObjectName corresponding to the J2EEServer managed object registered in the
140      * current MBeanServer. This method is used by EditTopAction to determine the list of
141      * JOnAS servers registered in the current registry (this code is particular to the current
142      * domain concept implementation).
143      * We should have one ObjectName corresponding to the current JOnAS server instance.
144      * @return an ObjectName which corresponds to a J2EEServer ObjectName pattern
145      * (having <code>j2eeType</code> key property equal to <code>J2EEServer</code>)
146      */

147     public static ObjectName JavaDoc getJ2eeServerObjectName() {
148         // Lookup for a J2EEServer managed object in the current MBeanServer
149
ObjectName JavaDoc pattern_server_on = J2eeObjectName.J2EEServers();
150         ObjectName JavaDoc server_on = null;
151         Iterator JavaDoc it = JonasManagementRepr.queryNames(pattern_server_on).iterator();
152         if (it.hasNext()) {
153             // Got one J2EEServer managed object ; normally should not be more than one
154
server_on = (ObjectName JavaDoc) it.next();
155         }
156         return server_on;
157     }
158
159     /**
160      * Return a list of JonasServerItem connected to the same registry.
161      *
162      * @param p_Request The http request
163      * @return List of JonasServerItem
164      * @throws Exception
165      */

166     public static ArrayList JavaDoc getListRemoteJonasServerItem(HttpServletRequest JavaDoc p_Request)
167         throws Exception JavaDoc {
168         synchronized (s_Synchro) {
169             ArrayList JavaDoc oServers = new ArrayList JavaDoc();
170             // Save current RmiConnector
171
String JavaDoc sCurrentRMIConnectorName = JonasManagementRepr.getCurrentRMIConnectorName();
172
173             // Find all RmiConnectors
174
Set JavaDoc setRmiConnector = JonasManagementRepr.getRMIConnectorsNames();
175             if (setRmiConnector.size() > 0) {
176                 Iterator JavaDoc oIt = setRmiConnector.iterator();
177                 while (oIt.hasNext()) {
178                     JonasServerItem oItem = new JonasServerItem();
179                     oItem.setNameRmiConnector(oIt.next().toString());
180                     // Find Jonas server name
181
JonasManagementRepr.setCurrentRMIConnectorName(oItem.getNameRmiConnector());
182                     // Get J2EEServer object
183
ObjectName JavaDoc server_on = getJ2eeServerObjectName();
184                     if (server_on != null) {
185                         String JavaDoc serverName = server_on.getKeyProperty("name");
186                         oItem.setNameServer(serverName);
187                         oServers.add(oItem);
188                     }
189                 }
190                 try {
191                     // Restore current RmiConnector
192
JonasManagementRepr.setCurrentRMIConnectorName(sCurrentRMIConnectorName);
193                 }
194                 catch (Exception JavaDoc e) {
195                     // May be the current server is shutdown
196
if (oServers.size() > 0) {
197                         JonasServerItem oItem = (JonasServerItem) oServers.get(0);
198                         JonasManagementRepr.setCurrentRMIConnectorName(oItem.getNameRmiConnector());
199                     }
200                 }
201             }
202             return oServers;
203         }
204     }
205
206     /**
207      * Verify if the Mbean gotten by the query in the current MbeanServer exists.
208      *
209      * @param p_On Query Mbean name to search
210      * @return true if MBean exists
211      * @throws ManagementException
212      */

213     public static boolean hasMBeanName(ObjectName JavaDoc p_On)
214         throws ManagementException {
215         synchronized (s_Synchro) {
216             ArrayList JavaDoc al = new ArrayList JavaDoc();
217             Iterator JavaDoc itNames = JonasManagementRepr.queryNames(p_On).iterator();
218             if (itNames.hasNext()) {
219                 return true;
220             }
221             return false;
222         }
223     }
224
225     /**
226      * Return the first Mbean name gotten by the query in the current MbeanServer.
227      *
228      * @param p_On Query Mbean name to search
229      * @return The first MBean name or null if not found
230      * @throws ManagementException
231      */

232     public static String JavaDoc getFirstMBeanName(ObjectName JavaDoc p_On)
233         throws ManagementException {
234         synchronized (s_Synchro) {
235             ArrayList JavaDoc al = new ArrayList JavaDoc();
236             Iterator JavaDoc itNames = JonasManagementRepr.queryNames(p_On).iterator();
237             if (itNames.hasNext()) {
238                 return itNames.next().toString();
239             }
240             return null;
241         }
242     }
243
244     /**
245      * Return the list of Mbean name gotten by the query in the current MbeanServer.
246      *
247      * @param p_On Query Mbean name to search
248      * @return A list of string Mbean name
249      * @throws ManagementException
250      */

251     public static List JavaDoc getListMBeanName(ObjectName JavaDoc p_On)
252         throws ManagementException {
253         synchronized (s_Synchro) {
254             ArrayList JavaDoc al = new ArrayList JavaDoc();
255             Iterator JavaDoc itNames = JonasManagementRepr.queryNames(p_On).iterator();
256             while (itNames.hasNext()) {
257                 ObjectName JavaDoc item = (ObjectName JavaDoc) itNames.next();
258                 al.add(item.toString());
259             }
260             Collections.sort(al);
261             return al;
262         }
263     }
264
265     /**
266      * Return the first <code>ObjectName</code> Mbean gotten by the query
267      * in the current MbeanServer.
268      *
269      * @param p_On Query Mbean name to search
270      * @return The first <code>ObjectName</code> or null if not found
271      * @throws ManagementException
272      */

273     public static ObjectName JavaDoc getFirstMbean(ObjectName JavaDoc p_On)
274         throws ManagementException {
275         synchronized (s_Synchro) {
276             ArrayList JavaDoc al = new ArrayList JavaDoc();
277             Iterator JavaDoc itNames = JonasManagementRepr.queryNames(p_On).iterator();
278             if (itNames.hasNext()) {
279                 return (ObjectName JavaDoc) itNames.next();
280             }
281             return null;
282         }
283     }
284
285     /**
286      * Return the list of <code>ObjectName</code> Mbean gotten by the query
287      * in the current MbeanServer.
288      *
289      * @param p_On Query Mbeans to search
290      * @return The list of <code>ObjectName</code>
291      * @throws ManagementException
292      */

293     public static List JavaDoc getListMbean(ObjectName JavaDoc p_On)
294         throws ManagementException {
295         synchronized (s_Synchro) {
296             ArrayList JavaDoc al = new ArrayList JavaDoc();
297             Iterator JavaDoc itNames = JonasManagementRepr.queryNames(p_On).iterator();
298             while (itNames.hasNext()) {
299                 al.add(itNames.next());
300             }
301             return al;
302         }
303     }
304
305     /**
306      * Extract the value of a key property from the MBean name.
307      * This method is usefull when we have the String form and not the ObjectName
308      * (avoid creating an ObjectName instance).
309      * @param pName Name of the key property
310      * @param pMBeanName Stringified ObjectName
311      * @return The value or null if not found
312      */

313     public static String JavaDoc extractValueMbeanName(String JavaDoc pName, String JavaDoc pMBeanName) {
314         String JavaDoc sValue = null;
315         try {
316             String JavaDoc sSearch = pName.trim() + "=";
317             int iPos = pMBeanName.indexOf(sSearch);
318             if (iPos > -1) {
319                 sValue = pMBeanName.substring(iPos + sSearch.length());
320                 iPos = sValue.indexOf(",");
321                 if (iPos > -1) {
322                     sValue = sValue.substring(0, iPos);
323                 }
324             }
325         } catch (NullPointerException JavaDoc e) {
326             // none
327
sValue = null;
328         }
329         return sValue;
330     }
331
332     /**
333      * Extract the filename of complete path.
334      *
335      * @param p_Path Complete path (directory and filename)
336      * @return The filename or null
337      */

338     public static String JavaDoc extractFilename(String JavaDoc p_Path) {
339         String JavaDoc sFilename = null;
340         try {
341             int iPosSeparator = p_Path.lastIndexOf("/");
342             if (iPosSeparator < 0) {
343                 iPosSeparator = p_Path.lastIndexOf("\\");
344                 if (iPosSeparator < 0) {
345                     sFilename = new String JavaDoc(p_Path);
346                 }
347                 else {
348                     sFilename = p_Path.substring(iPosSeparator + 1);
349                 }
350             }
351             else {
352                 sFilename = p_Path.substring(iPosSeparator + 1);
353             }
354             if (sFilename.length() > 0) {
355                 int iPos_1 = p_Path.indexOf(DIR_AUTOLOAD + "/" + sFilename);
356                 int iPos_2 = p_Path.indexOf(DIR_AUTOLOAD + "\\" + sFilename);
357                 if (iPos_1 > -1) {
358                     sFilename = DIR_AUTOLOAD + "/" + sFilename;
359                 }
360                 else if (iPos_2 > -1) {
361                     sFilename = DIR_AUTOLOAD + "\\" + sFilename;
362                 }
363             }
364             else {
365                 sFilename = null;
366             }
367         }
368         catch (NullPointerException JavaDoc e) {
369             // none action
370
sFilename = null;
371         }
372         return sFilename;
373     }
374
375     /**
376      *
377      */

378     private static String JavaDoc DIR_RARS = "rars";
379     private static String JavaDoc DIR_AUTOLOAD = "autoload";
380     private static String JavaDoc DIR_CONF = "conf";
381
382     private static ArrayList JavaDoc getFilenames(String JavaDoc p_Directory, String JavaDoc p_Extension) {
383         ArrayList JavaDoc al = new ArrayList JavaDoc();
384         String JavaDoc sExt = "." + p_Extension.toLowerCase();
385         String JavaDoc sFile;
386
387         File JavaDoc oFile = new File JavaDoc(p_Directory);
388         String JavaDoc[] asFiles = oFile.list();
389         int iPos;
390         if (asFiles != null) {
391             for (int i = 0; i < asFiles.length; i++) {
392                 oFile = new File JavaDoc(p_Directory, asFiles[i]);
393                 if (oFile.isFile() == true) {
394                     sFile = oFile.getName().toLowerCase();
395                     iPos = sFile.lastIndexOf(sExt);
396                     if (iPos > -1) {
397                         if (iPos == (sFile.length() - sExt.length())) {
398                             al.add(oFile.getName());
399                         }
400                     }
401                 }
402             }
403         }
404         Collections.sort(al);
405         return al;
406     }
407
408     private static ArrayList JavaDoc getDirectories(String JavaDoc p_Directory) {
409         ArrayList JavaDoc al = new ArrayList JavaDoc();
410         String JavaDoc sFile;
411
412         File JavaDoc oFile = new File JavaDoc(p_Directory);
413         String JavaDoc[] asFiles = oFile.list();
414
415         if (asFiles != null) {
416             for (int i = 0; i < asFiles.length; i++) {
417                 oFile = new File JavaDoc(p_Directory, asFiles[i]);
418                 if (oFile.isDirectory() == true) {
419                     al.add(oFile.getName());
420                 }
421             }
422         }
423         Collections.sort(al);
424         return al;
425     }
426
427     private static void appendDirectory(ArrayList JavaDoc p_List, String JavaDoc p_Dir) {
428         String JavaDoc sDir = p_Dir + "/";
429         for (int i = 0; i < p_List.size(); i++) {
430             p_List.set(i, sDir + p_List.get(i));
431         }
432     }
433
434     /**
435      * Return the list of JAR filename ready to deploy in the current server.
436      *
437      * @return The list of JAR filename.
438      * @throws ManagementException
439      */

440     public static ArrayList JavaDoc getJarFilesDeployable()
441         throws ManagementException {
442         ObjectName JavaDoc on = JonasObjectName.ejbService();
443         ArrayList JavaDoc al = (ArrayList JavaDoc) JonasManagementRepr.getAttribute(on, "DeployableJars");
444         String JavaDoc sDir = (String JavaDoc) JonasManagementRepr.getAttribute(on, "EjbjarsDirectory");
445
446         String JavaDoc sEarDir = null;
447         try {
448             on = JonasObjectName.earService();
449             sEarDir = (String JavaDoc) JonasManagementRepr.getAttribute(on, "AppsDirectory");
450         }
451         catch (Exception JavaDoc e) {
452             // nothing, Ear service not found
453
}
454         return prepareContainersToDisplay(al, sDir, sEarDir);
455     }
456
457     /**
458      * Return the list of RAR filename ready to deploy in the current server.
459      *
460      * @return The list of RAR filename.
461      * @throws ManagementException
462      */

463     public static ArrayList JavaDoc getRarFilesDeployable()
464         throws ManagementException {
465         ObjectName JavaDoc on = JonasObjectName.resourceService();
466         ArrayList JavaDoc al = (ArrayList JavaDoc) JonasManagementRepr.getAttribute(on, "DeployableRars");
467         String JavaDoc sDir = (String JavaDoc) JonasManagementRepr.getAttribute(on, "RarsDirectory");
468
469         String JavaDoc sEarDir = null;
470         try {
471             on = JonasObjectName.earService();
472             sEarDir = (String JavaDoc) JonasManagementRepr.getAttribute(on, "AppsDirectory");
473         }
474         catch (Exception JavaDoc e) {
475             // nothing, Ear service not found
476
}
477         return prepareContainersToDisplay(al, sDir, sEarDir);
478     }
479
480     /**
481      * Return the list of EAR filename ready to deploy in the current server.
482      *
483      * @return The list of EAR filename.
484      * @throws ManagementException
485      */

486     public static ArrayList JavaDoc getEarFilesDeployable()
487         throws ManagementException {
488         ObjectName JavaDoc on = JonasObjectName.earService();
489         ArrayList JavaDoc al = (ArrayList JavaDoc) JonasManagementRepr.getAttribute(on, "DeployableEars");
490         String JavaDoc sDir = (String JavaDoc) JonasManagementRepr.getAttribute(on, "AppsDirectory");
491         return prepareContainersToDisplay(al, sDir, null);
492     }
493
494     /**
495      * Return the list of WAR filename ready to deploy in the current server.
496      *
497      * @return The list of WAR filename.
498      * @throws ManagementException
499      */

500     public static ArrayList JavaDoc getWarFilesDeployable()
501         throws ManagementException {
502         ObjectName JavaDoc on = JonasObjectName.webContainerService();
503         ArrayList JavaDoc al = (ArrayList JavaDoc) JonasManagementRepr.getAttribute(on, "DeployableWars");
504         String JavaDoc sDir = (String JavaDoc) JonasManagementRepr.getAttribute(on, "WebappsDirectory");
505
506         String JavaDoc sEarDir = null;
507         try {
508             on = JonasObjectName.earService();
509             sEarDir = (String JavaDoc) JonasManagementRepr.getAttribute(on, "AppsDirectory");
510         }
511         catch (Exception JavaDoc e) {
512             // nothing, Ear service not found
513
}
514         return prepareContainersToDisplay(al, sDir, sEarDir);
515     }
516
517     /**
518      * Return the list of deployed JAR filename in the current server.
519      *
520      * @return The list of JAR filename.
521      * @throws ManagementException
522      */

523     public static ArrayList JavaDoc getJarFilesDeployed()
524         throws ManagementException {
525         ObjectName JavaDoc on = JonasObjectName.ejbService();
526         ArrayList JavaDoc al = (ArrayList JavaDoc) JonasManagementRepr.getAttribute(on, "DeployedJars");
527         String JavaDoc sDir = (String JavaDoc) JonasManagementRepr.getAttribute(on, "EjbjarsDirectory");
528
529         String JavaDoc sEarDir = null;
530         try {
531             on = JonasObjectName.earService();
532             sEarDir = (String JavaDoc) JonasManagementRepr.getAttribute(on, "AppsDirectory");
533         }
534         catch (Exception JavaDoc e) {
535             // nothing, Ear service not found
536
}
537         return prepareContainersToDisplay(al, sDir, sEarDir);
538     }
539
540     /**
541      * Return the list of deployed EAR filename in the current server.
542      *
543      * @return The list of EAR filename.
544      * @throws ManagementException
545      */

546     public static ArrayList JavaDoc getEarFilesDeployed()
547         throws ManagementException {
548         ObjectName JavaDoc on = JonasObjectName.earService();
549         ArrayList JavaDoc al = (ArrayList JavaDoc) JonasManagementRepr.getAttribute(on, "DeployedEars");
550         String JavaDoc sDir = (String JavaDoc) JonasManagementRepr.getAttribute(on, "AppsDirectory");
551         return prepareContainersToDisplay(al, sDir, null);
552     }
553
554     /**
555      * Return the list of deployed RAR filename in the current server.
556      *
557      * @return The list of RAR filename.
558      * @throws ManagementException
559      */

560     public static ArrayList JavaDoc getRarFilesDeployed()
561         throws ManagementException {
562         ObjectName JavaDoc on = JonasObjectName.resourceService();
563         ArrayList JavaDoc al = (ArrayList JavaDoc) JonasManagementRepr.getAttribute(on, "DeployedRars");
564         String JavaDoc sDir = (String JavaDoc) JonasManagementRepr.getAttribute(on, "RarsDirectory");
565
566         String JavaDoc sEarDir = null;
567         try {
568             on = JonasObjectName.earService();
569             sEarDir = (String JavaDoc) JonasManagementRepr.getAttribute(on, "AppsDirectory");
570         }
571         catch (ManagementException e) {
572             // nothing, Ear service not found
573
}
574         return prepareContainersToDisplay(al, sDir, sEarDir);
575     }
576
577     /**
578      * Return the list of deployed WAR filename in the current server.
579      *
580      * @return The list of WAR filename.
581      * @throws ManagementException
582      */

583     public static ArrayList JavaDoc getWarFilesDeployed()
584         throws ManagementException {
585         ObjectName JavaDoc on = JonasObjectName.webContainerService();
586         ArrayList JavaDoc al = (ArrayList JavaDoc) JonasManagementRepr.getAttribute(on, "DeployedWars");
587         String JavaDoc sDir = (String JavaDoc) JonasManagementRepr.getAttribute(on, "WebappsDirectory");
588
589         String JavaDoc sEarDir = null;
590         try {
591             on = JonasObjectName.earService();
592             sEarDir = (String JavaDoc) JonasManagementRepr.getAttribute(on, "AppsDirectory");
593         }
594         catch (ManagementException e) {
595             // nothing, Ear service not found
596
}
597         return prepareContainersToDisplay(al, sDir, sEarDir);
598     }
599
600     /**
601      * Prepare a list of containers to diplay.
602      * Deleting prefix root container directory, sorting the list.
603      * @param p_Containers The list of containers
604      * @param p_ContainerDir The root container directory
605      * @param p_EarDir The root ear directory or null
606      * @return The list of containers ready to display
607      */

608     public static ArrayList JavaDoc prepareContainersToDisplay(ArrayList JavaDoc p_Containers
609         , String JavaDoc p_ContainerDir, String JavaDoc p_EarDir) {
610         int iPos;
611         String JavaDoc sPath;
612         boolean bAdd;
613         ArrayList JavaDoc al = new ArrayList JavaDoc();
614         for (int i = 0; i < p_Containers.size(); i++) {
615             // Delete prefix root container directory
616
sPath = p_Containers.get(i).toString();
617             iPos = sPath.indexOf(p_ContainerDir);
618             if (iPos > -1) {
619                 sPath = sPath.substring(p_ContainerDir.length());
620             }
621             // Delete suffix slash
622
if (sPath.endsWith("/") == true) {
623                 sPath = sPath.substring(0, sPath.length() - 1);
624             }
625             // Flag to filter
626
bAdd = true;
627             // Filter Jar or War include in Ear
628
if (p_EarDir != null) {
629                 iPos = sPath.indexOf(p_EarDir);
630                 if (iPos > -1) {
631                     bAdd = false;
632                 }
633
634             }
635             if (bAdd == true) {
636                 al.add(sPath);
637             }
638         }
639         // Sort
640
Collections.sort(al);
641         return al;
642     }
643
644     private static ArrayList JavaDoc getFilesDeployed(ObjectName JavaDoc on)
645         throws ManagementException {
646         ArrayList JavaDoc alDeployed = new ArrayList JavaDoc();
647         String JavaDoc sPath;
648         String JavaDoc sFile;
649         Iterator JavaDoc itNames = JonasAdminJmx.getListMBeanName(on).iterator();
650         while (itNames.hasNext()) {
651             sPath = JonasAdminJmx.extractValueMbeanName("fname", itNames.next().toString());
652             sFile = JonasAdminJmx.extractFilename(sPath);
653             if (sFile != null) {
654                 alDeployed.add(sFile);
655             }
656         }
657         Collections.sort(alDeployed);
658         return alDeployed;
659
660     }
661
662     /**
663      * Return the list of Mail factory files ready to deploy in the current server.
664      *
665      * @return The list of Mail factory properties filenames.
666      * @throws ManagementException
667      */

668     public static ArrayList JavaDoc getMailFilesDeployable()
669         throws ManagementException {
670         ObjectName JavaDoc on = JonasObjectName.mailService();
671         return (ArrayList JavaDoc) JonasManagementRepr.getAttribute(on, "MailFactoryPropertiesFiles");
672     }
673
674     /**
675          * Return the list of MimePartDataSource Mail factory files ready to deploy in the current server.
676      *
677      * @return The list of MimePartDataSource Mail factory properties filenames.
678      * @throws ManagementException
679      */

680     public static ArrayList JavaDoc getMimePartMailFilesDeployable()
681         throws ManagementException {
682         ObjectName JavaDoc on = JonasObjectName.mailService();
683         return (ArrayList JavaDoc) JonasManagementRepr.getAttribute(on
684             , "MimePartMailFactoryPropertiesFiles");
685     }
686
687     /**
688      * Return the list of Session Mail factory files ready to deploy in the current server.
689      *
690      * @return The list of Session Mail factory properties filenames.
691      * @throws ManagementException
692      */

693     public static ArrayList JavaDoc getSessionMailFilesDeployable()
694         throws ManagementException {
695         ObjectName JavaDoc on = JonasObjectName.mailService();
696         return (ArrayList JavaDoc) JonasManagementRepr.getAttribute(on, "SessionMailFactoryPropertiesFiles");
697     }
698
699     /**
700      * Return the list of deployed MimePartDataSource Mail factories in the current server.
701      *
702      * @param p_WhereAreYou The container WhereAreYou
703      * @return The list of MimePartDataSource Mail factory filename.
704      * @throws ManagementException
705      */

706     public static ArrayList JavaDoc getMimePartMailFilesDeployed(WhereAreYou p_WhereAreYou)
707         throws ManagementException {
708         ArrayList JavaDoc alDeployed = new ArrayList JavaDoc();
709         String JavaDoc sName;
710         String JavaDoc domainName = p_WhereAreYou.getCurrentDomainName();
711         String JavaDoc serverName = p_WhereAreYou.getCurrentJonasServerName();
712         ObjectName JavaDoc on = J2eeObjectName.JavaMailResources(domainName, serverName
713             , MailServiceImpl.MIMEPART_PROPERTY_TYPE);
714         Iterator JavaDoc itNames = JonasManagementRepr.queryNames(on).iterator();
715         while (itNames.hasNext()) {
716             ObjectName JavaDoc it_on = (ObjectName JavaDoc) itNames.next();
717             sName = it_on.getKeyProperty("name");
718             if (sName != null) {
719                 alDeployed.add(sName);
720             }
721         }
722         Collections.sort(alDeployed);
723         return alDeployed;
724     }
725
726     /**
727      * Return the list of deployed Session Mail factories in the current server.
728      *
729      * @param p_WhereAreYou The container WhereAreYou
730      * @return The list of Session Mail factory filename.
731      * @throws ManagementException
732      */

733     public static ArrayList JavaDoc getSessionMailFilesDeployed(WhereAreYou p_WhereAreYou)
734         throws ManagementException {
735         ArrayList JavaDoc alDeployed = new ArrayList JavaDoc();
736         String JavaDoc sName;
737         String JavaDoc domainName = p_WhereAreYou.getCurrentDomainName();
738         String JavaDoc serverName = p_WhereAreYou.getCurrentJonasServerName();
739         ObjectName JavaDoc on = J2eeObjectName.JavaMailResources(domainName, serverName
740             , MailServiceImpl.SESSION_PROPERTY_TYPE);
741         Iterator JavaDoc itNames = JonasManagementRepr.queryNames(on).iterator();
742         while (itNames.hasNext()) {
743             ObjectName JavaDoc it_on = (ObjectName JavaDoc) itNames.next();
744             sName = it_on.getKeyProperty("name");
745             if (sName != null) {
746                 alDeployed.add(sName);
747             }
748         }
749         Collections.sort(alDeployed);
750         return alDeployed;
751     }
752
753     /**
754      * Return the list of deployed Mail factories in the current server.
755      *
756      * @param p_WhereAreYou The container WhereAreYou
757      * @return The list of Mail factory filename.
758      * @throws ManagementException
759      */

760     public static ArrayList JavaDoc getMailFilesDeployed(WhereAreYou p_WhereAreYou)
761         throws ManagementException {
762         ArrayList JavaDoc alDeployed = getSessionMailFilesDeployed(p_WhereAreYou);
763         alDeployed.addAll(getMimePartMailFilesDeployed(p_WhereAreYou));
764         Collections.sort(alDeployed);
765         return alDeployed;
766     }
767
768     /**
769      * Return the list of Datasource properties files ready to deploy in the current server.
770      *
771      * @return The list of Datasource properties filenames.
772      * @throws ManagementException Could not get managzement info from the MBeanServer
773      */

774     public static ArrayList JavaDoc getDatasourceFilesDeployable()
775         throws ManagementException {
776         ObjectName JavaDoc on = JonasObjectName.databaseService();
777         return (ArrayList JavaDoc) JonasManagementRepr.getAttribute(on, "DataSourcePropertiesFiles");
778     }
779
780     /**
781      * Return the list of deployed Datasources in the current server.
782      * @param domainName Current domain name
783      * @param serverName Current server name
784      * @return The list of Datasource filename.
785      * @throws ManagementException Could not get managzement info from the MBeanServer
786      */

787     public static ArrayList JavaDoc getDatasourceFilesDeployed(String JavaDoc domainName, String JavaDoc serverName)
788         throws ManagementException {
789
790         ArrayList JavaDoc alDeployed = new ArrayList JavaDoc();
791         ObjectName JavaDoc ons = J2eeObjectName.JDBCDataSources(domainName, serverName);
792         // iterate ovent the JDBCDataSources within the current server
793
Iterator JavaDoc itNames = JonasManagementRepr.queryNames(ons).iterator();
794         String JavaDoc sName = null;
795         while (itNames.hasNext()) {
796             ObjectName JavaDoc on = (ObjectName JavaDoc) itNames.next();
797             sName = on.getKeyProperty("name");
798             if (sName != null) {
799                 alDeployed.add(sName);
800             }
801         }
802         Collections.sort(alDeployed);
803         return alDeployed;
804     }
805
806     /**
807      * Return the list of Datasource dependences for a given datasource name in the current server.
808      *
809      * @param pDatasourceName The name of the datasource
810      * @param domainName Current domain name
811      * @param serverName Current server name
812      * @return The list of Datasource dependence (a list of names corresponding to EJBs using this datasource).
813      * @throws ManagementException Could not get managzement info from the MBeanServer
814      * @throws MalformedObjectNameException
815      */

816     public static ArrayList JavaDoc getDatasourceDependences(String JavaDoc pDatasourceName, String JavaDoc domainName, String JavaDoc serverName)
817         throws ManagementException {
818         ObjectName JavaDoc jdbcDatasource = J2eeObjectName.getJDBCDataSource(domainName, serverName, pDatasourceName);
819         String JavaDoc[] asParam = new String JavaDoc[1];
820         String JavaDoc[] asSignature = new String JavaDoc[1];
821         asSignature[0] = "java.lang.String";
822         ArrayList JavaDoc al = new ArrayList JavaDoc();
823         asParam[0] = (String JavaDoc) JonasManagementRepr.getAttribute(jdbcDatasource, "jndiName");
824         if (JonasManagementRepr.isRegistered(JonasObjectName.ejbService())) {
825             String JavaDoc sName;
826             Iterator JavaDoc it = ((java.util.Set JavaDoc) JonasManagementRepr.invoke(JonasObjectName.ejbService()
827                 , "getDataSourceDependence", asParam, asSignature)).iterator();
828             while (it.hasNext()) {
829                 sName = JonasAdminJmx.extractValueMbeanName(",name", it.next().toString());
830                 if (sName != null) {
831                     al.add(sName);
832                 }
833             }
834             Collections.sort(al);
835         }
836         return al;
837     }
838
839     /**
840      * Return the list of Mail factory dependences in the current server for a given factory name.
841      *
842      * @param p_MailFactoryName The name of the mail factory
843      * @param p_WhereAreYou The container WhereAreYou
844      * @return The list of Mail factory dependences (a list of names corresponding to EJBs using this mail factory).
845      * @throws ManagementException
846      */

847     public static ArrayList JavaDoc getMailFactoryDependences(String JavaDoc p_MailFactoryName
848         , WhereAreYou p_WhereAreYou)
849         throws ManagementException {
850         String JavaDoc jndiName = null;
851         String JavaDoc domainName = p_WhereAreYou.getCurrentDomainName();
852         String JavaDoc serverName = p_WhereAreYou.getCurrentJonasServerName();
853         String JavaDoc type = MailServiceImpl.SESSION_PROPERTY_TYPE;
854         // create an MBean name with the given MailFactory name
855
// - try with a session Mail Factory type
856
ObjectName JavaDoc on = J2eeObjectName.JavaMailResource(domainName, p_MailFactoryName, serverName
857             , type);
858         //ObjectName on = JonasObjectName.sessionMailFactory(p_MailFactoryName);
859
if (JonasManagementRepr.isRegistered(on) != true) {
860             // in this case, this is a MimePartDataSource mail factory
861
//on = JonasObjectName.mimeMailFactory(p_MailFactoryName);
862
type = MailServiceImpl.MIMEPART_PROPERTY_TYPE;
863             on = J2eeObjectName.JavaMailResource(domainName, p_MailFactoryName, serverName, type);
864         }
865         jndiName = (String JavaDoc) JonasManagementRepr.getAttribute(on, "Name");
866
867         String JavaDoc[] asParam = new String JavaDoc[1];
868         String JavaDoc[] asSignature = new String JavaDoc[1];
869         asSignature[0] = "java.lang.String";
870         ArrayList JavaDoc al = new ArrayList JavaDoc();
871         asParam[0] = jndiName;
872         if (JonasManagementRepr.isRegistered(JonasObjectName.ejbService()) == true) {
873             String JavaDoc sName;
874             Iterator JavaDoc it = ((java.util.Set JavaDoc) JonasManagementRepr.invoke(JonasObjectName.ejbService()
875                 , "getMailFactoryDependence", asParam, asSignature)).iterator();
876             while (it.hasNext()) {
877                 sName = JonasAdminJmx.extractValueMbeanName(",name", it.next().toString());
878                 if (sName != null) {
879                     al.add(sName);
880                 }
881             }
882             Collections.sort(al);
883         }
884         return al;
885     }
886
887     /**
888      * Return the list of deployed Session Mail Factories in the current server.
889      *
890      * @param p_WhereAreYou The container WhereAreYou
891      * @return The list
892      * @throws ManagementException
893      */

894     public static ArrayList JavaDoc getSessionMailFactoriesDeployed(WhereAreYou p_WhereAreYou)
895         throws ManagementException {
896
897         ArrayList JavaDoc alDeployed = new ArrayList JavaDoc();
898         String JavaDoc sName;
899         String JavaDoc domainName = p_WhereAreYou.getCurrentDomainName();
900         String JavaDoc serverName = p_WhereAreYou.getCurrentJonasServerName();
901         String JavaDoc type = MailServiceImpl.SESSION_PROPERTY_TYPE;
902
903         ObjectName JavaDoc any_on = J2eeObjectName.JavaMailResources(domainName, serverName, type);
904         Iterator JavaDoc itNames = JonasManagementRepr.queryNames(any_on).iterator();
905         while (itNames.hasNext()) {
906             ObjectName JavaDoc on = (ObjectName JavaDoc) itNames.next();
907             sName = on.getKeyProperty("name");
908             if (sName != null) {
909                 alDeployed.add(sName);
910             }
911         }
912
913         Collections.sort(alDeployed);
914         return alDeployed;
915     }
916
917     /**
918      * Return the list of deployed MimePartDatasource Mail Factories in the current server.
919      *
920      * @param p_WhereAreYou The container WhereAreYou
921      * @return The list
922      * @throws ManagementException
923      */

924     public static ArrayList JavaDoc getMimeMailPartFactoriesDeployed(WhereAreYou p_WhereAreYou)
925         throws ManagementException {
926         ArrayList JavaDoc alDeployed = new ArrayList JavaDoc();
927         String JavaDoc sName;
928         String JavaDoc domainName = p_WhereAreYou.getCurrentDomainName();
929         String JavaDoc serverName = p_WhereAreYou.getCurrentJonasServerName();
930         String JavaDoc type = MailServiceImpl.MIMEPART_PROPERTY_TYPE;
931
932         ObjectName JavaDoc any_on = J2eeObjectName.JavaMailResources(domainName, serverName, type);
933         Iterator JavaDoc itNames = JonasManagementRepr.queryNames(any_on).iterator();
934         while (itNames.hasNext()) {
935             ObjectName JavaDoc on = (ObjectName JavaDoc) itNames.next();
936             sName = on.getKeyProperty("name");
937             if (sName != null) {
938                 alDeployed.add(sName);
939             }
940         }
941         Collections.sort(alDeployed);
942         return alDeployed;
943     }
944
945     /**
946      * Return the list of Security Memory Factories in the current server.
947      *
948      * @return The list of Security Memory Factories
949      * @throws ManagementException
950      * @throws MalformedObjectNameException
951      */

952     public static ArrayList JavaDoc getSecurityMemoryFactories()
953         throws ManagementException, MalformedObjectNameException JavaDoc {
954         String JavaDoc sName;
955         ArrayList JavaDoc al = new ArrayList JavaDoc();
956         Iterator JavaDoc itNames = getListMBeanName(JonasObjectName.allSecurityMemoryFactories()).iterator();
957         while (itNames.hasNext()) {
958             sName = JonasAdminJmx.extractValueMbeanName(",name", itNames.next().toString());
959             if (sName != null) {
960                 al.add(sName);
961             }
962         }
963         Collections.sort(al);
964         return al;
965     }
966
967     /**
968      * Return the list of Security Datasource Factories in the current server.
969      *
970      * @return The list of Security Datasource Factories
971      * @throws ManagementException
972      * @throws MalformedObjectNameException
973      */

974     public static ArrayList JavaDoc getSecurityDatasourceFactories()
975         throws ManagementException, MalformedObjectNameException JavaDoc {
976         String JavaDoc sName;
977         ArrayList JavaDoc al = new ArrayList JavaDoc();
978         Iterator JavaDoc itNames = getListMBeanName(JonasObjectName.allSecurityDatasourceFactories()).
979             iterator();
980         while (itNames.hasNext()) {
981             sName = JonasAdminJmx.extractValueMbeanName(",name", itNames.next().toString());
982             if (sName != null) {
983                 al.add(sName);
984             }
985         }
986         Collections.sort(al);
987         return al;
988     }
989
990     /**
991      * Return the list of Security Ldap Factories in the current server.
992      *
993      * @return The list of Security Ldap Factories
994      * @throws ManagementException
995      * @throws MalformedObjectNameException
996      */

997     public static ArrayList JavaDoc getSecurityLdapFactories()
998         throws ManagementException, MalformedObjectNameException JavaDoc {
999         String JavaDoc sName;
1000        ArrayList JavaDoc al = new ArrayList JavaDoc();
1001        Iterator JavaDoc itNames = getListMBeanName(JonasObjectName.allSecurityLdapFactories()).iterator();
1002        while (itNames.hasNext()) {
1003            sName = JonasAdminJmx.extractValueMbeanName(",name", itNames.next().toString());
1004            if (sName != null) {
1005                al.add(sName);
1006            }
1007        }
1008        Collections.sort(al);
1009        return al;
1010    }
1011
1012    /**
1013     * Return the SubType of a Security Factory in the current server.
1014     *
1015     * @param p_NameFactory The factory name to find
1016     * @return The SubType or null if not found
1017     * @throws ManagementException
1018     * @throws MalformedObjectNameException
1019     */

1020    public static String JavaDoc findSecurityFactorySubType(String JavaDoc p_NameFactory)
1021        throws ManagementException, MalformedObjectNameException JavaDoc {
1022        String JavaDoc sName;
1023        String JavaDoc sSubType = null;
1024        ObjectName JavaDoc on = null;
1025
1026        Iterator JavaDoc itNames = getListMBeanName(JonasObjectName.allSecurityFactories()).iterator();
1027        while (itNames.hasNext()) {
1028            on = new ObjectName JavaDoc(itNames.next().toString());
1029            sName = on.getKeyProperty("name");
1030            if (p_NameFactory.equals(sName) == true) {
1031                sSubType = on.getKeyProperty("subtype");
1032                break;
1033            }
1034        }
1035        return sSubType;
1036    }
1037
1038    /**
1039     * Return the list of all users in a resource.
1040     *
1041     * @param p_Resource The resource
1042     * @return The list of users
1043     * @throws ManagementException
1044     * @throws MalformedObjectNameException
1045     */

1046    public static ArrayList JavaDoc getUsers(String JavaDoc p_Resource)
1047        throws ManagementException, MalformedObjectNameException JavaDoc {
1048        String JavaDoc sName;
1049        ArrayList JavaDoc al = new ArrayList JavaDoc();
1050        Iterator JavaDoc itNames = getListMBeanName(JonasObjectName.allUsers(p_Resource)).iterator();
1051        while (itNames.hasNext()) {
1052            sName = JonasAdminJmx.extractValueMbeanName(",name", itNames.next().toString());
1053            if (sName != null) {
1054                al.add(sName);
1055            }
1056        }
1057        Collections.sort(al);
1058        return al;
1059    }
1060
1061    /**
1062     * Return the list of all roles in a resource.
1063     *
1064     * @param p_Resource The resource
1065     * @return The list of roles
1066     * @throws ManagementException
1067     * @throws MalformedObjectNameException
1068     */

1069    public static ArrayList JavaDoc getRoles(String JavaDoc p_Resource)
1070        throws ManagementException, MalformedObjectNameException JavaDoc {
1071        String JavaDoc sName;
1072        ArrayList JavaDoc al = new ArrayList JavaDoc();
1073        Iterator JavaDoc itNames = getListMBeanName(JonasObjectName.allRoles(p_Resource)).iterator();
1074        while (itNames.hasNext()) {
1075            sName = JonasAdminJmx.extractValueMbeanName(",name", itNames.next().toString());
1076            if (sName != null) {
1077                al.add(sName);
1078            }
1079        }
1080        Collections.sort(al);
1081        return al;
1082    }
1083
1084    /**
1085     * Return the list of all groups in a resource.
1086     *
1087     * @param p_Resource The resource
1088     * @return The list of groups
1089     * @throws ManagementException
1090     * @throws MalformedObjectNameException
1091     */

1092    public static ArrayList JavaDoc getGroups(String JavaDoc p_Resource)
1093        throws ManagementException, MalformedObjectNameException JavaDoc {
1094        String JavaDoc sName;
1095        ArrayList JavaDoc al = new ArrayList JavaDoc();
1096        Iterator JavaDoc itNames = getListMBeanName(JonasObjectName.allGroups(p_Resource)).iterator();
1097        while (itNames.hasNext()) {
1098            sName = JonasAdminJmx.extractValueMbeanName(",name", itNames.next().toString());
1099            if (sName != null) {
1100                al.add(sName);
1101            }
1102        }
1103        Collections.sort(al);
1104        return al;
1105    }
1106
1107    /**
1108     * Return a list of names bounded in the registry.
1109     *
1110     * @return The list
1111     * @throws NamingException
1112     */

1113    public static ArrayList JavaDoc getRegistryList()
1114        throws NamingException JavaDoc {
1115        synchronized (s_Synchro) {
1116            ArrayList JavaDoc oNames = new ArrayList JavaDoc();
1117            // get the naming context
1118
Context JavaDoc ctx = JonasManagementRepr.getContext();
1119            // get all names bounded in the contexr
1120
for (NamingEnumeration JavaDoc e = ctx.list(""); e.hasMoreElements(); ) {
1121                oNames.add(((NameClassPair JavaDoc) e.nextElement()).getName());
1122            }
1123            return oNames;
1124        }
1125    }
1126
1127    /**
1128     * Return the Queue destinations list.
1129     * @return The list
1130     */

1131    public static ArrayList JavaDoc getQueuesList() {
1132        synchronized (s_Synchro) {
1133            ObjectName JavaDoc jmsServMB = JonasObjectName.jmsService();
1134            Set JavaDoc queues = (Set JavaDoc) JonasManagementRepr.getAttribute(jmsServMB
1135                , "AllJmsQueueDestinationNames");
1136            ArrayList JavaDoc al = new ArrayList JavaDoc();
1137            Iterator JavaDoc itNames = queues.iterator();
1138            while (itNames.hasNext()) {
1139                al.add(itNames.next());
1140            }
1141            return al;
1142        }
1143    }
1144
1145    /**
1146     * Return the Topic destinations list.
1147     * @return The list
1148     */

1149    public static ArrayList JavaDoc getTopicsList() {
1150        synchronized (s_Synchro) {
1151            ObjectName JavaDoc jmsServMB = JonasObjectName.jmsService();
1152            Set JavaDoc topics = (Set JavaDoc) JonasManagementRepr.getAttribute(jmsServMB
1153                , "AllJmsTopicDestinationNames");
1154            ArrayList JavaDoc al = new ArrayList JavaDoc();
1155            Iterator JavaDoc itNames = topics.iterator();
1156            while (itNames.hasNext()) {
1157                al.add(itNames.next());
1158            }
1159            return al;
1160        }
1161    }
1162
1163    /**
1164     * Return the default Connection Factories.
1165     *
1166     * @param p_Resources The messages
1167     * @return The list
1168     */

1169    public static ArrayList JavaDoc getConnectionFactoriesList(MessageResources p_Resources) {
1170        synchronized (s_Synchro) {
1171            ObjectName JavaDoc jmsServMB = JonasObjectName.jmsService();
1172            String JavaDoc cfName = (String JavaDoc) JonasManagementRepr.getAttribute(jmsServMB
1173                , "DefaultConnectionFactoryName");
1174            String JavaDoc tcfName = (String JavaDoc) JonasManagementRepr.getAttribute(jmsServMB
1175                , "DefaultTopicConnectionFactoryName");
1176            String JavaDoc qcfName = (String JavaDoc) JonasManagementRepr.getAttribute(jmsServMB
1177                , "DefaultQueueConnectionFactoryName");
1178            ArrayList JavaDoc al = new ArrayList JavaDoc();
1179            String JavaDoc comment = p_Resources.getMessage("tab.connfact.defaultconnfact");
1180            JmsConnFact cf = new JmsConnFact(cfName, comment);
1181            al.add(cf);
1182            comment = p_Resources.getMessage("tab.connfact.defaulttopicconnfact");
1183            cf = new JmsConnFact(tcfName, comment);
1184            al.add(cf);
1185            comment = p_Resources.getMessage("tab.connfact.defaultqueueconnfact");
1186            cf = new JmsConnFact(qcfName, comment);
1187            al.add(cf);
1188            return al;
1189        }
1190    }
1191
1192    /**
1193     * Return the list of all used loggers in this JOnAS server.
1194     * @param p_Resources The used message resource
1195     * @param p_WhereAreYou The used WhereAreYou instance
1196     * @param p_Action True to get the action (to use directly in jsp) or False to get the same action but in forward (write in the file struts-config.xml)
1197     * @return The list of loggers
1198     * @throws ManagementException
1199     */

1200    public static ArrayList JavaDoc getLoggers(MessageResources p_Resources, WhereAreYou p_WhereAreYou
1201        , boolean p_Action)
1202        throws ManagementException {
1203        ArrayList JavaDoc al = new ArrayList JavaDoc();
1204        String JavaDoc sActionForward;
1205        // Get JONAS logger
1206
if (p_Action == true) {
1207            sActionForward = "EditLoggingJonas.do";
1208        }
1209        else {
1210            sActionForward = "ActionEditLoggingJonas";
1211        }
1212        String JavaDoc itemName = p_Resources.getMessage("logger.jonas.name");
1213        String JavaDoc type = LoggerItem.LOGGER_JONAS;
1214        LoggerItem li = new LoggerItem(itemName, type, sActionForward);
1215        al.add(li);
1216        // Get Catalina Logger
1217
if (p_WhereAreYou.isCatalinaServer() == true) {
1218            ObjectName JavaDoc on = CatalinaObjectName.catalinaAccessLogValves(p_WhereAreYou.
1219                getCurrentCatalinaDomainName());
1220
1221            Iterator JavaDoc it = getListMbean(on).iterator();
1222            while (it.hasNext()) {
1223                ObjectName JavaDoc oItem = (ObjectName JavaDoc) it.next();
1224                if (p_Action) {
1225                    sActionForward = "EditCatalinaAccessLogger.do?select=" + oItem.toString();
1226                }
1227                else {
1228                    sActionForward = "ActionEditCatalinaAccessLogger";
1229                }
1230                itemName = p_Resources.getMessage("logger.catalina.access.name");
1231                String JavaDoc hostName = oItem.getKeyProperty("host");
1232                String JavaDoc containerName = null;
1233                String JavaDoc containerType = null;
1234                String JavaDoc containerLabel = null;
1235                if (hostName == null) {
1236                    type = LoggerItem.LOGGER_CATALINA_ACCESS_ENGINE;
1237                    containerType = p_Resources.getMessage("label.loggers.container.engine");
1238                    containerName = p_Resources.getMessage("label.loggers.container.engine.name");
1239                    containerLabel = containerName;
1240                } else {
1241                    String JavaDoc pathName = oItem.getKeyProperty("path");
1242                    if (pathName != null) {
1243                        type = LoggerItem.LOGGER_CATALINA_ACCESS_CONTEXT;
1244                        containerName = pathName;
1245                        containerType = p_Resources.getMessage("label.loggers.container.context");
1246                        containerLabel = WebAppItem.extractLabelPathContext(containerName);
1247                    } else {
1248                        type = LoggerItem.LOGGER_CATALINA_ACCESS_HOST;
1249                        containerName = hostName;
1250                        containerType = p_Resources.getMessage("label.loggers.container.host");
1251                        containerLabel = containerName;
1252                    }
1253                }
1254                itemName = itemName.concat(" " + containerLabel);
1255                li = new LoggerItem(itemName, type, sActionForward, oItem.toString(), containerType, containerName);
1256                al.add(li);
1257            }
1258        }
1259        // sort
1260
Collections.sort(al, new BeanComparator(new String JavaDoc[]{"name"}));
1261        return al;
1262    }
1263
1264    /**
1265     * Create a list for each family of Mbean.
1266     *
1267     * @return An array of lists
1268     * @throws ManagementException
1269     */

1270    public static ArrayList JavaDoc getMbeansLists()
1271        throws ManagementException {
1272
1273        MbeanItem oItem;
1274
1275        // Create the new list
1276
ArrayList JavaDoc al = new ArrayList JavaDoc();
1277        // Dispath each Mbean in its list
1278
Iterator JavaDoc it = JonasAdminJmx.getListMbean(null).iterator();
1279        while (it.hasNext()) {
1280            oItem = MbeanItem.build((ObjectName JavaDoc) it.next());
1281            al.add(oItem);
1282        }
1283        return al;
1284    }
1285
1286    /**
1287     * Create a list for each family of Mbean.
1288     *
1289     * @return An array of lists
1290     * @throws ManagementException
1291     */

1292    public static ArrayList JavaDoc[] getFamiliesMbeansLists()
1293        throws ManagementException {
1294
1295        MbeanItem oItem;
1296
1297        // Create the new lists
1298
ArrayList JavaDoc[] als = new ArrayList JavaDoc[3];
1299        for (int i = 0; i < MbeanItem.SIZE_FAMILIES; i++) {
1300            als[i] = new ArrayList JavaDoc();
1301        }
1302        // Dispath each Mbean in its list
1303
Iterator JavaDoc it = JonasAdminJmx.getListMbean(null).iterator();
1304        while (it.hasNext()) {
1305            oItem = MbeanItem.build((ObjectName JavaDoc) it.next());
1306            als[oItem.getFamily()].add(oItem);
1307        }
1308        return als;
1309    }
1310}
1311
Popular Tags