J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2003-2004 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 java.lang.management; |
| 27 | |
| 28 | /** |
| 29 | * The management interface for the runtime system of |
| 30 | * the Java virtual machine. |
| 31 | * |
| 32 | * <p> A Java virtual machine has a single instance of the implementation |
| 33 | * class of this interface. This instance implementing this interface is |
| 34 | * an <a href="ManagementFactory.html#MXBean">MXBean</a> |
| 35 | * that can be obtained by calling |
| 36 | * the {@link ManagementFactory#getRuntimeMXBean} method or |
| 37 | * from the {@link ManagementFactory#getPlatformMBeanServer |
| 38 | * platform <tt>MBeanServer</tt>} method. |
| 39 | * |
| 40 | * <p>The <tt>ObjectName</tt> for uniquely identifying the MXBean for |
| 41 | * the runtime system within an MBeanServer is: |
| 42 | * <blockquote> |
| 43 | * {@link ManagementFactory#RUNTIME_MXBEAN_NAME |
| 44 | * <tt>java.lang:type=Runtime</tt>} |
| 45 | * </blockquote> |
| 46 | * |
| 47 | * <p> This interface defines several convenient methods for accessing |
| 48 | * system properties about the Java virtual machine. |
| 49 | * |
| 50 | * @see <a href="../../../javax/management/package-summary.html"> |
| 51 | * JMX Specification.</a> |
| 52 | * @see <a href="package-summary.html#examples"> |
| 53 | * Ways to Access MXBeans</a> |
| 54 | * |
| 55 | * @author Mandy Chung |
| 56 | * @since 1.5 |
| 57 | */ |
| 58 | public interface RuntimeMXBean { |
| 59 | /** |
| 60 | * Returns the name representing the running Java virtual machine. |
| 61 | * The returned name string can be any arbitrary string and |
| 62 | * a Java virtual machine implementation can choose |
| 63 | * to embed platform-specific useful information in the |
| 64 | * returned name string. Each running virtual machine could have |
| 65 | * a different name. |
| 66 | * |
| 67 | * @return the name representing the running Java virtual machine. |
| 68 | */ |
| 69 | public String getName(); |
| 70 | |
| 71 | /** |
| 72 | * Returns the Java virtual machine implementation name. |
| 73 | * This method is equivalent to {@link System#getProperty |
| 74 | * System.getProperty("java.vm.name")}. |
| 75 | * |
| 76 | * @return the Java virtual machine implementation name. |
| 77 | * |
| 78 | * @throws java.lang.SecurityException |
| 79 | * if a security manager exists and its |
| 80 | * <code>checkPropertiesAccess</code> method doesn't allow access |
| 81 | * to this system property. |
| 82 | * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String) |
| 83 | * @see java.lang.System#getProperty |
| 84 | */ |
| 85 | public String getVmName(); |
| 86 | |
| 87 | /** |
| 88 | * Returns the Java virtual machine implementation vendor. |
| 89 | * This method is equivalent to {@link System#getProperty |
| 90 | * System.getProperty("java.vm.vendor")}. |
| 91 | * |
| 92 | * @return the Java virtual machine implementation vendor. |
| 93 | * |
| 94 | * @throws java.lang.SecurityException |
| 95 | * if a security manager exists and its |
| 96 | * <code>checkPropertiesAccess</code> method doesn't allow access |
| 97 | * to this system property. |
| 98 | * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String) |
| 99 | * @see java.lang.System#getProperty |
| 100 | */ |
| 101 | public String getVmVendor(); |
| 102 | |
| 103 | /** |
| 104 | * Returns the Java virtual machine implementation version. |
| 105 | * This method is equivalent to {@link System#getProperty |
| 106 | * System.getProperty("java.vm.version")}. |
| 107 | * |
| 108 | * @return the Java virtual machine implementation version. |
| 109 | * |
| 110 | * @throws java.lang.SecurityException |
| 111 | * if a security manager exists and its |
| 112 | * <code>checkPropertiesAccess</code> method doesn't allow access |
| 113 | * to this system property. |
| 114 | * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String) |
| 115 | * @see java.lang.System#getProperty |
| 116 | */ |
| 117 | public String getVmVersion(); |
| 118 | |
| 119 | /** |
| 120 | * Returns the Java virtual machine specification name. |
| 121 | * This method is equivalent to {@link System#getProperty |
| 122 | * System.getProperty("java.vm.specification.name")}. |
| 123 | * |
| 124 | * @return the Java virtual machine specification name. |
| 125 | * |
| 126 | * @throws java.lang.SecurityException |
| 127 | * if a security manager exists and its |
| 128 | * <code>checkPropertiesAccess</code> method doesn't allow access |
| 129 | * to this system property. |
| 130 | * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String) |
| 131 | * @see java.lang.System#getProperty |
| 132 | */ |
| 133 | public String getSpecName(); |
| 134 | |
| 135 | /** |
| 136 | * Returns the Java virtual machine specification vendor. |
| 137 | * This method is equivalent to {@link System#getProperty |
| 138 | * System.getProperty("java.vm.specification.vendor")}. |
| 139 | * |
| 140 | * @return the Java virtual machine specification vendor. |
| 141 | * |
| 142 | * @throws java.lang.SecurityException |
| 143 | * if a security manager exists and its |
| 144 | * <code>checkPropertiesAccess</code> method doesn't allow access |
| 145 | * to this system property. |
| 146 | * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String) |
| 147 | * @see java.lang.System#getProperty |
| 148 | */ |
| 149 | public String getSpecVendor(); |
| 150 | |
| 151 | /** |
| 152 | * Returns the Java virtual machine specification version. |
| 153 | * This method is equivalent to {@link System#getProperty |
| 154 | * System.getProperty("java.vm.specification.version")}. |
| 155 | * |
| 156 | * @return the Java virtual machine specification version. |
| 157 | * |
| 158 | * @throws java.lang.SecurityException |
| 159 | * if a security manager exists and its |
| 160 | * <code>checkPropertiesAccess</code> method doesn't allow access |
| 161 | * to this system property. |
| 162 | * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String) |
| 163 | * @see java.lang.System#getProperty |
| 164 | */ |
| 165 | public String getSpecVersion(); |
| 166 | |
| 167 | |
| 168 | /** |
| 169 | * Returns the version of the specification for the management interface |
| 170 | * implemented by the running Java virtual machine. |
| 171 | * |
| 172 | * @return the version of the specification for the management interface |
| 173 | * implemented by the running Java virtual machine. |
| 174 | */ |
| 175 | public String getManagementSpecVersion(); |
| 176 | |
| 177 | /** |
| 178 | * Returns the Java class path that is used by the system class loader |
| 179 | * to search for class files. |
| 180 | * This method is equivalent to {@link System#getProperty |
| 181 | * System.getProperty("java.class.path")}. |
| 182 | * |
| 183 | * <p> Multiple paths in the Java class path are separated by the |
| 184 | * path separator character of the platform of the Java virtual machine |
| 185 | * being monitored. |
| 186 | * |
| 187 | * @return the Java class path. |
| 188 | * |
| 189 | * @throws java.lang.SecurityException |
| 190 | * if a security manager exists and its |
| 191 | * <code>checkPropertiesAccess</code> method doesn't allow access |
| 192 | * to this system property. |
| 193 | * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String) |
| 194 | * @see java.lang.System#getProperty |
| 195 | */ |
| 196 | public String getClassPath(); |
| 197 | |
| 198 | /** |
| 199 | * Returns the Java library path. |
| 200 | * This method is equivalent to {@link System#getProperty |
| 201 | * System.getProperty("java.library.path")}. |
| 202 | * |
| 203 | * <p> Multiple paths in the Java library path are separated by the |
| 204 | * path separator character of the platform of the Java virtual machine |
| 205 | * being monitored. |
| 206 | * |
| 207 | * @return the Java library path. |
| 208 | * |
| 209 | * @throws java.lang.SecurityException |
| 210 | * if a security manager exists and its |
| 211 | * <code>checkPropertiesAccess</code> method doesn't allow access |
| 212 | * to this system property. |
| 213 | * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String) |
| 214 | * @see java.lang.System#getProperty |
| 215 | */ |
| 216 | public String getLibraryPath(); |
| 217 | |
| 218 | /** |
| 219 | * Tests if the Java virtual machine supports the boot class path |
| 220 | * mechanism used by the bootstrap class loader to search for class |
| 221 | * files. |
| 222 | * |
| 223 | * @return <tt>true</tt> if the Java virtual machine supports the |
| 224 | * class path mechanism; <tt>false</tt> otherwise. |
| 225 | */ |
| 226 | public boolean isBootClassPathSupported(); |
| 227 | |
| 228 | /** |
| 229 | * Returns the boot class path that is used by the bootstrap class loader |
| 230 | * to search for class files. |
| 231 | * |
| 232 | * <p> Multiple paths in the boot class path are separated by the |
| 233 | * path separator character of the platform on which the Java |
| 234 | * virtual machine is running. |
| 235 | * |
| 236 | * <p>A Java virtual machine implementation may not support |
| 237 | * the boot class path mechanism for the bootstrap class loader |
| 238 | * to search for class files. |
| 239 | * The {@link #isBootClassPathSupported} method can be used |
| 240 | * to determine if the Java virtual machine supports this method. |
| 241 | * |
| 242 | * @return the boot class path. |
| 243 | * |
| 244 | * @throws java.lang.UnsupportedOperationException |
| 245 | * if the Java virtual machine does not support this operation. |
| 246 | * |
| 247 | * @throws java.lang.SecurityException |
| 248 | * if a security manager exists and the caller does not have |
| 249 | * ManagementPermission("monitor"). |
| 250 | */ |
| 251 | public String getBootClassPath(); |
| 252 | |
| 253 | /** |
| 254 | * Returns the input arguments passed to the Java virtual machine |
| 255 | * which does not include the arguments to the <tt>main</tt> method. |
| 256 | * This method returns an empty list if there is no input argument |
| 257 | * to the Java virtual machine. |
| 258 | * <p> |
| 259 | * Some Java virtual machine implementations may take input arguments |
| 260 | * from multiple different sources: for examples, arguments passed from |
| 261 | * the application that launches the Java virtual machine such as |
| 262 | * the 'java' command, environment variables, configuration files, etc. |
| 263 | * <p> |
| 264 | * Typically, not all command-line options to the 'java' command |
| 265 | * are passed to the Java virtual machine. |
| 266 | * Thus, the returned input arguments may not |
| 267 | * include all command-line options. |
| 268 | * |
| 269 | * <p> |
| 270 | * <b>MBeanServer access</b>:<br> |
| 271 | * The mapped type of <tt>List<String></tt> is <tt>String[]</tt>. |
| 272 | * |
| 273 | * @return a list of <tt>String</tt> objects; each element |
| 274 | * is an argument passed to the Java virtual machine. |
| 275 | * |
| 276 | * @throws java.lang.SecurityException |
| 277 | * if a security manager exists and the caller does not have |
| 278 | * ManagementPermission("monitor"). |
| 279 | */ |
| 280 | public java.util.List<String> getInputArguments(); |
| 281 | |
| 282 | /** |
| 283 | * Returns the uptime of the Java virtual machine in milliseconds. |
| 284 | * |
| 285 | * @return uptime of the Java virtual machine in milliseconds. |
| 286 | */ |
| 287 | public long getUptime(); |
| 288 | |
| 289 | /** |
| 290 | * Returns the start time of the Java virtual machine in milliseconds. |
| 291 | * This method returns the approximate time when the Java virtual |
| 292 | * machine started. |
| 293 | * |
| 294 | * @return start time of the Java virtual machine in milliseconds. |
| 295 | * |
| 296 | */ |
| 297 | public long getStartTime(); |
| 298 | |
| 299 | /** |
| 300 | * Returns a map of names and values of all system properties. |
| 301 | * This method calls {@link System#getProperties} to get all |
| 302 | * system properties. Properties whose name or value is not |
| 303 | * a <tt>String</tt> are omitted. |
| 304 | * |
| 305 | * <p> |
| 306 | * <b>MBeanServer access</b>:<br> |
| 307 | * The mapped type of <tt>Map<String,String></tt> is |
| 308 | * {@link javax.management.openmbean.TabularData TabularData} |
| 309 | * with two items in each row as follows: |
| 310 | * <blockquote> |
| 311 | * <table border> |
| 312 | * <tr> |
| 313 | * <th>Item Name</th> |
| 314 | * <th>Item Type</th> |
| 315 | * </tr> |
| 316 | * <tr> |
| 317 | * <td><tt>key</tt></td> |
| 318 | * <td><tt>String</tt></td> |
| 319 | * </tr> |
| 320 | * <tr> |
| 321 | * <td><tt>value</tt></td> |
| 322 | * <td><tt>String</tt></td> |
| 323 | * </tr> |
| 324 | * </table> |
| 325 | * </blockquote> |
| 326 | * |
| 327 | * @return a map of names and values of all system properties. |
| 328 | * |
| 329 | * @throws java.lang.SecurityException |
| 330 | * if a security manager exists and its |
| 331 | * <code>checkPropertiesAccess</code> method doesn't allow access |
| 332 | * to the system properties. |
| 333 | */ |
| 334 | public java.util.Map<String, String> getSystemProperties(); |
| 335 | } |