KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > jbi > management > service > MBeanNamesImpl


1 /**
2  * PETALS: PETALS Services Platform
3  * Copyright (C) 2005 EBM WebSourcing
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA.
19  *
20  * Initial developer(s): EBM WebSourcing
21  * --------------------------------------------------------------------------
22  * $Id: MBeanNamesImpl.java,v 1.2 2005/07/22 10:24:27 alouis Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.petals.jbi.management.service;
27
28 import javax.management.MalformedObjectNameException JavaDoc;
29 import javax.management.ObjectName JavaDoc;
30
31 /**
32  * Implement the JBI <code>MBeanNames</code> element, which is offered to
33  * components for creating mBean names for their optional mBean elements. It
34  * also offers methods to the <code>Manager</code> for creating JBI elements
35  * mBean names (binding and engine components, and system services components).
36  *
37  * @author Adrien LOUIS - EBM WebSourcing
38  */

39 public class MBeanNamesImpl implements javax.jbi.management.MBeanNames {
40
41     private static final String JavaDoc BINDING = "binding";
42
43     private static final String JavaDoc CUSTOM = "custom";
44
45     private static final String JavaDoc ENGINE = "engine";
46
47     private static final String JavaDoc INSTALLER = "installer";
48
49     private static final String JavaDoc SYSTEM = "system";
50
51     private String JavaDoc domain;
52
53     /**
54      * Constructs the MBeanNames with the specified domain name. This domain
55      * name will be used for creating mBean names.
56      *
57      * @param domain
58      */

59     public MBeanNamesImpl(String JavaDoc domain) {
60         this.domain = domain;
61     }
62
63     public ObjectName JavaDoc createBindingComponentMBeanName(String JavaDoc name) {
64         return createMBeanName(name, BINDING);
65     }
66
67     /**
68      * @see javax.jbi.management.MBeanNames#createCustomComponentMBeanName(String
69      * customName)
70      */

71     public ObjectName JavaDoc createCustomComponentMBeanName(String JavaDoc customName) {
72         return createMBeanName(customName, CUSTOM);
73     }
74
75     // ////////////////////
76
// non jbi
77
// ////////////////////
78

79     public ObjectName JavaDoc createEngineComponentMBeanName(String JavaDoc name) {
80         return createMBeanName(name, ENGINE);
81     }
82
83     public ObjectName JavaDoc createInstallerMBeanName(String JavaDoc name) {
84         return createMBeanName(name, INSTALLER);
85     }
86
87     protected ObjectName JavaDoc createMBeanName(String JavaDoc name, String JavaDoc type) {
88         ObjectName JavaDoc on = null;
89         String JavaDoc theType = type != null ? "type=" + type + "," : "";
90         String JavaDoc theName = "name=" + name;
91
92         try {
93             on = new ObjectName JavaDoc(domain + ":" + theType + theName);
94         } catch (MalformedObjectNameException JavaDoc e) {
95             throw new RuntimeException JavaDoc(e);
96             // internal use, so exeception should never be thrown
97
}
98         return on;
99     }
100
101     public ObjectName JavaDoc createSystemComponentMBeanName(String JavaDoc name) {
102         return createMBeanName(name, SYSTEM);
103     }
104
105     /**
106      * @see javax.jbi.management.MBeanNames#getJmxDomainName()
107      */

108     public String JavaDoc getJmxDomainName() {
109         return domain;
110     }
111 }
112
Popular Tags