KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 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: JonasManagementRepr.java,v 1.7 2005/06/22 22:27:40 vivekl Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jmx;
27
28 import java.util.Set JavaDoc;
29 import java.util.Properties JavaDoc;
30 import javax.naming.Context JavaDoc;
31 import javax.management.AttributeList JavaDoc;
32 import javax.management.ObjectName JavaDoc;
33 import javax.management.MBeanInfo JavaDoc;
34
35 /**
36  * Wraper class. Apply the management operations on the ManagementRep instance.
37  * @author Adriana Danes
38  */

39 public class JonasManagementRepr {
40
41     /**
42      * Using getManagementRepr() without parameters makes creating a ManagemenrReprImpl
43      * object (an "old" style representant which uses proprietary RMIConnector object)
44      */

45     //private static ManagementRepr repr = ManagementReprFactory.getManagementRepr();
46
// Let repr null and then use setRepr method, will allow to set/change representative
47
// in order to set/change the managed server.
48
private static ManagementRepr repr = null;
49
50     /**
51      * Test if repr null. This means that the ManagementRepFactory did not managed to instantiate the ManagementRep class.
52      * @return true if ManagementRep not null
53      */

54     public static boolean reprNull() {
55         if (repr == null) {
56             return true;
57         } else {
58             return false;
59         }
60     }
61     /**
62      * @return True if the MBean is already registered in the MBean server, false otherwise or if an exception is catched.
63      * @param on ObjectName of the MBean we are looking for
64      */

65     public static boolean isRegistered(ObjectName JavaDoc on) {
66         return repr.isRegistered(on);
67     }
68
69     /**
70      * @param on The ObjectName of the MBean from which the attribute is to be retrieved.
71      * @param attribute A String specifying the name of the attribute to be retrieve.
72      * @return The value of the attribute.
73      */

74     public static Object JavaDoc getAttribute(ObjectName JavaDoc on, String JavaDoc attribute)
75         throws ManagementException
76     {
77         return repr.getAttribute(on, attribute);
78     }
79
80     /**
81      * @param on The ObjectName of the MBean from which the attributes are to be retrieved.
82      * @param attributes A String array specifying the names of the attributes to be retrieved.
83      * @return The value of the attributes.
84      */

85     public static AttributeList JavaDoc getAttributes(ObjectName JavaDoc on, String JavaDoc[] attributes)
86         throws ManagementException
87     {
88         return repr.getAttributes(on, attributes);
89     }
90
91     /**
92      * @param on The ObjectName of the MBean within which the attribute is to be set.
93      * @param attribute A String specifying the name of the attribute to be retrieve.
94      * @param value The value to set to the attribute.
95      */

96     public static void setAttribute(ObjectName JavaDoc on, String JavaDoc attribute, Object JavaDoc value)
97         throws ManagementException
98     {
99         repr.setAttribute(on, attribute, value);
100     }
101
102     /**
103      * @param on
104      */

105     public static Object JavaDoc invoke(ObjectName JavaDoc on, String JavaDoc operation, Object JavaDoc[] param, String JavaDoc[] signature)
106         throws ManagementException
107     {
108         return repr.invoke(on, operation, param, signature);
109     }
110
111     /**
112      * @return A set containing the ObjectNames for the MBeans selected.
113      */

114     public static java.util.Set JavaDoc queryNames(ObjectName JavaDoc on) throws ManagementException
115     {
116         return repr.queryNames(on);
117     }
118
119     /**
120      * @return An instance of MBeanInfo allowing the retrieval of all
121      * attributes and operations of this MBean.
122      */

123     public static MBeanInfo JavaDoc getMBeanInfo(ObjectName JavaDoc name) throws ManagementException {
124         return (MBeanInfo JavaDoc)repr.getMBeanInfo(name);
125     }
126
127     /**
128      * @return Context the current application context.
129      */

130     public static Context JavaDoc getContext() throws javax.naming.NamingException JavaDoc {
131         return repr.getContext();
132     }
133     /**
134      * @return String the name of the current RMI connector.
135      * Return null if no RMI connector is available.
136      */

137     public static String JavaDoc getCurrentRMIConnectorName() {
138         return repr.getCurrentRMIConnectorName();
139     }
140     /**
141      * Set the currentRMIConnectorName to the specified value
142      */

143     public static void setCurrentRMIConnectorName(String JavaDoc name) throws Exception JavaDoc {
144         repr.setCurrentRMIConnectorName(name);
145     }
146     /**
147      * Set the currentRMIConnectorName to null
148      */

149     public static void resetCurrentRMIConnectorName() {
150         repr.resetCurrentRMIConnectorName();
151     }
152     /**
153      * @return Set a set containning all RMI connector names available in the current context.
154      */

155     public static Set JavaDoc getRMIConnectorsNames() throws javax.naming.NamingException JavaDoc {
156         return repr.getRMIConnectorsNames();
157     }
158     /**
159      * @return String the value of the PROVIDER_URL property in the current context.
160      */

161     public static String JavaDoc getJonasNamingServiceURL() {
162         return repr.getJonasNamingServiceURL();
163     }
164     /**
165      * Sets the PROVIDER_URL property to the specified value.
166      */

167     public static void setJonasNamingServiceURL(String JavaDoc url) throws javax.naming.NamingException JavaDoc {
168         repr.setJonasNamingServiceURL(url);
169     }
170
171     /**
172      * Create a new naming context based on the given env. properties
173      * @param env properties to create a new naming context
174      */

175     public static void setNamingEnvCtx(Properties JavaDoc env) throws javax.naming.NamingException JavaDoc {
176         repr.setNamingEnvCtx(env);
177     }
178
179     /**
180      * @return Returns the repr.
181      */

182     public static ManagementRepr getRepr() {
183         return repr;
184     }
185
186     /**
187      * @param repr The repr to set.
188      */

189     public static void setRepr(ManagementRepr repr) {
190         JonasManagementRepr.repr = repr;
191     }
192 }
193
Popular Tags