src/java.management/share/classes/java/lang/management/package.html
author psadhukhan
Tue, 18 Sep 2018 18:12:40 +0530
changeset 51927 c88fd713b51c
parent 47216 71c04702a3d5
child 52469 190b77982361
permissions -rw-r--r--
8191178: [macos] Problem with input of yen symbol Reviewed-by: dmarkov, mhalder
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1935
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
     1
<!--
45138
ddcafe0d0ea3 8180082: Broken javadoc links
rriggs
parents: 44858
diff changeset
     2
 Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
1935
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
     3
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
     4
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
     5
 This code is free software; you can redistribute it and/or modify it
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
     6
 under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1935
diff changeset
     7
 published by the Free Software Foundation.  Oracle designates this
1935
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
     8
 particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1935
diff changeset
     9
 by Oracle in the LICENSE file that accompanied this code.
1935
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
    10
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
    11
 This code is distributed in the hope that it will be useful, but WITHOUT
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
    12
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
    13
 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
    14
 version 2 for more details (a copy is included in the LICENSE file that
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
    15
 accompanied this code).
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
    16
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
    17
 You should have received a copy of the GNU General Public License version
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
    18
 2 along with this work; if not, write to the Free Software Foundation,
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
    19
 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
    20
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1935
diff changeset
    21
 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1935
diff changeset
    22
 or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1935
diff changeset
    23
 questions.
1935
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
    24
-->
4010e03f8c1c 6719182: update legal notice in java/lang/instrument/package.html
darcy
parents: 2
diff changeset
    25
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
<html>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
<body bgcolor="white">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    30
Provides the management interfaces for monitoring and management of the
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    31
Java virtual machine and other components in the Java runtime.
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    32
It allows both local and remote
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    33
monitoring and management of the running Java virtual machine.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
44858
7183899b064b 8179415: Update java.management and java.management.rmi to be HTML-5 friendly
ksrini
parents: 32034
diff changeset
    35
<h3><a id="MXBean">Platform MXBean</a></h3>
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    36
<p>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    37
A platform MXBean is a <i>managed bean</i> that
45138
ddcafe0d0ea3 8180082: Broken javadoc links
rriggs
parents: 44858
diff changeset
    38
conforms to the {@linkplain javax.management JMX}
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    39
Instrumentation Specification and only uses a set of basic data types.
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    40
Each platform MXBean is a {@link java.lang.management.PlatformManagedObject}
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    41
with a unique
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    42
{@linkplain java.lang.management.PlatformManagedObject#getObjectName name}.
44858
7183899b064b 8179415: Update java.management and java.management.rmi to be HTML-5 friendly
ksrini
parents: 32034
diff changeset
    43
<h3>ManagementFactory</h3>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    45
<p>The {@link java.lang.management.ManagementFactory} class is the management
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    46
factory class for the Java platform.  This class provides a set of
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    47
static factory methods to obtain the MXBeans for the Java platform
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    48
to allow an application to access the MXBeans directly.
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    49
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    50
<p>A <em>platform MBeanServer</em> can be accessed with the
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    51
{@link java.lang.management.ManagementFactory#getPlatformMBeanServer
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    52
 getPlatformMBeanServer} method.  On the first call to this method,
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    53
it creates the platform MBeanServer and registers all platform MXBeans
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    54
including {@linkplain java.lang.management.PlatformManagedObject
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    55
platform MXBeans}.
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    56
Each platform MXBean is registered with a unique name defined in
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    57
the specification of the management interface.
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    58
This is a single MBeanServer that can be shared by different managed
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    59
components running within the same Java virtual machine.
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    60
44858
7183899b064b 8179415: Update java.management and java.management.rmi to be HTML-5 friendly
ksrini
parents: 32034
diff changeset
    61
<h3>Interoperability</h3>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    63
<p>A management application and a platform MBeanServer of a running
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    64
virtual machine can interoperate
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    65
without requiring classes used by the platform MXBean interfaces.
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    66
The data types being transmitted between the JMX connector
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    67
server and the connector client are JMX
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    68
{@linkplain javax.management.openmbean.OpenType open types} and
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    69
this allows interoperation across versions.
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    70
A data type used by the MXBean interfaces are mapped to an
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    71
open type when being accessed via MBeanServer interface.
45138
ddcafe0d0ea3 8180082: Broken javadoc links
rriggs
parents: 44858
diff changeset
    72
See the <a href="{@docRoot}/javax/management/MXBean.html#MXBean-spec">
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    73
MXBean</a> specification for details.
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    74
44858
7183899b064b 8179415: Update java.management and java.management.rmi to be HTML-5 friendly
ksrini
parents: 32034
diff changeset
    75
<h3><a id="examples">Ways to Access MXBeans</a></h3>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    77
<p>An application can monitor the instrumentation of the
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    78
Java virtual machine and the runtime in the following ways:
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    79
<p>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    80
<b>1. Direct access to an MXBean interface</b>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    81
<ul>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    82
<li>Get an MXBean instance locally in the running Java virtual machine:
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    83
<pre>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    84
   RuntimeMXBean mxbean = ManagementFactory.getRuntimeMXBean();
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    85
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    86
   // Get the standard attribute "VmVendor"
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    87
   String vendor = mxbean.getVmVendor();
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    88
</pre>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    89
<p>Or by calling the
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    90
        {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    91
               getPlatformMXBean} or
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    92
        {@link java.lang.management.ManagementFactory#getPlatformMXBeans(Class)
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    93
               getPlatformMXBeans} method:
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    94
<pre>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    95
   RuntimeMXBean mxbean = ManagementFactory.getPlatformMXBean(RuntimeMXBean.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    97
   // Get the standard attribute "VmVendor"
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    98
   String vendor = mxbean.getVmVendor();
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
    99
</pre>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   100
</li>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   101
<li>Construct an MXBean proxy instance that forwards the
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   102
    method calls to a given MBeanServer:
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   103
<pre>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   104
   MBeanServerConnection mbs;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   106
   // Connect to a running JVM (or itself) and get MBeanServerConnection
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   107
   // that has the JVM MBeans registered in it
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   108
   ...
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   110
   // Get a MBean proxy for RuntimeMXBean interface
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   111
   RuntimeMXBean proxy =
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   112
       {@link java.lang.management.ManagementFactory#getPlatformMXBean(MBeanServerConnection, Class)
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   113
       ManagementFactory.getPlatformMXBean}(mbs,
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   114
                                           RuntimeMXBean.class);
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   115
   // Get standard attribute "VmVendor"
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   116
   String vendor = proxy.getVmVendor();
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   117
</pre>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   118
<p>A proxy is typically used to access an MXBean
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   119
   in a remote Java virtual machine.
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   120
   An alternative way to create an MXBean proxy is:
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   121
<pre>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   122
   RuntimeMXBean proxy =
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   123
       {@link java.lang.management.ManagementFactory#newPlatformMXBeanProxy
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   124
              ManagementFactory.newPlatformMXBeanProxy}(mbs,
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   125
                                                ManagementFactory.RUNTIME_MXBEAN_NAME,
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   126
                                                RuntimeMXBean.class);
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   127
</pre>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   128
</li>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   129
</ul>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   130
<p>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   131
<b>2. Indirect access to an MXBean interface via MBeanServer</b>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   132
<ul>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   133
<li>Go through the
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   134
    {@link java.lang.management.ManagementFactory#getPlatformMBeanServer
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   135
    platform MBeanServer} to access MXBeans locally or
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   136
    a specific {@code MBeanServerConnection} to access
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   137
    MXBeans remotely.
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   138
    The attributes and operations of an MXBean use only
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   139
    <em>JMX open types</em> which include basic data types,
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   140
    {@link javax.management.openmbean.CompositeData CompositeData},
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   141
    and {@link javax.management.openmbean.TabularData TabularData}
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   142
    defined in {@link javax.management.openmbean.OpenType OpenType}.
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   143
<pre>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   144
   MBeanServerConnection mbs;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   146
   // Connect to a running JVM (or itself) and get MBeanServerConnection
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   147
   // that has the JVM MXBeans registered in it
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   148
   ...
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   149
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   150
   try {
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   151
       // Assuming the RuntimeMXBean has been registered in mbs
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   152
       ObjectName oname = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   154
       // Get standard attribute "VmVendor"
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   155
       String vendor = (String) mbs.getAttribute(oname, "VmVendor");
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   156
   } catch (....) {
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   157
       // Catch the exceptions thrown by ObjectName constructor
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   158
       // and MBeanServer.getAttribute method
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   159
       ...
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   160
   }
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   161
</pre>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   162
</li>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   163
</ul>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
44858
7183899b064b 8179415: Update java.management and java.management.rmi to be HTML-5 friendly
ksrini
parents: 32034
diff changeset
   166
<h3><a id="extension">Platform Extension</a></h3>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   168
<p>A Java virtual machine implementation may add its platform extension to
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   169
the management interface by defining platform-dependent
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   170
interfaces that extend the standard management interfaces to include
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   171
platform-specific metrics and management operations.
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   172
The static factory methods in the <code>ManagementFactory</code> class will
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   173
return the MXBeans with the platform extension.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
<p>
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   176
It is recommended to name the platform-specific attributes with
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   177
a vendor-specific prefix such as the vendor's name to
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   178
avoid collisions of the attribute name between the future extension
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   179
to the standard management interface and the platform extension.
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   180
If the future extension to the standard management interface defines
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   181
a new attribute for a management interface and the attribute name
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   182
is happened to be same as some vendor-specific attribute's name,
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   183
the applications accessing that vendor-specific attribute would have
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   184
to be modified to cope with versioning and compatibility issues.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   186
<p>Below is an example showing how to access an attribute
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   187
from the platform extension:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   189
<p>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   190
1) Direct access to the Oracle-specific MXBean interface
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
<blockquote>
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   192
<pre>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   193
   List&lt;com.sun.management.GarbageCollectorMXBean&gt; mxbeans =
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   194
       ManagementFactory.getPlatformMXBeans(com.sun.management.GarbageCollectorMXBean.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   196
   for (com.sun.management.GarbageCollectorMXBean gc : mxbeans) {
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   197
       // Get the standard attribute "CollectionCount"
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   198
       String count = mxbean.getCollectionCount();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   200
       // Get the platform-specific attribute "LastGcInfo"
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   201
       GcInfo gcinfo = gc.getLastGcInfo();
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   202
       ...
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   203
   }
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   204
</pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
</blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   207
<p>
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   208
2) Access the Oracle-specific MXBean interface via <code>MBeanServer</code>
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   209
   through proxy
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   211
<blockquote><pre>
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   212
   MBeanServerConnection mbs;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   214
   // Connect to a running JVM (or itself) and get MBeanServerConnection
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   215
   // that has the JVM MXBeans registered in it
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   216
   ...
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   218
   List&lt;com.sun.management.GarbageCollectorMXBean&gt; mxbeans =
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   219
       ManagementFactory.getPlatformMXBeans(mbs, com.sun.management.GarbageCollectorMXBean.class);
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   220
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   221
   for (com.sun.management.GarbageCollectorMXBean gc : mxbeans) {
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   222
       // Get the standard attribute "CollectionCount"
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   223
       String count = mxbean.getCollectionCount();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   225
       // Get the platform-specific attribute "LastGcInfo"
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   226
       GcInfo gcinfo = gc.getLastGcInfo();
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   227
       ...
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   228
   }
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   229
</pre></blockquote>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   231
<p> Unless otherwise noted, passing a <code>null</code> argument to a constructor
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   232
or method in any class or interface in this package will cause a {@link
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   233
java.lang.NullPointerException NullPointerException} to be thrown.
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   234
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   235
<p> The java.lang.management API is thread-safe.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
45138
ddcafe0d0ea3 8180082: Broken javadoc links
rriggs
parents: 44858
diff changeset
   237
@see {@linkplain javax.management JMX Specification}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
25859
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   239
@author  Mandy Chung
3317bb8137f4 8054834: Modular Source Code
chegar
parents: 24865
diff changeset
   240
@since   1.5
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
</body>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
</html>