KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jmx > J2eeObjectName


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: J2eeObjectName.java,v 1.35 2005/07/25 22:49:52 vivekl Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jmx;
27
28 import java.util.ArrayList JavaDoc;
29 import java.util.Collections JavaDoc;
30 import java.util.Iterator JavaDoc;
31 import java.util.List JavaDoc;
32
33 import javax.management.MBeanServer JavaDoc;
34 import javax.management.MBeanServerConnection JavaDoc;
35 import javax.management.ObjectName JavaDoc;
36
37 /**
38  * A set of static methods used to create object names for J2EE managed object.
39  * This implementation is conformant to the JSR77.
40  * @author Adriana Danes
41  * @author Michel-Ange Anton
42  */

43 public class J2eeObjectName {
44
45     private static MBeanServerConnection JavaDoc localManagementRepr = null;
46
47     /**
48      * private constructor
49      */

50     private J2eeObjectName() {
51     }
52
53     // --------------------------------------------------------- Constants
54
/**
55      * Constant used in pattern ObjectNames
56      */

57     public static final String JavaDoc ALL = "*";
58
59     /**
60      * Constant used in ObjectNames of standalone modules
61      */

62     public static final String JavaDoc NONE = "none";
63
64     // --------------------------------------------------------- Public Methods
65
/**
66      * @param pObjectName Stringified ObjectName
67      * @return ObjectName instance corresponding to the received argument
68      */

69     public static ObjectName JavaDoc getObjectName(String JavaDoc pObjectName) {
70         try {
71             return ObjectName.getInstance(pObjectName);
72         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
73             // this should never occur
74
return null;
75         }
76     }
77
78     /**
79      * Return the list of <code>ObjectName</code> gotten by the query in the
80      * current MbeanServer.
81      * @param pOn Query Mbeans to search
82      * @return The list of <code>ObjectName</code>
83      * @throws ManagementException
84      */

85     public static List JavaDoc queryObjectNames(ObjectName JavaDoc pOn) throws ManagementException {
86         ArrayList JavaDoc al = new ArrayList JavaDoc();
87         if (localManagementRepr == null) {
88             localManagementRepr = ManagementReprFactory.getLocalManagementRepr();
89             if (localManagementRepr == null) {
90                 return al;
91             }
92         }
93         Iterator JavaDoc itNames = ((MBeanServer JavaDoc) localManagementRepr).queryNames(pOn, null).iterator();
94         while (itNames.hasNext()) {
95             al.add(itNames.next());
96         }
97         return al;
98     }
99
100     /**
101      * Return the list of ObjectName's String gotten by the query in the current
102      * MbeanServer.
103      * @param pOn Query Mbeans to search
104      * @return A list of <code>ObjectName</code> convert to String
105      * @throws ManagementException
106      */

107     public static List JavaDoc queryStrings(ObjectName JavaDoc pOn) throws ManagementException {
108         ArrayList JavaDoc al = new ArrayList JavaDoc();
109         if (localManagementRepr == null) {
110             localManagementRepr = ManagementReprFactory.getLocalManagementRepr();
111             if (localManagementRepr == null) {
112                 return al;
113             }
114         }
115         Iterator JavaDoc itNames = ((MBeanServer JavaDoc) localManagementRepr).queryNames(pOn, null).iterator();
116         while (itNames.hasNext()) {
117             ObjectName JavaDoc item = (ObjectName JavaDoc) itNames.next();
118             al.add(item.toString());
119         }
120         Collections.sort(al);
121         return al;
122     }
123
124     public static ObjectName JavaDoc J2EEDomain(String JavaDoc pDomain) {
125         try {
126             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
127             sb.append(":j2eeType=J2EEDomain");
128             sb.append(",name=");
129             sb.append(pDomain);
130             return new ObjectName JavaDoc(sb.toString());
131         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
132             // this should never occur
133
return null;
134         }
135     }
136
137     public static ObjectName JavaDoc J2EEDomains() {
138         try {
139             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(ALL);
140             sb.append(":j2eeType=J2EEDomain");
141             sb.append(",");
142             sb.append(ALL);
143             return new ObjectName JavaDoc(sb.toString());
144         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
145             // this should never occur
146
return null;
147         }
148     }
149
150     public static ObjectName JavaDoc J2EEServers() {
151         try {
152             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(ALL);
153             sb.append(":j2eeType=J2EEServer");
154             sb.append(",");
155             sb.append(ALL);
156             return new ObjectName JavaDoc(sb.toString());
157         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
158             // this should never occur
159
return null;
160         }
161     }
162
163     public static ObjectName JavaDoc J2EEServers(String JavaDoc pDomain) {
164         try {
165             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
166             sb.append(":j2eeType=J2EEServer");
167             sb.append(",");
168             sb.append(ALL);
169             return new ObjectName JavaDoc(sb.toString());
170         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
171             // this should never occur
172
return null;
173         }
174     }
175
176     public static ObjectName JavaDoc J2EEServer(String JavaDoc pDomain, String JavaDoc pServer) {
177         try {
178             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
179             sb.append(":j2eeType=J2EEServer");
180             sb.append(",name=");
181             sb.append(pServer);
182             return new ObjectName JavaDoc(sb.toString());
183         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
184             // this should never occur
185
return null;
186         }
187     }
188
189     public static ObjectName JavaDoc JVM(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pName) {
190         try {
191             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
192             sb.append(":j2eeType=JVM");
193             sb.append(",name=");
194             sb.append(pName);
195             sb.append(",J2EEServer=");
196             sb.append(pServer);
197             return new ObjectName JavaDoc(sb.toString());
198         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
199             // this should never occur
200
return null;
201         }
202     }
203
204     public static ObjectName JavaDoc JVMs(String JavaDoc pDomain, String JavaDoc pServer) {
205         try {
206             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
207             sb.append(":j2eeType=JVM");
208             sb.append(",J2EEServer=");
209             sb.append(pServer);
210             sb.append(",");
211             sb.append(ALL);
212             return new ObjectName JavaDoc(sb.toString());
213         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
214             // this should never occur
215
return null;
216         }
217     }
218
219     public static ObjectName JavaDoc J2EEApplications() {
220         try {
221             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(ALL);
222             sb.append(":j2eeType=J2EEApplication");
223             sb.append(",");
224             sb.append(ALL);
225             return new ObjectName JavaDoc(sb.toString());
226         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
227             // this should never occur
228
return null;
229         }
230     }
231
232     public static ObjectName JavaDoc J2EEApplications(String JavaDoc pDomain) {
233         try {
234             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
235             sb.append(":j2eeType=J2EEApplication");
236             sb.append(",");
237             sb.append(ALL);
238             return new ObjectName JavaDoc(sb.toString());
239         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
240             // this should never occur
241
return null;
242         }
243     }
244
245     public static ObjectName JavaDoc J2EEApplications(String JavaDoc pDomain, String JavaDoc pServer) {
246         try {
247             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
248             sb.append(":j2eeType=J2EEApplication");
249             sb.append(",J2EEServer=");
250             sb.append(pServer);
251             sb.append(",");
252             sb.append(ALL);
253             return new ObjectName JavaDoc(sb.toString());
254         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
255             // this should never occur
256
return null;
257         }
258     }
259
260     public static ObjectName JavaDoc J2EEApplication(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pName) {
261         try {
262             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
263             sb.append(":j2eeType=J2EEApplication");
264             sb.append(",name=");
265             sb.append(pName);
266             sb.append(",J2EEServer=");
267             sb.append(pServer);
268             return new ObjectName JavaDoc(sb.toString());
269         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
270             // this should never occur
271
return null;
272         }
273     }
274     /**
275      * Create generic name for all AppClientModules deployed in a given server, possibly belonging
276      * to a given J2EE application
277      * @param pDomain domain name
278      * @param pServer server name
279      * @param pApplication application name
280      * @return generic name for the AppClientModules in a given server and application
281      */

282     public static ObjectName JavaDoc getAppClientModules(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pApplication) {
283         try {
284             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
285             sb.append(":j2eeType=AppClientModule");
286             sb.append(",J2EEApplication=");
287             if ((pApplication != null) && (pApplication.length() > 0)) {
288                 sb.append(pApplication);
289             } else {
290                 sb.append(NONE);
291             }
292             sb.append(",J2EEServer=");
293             sb.append(pServer);
294             sb.append(",");
295             sb.append(ALL);
296             return new ObjectName JavaDoc(sb.toString());
297         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
298             // this should never occur
299
return null;
300         }
301     }
302     /**
303      * Create ObjectName for an AppClientModule
304      * @param pDomain domain name
305      * @param pServer server name
306      * @param pApplication application name
307      * @param pName module name
308      * @return ObjectName for an AppClientModule
309      */

310     public static ObjectName JavaDoc getAppClientModule(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pApplication, String JavaDoc pName) {
311         try {
312             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
313             sb.append(":j2eeType=AppClientModule");
314             sb.append(",name=");
315             sb.append(pName);
316             sb.append(",J2EEApplication=");
317             if ((pApplication != null) && (pApplication.length() > 0)) {
318                 sb.append(pApplication);
319             } else {
320                 sb.append(NONE);
321             }
322             sb.append(",J2EEServer=");
323             sb.append(pServer);
324             return new ObjectName JavaDoc(sb.toString());
325         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
326             // this should never occur
327
return null;
328         }
329     }
330     public static ObjectName JavaDoc getEJBModules() {
331         try {
332             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(ALL);
333             sb.append(":j2eeType=EJBModule");
334             sb.append(",");
335             sb.append(ALL);
336             return new ObjectName JavaDoc(sb.toString());
337         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
338             // this should never occur
339
return null;
340         }
341     }
342
343     public static ObjectName JavaDoc getEJBModules(String JavaDoc pDomain) {
344         try {
345             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
346             sb.append(":j2eeType=EJBModule");
347             sb.append(",");
348             sb.append(ALL);
349             return new ObjectName JavaDoc(sb.toString());
350         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
351             // this should never occur
352
return null;
353         }
354     }
355
356     public static ObjectName JavaDoc getEJBModules(String JavaDoc pDomain, String JavaDoc pServer) {
357         try {
358             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
359             sb.append(":j2eeType=EJBModule");
360             sb.append(",J2EEServer=");
361             sb.append(pServer);
362             sb.append(",");
363             sb.append(ALL);
364             return new ObjectName JavaDoc(sb.toString());
365         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
366             // this should never occur
367
return null;
368         }
369     }
370
371     public static ObjectName JavaDoc getEJBModules(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pApplication) {
372         try {
373             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
374             sb.append(":j2eeType=EJBModule");
375             sb.append(",J2EEApplication=");
376             if ((pApplication != null) && (pApplication.length() > 0)) {
377                 sb.append(pApplication);
378             } else {
379                 sb.append(NONE);
380             }
381             sb.append(",J2EEServer=");
382             sb.append(pServer);
383             sb.append(",");
384             sb.append(ALL);
385             return new ObjectName JavaDoc(sb.toString());
386         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
387             // this should never occur
388
return null;
389         }
390     }
391
392     public static ObjectName JavaDoc getEJBModule(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pApplication, String JavaDoc pName) {
393         try {
394             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
395             sb.append(":j2eeType=EJBModule");
396             sb.append(",name=");
397             sb.append(pName);
398             sb.append(",J2EEApplication=");
399             if ((pApplication != null) && (pApplication.length() > 0)) {
400                 sb.append(pApplication);
401             } else {
402                 sb.append(NONE);
403             }
404             sb.append(",J2EEServer=");
405             sb.append(pServer);
406             return new ObjectName JavaDoc(sb.toString());
407         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
408             // this should never occur
409
return null;
410         }
411     }
412
413     public static ObjectName JavaDoc getEntityBean(String JavaDoc pDomain, String JavaDoc pModule, String JavaDoc pServer, String JavaDoc pApplication,
414             String JavaDoc pName) {
415         try {
416             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
417             sb.append(":j2eeType=EntityBean");
418             sb.append(",name=");
419             sb.append(pName);
420             sb.append(",EJBModule=");
421             sb.append(pModule);
422             sb.append(",J2EEApplication=");
423             if ((pApplication != null) && (pApplication.length() > 0)) {
424                 sb.append(pApplication);
425             } else {
426                 sb.append(NONE);
427             }
428             sb.append(",J2EEServer=");
429             sb.append(pServer);
430             return new ObjectName JavaDoc(sb.toString());
431         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
432             // this should never occur
433
return null;
434         }
435     }
436
437     public static ObjectName JavaDoc getEntityBeans(String JavaDoc pDomain, String JavaDoc pModule) {
438         try {
439             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
440             sb.append(":j2eeType=EntityBean");
441             sb.append(",EJBModule=");
442             sb.append(pModule);
443             sb.append(",");
444             sb.append(ALL);
445             return new ObjectName JavaDoc(sb.toString());
446         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
447             // this should never occur
448
return null;
449         }
450     }
451
452     public static ObjectName JavaDoc getEntityBeans(String JavaDoc pDomain, String JavaDoc pModule, String JavaDoc pServer) {
453         try {
454             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
455             sb.append(":j2eeType=EntityBean");
456             sb.append(",EJBModule=");
457             sb.append(pModule);
458             sb.append(",J2EEServer=");
459             sb.append(pServer);
460             sb.append(",");
461             sb.append(ALL);
462             return new ObjectName JavaDoc(sb.toString());
463         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
464             // this should never occur
465
return null;
466         }
467     }
468
469     public static ObjectName JavaDoc getStatefulSessionBean(String JavaDoc pDomain, String JavaDoc pModule, String JavaDoc pServer,
470             String JavaDoc pApplication, String JavaDoc pName) {
471         try {
472             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
473             sb.append(":j2eeType=StatefulSessionBean");
474             sb.append(",name=");
475             sb.append(pName);
476             sb.append(",EJBModule=");
477             sb.append(pModule);
478             sb.append(",J2EEApplication=");
479             if ((pApplication != null) && (pApplication.length() > 0)) {
480                 sb.append(pApplication);
481             } else {
482                 sb.append(NONE);
483             }
484             sb.append(",J2EEServer=");
485             sb.append(pServer);
486             return new ObjectName JavaDoc(sb.toString());
487         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
488             // this should never occur
489
return null;
490         }
491     }
492
493     public static ObjectName JavaDoc getStatefulSessionBeans(String JavaDoc pDomain, String JavaDoc pModule) {
494         try {
495             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
496             sb.append(":j2eeType=StatefulSessionBean");
497             sb.append(",EJBModule=");
498             sb.append(pModule);
499             sb.append(",");
500             sb.append(ALL);
501             return new ObjectName JavaDoc(sb.toString());
502         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
503             // this should never occur
504
return null;
505         }
506     }
507
508     public static ObjectName JavaDoc getStatefulSessionBeans(String JavaDoc pDomain, String JavaDoc pModule, String JavaDoc pServer) {
509         try {
510             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
511             sb.append(":j2eeType=StatefulSessionBean");
512             sb.append(",EJBModule=");
513             sb.append(pModule);
514             sb.append(",J2EEServer=");
515             sb.append(pServer);
516             sb.append(",");
517             sb.append(ALL);
518             return new ObjectName JavaDoc(sb.toString());
519         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
520             // this should never occur
521
return null;
522         }
523     }
524
525     public static ObjectName JavaDoc getStatelessSessionBean(String JavaDoc pDomain, String JavaDoc pModule, String JavaDoc pServer,
526             String JavaDoc pApplication, String JavaDoc pName) {
527         try {
528             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
529             sb.append(":j2eeType=StatelessSessionBean");
530             sb.append(",name=");
531             sb.append(pName);
532             sb.append(",EJBModule=");
533             sb.append(pModule);
534             sb.append(",J2EEApplication=");
535             if ((pApplication != null) && (pApplication.length() > 0)) {
536                 sb.append(pApplication);
537             } else {
538                 sb.append(NONE);
539             }
540             sb.append(",J2EEServer=");
541             sb.append(pServer);
542             return new ObjectName JavaDoc(sb.toString());
543         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
544             // this should never occur
545
return null;
546         }
547     }
548
549     public static ObjectName JavaDoc getStatelessSessionBeans(String JavaDoc pDomain, String JavaDoc pModule) {
550         try {
551             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
552             sb.append(":j2eeType=StatelessSessionBean");
553             sb.append(",EJBModule=");
554             sb.append(pModule);
555             sb.append(",");
556             sb.append(ALL);
557             return new ObjectName JavaDoc(sb.toString());
558         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
559             // this should never occur
560
return null;
561         }
562     }
563
564     public static ObjectName JavaDoc getStatelessSessionBeans(String JavaDoc pDomain) {
565         try {
566             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
567             sb.append(":j2eeType=StatelessSessionBean");
568             sb.append(",");
569             sb.append(ALL);
570             return new ObjectName JavaDoc(sb.toString());
571         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
572              // this should never occur
573
return null;
574         }
575     }
576
577
578     public static ObjectName JavaDoc getStatelessSessionBeans(String JavaDoc pDomain, String JavaDoc pModule, String JavaDoc pServer) {
579         try {
580             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
581             sb.append(":j2eeType=StatelessSessionBean");
582             sb.append(",EJBModule=");
583             sb.append(pModule);
584             sb.append(",J2EEServer=");
585             sb.append(pServer);
586             sb.append(",");
587             sb.append(ALL);
588             return new ObjectName JavaDoc(sb.toString());
589         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
590             // this should never occur
591
return null;
592         }
593     }
594
595     public static ObjectName JavaDoc getMessageDrivenBean(String JavaDoc pDomain, String JavaDoc pModule, String JavaDoc pServer,
596             String JavaDoc pApplication, String JavaDoc pName) {
597         try {
598             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
599             sb.append(":j2eeType=MessageDrivenBean");
600             sb.append(",name=");
601             sb.append(pName);
602             sb.append(",EJBModule=");
603             sb.append(pModule);
604             sb.append(",J2EEApplication=");
605             if ((pApplication != null) && (pApplication.length() > 0)) {
606                 sb.append(pApplication);
607             } else {
608                 sb.append(NONE);
609             }
610             sb.append(",J2EEServer=");
611             sb.append(pServer);
612             return new ObjectName JavaDoc(sb.toString());
613         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
614             // this should never occur
615
return null;
616         }
617     }
618
619     public static ObjectName JavaDoc getMessageDrivenBeans(String JavaDoc pDomain, String JavaDoc pModule, String JavaDoc pServer) {
620         try {
621             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
622             sb.append(":j2eeType=MessageDrivenBean");
623             sb.append(",EJBModule=");
624             sb.append(pModule);
625             sb.append(",J2EEServer=");
626             sb.append(pServer);
627             sb.append(",");
628             sb.append(ALL);
629             return new ObjectName JavaDoc(sb.toString());
630         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
631             // this should never occur
632
return null;
633         }
634     }
635
636     public static ObjectName JavaDoc getMessageDrivenBeans(String JavaDoc pDomain, String JavaDoc pModule) {
637         try {
638             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
639             sb.append(":j2eeType=MessageDrivenBean");
640             sb.append(",EJBModule=");
641             sb.append(pModule);
642             sb.append(",");
643             sb.append(ALL);
644             return new ObjectName JavaDoc(sb.toString());
645         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
646             // this should never occur
647
return null;
648         }
649     }
650     
651     public static ObjectName JavaDoc getWebServices(String JavaDoc pDomain, String JavaDoc pServer) {
652         //TODO: Add a proper web service mbean instead.
653
try {
654             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
655             sb.append(":type=WebService");
656             sb.append(",");
657             sb.append(ALL);
658             sb.append(",J2EEServer=");
659             sb.append(pServer);
660             sb.append(",");
661             sb.append(ALL);
662             return new ObjectName JavaDoc(sb.toString());
663         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
664             // this should never occur
665
return null;
666         }
667     }
668
669     public static ObjectName JavaDoc getWebServices() {
670         try {
671             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(ALL);
672             sb.append(":type=WebService");
673             sb.append(",");
674             sb.append(ALL);
675             return new ObjectName JavaDoc(sb.toString());
676         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
677             // this should never occur
678
return null;
679         }
680     }
681
682
683     public static ObjectName JavaDoc JavaMailResource(String JavaDoc pDomain, String JavaDoc pName, String JavaDoc pServer, String JavaDoc p_Type) {
684         try {
685             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
686             sb.append(":j2eeType=JavaMailResource");
687             sb.append(",name=");
688             sb.append(pName);
689             sb.append(",J2EEServer=");
690             sb.append(pServer);
691             sb.append(",type=");
692             sb.append(p_Type);
693             return new ObjectName JavaDoc(sb.toString());
694         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
695             // this should never occur
696
return null;
697         }
698     }
699
700     public static ObjectName JavaDoc JavaMailResources(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc p_Type) {
701         try {
702             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
703             sb.append(":j2eeType=JavaMailResource");
704             sb.append(",");
705             sb.append(ALL);
706             sb.append(",J2EEServer=");
707             sb.append(pServer);
708             sb.append(",type=");
709             sb.append(p_Type);
710             return new ObjectName JavaDoc(sb.toString());
711         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
712             // this should never occur
713
return null;
714         }
715     }
716
717     public static ObjectName JavaDoc JNDIResources(String JavaDoc pDomain, String JavaDoc pServer) {
718         try {
719             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
720             sb.append(":j2eeType=JNDIResource");
721             sb.append(",J2EEServer=");
722             sb.append(pServer);
723             sb.append(",");
724             sb.append(ALL);
725             return new ObjectName JavaDoc(sb.toString());
726         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
727             // this should never occur
728
return null;
729         }
730     }
731
732     public static ObjectName JavaDoc getWebModules() {
733         try {
734             return new ObjectName JavaDoc("*:j2eeType=WebModule,*");
735         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
736             // this should never occur
737
return null;
738         }
739     }
740
741     public static ObjectName JavaDoc getWebModules(String JavaDoc pDomain) {
742         try {
743             return new ObjectName JavaDoc(pDomain + ":j2eeType=WebModule,*");
744         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
745             // this should never occur
746
return null;
747         }
748     }
749
750     public static ObjectName JavaDoc getWebModules(String JavaDoc pDomain, String JavaDoc pServer) {
751         try {
752             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
753             sb.append(":j2eeType=WebModule");
754             if ((pServer != null) && (pServer.length() > 0)) {
755                 sb.append(",J2EEServer=");
756                 sb.append(pServer);
757             }
758             sb.append(",*");
759             return new ObjectName JavaDoc(sb.toString());
760         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
761             // this should never occur
762
return null;
763         }
764     }
765
766     public static ObjectName JavaDoc getWebModules(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pApplication) {
767         try {
768             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
769             sb.append(":j2eeType=WebModule");
770             if ((pServer != null) && (pServer.length() > 0)) {
771                 sb.append(",J2EEServer=");
772                 sb.append(pServer);
773             }
774             if ((pApplication != null) && (pApplication.length() > 0)) {
775                 sb.append(",J2EEApplication=");
776                 sb.append(pApplication);
777             }
778             sb.append(",*");
779             return new ObjectName JavaDoc(sb.toString());
780         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
781             // this should never occur
782
return null;
783         }
784     }
785
786     public static ObjectName JavaDoc getWebModule(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pApplication, String JavaDoc pName) {
787         try {
788             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
789             sb.append(":j2eeType=WebModule");
790             sb.append(",name=");
791             sb.append(pName);
792             sb.append(",J2EEServer=");
793             sb.append(pServer);
794             sb.append(",J2EEApplication=");
795             if ((pApplication != null) && (pApplication.length() > 0)) {
796                 sb.append(pApplication);
797             } else {
798                 sb.append(NONE);
799             }
800
801             return new ObjectName JavaDoc(sb.toString());
802         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
803             // this should never occur
804
return null;
805         }
806     }
807
808     public static ObjectName JavaDoc getResourceAdapterModule(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pApplication,
809             String JavaDoc pName) {
810         try {
811             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
812             sb.append(":j2eeType=ResourceAdapterModule");
813             sb.append(",name=");
814             sb.append(pName);
815             sb.append(",J2EEServer=");
816             sb.append(pServer);
817             sb.append(",J2EEApplication=");
818             if ((pApplication == null) || (pApplication.length() == 0)) {
819                 sb.append(NONE);
820             } else {
821                 sb.append(pApplication);
822             }
823             return new ObjectName JavaDoc(sb.toString());
824         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
825             // this should never occur
826
return null;
827         }
828     }
829
830     public static ObjectName JavaDoc getResourceAdapterModules(String JavaDoc pDomain, String JavaDoc pServer) {
831         try {
832             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
833             sb.append(":j2eeType=ResourceAdapterModule");
834             if ((pServer != null) && (pServer.length() > 0)) {
835                 sb.append(",J2EEServer=");
836                 sb.append(pServer);
837             }
838             sb.append(",");
839             sb.append(ALL);
840             return new ObjectName JavaDoc(sb.toString());
841         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
842             // this should never occur
843
return null;
844         }
845     }
846
847     public static ObjectName JavaDoc getResourceAdapterModules(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pApplication) {
848         try {
849             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
850             sb.append(":j2eeType=ResourceAdapterModule");
851             if ((pServer != null) && (pServer.length() > 0)) {
852                 sb.append(",J2EEServer=");
853                 sb.append(pServer);
854             }
855             if ((pApplication != null) && (pApplication.length() > 0)) {
856                 sb.append(",J2EEApplication=");
857                 sb.append(pApplication);
858             }
859             sb.append(",");
860             sb.append(ALL);
861             return new ObjectName JavaDoc(sb.toString());
862         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
863             // this should never occur
864
return null;
865         }
866     }
867
868     public static ObjectName JavaDoc getResourceAdapter(String JavaDoc pDomain, String JavaDoc pResourceAdapterModule, String JavaDoc pApplication,
869             String JavaDoc pServer, String JavaDoc pName) {
870         try {
871             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
872             sb.append(":j2eeType=ResourceAdapter");
873             sb.append(",name=");
874             sb.append(pName);
875             sb.append(",ResourceAdapterModule=");
876             sb.append(pResourceAdapterModule);
877             sb.append(",J2EEApplication=");
878             if ((pApplication == null) || (pApplication.length() == 0)) {
879                 sb.append(NONE);
880             } else {
881                 sb.append(pApplication);
882             }
883             sb.append(",J2EEServer=");
884             sb.append(pServer);
885             return new ObjectName JavaDoc(sb.toString());
886         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
887             // this should never occur
888
return null;
889         }
890     }
891
892     public static ObjectName JavaDoc getResourceAdapters(String JavaDoc pDomain, String JavaDoc pServer) {
893         try {
894             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
895             sb.append(":j2eeType=ResourceAdapter");
896             if ((pServer != null) && (pServer.length() > 0)) {
897                 sb.append(",J2EEServer=");
898                 sb.append(pServer);
899             }
900             sb.append(",");
901             sb.append(ALL);
902             return new ObjectName JavaDoc(sb.toString());
903         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
904             // this should never occur
905
return null;
906         }
907     }
908
909     public static ObjectName JavaDoc getResourceAdapters(String JavaDoc pDomain, String JavaDoc pApplication, String JavaDoc pServer) {
910         try {
911             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
912             sb.append(":j2eeType=ResourceAdapter");
913             sb.append(",J2EEApplication=");
914             if ((pApplication == null) || (pApplication.length() == 0)) {
915                 sb.append(NONE);
916             } else {
917                 sb.append(pApplication);
918             }
919             if ((pServer != null) && (pServer.length() > 0)) {
920                 sb.append(",J2EEServer=");
921                 sb.append(pServer);
922             }
923             sb.append(",");
924             sb.append(ALL);
925             return new ObjectName JavaDoc(sb.toString());
926         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
927             // this should never occur
928
return null;
929         }
930     }
931     public static ObjectName JavaDoc getJCAResource(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pResourceAdapter, String JavaDoc pName) {
932         try {
933             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
934             sb.append(":j2eeType=JCAResource");
935             sb.append(",name=");
936             sb.append(pName);
937             sb.append(",J2EEServer=");
938             sb.append(pServer);
939             sb.append(",ResourceAdapter=");
940             sb.append(pResourceAdapter);
941             return new ObjectName JavaDoc(sb.toString());
942         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
943             // this should never occur
944
return null;
945         }
946     }
947
948     public static ObjectName JavaDoc getJCAActivationSpec(String JavaDoc pDomain, String JavaDoc pJCAResource, String JavaDoc pServer, String JavaDoc pName) {
949         try {
950             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
951             sb.append(":j2eeType=JCAActivationSpec");
952             sb.append(",name=");
953             sb.append(pName);
954             sb.append(",JCAResource=");
955             sb.append(pJCAResource);
956             sb.append(",J2EEServer=");
957             sb.append(pServer);
958             return new ObjectName JavaDoc(sb.toString());
959         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
960             // this should never occur
961
return null;
962         }
963     }
964
965     public static ObjectName JavaDoc getJCAAdminObject(String JavaDoc pDomain, String JavaDoc pJCAResource, String JavaDoc pServer, String JavaDoc pName) {
966         try {
967             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
968             sb.append(":j2eeType=JCAAdminObject");
969             sb.append(",name=");
970             sb.append(pName);
971             sb.append(",JCAResource=");
972             sb.append(pJCAResource);
973             sb.append(",J2EEServer=");
974             sb.append(pServer);
975             return new ObjectName JavaDoc(sb.toString());
976         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
977             // this should never occur
978
return null;
979         }
980     }
981
982     public static ObjectName JavaDoc getJCAConnectionFactory(String JavaDoc pDomain, String JavaDoc pJCAResource, String JavaDoc pServer,
983             String JavaDoc pName) {
984         try {
985             StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
986             sb.append(":j2eeType=JCAConnectionFactory");
987             sb.append(",name=");
988             sb.append(pName);
989             sb.append(",JCAResource=");
990             sb.append(pJCAResource);
991             sb.append(",J2EEServer=");
992             sb.append(pServer);
993             return new ObjectName JavaDoc(sb.toString());
994         } catch (javax.management.MalformedObjectNameException JavaDoc e) {
995             // this should never occur
996
return null;
997         }
998     }
999
1000    public static ObjectName JavaDoc getJCAManagedConnectionFactory(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pName) {
1001        try {
1002            StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
1003            sb.append(":j2eeType=JCAManagedConnectionFactory");
1004            sb.append(",name=");
1005            sb.append(pName);
1006            sb.append(",J2EEServer=");
1007            sb.append(pServer);
1008            return new ObjectName JavaDoc(sb.toString());
1009        } catch (javax.management.MalformedObjectNameException JavaDoc e) {
1010            // this should never occur
1011
return null;
1012        }
1013    }
1014
1015    public static ObjectName JavaDoc ManagementListener(String JavaDoc pDomain, String JavaDoc pServer) {
1016        try {
1017            StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
1018            sb.append(":type=management,name=managementListener");
1019            sb.append(",J2EEServer=");
1020            sb.append(pServer);
1021            return new ObjectName JavaDoc(sb.toString());
1022        } catch (javax.management.MalformedObjectNameException JavaDoc e) {
1023            // this should never occur
1024
return null;
1025        }
1026    }
1027
1028    public static ObjectName JavaDoc JTAResource(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pName) {
1029        try {
1030            StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
1031            sb.append(":j2eeType=JTAResource");
1032            sb.append(",name=");
1033            sb.append(pName);
1034            sb.append(",J2EEServer=");
1035            sb.append(pServer);
1036            return new ObjectName JavaDoc(sb.toString());
1037        } catch (javax.management.MalformedObjectNameException JavaDoc e) {
1038            // this should never occur
1039
return null;
1040        }
1041    }
1042
1043    /**
1044     * Create ObjectName for a JDBCResource MBean
1045     * @param pDomain domain name
1046     * @param pServer server name
1047     * @param pName MBean name
1048     * @return ObjectName for a JDBCResource MBean
1049     */

1050    public static ObjectName JavaDoc JDBCResource(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pName) {
1051        try {
1052            StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
1053            sb.append(":j2eeType=JDBCResource");
1054            sb.append(",name=");
1055            sb.append(pName);
1056            sb.append(",J2EEServer=");
1057            sb.append(pServer);
1058            return new ObjectName JavaDoc(sb.toString());
1059        } catch (javax.management.MalformedObjectNameException JavaDoc e) {
1060            // this should never occur
1061
return null;
1062        }
1063    }
1064
1065    /**
1066     * Create ObjectName for a JDBCResource MBean using name="JDBCResource"
1067     * @param pDomain
1068     * @param pServer server name
1069     * @return ObjectName for a JDBCResource MBean
1070     */

1071    public static ObjectName JavaDoc JDBCResource(String JavaDoc pDomain, String JavaDoc pServer) {
1072        try {
1073            StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
1074            sb.append(":j2eeType=JDBCResource");
1075            sb.append(",name=");
1076            sb.append("JDBCResource");
1077            sb.append(",J2EEServer=");
1078            sb.append(pServer);
1079            return new ObjectName JavaDoc(sb.toString());
1080        } catch (javax.management.MalformedObjectNameException JavaDoc e) {
1081            // this should never occur
1082
return null;
1083        }
1084    }
1085
1086    /**
1087     * Create ObjectName for a JDBCDataSource MBeans in a JDBCResource named "JDBCResource"
1088     * @param pDomain domain name
1089     * @param pServer server name
1090     * @param pName JDBCDataSource name
1091     * @return ObjectName for a JDBCDataSource MBean
1092     */

1093    public static ObjectName JavaDoc getJDBCDataSource(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pName) {
1094        try {
1095            StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
1096            sb.append(":j2eeType=JDBCDataSource");
1097            sb.append(",name=");
1098            sb.append(pName);
1099            sb.append(",JDBCResource=");
1100            sb.append("JDBCResource");
1101            sb.append(",J2EEServer=");
1102            sb.append(pServer);
1103            return new ObjectName JavaDoc(sb.toString());
1104        } catch (javax.management.MalformedObjectNameException JavaDoc e) {
1105            // this should never occur
1106
return null;
1107        }
1108    }
1109
1110    /**
1111     * @param pDomain domain name
1112     * @param pServer server name
1113     * @return ObjectName for all JDBCDataSource MBeans in the JDBCResource of a given server
1114     */

1115    public static ObjectName JavaDoc getJDBCDataSources(String JavaDoc pDomain, String JavaDoc pServer) {
1116        try {
1117            StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
1118            sb.append(":j2eeType=JDBCDataSource");
1119            sb.append(",JDBCResource=");
1120            sb.append("JDBCResource");
1121            sb.append(",J2EEServer=");
1122            sb.append(pServer);
1123            sb.append(",");
1124            sb.append(ALL);
1125            return new ObjectName JavaDoc(sb.toString());
1126        } catch (javax.management.MalformedObjectNameException JavaDoc e) {
1127            // this should never occur
1128
return null;
1129        }
1130    }
1131
1132    /**
1133     * This method is equivalent with the previous as in a server we currently have a
1134     * sole JDBCResource MBean.
1135     * @param pDomain domain name
1136     * @param pServer server name
1137     * @return ObjectName for all JDBCDataSource MBeans in a given server
1138     */

1139    public static ObjectName JavaDoc JDBCDataSources(String JavaDoc pDomain, String JavaDoc pServer) {
1140        try {
1141            StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
1142            sb.append(":j2eeType=JDBCDataSource");
1143            sb.append(",J2EEServer=");
1144            sb.append(pServer);
1145            sb.append(",");
1146            sb.append(ALL);
1147            return new ObjectName JavaDoc(sb.toString());
1148        } catch (javax.management.MalformedObjectNameException JavaDoc e) {
1149            // this should never occur
1150
return null;
1151        }
1152    }
1153
1154    public static ObjectName JavaDoc JDBCDataSources(String JavaDoc pDomain, String JavaDoc pJDBCResource, String JavaDoc pServer) {
1155        try {
1156            StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
1157            sb.append(":j2eeType=JDBCDataSource");
1158            sb.append(",JDBCResource=");
1159            sb.append(pJDBCResource);
1160            sb.append(",J2EEServer=");
1161            sb.append(pServer);
1162            sb.append(",");
1163            sb.append(ALL);
1164            return new ObjectName JavaDoc(sb.toString());
1165        } catch (javax.management.MalformedObjectNameException JavaDoc e) {
1166            // this should never occur
1167
return null;
1168        }
1169    }
1170
1171    public static ObjectName JavaDoc getJDBCDriver(String JavaDoc pDomain, String JavaDoc pServer, String JavaDoc pName) {
1172        try {
1173            StringBuffer JavaDoc sb = new StringBuffer JavaDoc(pDomain);
1174            sb.append(":j2eeType=JDBCDriver");
1175            sb.append(",name=");
1176            sb.append(pName);
1177            sb.append(",J2EEServer=");
1178            sb.append(pServer);
1179            return new ObjectName JavaDoc(sb.toString());
1180        } catch (javax.management.MalformedObjectNameException JavaDoc e) {
1181            // this should never occur
1182
return null;
1183        }
1184    }
1185
1186}
Popular Tags