author | dfuchs |
Thu, 12 Mar 2009 15:36:14 +0100 | |
changeset 2285 | 37fdbed8178f |
parent 2 | 90ce3da70b43 |
child 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
2 | 1 |
/* |
2 |
* Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
||
26 |
package sun.management; |
|
27 |
||
28 |
import java.io.File; |
|
29 |
import java.io.InputStream; |
|
30 |
import java.io.FileInputStream; |
|
31 |
import java.io.BufferedInputStream; |
|
32 |
import java.io.FileNotFoundException; |
|
33 |
import java.io.IOException; |
|
2285
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
34 |
import java.lang.reflect.InvocationTargetException; |
2 | 35 |
import java.text.MessageFormat; |
36 |
import java.util.Properties; |
|
37 |
import java.util.ResourceBundle; |
|
38 |
import java.util.MissingResourceException; |
|
39 |
import java.lang.management.ManagementFactory; |
|
40 |
import java.lang.reflect.Method; |
|
41 |
||
42 |
import javax.management.remote.JMXConnectorServer; |
|
43 |
||
44 |
import sun.management.jmxremote.ConnectorBootstrap; |
|
45 |
import static sun.management.AgentConfigurationError.*; |
|
46 |
import sun.misc.VMSupport; |
|
47 |
||
48 |
/** |
|
49 |
* This Agent is started by the VM when -Dcom.sun.management.snmp |
|
50 |
* or -Dcom.sun.management.jmxremote is set. This class will be |
|
51 |
* loaded by the system class loader. |
|
52 |
*/ |
|
53 |
public class Agent { |
|
54 |
// management properties |
|
55 |
private static Properties mgmtProps; |
|
56 |
private static ResourceBundle messageRB; |
|
57 |
||
58 |
private static final String CONFIG_FILE = |
|
59 |
"com.sun.management.config.file"; |
|
60 |
private static final String SNMP_PORT = |
|
61 |
"com.sun.management.snmp.port"; |
|
62 |
private static final String JMXREMOTE = |
|
63 |
"com.sun.management.jmxremote"; |
|
64 |
private static final String JMXREMOTE_PORT = |
|
65 |
"com.sun.management.jmxremote.port"; |
|
66 |
private static final String ENABLE_THREAD_CONTENTION_MONITORING = |
|
67 |
"com.sun.management.enableThreadContentionMonitoring"; |
|
68 |
private static final String LOCAL_CONNECTOR_ADDRESS_PROP = |
|
69 |
"com.sun.management.jmxremote.localConnectorAddress"; |
|
70 |
||
2285
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
71 |
private static final String SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME = |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
72 |
"sun.management.snmp.AdaptorBootstrap"; |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
73 |
|
2 | 74 |
// invoked by -javaagent or -Dcom.sun.management.agent.class |
75 |
public static void premain(String args) throws Exception { |
|
76 |
agentmain(args); |
|
77 |
} |
|
78 |
||
79 |
// invoked by attach mechanism |
|
80 |
public static void agentmain(String args) throws Exception { |
|
81 |
if (args == null || args.length() == 0) { |
|
82 |
args = JMXREMOTE; // default to local management |
|
83 |
} |
|
84 |
||
85 |
// Parse agent options into properties |
|
86 |
||
87 |
Properties arg_props = new Properties(); |
|
88 |
if (args != null) { |
|
89 |
String[] options = args.split(","); |
|
90 |
for (int i=0; i<options.length; i++) { |
|
91 |
String[] option = options[i].split("="); |
|
92 |
if (option.length >= 1 && option.length <= 2) { |
|
93 |
String name = option[0]; |
|
94 |
String value = (option.length == 1) ? "" : option[1]; |
|
95 |
if (name != null && name.length() > 0) { |
|
96 |
||
97 |
// Assume that any com.sun.management.* options are okay |
|
98 |
if (name.startsWith("com.sun.management.")) { |
|
99 |
arg_props.setProperty(name, value); |
|
100 |
} else { |
|
101 |
error(INVALID_OPTION, name); |
|
102 |
} |
|
103 |
} |
|
104 |
} |
|
105 |
} |
|
106 |
} |
|
107 |
||
108 |
// Read properties from the config file |
|
109 |
Properties config_props = new Properties(); |
|
110 |
String fname = arg_props.getProperty(CONFIG_FILE); |
|
111 |
readConfiguration(fname, config_props); |
|
112 |
||
113 |
// Arguments override config file |
|
114 |
config_props.putAll(arg_props); |
|
115 |
startAgent(config_props); |
|
116 |
} |
|
117 |
||
118 |
private static void startAgent(Properties props) throws Exception { |
|
119 |
String snmpPort = props.getProperty(SNMP_PORT); |
|
120 |
String jmxremote = props.getProperty(JMXREMOTE); |
|
121 |
String jmxremotePort = props.getProperty(JMXREMOTE_PORT); |
|
122 |
||
123 |
// Enable optional monitoring functionality if requested |
|
124 |
final String enableThreadContentionMonitoring = |
|
125 |
props.getProperty(ENABLE_THREAD_CONTENTION_MONITORING); |
|
126 |
if (enableThreadContentionMonitoring != null) { |
|
127 |
ManagementFactory.getThreadMXBean(). |
|
128 |
setThreadContentionMonitoringEnabled(true); |
|
129 |
} |
|
130 |
||
131 |
try { |
|
132 |
if (snmpPort != null) { |
|
2285
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
133 |
loadSnmpAgent(snmpPort, props); |
2 | 134 |
} |
135 |
||
136 |
/* |
|
137 |
* If the jmxremote.port property is set then we start the |
|
138 |
* RMIConnectorServer for remote M&M. |
|
139 |
* |
|
140 |
* If the jmxremote or jmxremote.port properties are set then |
|
141 |
* we start a RMIConnectorServer for local M&M. The address |
|
142 |
* of this "local" server is exported as a counter to the jstat |
|
143 |
* instrumentation buffer. |
|
144 |
*/ |
|
145 |
if (jmxremote != null || jmxremotePort != null) { |
|
146 |
if (jmxremotePort != null) { |
|
147 |
ConnectorBootstrap.initialize(jmxremotePort, props); |
|
148 |
} |
|
149 |
||
150 |
Properties agentProps = VMSupport.getAgentProperties(); |
|
151 |
// start local connector if not started |
|
152 |
// System.out.println("local address : " + |
|
153 |
// agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP)); |
|
154 |
if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) { |
|
155 |
JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer(); |
|
156 |
String address = cs.getAddress().toString(); |
|
157 |
// Add the local connector address to the agent properties |
|
158 |
agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address); |
|
159 |
||
160 |
try { |
|
161 |
// export the address to the instrumentation buffer |
|
162 |
ConnectorAddressLink.export(address); |
|
163 |
} catch (Exception x) { |
|
164 |
// Connector server started but unable to export address |
|
165 |
// to instrumentation buffer - non-fatal error. |
|
166 |
warning(EXPORT_ADDRESS_FAILED, x.getMessage()); |
|
167 |
} |
|
168 |
} |
|
169 |
} |
|
170 |
} catch (AgentConfigurationError e) { |
|
171 |
error(e.getError(), e.getParams()); |
|
172 |
} catch (Exception e) { |
|
173 |
error(e); |
|
174 |
} |
|
175 |
} |
|
176 |
||
177 |
public static Properties loadManagementProperties() { |
|
178 |
Properties props = new Properties(); |
|
179 |
||
180 |
// Load the management properties from the config file |
|
181 |
||
182 |
String fname = System.getProperty(CONFIG_FILE); |
|
183 |
readConfiguration(fname, props); |
|
184 |
||
185 |
// management properties can be overridden by system properties |
|
186 |
// which take precedence |
|
187 |
props.putAll(System.getProperties()); |
|
188 |
||
189 |
return props; |
|
190 |
} |
|
191 |
||
192 |
public static synchronized Properties getManagementProperties() { |
|
193 |
if (mgmtProps == null) { |
|
194 |
String configFile = System.getProperty(CONFIG_FILE); |
|
195 |
String snmpPort = System.getProperty(SNMP_PORT); |
|
196 |
String jmxremote = System.getProperty(JMXREMOTE); |
|
197 |
String jmxremotePort = System.getProperty(JMXREMOTE_PORT); |
|
198 |
||
199 |
if (configFile == null && snmpPort == null && |
|
200 |
jmxremote == null && jmxremotePort == null) { |
|
201 |
// return if out-of-the-management option is not specified |
|
202 |
return null; |
|
203 |
} |
|
204 |
mgmtProps = loadManagementProperties(); |
|
205 |
} |
|
206 |
return mgmtProps; |
|
207 |
} |
|
208 |
||
2285
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
209 |
private static void loadSnmpAgent(String snmpPort, Properties props) { |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
210 |
try { |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
211 |
// invoke the following through reflection: |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
212 |
// AdaptorBootstrap.initialize(snmpPort, props); |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
213 |
final Class<?> adaptorClass = |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
214 |
Class.forName(SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME,true,null); |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
215 |
final Method initializeMethod = |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
216 |
adaptorClass.getMethod("initialize", |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
217 |
String.class, Properties.class); |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
218 |
initializeMethod.invoke(null,snmpPort,props); |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
219 |
} catch (ClassNotFoundException x) { |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
220 |
// The SNMP packages are not present: throws an exception. |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
221 |
throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x); |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
222 |
} catch (NoSuchMethodException x) { |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
223 |
// should not happen... |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
224 |
throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x); |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
225 |
} catch (InvocationTargetException x) { |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
226 |
final Throwable cause = x.getCause(); |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
227 |
if (cause instanceof RuntimeException) |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
228 |
throw (RuntimeException) cause; |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
229 |
else if (cause instanceof Error) |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
230 |
throw (Error) cause; |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
231 |
// should not happen... |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
232 |
throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,cause); |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
233 |
} catch (IllegalAccessException x) { |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
234 |
// should not happen... |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
235 |
throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x); |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
236 |
} |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
237 |
} |
37fdbed8178f
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents:
2
diff
changeset
|
238 |
|
2 | 239 |
// read config file and initialize the properties |
240 |
private static void readConfiguration(String fname, Properties p) { |
|
241 |
if (fname == null) { |
|
242 |
String home = System.getProperty("java.home"); |
|
243 |
if (home == null) { |
|
244 |
throw new Error("Can't find java.home ??"); |
|
245 |
} |
|
246 |
StringBuffer defaultFileName = new StringBuffer(home); |
|
247 |
defaultFileName.append(File.separator).append("lib"); |
|
248 |
defaultFileName.append(File.separator).append("management"); |
|
249 |
defaultFileName.append(File.separator).append("management.properties"); |
|
250 |
// Set file name |
|
251 |
fname = defaultFileName.toString(); |
|
252 |
} |
|
253 |
final File configFile = new File(fname); |
|
254 |
if (!configFile.exists()) { |
|
255 |
error(CONFIG_FILE_NOT_FOUND, fname); |
|
256 |
} |
|
257 |
||
258 |
InputStream in = null; |
|
259 |
try { |
|
260 |
in = new FileInputStream(configFile); |
|
261 |
BufferedInputStream bin = new BufferedInputStream(in); |
|
262 |
p.load(bin); |
|
263 |
} catch (FileNotFoundException e) { |
|
264 |
error(CONFIG_FILE_OPEN_FAILED, e.getMessage()); |
|
265 |
} catch (IOException e) { |
|
266 |
error(CONFIG_FILE_OPEN_FAILED, e.getMessage()); |
|
267 |
} catch (SecurityException e) { |
|
268 |
error(CONFIG_FILE_ACCESS_DENIED, fname); |
|
269 |
} finally { |
|
270 |
if (in != null) { |
|
271 |
try { |
|
272 |
in.close(); |
|
273 |
} catch (IOException e) { |
|
274 |
error(CONFIG_FILE_CLOSE_FAILED, fname); |
|
275 |
} |
|
276 |
} |
|
277 |
} |
|
278 |
} |
|
279 |
||
280 |
public static void startAgent() throws Exception { |
|
281 |
String prop = System.getProperty("com.sun.management.agent.class"); |
|
282 |
||
283 |
// -Dcom.sun.management.agent.class not set so read management |
|
284 |
// properties and start agent |
|
285 |
if (prop == null) { |
|
286 |
// initialize management properties |
|
287 |
Properties props = getManagementProperties(); |
|
288 |
if (props != null) { |
|
289 |
startAgent(props); |
|
290 |
} |
|
291 |
return; |
|
292 |
} |
|
293 |
||
294 |
// -Dcom.sun.management.agent.class=<agent classname>:<agent args> |
|
295 |
String[] values = prop.split(":"); |
|
296 |
if (values.length < 1 || values.length > 2) { |
|
297 |
error(AGENT_CLASS_INVALID, "\"" + prop + "\""); |
|
298 |
} |
|
299 |
String cname = values[0]; |
|
300 |
String args = (values.length == 2 ? values[1] : null); |
|
301 |
||
302 |
if (cname == null || cname.length() == 0) { |
|
303 |
error(AGENT_CLASS_INVALID, "\"" + prop + "\""); |
|
304 |
} |
|
305 |
||
306 |
if (cname != null) { |
|
307 |
try { |
|
308 |
// Instantiate the named class. |
|
309 |
// invoke the premain(String args) method |
|
310 |
Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(cname); |
|
311 |
Method premain = clz.getMethod("premain", |
|
312 |
new Class[] { String.class }); |
|
313 |
premain.invoke(null, /* static */ |
|
314 |
new Object[] { args }); |
|
315 |
} catch (ClassNotFoundException ex) { |
|
316 |
error(AGENT_CLASS_NOT_FOUND, "\"" + cname + "\""); |
|
317 |
} catch (NoSuchMethodException ex) { |
|
318 |
error(AGENT_CLASS_PREMAIN_NOT_FOUND, "\"" + cname + "\""); |
|
319 |
} catch (SecurityException ex) { |
|
320 |
error(AGENT_CLASS_ACCESS_DENIED); |
|
321 |
} catch (Exception ex) { |
|
322 |
String msg = (ex.getCause() == null |
|
323 |
? ex.getMessage() |
|
324 |
: ex.getCause().getMessage()); |
|
325 |
error(AGENT_CLASS_FAILED, msg); |
|
326 |
} |
|
327 |
} |
|
328 |
} |
|
329 |
||
330 |
public static void error(String key) { |
|
331 |
String keyText = getText(key); |
|
332 |
System.err.print(getText("agent.err.error") + ": " + keyText); |
|
333 |
throw new RuntimeException(keyText); |
|
334 |
} |
|
335 |
||
336 |
public static void error(String key, String[] params) { |
|
337 |
if (params == null || params.length == 0) { |
|
338 |
error(key); |
|
339 |
} else { |
|
340 |
StringBuffer message = new StringBuffer(params[0]); |
|
341 |
for (int i = 1; i < params.length; i++) { |
|
342 |
message.append(" " + params[i]); |
|
343 |
} |
|
344 |
error(key, message.toString()); |
|
345 |
} |
|
346 |
} |
|
347 |
||
348 |
||
349 |
public static void error(String key, String message) { |
|
350 |
String keyText = getText(key); |
|
351 |
System.err.print(getText("agent.err.error") + ": " + keyText); |
|
352 |
System.err.println(": " + message); |
|
353 |
throw new RuntimeException(keyText); |
|
354 |
} |
|
355 |
||
356 |
public static void error(Exception e) { |
|
357 |
e.printStackTrace(); |
|
358 |
System.err.println(getText(AGENT_EXCEPTION) + ": " + e.toString()); |
|
359 |
throw new RuntimeException(e); |
|
360 |
} |
|
361 |
||
362 |
public static void warning(String key, String message) { |
|
363 |
System.err.print(getText("agent.err.warning") + ": " + getText(key)); |
|
364 |
System.err.println(": " + message); |
|
365 |
} |
|
366 |
||
367 |
private static void initResource() { |
|
368 |
try { |
|
369 |
messageRB = |
|
370 |
ResourceBundle.getBundle("sun.management.resources.agent"); |
|
371 |
} catch (MissingResourceException e) { |
|
372 |
throw new Error("Fatal: Resource for management agent is missing"); |
|
373 |
} |
|
374 |
} |
|
375 |
||
376 |
public static String getText(String key) { |
|
377 |
if (messageRB == null) { |
|
378 |
initResource(); |
|
379 |
} |
|
380 |
try { |
|
381 |
return messageRB.getString(key); |
|
382 |
} catch (MissingResourceException e) { |
|
383 |
return "Missing management agent resource bundle: key = \"" + key + "\""; |
|
384 |
} |
|
385 |
} |
|
386 |
||
387 |
public static String getText(String key, String... args) { |
|
388 |
if (messageRB == null) { |
|
389 |
initResource(); |
|
390 |
} |
|
391 |
String format = messageRB.getString(key); |
|
392 |
if (format == null) { |
|
393 |
format = "missing resource key: key = \"" + key + "\", " + |
|
394 |
"arguments = \"{0}\", \"{1}\", \"{2}\""; |
|
395 |
} |
|
396 |
return MessageFormat.format(format, (Object[]) args); |
|
397 |
} |
|
398 |
||
399 |
} |