author | sjiang |
Fri, 17 Apr 2015 09:40:02 +0200 | |
changeset 30355 | e37c7eba132f |
parent 28775 | d786aae24263 |
child 32034 | 05676cfd40b5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
2 |
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
package java.lang.management; |
|
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
27 |
import java.io.FilePermission; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
28 |
import java.io.IOException; |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
29 |
import javax.management.DynamicMBean; |
2 | 30 |
import javax.management.MBeanServer; |
31 |
import javax.management.MBeanServerConnection; |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
32 |
import javax.management.MBeanServerFactory; |
2 | 33 |
import javax.management.MBeanServerPermission; |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
34 |
import javax.management.NotificationEmitter; |
2 | 35 |
import javax.management.ObjectName; |
36 |
import javax.management.InstanceNotFoundException; |
|
37 |
import javax.management.MalformedObjectNameException; |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
38 |
import javax.management.StandardEmitterMBean; |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
39 |
import javax.management.StandardMBean; |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
40 |
import java.util.Collections; |
2 | 41 |
import java.util.List; |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
42 |
import java.util.Set; |
17954 | 43 |
import java.util.Map; |
2 | 44 |
import java.security.AccessController; |
45 |
import java.security.Permission; |
|
46 |
import java.security.PrivilegedAction; |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
47 |
import java.security.PrivilegedActionException; |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
48 |
import java.security.PrivilegedExceptionAction; |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
49 |
import java.util.ArrayList; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
50 |
import java.util.Collection; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
51 |
import java.util.Optional; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
52 |
import java.util.ServiceLoader; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
53 |
import java.util.function.Function; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
54 |
import java.util.stream.Collectors; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
55 |
import static java.util.stream.Collectors.toMap; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
56 |
import java.util.stream.Stream; |
2 | 57 |
import javax.management.JMX; |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
58 |
import sun.management.Util; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
59 |
import sun.management.spi.PlatformMBeanProvider; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
60 |
import sun.management.spi.PlatformMBeanProvider.PlatformComponent; |
2 | 61 |
|
62 |
/** |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
63 |
* The {@code ManagementFactory} class is a factory class for getting |
2 | 64 |
* managed beans for the Java platform. |
65 |
* This class consists of static methods each of which returns |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
66 |
* one or more <i>platform MXBeans</i> representing |
2 | 67 |
* the management interface of a component of the Java virtual |
68 |
* machine. |
|
21334 | 69 |
* |
18799
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
70 |
* <h3><a name="MXBean">Platform MXBeans</a></h3> |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
71 |
* <p> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
72 |
* A platform MXBean is a <i>managed bean</i> that |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
73 |
* conforms to the <a href="../../../javax/management/package-summary.html">JMX</a> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
74 |
* Instrumentation Specification and only uses a set of basic data types. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
75 |
* A JMX management application and the {@linkplain |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
76 |
* #getPlatformMBeanServer platform MBeanServer} |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
77 |
* can interoperate without requiring classes for MXBean specific |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
78 |
* data types. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
79 |
* The data types being transmitted between the JMX connector |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
80 |
* server and the connector client are |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
81 |
* {@linkplain javax.management.openmbean.OpenType open types} |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
82 |
* and this allows interoperation across versions. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
83 |
* See <a href="../../../javax/management/MXBean.html#MXBean-spec"> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
84 |
* the specification of MXBeans</a> for details. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
85 |
* |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
86 |
* <a name="MXBeanNames"></a> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
87 |
* <p>Each platform MXBean is a {@link PlatformManagedObject} |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
88 |
* and it has a unique |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
89 |
* {@link javax.management.ObjectName ObjectName} for |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
90 |
* registration in the platform {@code MBeanServer} as returned by |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
91 |
* by the {@link PlatformManagedObject#getObjectName getObjectName} |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
92 |
* method. |
2 | 93 |
* |
94 |
* <p> |
|
95 |
* An application can access a platform MXBean in the following ways: |
|
18799
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
96 |
* <h4>1. Direct access to an MXBean interface</h4> |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
97 |
* <blockquote> |
2 | 98 |
* <ul> |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
99 |
* <li>Get an MXBean instance by calling the |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
100 |
* {@link #getPlatformMXBean(Class) getPlatformMXBean} or |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
101 |
* {@link #getPlatformMXBeans(Class) getPlatformMXBeans} method |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
102 |
* and access the MXBean locally in the running |
2 | 103 |
* virtual machine. |
104 |
* </li> |
|
105 |
* <li>Construct an MXBean proxy instance that forwards the |
|
106 |
* method calls to a given {@link MBeanServer MBeanServer} by calling |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
107 |
* the {@link #getPlatformMXBean(MBeanServerConnection, Class)} or |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
108 |
* {@link #getPlatformMXBeans(MBeanServerConnection, Class)} method. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
109 |
* The {@link #newPlatformMXBeanProxy newPlatformMXBeanProxy} method |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
110 |
* can also be used to construct an MXBean proxy instance of |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
111 |
* a given {@code ObjectName}. |
2 | 112 |
* A proxy is typically constructed to remotely access |
113 |
* an MXBean of another running virtual machine. |
|
114 |
* </li> |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
115 |
* </ul> |
18799
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
116 |
* <h4>2. Indirect access to an MXBean interface via MBeanServer</h4> |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
117 |
* <ul> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
118 |
* <li>Go through the platform {@code MBeanServer} to access MXBeans |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
119 |
* locally or a specific <tt>MBeanServerConnection</tt> to access |
2 | 120 |
* MXBeans remotely. |
121 |
* The attributes and operations of an MXBean use only |
|
122 |
* <em>JMX open types</em> which include basic data types, |
|
123 |
* {@link javax.management.openmbean.CompositeData CompositeData}, |
|
124 |
* and {@link javax.management.openmbean.TabularData TabularData} |
|
125 |
* defined in |
|
126 |
* {@link javax.management.openmbean.OpenType OpenType}. |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
127 |
* The mapping is specified in |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
128 |
* the {@linkplain javax.management.MXBean MXBean} specification |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
129 |
* for details. |
2 | 130 |
* </li> |
131 |
* </ul> |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
132 |
* </blockquote> |
2 | 133 |
* |
134 |
* <p> |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
135 |
* The {@link #getPlatformManagementInterfaces getPlatformManagementInterfaces} |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
136 |
* method returns all management interfaces supported in the Java virtual machine |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
137 |
* including the standard management interfaces listed in the tables |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
138 |
* below as well as the management interfaces extended by the JDK implementation. |
2 | 139 |
* <p> |
140 |
* A Java virtual machine has a single instance of the following management |
|
141 |
* interfaces: |
|
142 |
* |
|
143 |
* <blockquote> |
|
18799
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
144 |
* <table border summary="The list of Management Interfaces and their single instances"> |
2 | 145 |
* <tr> |
146 |
* <th>Management Interface</th> |
|
147 |
* <th>ObjectName</th> |
|
148 |
* </tr> |
|
149 |
* <tr> |
|
150 |
* <td> {@link ClassLoadingMXBean} </td> |
|
151 |
* <td> {@link #CLASS_LOADING_MXBEAN_NAME |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
152 |
* java.lang:type=ClassLoading}</td> |
2 | 153 |
* </tr> |
154 |
* <tr> |
|
155 |
* <td> {@link MemoryMXBean} </td> |
|
156 |
* <td> {@link #MEMORY_MXBEAN_NAME |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
157 |
* java.lang:type=Memory}</td> |
2 | 158 |
* </tr> |
159 |
* <tr> |
|
160 |
* <td> {@link ThreadMXBean} </td> |
|
161 |
* <td> {@link #THREAD_MXBEAN_NAME |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
162 |
* java.lang:type=Threading}</td> |
2 | 163 |
* </tr> |
164 |
* <tr> |
|
165 |
* <td> {@link RuntimeMXBean} </td> |
|
166 |
* <td> {@link #RUNTIME_MXBEAN_NAME |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
167 |
* java.lang:type=Runtime}</td> |
2 | 168 |
* </tr> |
169 |
* <tr> |
|
170 |
* <td> {@link OperatingSystemMXBean} </td> |
|
171 |
* <td> {@link #OPERATING_SYSTEM_MXBEAN_NAME |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
172 |
* java.lang:type=OperatingSystem}</td> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
173 |
* </tr> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
174 |
* <tr> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
175 |
* <td> {@link PlatformLoggingMXBean} </td> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
176 |
* <td> {@link java.util.logging.LogManager#LOGGING_MXBEAN_NAME |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
177 |
* java.util.logging:type=Logging}</td> |
2 | 178 |
* </tr> |
179 |
* </table> |
|
180 |
* </blockquote> |
|
181 |
* |
|
182 |
* <p> |
|
183 |
* A Java virtual machine has zero or a single instance of |
|
184 |
* the following management interfaces. |
|
185 |
* |
|
186 |
* <blockquote> |
|
18799
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
187 |
* <table border summary="The list of Management Interfaces and their single instances"> |
2 | 188 |
* <tr> |
189 |
* <th>Management Interface</th> |
|
190 |
* <th>ObjectName</th> |
|
191 |
* </tr> |
|
192 |
* <tr> |
|
193 |
* <td> {@link CompilationMXBean} </td> |
|
194 |
* <td> {@link #COMPILATION_MXBEAN_NAME |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
195 |
* java.lang:type=Compilation}</td> |
2 | 196 |
* </tr> |
197 |
* </table> |
|
198 |
* </blockquote> |
|
199 |
* |
|
200 |
* <p> |
|
201 |
* A Java virtual machine may have one or more instances of the following |
|
202 |
* management interfaces. |
|
203 |
* <blockquote> |
|
18799
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
204 |
* <table border summary="The list of Management Interfaces and their single instances"> |
2 | 205 |
* <tr> |
206 |
* <th>Management Interface</th> |
|
207 |
* <th>ObjectName</th> |
|
208 |
* </tr> |
|
209 |
* <tr> |
|
210 |
* <td> {@link GarbageCollectorMXBean} </td> |
|
211 |
* <td> {@link #GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
212 |
* java.lang:type=GarbageCollector}<tt>,name=</tt><i>collector's name</i></td> |
2 | 213 |
* </tr> |
214 |
* <tr> |
|
215 |
* <td> {@link MemoryManagerMXBean} </td> |
|
216 |
* <td> {@link #MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
217 |
* java.lang:type=MemoryManager}<tt>,name=</tt><i>manager's name</i></td> |
2 | 218 |
* </tr> |
219 |
* <tr> |
|
220 |
* <td> {@link MemoryPoolMXBean} </td> |
|
221 |
* <td> {@link #MEMORY_POOL_MXBEAN_DOMAIN_TYPE |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
222 |
* java.lang:type=MemoryPool}<tt>,name=</tt><i>pool's name</i></td> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
223 |
* </tr> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
224 |
* <tr> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
225 |
* <td> {@link BufferPoolMXBean} </td> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
226 |
* <td> {@code java.nio:type=BufferPool,name=}<i>pool name</i></td> |
2 | 227 |
* </tr> |
228 |
* </table> |
|
229 |
* </blockquote> |
|
230 |
* |
|
231 |
* @see <a href="../../../javax/management/package-summary.html"> |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
232 |
* JMX Specification</a> |
2 | 233 |
* @see <a href="package-summary.html#examples"> |
234 |
* Ways to Access Management Metrics</a> |
|
235 |
* @see javax.management.MXBean |
|
236 |
* |
|
237 |
* @author Mandy Chung |
|
238 |
* @since 1.5 |
|
239 |
*/ |
|
240 |
public class ManagementFactory { |
|
241 |
// A class with only static fields and methods. |
|
242 |
private ManagementFactory() {}; |
|
243 |
||
244 |
/** |
|
245 |
* String representation of the |
|
246 |
* <tt>ObjectName</tt> for the {@link ClassLoadingMXBean}. |
|
247 |
*/ |
|
248 |
public final static String CLASS_LOADING_MXBEAN_NAME = |
|
249 |
"java.lang:type=ClassLoading"; |
|
250 |
||
251 |
/** |
|
252 |
* String representation of the |
|
253 |
* <tt>ObjectName</tt> for the {@link CompilationMXBean}. |
|
254 |
*/ |
|
255 |
public final static String COMPILATION_MXBEAN_NAME = |
|
256 |
"java.lang:type=Compilation"; |
|
257 |
||
258 |
/** |
|
259 |
* String representation of the |
|
260 |
* <tt>ObjectName</tt> for the {@link MemoryMXBean}. |
|
261 |
*/ |
|
262 |
public final static String MEMORY_MXBEAN_NAME = |
|
263 |
"java.lang:type=Memory"; |
|
264 |
||
265 |
/** |
|
266 |
* String representation of the |
|
267 |
* <tt>ObjectName</tt> for the {@link OperatingSystemMXBean}. |
|
268 |
*/ |
|
269 |
public final static String OPERATING_SYSTEM_MXBEAN_NAME = |
|
270 |
"java.lang:type=OperatingSystem"; |
|
271 |
||
272 |
/** |
|
273 |
* String representation of the |
|
274 |
* <tt>ObjectName</tt> for the {@link RuntimeMXBean}. |
|
275 |
*/ |
|
276 |
public final static String RUNTIME_MXBEAN_NAME = |
|
277 |
"java.lang:type=Runtime"; |
|
278 |
||
279 |
/** |
|
280 |
* String representation of the |
|
281 |
* <tt>ObjectName</tt> for the {@link ThreadMXBean}. |
|
282 |
*/ |
|
283 |
public final static String THREAD_MXBEAN_NAME = |
|
284 |
"java.lang:type=Threading"; |
|
285 |
||
286 |
/** |
|
287 |
* The domain name and the type key property in |
|
288 |
* the <tt>ObjectName</tt> for a {@link GarbageCollectorMXBean}. |
|
289 |
* The unique <tt>ObjectName</tt> for a <tt>GarbageCollectorMXBean</tt> |
|
290 |
* can be formed by appending this string with |
|
291 |
* "<tt>,name=</tt><i>collector's name</i>". |
|
292 |
*/ |
|
293 |
public final static String GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE = |
|
294 |
"java.lang:type=GarbageCollector"; |
|
295 |
||
296 |
/** |
|
297 |
* The domain name and the type key property in |
|
298 |
* the <tt>ObjectName</tt> for a {@link MemoryManagerMXBean}. |
|
299 |
* The unique <tt>ObjectName</tt> for a <tt>MemoryManagerMXBean</tt> |
|
300 |
* can be formed by appending this string with |
|
301 |
* "<tt>,name=</tt><i>manager's name</i>". |
|
302 |
*/ |
|
303 |
public final static String MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE= |
|
304 |
"java.lang:type=MemoryManager"; |
|
305 |
||
306 |
/** |
|
307 |
* The domain name and the type key property in |
|
308 |
* the <tt>ObjectName</tt> for a {@link MemoryPoolMXBean}. |
|
309 |
* The unique <tt>ObjectName</tt> for a <tt>MemoryPoolMXBean</tt> |
|
310 |
* can be formed by appending this string with |
|
311 |
* <tt>,name=</tt><i>pool's name</i>. |
|
312 |
*/ |
|
313 |
public final static String MEMORY_POOL_MXBEAN_DOMAIN_TYPE= |
|
314 |
"java.lang:type=MemoryPool"; |
|
315 |
||
316 |
/** |
|
317 |
* Returns the managed bean for the class loading system of |
|
318 |
* the Java virtual machine. |
|
319 |
* |
|
320 |
* @return a {@link ClassLoadingMXBean} object for |
|
321 |
* the Java virtual machine. |
|
322 |
*/ |
|
323 |
public static ClassLoadingMXBean getClassLoadingMXBean() { |
|
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
324 |
return getPlatformMXBean(ClassLoadingMXBean.class); |
2 | 325 |
} |
326 |
||
327 |
/** |
|
328 |
* Returns the managed bean for the memory system of |
|
329 |
* the Java virtual machine. |
|
330 |
* |
|
331 |
* @return a {@link MemoryMXBean} object for the Java virtual machine. |
|
332 |
*/ |
|
333 |
public static MemoryMXBean getMemoryMXBean() { |
|
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
334 |
return getPlatformMXBean(MemoryMXBean.class); |
2 | 335 |
} |
336 |
||
337 |
/** |
|
338 |
* Returns the managed bean for the thread system of |
|
339 |
* the Java virtual machine. |
|
340 |
* |
|
341 |
* @return a {@link ThreadMXBean} object for the Java virtual machine. |
|
342 |
*/ |
|
343 |
public static ThreadMXBean getThreadMXBean() { |
|
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
344 |
return getPlatformMXBean(ThreadMXBean.class); |
2 | 345 |
} |
346 |
||
347 |
/** |
|
348 |
* Returns the managed bean for the runtime system of |
|
349 |
* the Java virtual machine. |
|
350 |
* |
|
351 |
* @return a {@link RuntimeMXBean} object for the Java virtual machine. |
|
352 |
||
353 |
*/ |
|
354 |
public static RuntimeMXBean getRuntimeMXBean() { |
|
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
355 |
return getPlatformMXBean(RuntimeMXBean.class); |
2 | 356 |
} |
357 |
||
358 |
/** |
|
359 |
* Returns the managed bean for the compilation system of |
|
360 |
* the Java virtual machine. This method returns <tt>null</tt> |
|
361 |
* if the Java virtual machine has no compilation system. |
|
362 |
* |
|
363 |
* @return a {@link CompilationMXBean} object for the Java virtual |
|
364 |
* machine or <tt>null</tt> if the Java virtual machine has |
|
365 |
* no compilation system. |
|
366 |
*/ |
|
367 |
public static CompilationMXBean getCompilationMXBean() { |
|
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
368 |
return getPlatformMXBean(CompilationMXBean.class); |
2 | 369 |
} |
370 |
||
371 |
/** |
|
372 |
* Returns the managed bean for the operating system on which |
|
373 |
* the Java virtual machine is running. |
|
374 |
* |
|
375 |
* @return an {@link OperatingSystemMXBean} object for |
|
376 |
* the Java virtual machine. |
|
377 |
*/ |
|
378 |
public static OperatingSystemMXBean getOperatingSystemMXBean() { |
|
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
379 |
return getPlatformMXBean(OperatingSystemMXBean.class); |
2 | 380 |
} |
381 |
||
382 |
/** |
|
383 |
* Returns a list of {@link MemoryPoolMXBean} objects in the |
|
384 |
* Java virtual machine. |
|
385 |
* The Java virtual machine can have one or more memory pools. |
|
386 |
* It may add or remove memory pools during execution. |
|
387 |
* |
|
388 |
* @return a list of <tt>MemoryPoolMXBean</tt> objects. |
|
389 |
* |
|
390 |
*/ |
|
391 |
public static List<MemoryPoolMXBean> getMemoryPoolMXBeans() { |
|
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
392 |
return getPlatformMXBeans(MemoryPoolMXBean.class); |
2 | 393 |
} |
394 |
||
395 |
/** |
|
396 |
* Returns a list of {@link MemoryManagerMXBean} objects |
|
397 |
* in the Java virtual machine. |
|
398 |
* The Java virtual machine can have one or more memory managers. |
|
399 |
* It may add or remove memory managers during execution. |
|
400 |
* |
|
401 |
* @return a list of <tt>MemoryManagerMXBean</tt> objects. |
|
402 |
* |
|
403 |
*/ |
|
404 |
public static List<MemoryManagerMXBean> getMemoryManagerMXBeans() { |
|
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
405 |
return getPlatformMXBeans(MemoryManagerMXBean.class); |
2 | 406 |
} |
407 |
||
408 |
||
409 |
/** |
|
410 |
* Returns a list of {@link GarbageCollectorMXBean} objects |
|
411 |
* in the Java virtual machine. |
|
412 |
* The Java virtual machine may have one or more |
|
413 |
* <tt>GarbageCollectorMXBean</tt> objects. |
|
414 |
* It may add or remove <tt>GarbageCollectorMXBean</tt> |
|
415 |
* during execution. |
|
416 |
* |
|
417 |
* @return a list of <tt>GarbageCollectorMXBean</tt> objects. |
|
418 |
* |
|
419 |
*/ |
|
420 |
public static List<GarbageCollectorMXBean> getGarbageCollectorMXBeans() { |
|
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
421 |
return getPlatformMXBeans(GarbageCollectorMXBean.class); |
2 | 422 |
} |
423 |
||
424 |
private static MBeanServer platformMBeanServer; |
|
425 |
/** |
|
426 |
* Returns the platform {@link javax.management.MBeanServer MBeanServer}. |
|
427 |
* On the first call to this method, it first creates the platform |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
428 |
* {@code MBeanServer} by calling the |
2 | 429 |
* {@link javax.management.MBeanServerFactory#createMBeanServer |
430 |
* MBeanServerFactory.createMBeanServer} |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
431 |
* method and registers each platform MXBean in this platform |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
432 |
* {@code MBeanServer} with its |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
433 |
* {@link PlatformManagedObject#getObjectName ObjectName}. |
2 | 434 |
* This method, in subsequent calls, will simply return the |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
435 |
* initially created platform {@code MBeanServer}. |
2 | 436 |
* <p> |
437 |
* MXBeans that get created and destroyed dynamically, for example, |
|
438 |
* memory {@link MemoryPoolMXBean pools} and |
|
439 |
* {@link MemoryManagerMXBean managers}, |
|
440 |
* will automatically be registered and deregistered into the platform |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
441 |
* {@code MBeanServer}. |
2 | 442 |
* <p> |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
443 |
* If the system property {@code javax.management.builder.initial} |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
444 |
* is set, the platform {@code MBeanServer} creation will be done |
2 | 445 |
* by the specified {@link javax.management.MBeanServerBuilder}. |
446 |
* <p> |
|
447 |
* It is recommended that this platform MBeanServer also be used |
|
448 |
* to register other application managed beans |
|
449 |
* besides the platform MXBeans. |
|
450 |
* This will allow all MBeans to be published through the same |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
451 |
* {@code MBeanServer} and hence allow for easier network publishing |
2 | 452 |
* and discovery. |
453 |
* Name conflicts with the platform MXBeans should be avoided. |
|
454 |
* |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
455 |
* @return the platform {@code MBeanServer}; the platform |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
456 |
* MXBeans are registered into the platform {@code MBeanServer} |
2 | 457 |
* at the first time this method is called. |
458 |
* |
|
459 |
* @exception SecurityException if there is a security manager |
|
460 |
* and the caller does not have the permission required by |
|
461 |
* {@link javax.management.MBeanServerFactory#createMBeanServer}. |
|
462 |
* |
|
463 |
* @see javax.management.MBeanServerFactory |
|
464 |
* @see javax.management.MBeanServerFactory#createMBeanServer |
|
465 |
*/ |
|
466 |
public static synchronized MBeanServer getPlatformMBeanServer() { |
|
467 |
SecurityManager sm = System.getSecurityManager(); |
|
468 |
if (sm != null) { |
|
469 |
Permission perm = new MBeanServerPermission("createMBeanServer"); |
|
470 |
sm.checkPermission(perm); |
|
471 |
} |
|
472 |
||
473 |
if (platformMBeanServer == null) { |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
474 |
platformMBeanServer = MBeanServerFactory.createMBeanServer(); |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
475 |
platformComponents() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
476 |
.stream() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
477 |
.filter(PlatformComponent::shouldRegister) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
478 |
.flatMap(pc -> pc.nameToMBeanMap().entrySet().stream()) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
479 |
.forEach(entry -> addMXBean(platformMBeanServer, entry.getKey(), entry.getValue())); |
2 | 480 |
} |
481 |
return platformMBeanServer; |
|
482 |
} |
|
483 |
||
484 |
/** |
|
485 |
* Returns a proxy for a platform MXBean interface of a |
|
486 |
* given <a href="#MXBeanNames">MXBean name</a> |
|
487 |
* that forwards its method calls through the given |
|
488 |
* <tt>MBeanServerConnection</tt>. |
|
489 |
* |
|
490 |
* <p>This method is equivalent to: |
|
491 |
* <blockquote> |
|
492 |
* {@link java.lang.reflect.Proxy#newProxyInstance |
|
493 |
* Proxy.newProxyInstance}<tt>(mxbeanInterface.getClassLoader(), |
|
494 |
* new Class[] { mxbeanInterface }, handler)</tt> |
|
495 |
* </blockquote> |
|
496 |
* |
|
497 |
* where <tt>handler</tt> is an {@link java.lang.reflect.InvocationHandler |
|
498 |
* InvocationHandler} to which method invocations to the MXBean interface |
|
499 |
* are dispatched. This <tt>handler</tt> converts an input parameter |
|
500 |
* from an MXBean data type to its mapped open type before forwarding |
|
501 |
* to the <tt>MBeanServer</tt> and converts a return value from |
|
502 |
* an MXBean method call through the <tt>MBeanServer</tt> |
|
503 |
* from an open type to the corresponding return type declared in |
|
504 |
* the MXBean interface. |
|
505 |
* |
|
506 |
* <p> |
|
507 |
* If the MXBean is a notification emitter (i.e., |
|
508 |
* it implements |
|
509 |
* {@link javax.management.NotificationEmitter NotificationEmitter}), |
|
510 |
* both the <tt>mxbeanInterface</tt> and <tt>NotificationEmitter</tt> |
|
511 |
* will be implemented by this proxy. |
|
512 |
* |
|
513 |
* <p> |
|
514 |
* <b>Notes:</b> |
|
515 |
* <ol> |
|
516 |
* <li>Using an MXBean proxy is a convenience remote access to |
|
517 |
* a platform MXBean of a running virtual machine. All method |
|
518 |
* calls to the MXBean proxy are forwarded to an |
|
519 |
* <tt>MBeanServerConnection</tt> where |
|
520 |
* {@link java.io.IOException IOException} may be thrown |
|
521 |
* when the communication problem occurs with the connector server. |
|
522 |
* An application remotely accesses the platform MXBeans using |
|
523 |
* proxy should prepare to catch <tt>IOException</tt> as if |
|
524 |
* accessing with the <tt>MBeanServerConnector</tt> interface.</li> |
|
525 |
* |
|
526 |
* <li>When a client application is designed to remotely access MXBeans |
|
527 |
* for a running virtual machine whose version is different than |
|
528 |
* the version on which the application is running, |
|
529 |
* it should prepare to catch |
|
530 |
* {@link java.io.InvalidObjectException InvalidObjectException} |
|
531 |
* which is thrown when an MXBean proxy receives a name of an |
|
532 |
* enum constant which is missing in the enum class loaded in |
|
533 |
* the client application. </li> |
|
534 |
* |
|
535 |
* <li>{@link javax.management.MBeanServerInvocationHandler |
|
536 |
* MBeanServerInvocationHandler} or its |
|
537 |
* {@link javax.management.MBeanServerInvocationHandler#newProxyInstance |
|
538 |
* newProxyInstance} method cannot be used to create |
|
539 |
* a proxy for a platform MXBean. The proxy object created |
|
540 |
* by <tt>MBeanServerInvocationHandler</tt> does not handle |
|
541 |
* the properties of the platform MXBeans described in |
|
542 |
* the <a href="#MXBean">class specification</a>. |
|
543 |
*</li> |
|
544 |
* </ol> |
|
545 |
* |
|
546 |
* @param connection the <tt>MBeanServerConnection</tt> to forward to. |
|
547 |
* @param mxbeanName the name of a platform MXBean within |
|
548 |
* <tt>connection</tt> to forward to. <tt>mxbeanName</tt> must be |
|
549 |
* in the format of {@link ObjectName ObjectName}. |
|
550 |
* @param mxbeanInterface the MXBean interface to be implemented |
|
551 |
* by the proxy. |
|
18799
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
552 |
* @param <T> an {@code mxbeanInterface} type parameter |
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
553 |
* |
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
554 |
* @return a proxy for a platform MXBean interface of a |
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
555 |
* given <a href="#MXBeanNames">MXBean name</a> |
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
556 |
* that forwards its method calls through the given |
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
557 |
* <tt>MBeanServerConnection</tt>, or {@code null} if not exist. |
2 | 558 |
* |
559 |
* @throws IllegalArgumentException if |
|
560 |
* <ul> |
|
561 |
* <li><tt>mxbeanName</tt> is not with a valid |
|
562 |
* {@link ObjectName ObjectName} format, or</li> |
|
563 |
* <li>the named MXBean in the <tt>connection</tt> is |
|
564 |
* not a MXBean provided by the platform, or</li> |
|
565 |
* <li>the named MXBean is not registered in the |
|
566 |
* <tt>MBeanServerConnection</tt>, or</li> |
|
567 |
* <li>the named MXBean is not an instance of the given |
|
568 |
* <tt>mxbeanInterface</tt></li> |
|
569 |
* </ul> |
|
570 |
* |
|
571 |
* @throws java.io.IOException if a communication problem |
|
572 |
* occurred when accessing the <tt>MBeanServerConnection</tt>. |
|
573 |
*/ |
|
574 |
public static <T> T |
|
575 |
newPlatformMXBeanProxy(MBeanServerConnection connection, |
|
576 |
String mxbeanName, |
|
577 |
Class<T> mxbeanInterface) |
|
578 |
throws java.io.IOException { |
|
579 |
||
580 |
// Only allow MXBean interfaces from rt.jar loaded by the |
|
581 |
// bootstrap class loader |
|
13589
da4cb574f4a6
7193339: Prepare system classes be defined by a non-null module loader
mchung
parents:
12189
diff
changeset
|
582 |
final Class<?> cls = mxbeanInterface; |
da4cb574f4a6
7193339: Prepare system classes be defined by a non-null module loader
mchung
parents:
12189
diff
changeset
|
583 |
ClassLoader loader = |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
584 |
AccessController.doPrivileged( |
30355
e37c7eba132f
8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents:
28775
diff
changeset
|
585 |
(PrivilegedAction<ClassLoader>) () -> cls.getClassLoader()); |
13589
da4cb574f4a6
7193339: Prepare system classes be defined by a non-null module loader
mchung
parents:
12189
diff
changeset
|
586 |
if (!sun.misc.VM.isSystemDomainLoader(loader)) { |
2 | 587 |
throw new IllegalArgumentException(mxbeanName + |
588 |
" is not a platform MXBean"); |
|
589 |
} |
|
590 |
||
591 |
try { |
|
592 |
final ObjectName objName = new ObjectName(mxbeanName); |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
593 |
// skip the isInstanceOf check for LoggingMXBean |
13589
da4cb574f4a6
7193339: Prepare system classes be defined by a non-null module loader
mchung
parents:
12189
diff
changeset
|
594 |
String intfName = mxbeanInterface.getName(); |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
595 |
if (!connection.isInstanceOf(objName, intfName)) { |
2 | 596 |
throw new IllegalArgumentException(mxbeanName + |
13589
da4cb574f4a6
7193339: Prepare system classes be defined by a non-null module loader
mchung
parents:
12189
diff
changeset
|
597 |
" is not an instance of " + mxbeanInterface); |
2 | 598 |
} |
599 |
||
600 |
// check if the registered MBean is a notification emitter |
|
601 |
boolean emitter = connection.isInstanceOf(objName, NOTIF_EMITTER); |
|
602 |
||
603 |
// create an MXBean proxy |
|
604 |
return JMX.newMXBeanProxy(connection, objName, mxbeanInterface, |
|
605 |
emitter); |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
606 |
} catch (InstanceNotFoundException|MalformedObjectNameException e) { |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
607 |
throw new IllegalArgumentException(e); |
2 | 608 |
} |
609 |
} |
|
610 |
||
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
611 |
/** |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
612 |
* Returns the platform MXBean implementing |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
613 |
* the given {@code mxbeanInterface} which is specified |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
614 |
* to have one single instance in the Java virtual machine. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
615 |
* This method may return {@code null} if the management interface |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
616 |
* is not implemented in the Java virtual machine (for example, |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
617 |
* a Java virtual machine with no compilation system does not |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
618 |
* implement {@link CompilationMXBean}); |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
619 |
* otherwise, this method is equivalent to calling: |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
620 |
* <pre> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
621 |
* {@link #getPlatformMXBeans(Class) |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
622 |
* getPlatformMXBeans(mxbeanInterface)}.get(0); |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
623 |
* </pre> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
624 |
* |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
625 |
* @param mxbeanInterface a management interface for a platform |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
626 |
* MXBean with one single instance in the Java virtual machine |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
627 |
* if implemented. |
18799
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
628 |
* @param <T> an {@code mxbeanInterface} type parameter |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
629 |
* |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
630 |
* @return the platform MXBean that implements |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
631 |
* {@code mxbeanInterface}, or {@code null} if not exist. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
632 |
* |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
633 |
* @throws IllegalArgumentException if {@code mxbeanInterface} |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
634 |
* is not a platform management interface or |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
635 |
* not a singleton platform MXBean. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
636 |
* |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
637 |
* @since 1.7 |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
638 |
*/ |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
639 |
public static <T extends PlatformManagedObject> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
640 |
T getPlatformMXBean(Class<T> mxbeanInterface) { |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
641 |
PlatformComponent<?> pc = PlatformMBeanFinder.findSingleton(mxbeanInterface); |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
642 |
|
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
643 |
List<? extends T> mbeans = pc.getMBeans(mxbeanInterface); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
644 |
assert mbeans.isEmpty() || mbeans.size() == 1; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
645 |
return mbeans.isEmpty() ? null : mbeans.get(0); |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
646 |
} |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
647 |
|
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
648 |
/** |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
649 |
* Returns the list of platform MXBeans implementing |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
650 |
* the given {@code mxbeanInterface} in the Java |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
651 |
* virtual machine. |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
652 |
* The returned list may contain zero, one, or more instances. |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
653 |
* The number of instances in the returned list is defined |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
654 |
* in the specification of the given management interface. |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
655 |
* The order is undefined and there is no guarantee that |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
656 |
* the list returned is in the same order as previous invocations. |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
657 |
* |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
658 |
* @param mxbeanInterface a management interface for a platform |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
659 |
* MXBean |
18799
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
660 |
* @param <T> an {@code mxbeanInterface} type parameter |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
661 |
* |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
662 |
* @return the list of platform MXBeans that implement |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
663 |
* {@code mxbeanInterface}. |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
664 |
* |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
665 |
* @throws IllegalArgumentException if {@code mxbeanInterface} |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
666 |
* is not a platform management interface. |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
667 |
* |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
668 |
* @since 1.7 |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
669 |
*/ |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
670 |
public static <T extends PlatformManagedObject> List<T> |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
671 |
getPlatformMXBeans(Class<T> mxbeanInterface) { |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
672 |
// Validates at first the specified interface by finding at least one |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
673 |
// PlatformComponent whose MXBean implements this interface. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
674 |
// An interface can be implemented by different MBeans, provided by |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
675 |
// different platform components. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
676 |
PlatformComponent<?> pc = PlatformMBeanFinder.findFirst(mxbeanInterface); |
27198
43984b895da5
8044473: Allow for extended set of platform MXBeans
bchristi
parents:
25859
diff
changeset
|
677 |
if (pc == null) { |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
678 |
throw new IllegalArgumentException(mxbeanInterface.getName() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
679 |
+ " is not a platform management interface"); |
27198
43984b895da5
8044473: Allow for extended set of platform MXBeans
bchristi
parents:
25859
diff
changeset
|
680 |
} |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
681 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
682 |
return platformComponents().stream() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
683 |
.flatMap(p -> p.getMBeans(mxbeanInterface).stream()) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
684 |
.collect(Collectors.toList()); |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
685 |
} |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
686 |
|
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
687 |
/** |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
688 |
* Returns the platform MXBean proxy for |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
689 |
* {@code mxbeanInterface} which is specified to have one single |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
690 |
* instance in a Java virtual machine and the proxy will |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
691 |
* forward the method calls through the given {@code MBeanServerConnection}. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
692 |
* This method may return {@code null} if the management interface |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
693 |
* is not implemented in the Java virtual machine being monitored |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
694 |
* (for example, a Java virtual machine with no compilation system |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
695 |
* does not implement {@link CompilationMXBean}); |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
696 |
* otherwise, this method is equivalent to calling: |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
697 |
* <pre> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
698 |
* {@link #getPlatformMXBeans(MBeanServerConnection, Class) |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
699 |
* getPlatformMXBeans(connection, mxbeanInterface)}.get(0); |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
700 |
* </pre> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
701 |
* |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
702 |
* @param connection the {@code MBeanServerConnection} to forward to. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
703 |
* @param mxbeanInterface a management interface for a platform |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
704 |
* MXBean with one single instance in the Java virtual machine |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
705 |
* being monitored, if implemented. |
18799
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
706 |
* @param <T> an {@code mxbeanInterface} type parameter |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
707 |
* |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
708 |
* @return the platform MXBean proxy for |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
709 |
* forwarding the method calls of the {@code mxbeanInterface} |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
710 |
* through the given {@code MBeanServerConnection}, |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
711 |
* or {@code null} if not exist. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
712 |
* |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
713 |
* @throws IllegalArgumentException if {@code mxbeanInterface} |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
714 |
* is not a platform management interface or |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
715 |
* not a singleton platform MXBean. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
716 |
* @throws java.io.IOException if a communication problem |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
717 |
* occurred when accessing the {@code MBeanServerConnection}. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
718 |
* |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
719 |
* @see #newPlatformMXBeanProxy |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
720 |
* @since 1.7 |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
721 |
*/ |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
722 |
public static <T extends PlatformManagedObject> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
723 |
T getPlatformMXBean(MBeanServerConnection connection, |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
724 |
Class<T> mxbeanInterface) |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
725 |
throws java.io.IOException |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
726 |
{ |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
727 |
PlatformComponent<?> pc = PlatformMBeanFinder.findSingleton(mxbeanInterface); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
728 |
return newPlatformMXBeanProxy(connection, pc.getObjectNamePattern(), mxbeanInterface); |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
729 |
} |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
730 |
|
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
731 |
/** |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
732 |
* Returns the list of the platform MXBean proxies for |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
733 |
* forwarding the method calls of the {@code mxbeanInterface} |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
734 |
* through the given {@code MBeanServerConnection}. |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
735 |
* The returned list may contain zero, one, or more instances. |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
736 |
* The number of instances in the returned list is defined |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
737 |
* in the specification of the given management interface. |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
738 |
* The order is undefined and there is no guarantee that |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
739 |
* the list returned is in the same order as previous invocations. |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
740 |
* |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
741 |
* @param connection the {@code MBeanServerConnection} to forward to. |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
742 |
* @param mxbeanInterface a management interface for a platform |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
743 |
* MXBean |
18799
31062cb3cc8e
8020308: Fix doclint issues in java.lang.management
sspitsyn
parents:
17954
diff
changeset
|
744 |
* @param <T> an {@code mxbeanInterface} type parameter |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
745 |
* |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
746 |
* @return the list of platform MXBean proxies for |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
747 |
* forwarding the method calls of the {@code mxbeanInterface} |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
748 |
* through the given {@code MBeanServerConnection}. |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
749 |
* |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
750 |
* @throws IllegalArgumentException if {@code mxbeanInterface} |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
751 |
* is not a platform management interface. |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
752 |
* |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
753 |
* @throws java.io.IOException if a communication problem |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
754 |
* occurred when accessing the {@code MBeanServerConnection}. |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
755 |
* |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
756 |
* @see #newPlatformMXBeanProxy |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
757 |
* @since 1.7 |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
758 |
*/ |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
759 |
public static <T extends PlatformManagedObject> |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
760 |
List<T> getPlatformMXBeans(MBeanServerConnection connection, |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
761 |
Class<T> mxbeanInterface) |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
762 |
throws java.io.IOException |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
763 |
{ |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
764 |
// Validates at first the specified interface by finding at least one |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
765 |
// PlatformComponent whose MXBean implements this interface. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
766 |
// An interface can be implemented by different MBeans, provided by |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
767 |
// different platform components. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
768 |
PlatformComponent<?> pc = PlatformMBeanFinder.findFirst(mxbeanInterface); |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
769 |
if (pc == null) { |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
770 |
throw new IllegalArgumentException(mxbeanInterface.getName() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
771 |
+ " is not a platform management interface"); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
772 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
773 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
774 |
// Collect all names, eliminate duplicates. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
775 |
Stream<String> names = Stream.empty(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
776 |
for (PlatformComponent<?> p : platformComponents()) { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
777 |
names = Stream.concat(names, getProxyNames(p, connection, mxbeanInterface)); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
778 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
779 |
Set<String> objectNames = names.collect(Collectors.toSet()); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
780 |
if (objectNames.isEmpty()) return Collections.emptyList(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
781 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
782 |
// Map names on proxies. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
783 |
List<T> proxies = new ArrayList<>(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
784 |
for (String name : objectNames) { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
785 |
proxies.add(newPlatformMXBeanProxy(connection, name, mxbeanInterface)); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
786 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
787 |
return proxies; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
788 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
789 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
790 |
// Returns a stream containing all ObjectNames of the MBeans represented by |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
791 |
// the specified PlatformComponent and implementing the specified interface. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
792 |
// If the PlatformComponent is a singleton, the name returned by |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
793 |
// PlatformComponent.getObjectNamePattern() will be used, otherwise |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
794 |
// we will query the specified MBeanServerConnection (conn.queryNames) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
795 |
// with the pattern returned by PlatformComponent.getObjectNamePattern() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
796 |
// in order to find the names of matching MBeans. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
797 |
// In case of singleton, we do not check whether the MBean is registered |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
798 |
// in the connection because the caller "getPlatformMXBeans" will do the check |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
799 |
// when creating a proxy. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
800 |
private static Stream<String> getProxyNames(PlatformComponent<?> pc, |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
801 |
MBeanServerConnection conn, |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
802 |
Class<?> intf) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
803 |
throws IOException |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
804 |
{ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
805 |
if (pc.mbeanInterfaceNames().contains(intf.getName())) { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
806 |
if (pc.isSingleton()) { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
807 |
return Stream.of(pc.getObjectNamePattern()); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
808 |
} else { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
809 |
return conn.queryNames(Util.newObjectName(pc.getObjectNamePattern()), null) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
810 |
.stream().map(ObjectName::getCanonicalName); |
27198
43984b895da5
8044473: Allow for extended set of platform MXBeans
bchristi
parents:
25859
diff
changeset
|
811 |
} |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
812 |
} |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
813 |
return Stream.empty(); |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
814 |
} |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
815 |
|
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
816 |
/** |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
817 |
* Returns the set of {@code Class} objects, subinterface of |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
818 |
* {@link PlatformManagedObject}, representing |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
819 |
* all management interfaces for |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
820 |
* monitoring and managing the Java platform. |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
821 |
* |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
822 |
* @return the set of {@code Class} objects, subinterface of |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
823 |
* {@link PlatformManagedObject} representing |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
824 |
* the management interfaces for |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
825 |
* monitoring and managing the Java platform. |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
826 |
* |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
827 |
* @since 1.7 |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
828 |
*/ |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
829 |
public static Set<Class<? extends PlatformManagedObject>> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
830 |
getPlatformManagementInterfaces() |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
7803
diff
changeset
|
831 |
{ |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
832 |
return platformComponents() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
833 |
.stream() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
834 |
.flatMap(pc -> pc.mbeanInterfaces().stream()) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
835 |
.filter(clazz -> PlatformManagedObject.class.isAssignableFrom(clazz)) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
836 |
.map(clazz -> clazz.asSubclass(PlatformManagedObject.class)) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
837 |
.collect(Collectors.toSet()); |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
838 |
} |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
839 |
|
2 | 840 |
private static final String NOTIF_EMITTER = |
841 |
"javax.management.NotificationEmitter"; |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
842 |
|
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
843 |
private static void addMXBean(final MBeanServer mbs, String name, final Object pmo) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
844 |
{ |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
845 |
try { |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
846 |
ObjectName oname = ObjectName.getInstance(name); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
847 |
// Make DynamicMBean out of MXBean by wrapping it with a StandardMBean |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
848 |
AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
849 |
final DynamicMBean dmbean; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
850 |
if (pmo instanceof DynamicMBean) { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
851 |
dmbean = DynamicMBean.class.cast(pmo); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
852 |
} else if (pmo instanceof NotificationEmitter) { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
853 |
dmbean = new StandardEmitterMBean(pmo, null, true, (NotificationEmitter) pmo); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
854 |
} else { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
855 |
dmbean = new StandardMBean(pmo, null, true); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
856 |
} |
16109 | 857 |
|
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
858 |
mbs.registerMBean(dmbean, oname); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
859 |
return null; |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
860 |
}); |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
861 |
} catch (MalformedObjectNameException mone) { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
862 |
throw new IllegalArgumentException(mone); |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
863 |
} catch (PrivilegedActionException e) { |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
864 |
throw new RuntimeException(e.getException()); |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
865 |
} |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
866 |
} |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
867 |
|
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
868 |
private static Collection<PlatformComponent<?>> platformComponents() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
869 |
{ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
870 |
return PlatformMBeanFinder.getMap().values(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
871 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
872 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
873 |
private static class PlatformMBeanFinder |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
874 |
{ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
875 |
private static final Map<String, PlatformComponent<?>> componentMap; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
876 |
static { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
877 |
// get all providers |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
878 |
List<PlatformMBeanProvider> providers = AccessController.doPrivileged( |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
879 |
(PrivilegedAction<List<PlatformMBeanProvider>>) () -> { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
880 |
List<PlatformMBeanProvider> all = new ArrayList<>(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
881 |
ServiceLoader.loadInstalled(PlatformMBeanProvider.class) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
882 |
.forEach(all::add); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
883 |
all.add(new DefaultPlatformMBeanProvider()); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
884 |
return all; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
885 |
}, null, new FilePermission("<<ALL FILES>>", "read"), |
30355
e37c7eba132f
8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents:
28775
diff
changeset
|
886 |
new RuntimePermission("sun.management.spi.PlatformMBeanProvider.subclass")); |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
887 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
888 |
// load all platform components into a map |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
889 |
componentMap = providers.stream() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
890 |
.flatMap(p -> toPlatformComponentStream(p)) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
891 |
// The first one wins if multiple PlatformComponents |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
892 |
// with same ObjectName pattern, |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
893 |
.collect(toMap(PlatformComponent::getObjectNamePattern, |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
894 |
Function.identity(), |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
895 |
(p1, p2) -> p1)); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
896 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
897 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
898 |
static Map<String, PlatformComponent<?>> getMap() { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
899 |
return componentMap; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
900 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
901 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
902 |
// Loads all platform components from a provider into a stream |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
903 |
// Ensures that two different components are not declared with the same |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
904 |
// object name pattern. Throws InternalError if the provider incorrectly |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
905 |
// declares two platform components with the same pattern. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
906 |
private static Stream<PlatformComponent<?>> |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
907 |
toPlatformComponentStream(PlatformMBeanProvider provider) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
908 |
{ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
909 |
return provider.getPlatformComponentList() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
910 |
.stream() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
911 |
.collect(toMap(PlatformComponent::getObjectNamePattern, |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
912 |
Function.identity(), |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
913 |
(p1, p2) -> { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
914 |
throw new InternalError( |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
915 |
p1.getObjectNamePattern() + |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
916 |
" has been used as key for " + p1 + |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
917 |
", it cannot be reused for " + p2); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
918 |
})) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
919 |
.values().stream(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
920 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
921 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
922 |
// Finds the first PlatformComponent whose mbeanInterfaceNames() list |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
923 |
// contains the specified class name. An MBean interface can be implemented |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
924 |
// by different MBeans, provided by different platform components. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
925 |
// For instance the MemoryManagerMXBean interface is implemented both by |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
926 |
// regular memory managers, and garbage collector MXBeans. This method is |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
927 |
// mainly used to verify that there is at least one PlatformComponent |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
928 |
// which provides an implementation of the desired interface. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
929 |
static PlatformComponent<?> findFirst(Class<?> mbeanIntf) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
930 |
{ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
931 |
String name = mbeanIntf.getName(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
932 |
Optional<PlatformComponent<?>> op = getMap().values() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
933 |
.stream() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
934 |
.filter(pc -> pc.mbeanInterfaceNames().contains(name)) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
935 |
.findFirst(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
936 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
937 |
if (op.isPresent()) { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
938 |
return op.get(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
939 |
} else { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
940 |
return null; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
941 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
942 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
943 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
944 |
// Finds a PlatformComponent whose mbeanInterface name list contains |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
945 |
// the specified class name, and make sure that one and only one exists. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
946 |
static PlatformComponent<?> findSingleton(Class<?> mbeanIntf) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
947 |
{ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
948 |
String name = mbeanIntf.getName(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
949 |
Optional<PlatformComponent<?>> op = getMap().values() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
950 |
.stream() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
951 |
.filter(pc -> pc.mbeanInterfaceNames().contains(name)) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
952 |
.reduce((p1, p2) -> { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
953 |
if (p2 != null) { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
954 |
throw new IllegalArgumentException(mbeanIntf.getName() + |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
955 |
" can have more than one instance"); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
956 |
} else { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
957 |
return p1; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
958 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
959 |
}); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
960 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
961 |
PlatformComponent<?> singleton = op.isPresent() ? op.get() : null; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
962 |
if (singleton == null) { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
963 |
throw new IllegalArgumentException(mbeanIntf.getName() + |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
964 |
" is not a platform management interface"); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
965 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
966 |
if (!singleton.isSingleton()) { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
967 |
throw new IllegalArgumentException(mbeanIntf.getName() + |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
968 |
" can have more than one instance"); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
969 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
27198
diff
changeset
|
970 |
return singleton; |
17954 | 971 |
} |
972 |
} |
|
30355
e37c7eba132f
8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents:
28775
diff
changeset
|
973 |
|
e37c7eba132f
8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents:
28775
diff
changeset
|
974 |
static { |
e37c7eba132f
8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents:
28775
diff
changeset
|
975 |
AccessController.doPrivileged((PrivilegedAction<Void>) () -> { |
e37c7eba132f
8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents:
28775
diff
changeset
|
976 |
System.loadLibrary("management"); |
e37c7eba132f
8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents:
28775
diff
changeset
|
977 |
return null; |
e37c7eba132f
8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents:
28775
diff
changeset
|
978 |
}); |
e37c7eba132f
8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents:
28775
diff
changeset
|
979 |
} |
2 | 980 |
} |