1 /*
   2  * Copyright (c) 2003, 2008, Oracle and/or its affiliates. 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.lang.management;
  27 
  28 /**
  29  * The management interface for the operating system on which
  30  * the Java virtual machine is running.
  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#getOperatingSystemMXBean} method or
  37  * from the {@link ManagementFactory#getPlatformMBeanServer
  38  * platform MBeanServer} method.
  39  *
  40  * <p>The {@code ObjectName} for uniquely identifying the MXBean for
  41  * the operating system within an MBeanServer is:
  42  * <blockquote>
  43  *    {@link ManagementFactory#OPERATING_SYSTEM_MXBEAN_NAME
  44  *      java.lang:type=OperatingSystem}
  45  * </blockquote>
  46  *
  47  * It can be obtained by calling the
  48  * {@link PlatformManagedObject#getObjectName} method.
  49  *
  50  * <p> This interface defines several convenient methods for accessing
  51  * system properties about the operating system on which the Java
  52  * virtual machine is running.
  53  *
  54  * @see ManagementFactory#getPlatformMXBeans(Class)
  55  * @see <a href="../../../javax/management/package-summary.html">
  56  *      JMX Specification.</a>
  57  * @see <a href="package-summary.html#examples">
  58  *      Ways to Access MXBeans</a>
  59  *
  60  * @author  Mandy Chung
  61  * @since   1.5
  62  */
  63 public interface OperatingSystemMXBean extends PlatformManagedObject {
  64     /**
  65      * Returns the operating system name.
  66      * This method is equivalent to {@code System.getProperty("os.name")}.
  67      *
  68      * @return the operating system name.
  69      *
  70      * @throws  java.lang.SecurityException
  71      *     if a security manager exists and its
  72      *     <code>checkPropertiesAccess</code> method doesn't allow access
  73      *     to this system property.
  74      * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
  75      * @see java.lang.System#getProperty
  76      */
  77     public String getName();
  78 
  79     /**
  80      * Returns the operating system architecture.
  81      * This method is equivalent to {@code System.getProperty("os.arch")}.
  82      *
  83      * @return the operating system architecture.
  84      *
  85      * @throws  java.lang.SecurityException
  86      *     if a security manager exists and its
  87      *     <code>checkPropertiesAccess</code> method doesn't allow access
  88      *     to this system property.
  89      * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
  90      * @see java.lang.System#getProperty
  91      */
  92     public String getArch();
  93 
  94     /**
  95      * Returns the operating system version.
  96      * This method is equivalent to {@code System.getProperty("os.version")}.
  97      *
  98      * @return the operating system version.
  99      *
 100      * @throws  java.lang.SecurityException
 101      *     if a security manager exists and its
 102      *     <code>checkPropertiesAccess</code> method doesn't allow access
 103      *     to this system property.
 104      * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
 105      * @see java.lang.System#getProperty
 106      */
 107     public String getVersion();
 108 
 109     /**
 110      * Returns the number of processors available to the Java virtual machine.
 111      * This method is equivalent to the {@link Runtime#availableProcessors()}
 112      * method.
 113      * <p> This value may change during a particular invocation of
 114      * the virtual machine.
 115      *
 116      * @return  the number of processors available to the virtual
 117      *          machine; never smaller than one.
 118      */
 119     public int getAvailableProcessors();
 120 
 121     /**
 122      * Returns the system load average for the last minute.
 123      * The system load average is the sum of the number of runnable entities
 124      * queued to the {@linkplain #getAvailableProcessors available processors}
 125      * and the number of runnable entities running on the available processors
 126      * averaged over a period of time.
 127      * The way in which the load average is calculated is operating system
 128      * specific but is typically a damped time-dependent average.
 129      * <p>
 130      * If the load average is not available, a negative value is returned.
 131      * <p>
 132      * This method is designed to provide a hint about the system load
 133      * and may be queried frequently.
 134      * The load average may be unavailable on some platform where it is
 135      * expensive to implement this method.
 136      *
 137      * @return the system load average; or a negative value if not available.
 138      *
 139      * @since 1.6
 140      */
 141     public double getSystemLoadAverage();
 142 }