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