author | sjiang |
Fri, 17 Apr 2015 09:40:02 +0200 | |
changeset 30355 | e37c7eba132f |
parent 28775 | d786aae24263 |
permissions | -rw-r--r-- |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
1 |
/* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
4 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
10 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
15 |
* accompanied this code). |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
16 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
20 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
23 |
* questions. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
24 |
*/ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
25 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
26 |
package sun.management.spi; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
27 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
28 |
import java.util.Collections; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
29 |
import java.util.List; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
30 |
import java.util.Map; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
31 |
import java.util.ServiceLoader; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
32 |
import java.util.Set; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
33 |
import java.util.stream.Collectors; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
34 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
35 |
/** |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
36 |
* The PlatformMBeanProvider class defines the abstract service interface |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
37 |
* that the {@link java.lang.management.ManagementFactory} will invoke to find, |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
38 |
* load, and register Platform MBeans. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
39 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
40 |
* ManagementFactory loads the {@linkplain ServiceLoader#loadInstalled(java.lang.Class) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
41 |
* installed providers} of this service interface and each provides the |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
42 |
* {@linkplain PlatformComponent platform components} that defines MXBean |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
43 |
* or DynamicMBean to be registered in the platform MBeanServer. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
44 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
45 |
* A {@code PlatformMBeanProvider} will implement the {@code getPlatformComponentList()} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
46 |
* method to return the list of {@code PlatformComponents} it provides. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
47 |
*/ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
48 |
public abstract class PlatformMBeanProvider { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
49 |
/** |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
50 |
* {@code PlatformComponent} models MBeans of a management interface supported |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
51 |
* by the platform. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
52 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
53 |
* If a PlatformComponent models a singleton MBean, the {@link #getObjectNamePattern() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
54 |
* ObjectName pattern} must be the {@link |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
55 |
* javax.management.ObjectName#getCanonicalName() canonical name} of that |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
56 |
* singleton MBean. Otherwise, it must be an ObjectName pattern |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
57 |
* that can be used to query the MBeans for this |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
58 |
* PlatformComponent registered in a {@code MBeanServer}. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
59 |
* <br> |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
60 |
* The {@link #getObjectNamePattern() ObjectName pattern} serves as a unique |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
61 |
* key for identifying the instance of PlatformComponent. It is thus illegal |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
62 |
* for a given {@link PlatformMBeanProvider} to export several instance of |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
63 |
* PlatformComponent with the same |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
64 |
* {@link #getObjectNamePattern() ObjectName pattern} string. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
65 |
* <br> |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
66 |
* If two different provider instances export a PlatformComponent for the |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
67 |
* same ObjectName pattern, only the PlatformComponent instance of the first |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
68 |
* provider will be taken into account. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
69 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
70 |
* @param <T> The higher level interface for which the MBeans modeled by |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
71 |
* this object should be recognized. For instance, for the {@link |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
72 |
* java.lang.management.ManagementFactory#getOperatingSystemMXBean() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
73 |
* Operating System MXBean}, this should be {@link |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
74 |
* java.lang.management.OperatingSystemMXBean |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
75 |
* java.lang.management.OperatingSystemMXBean}. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
76 |
*/ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
77 |
public interface PlatformComponent<T> { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
78 |
/** |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
79 |
* Returns the names of the management interfaces implemented by the |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
80 |
* MBeans modeled by this {@code PlatformComponent}. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
81 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
82 |
* @implNote |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
83 |
* When {@link java.lang.management.ManagementFactory#getPlatformMXBean(java.lang.Class) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
84 |
* ManagementFactory.getPlatformMXBean(mxbeanInterface)} or {@link |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
85 |
* java.lang.management.ManagementFactory#getPlatformMXBeans(java.lang.Class) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
86 |
* ManagementFactory.getPlatformMXBeans(mxbeanInterface)} are invoked, |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
87 |
* this PlatformComponent instance will match only if the name of the |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
88 |
* given {@code mxbeanInterface} is found in this list. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
89 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
90 |
* @return the names of the management interfaces exported by the MBeans |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
91 |
* modeled by this object. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
92 |
*/ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
93 |
public Set<String> mbeanInterfaceNames(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
94 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
95 |
/** |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
96 |
* A map from ObjectName string to the MBean instance this |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
97 |
* {@code PlatformComponent} creates. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
98 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
99 |
* @implNote |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
100 |
* If {@link #shouldRegister()} is {@code true}, this method |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
101 |
* will be called when the {@link java.lang.management.ManagementFactory |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
102 |
* #getPlatformMBeanServer() Platform MBeanServer} is initialized. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
103 |
* By default, this method will also be called by {@link |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
104 |
* #getMBeans(java.lang.Class)}, when {@link |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
105 |
* java.lang.management.ManagementFactory#getPlatformMXBean(java.lang.Class) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
106 |
* ManagementFactory.getPlatformMXBean(mxbeanInterface)} or {@link |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
107 |
* java.lang.management.ManagementFactory#getPlatformMXBeans(java.lang.Class) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
108 |
* ManagementFactory.getPlatformMXBeans(mxbeanInterface)} are invoked, |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
109 |
* and when the name of the given {@code mxbeanInterface} is contained |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
110 |
* in the names of management interfaces returned by {@link |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
111 |
* #mbeanInterfaceNames()}. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
112 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
113 |
* @return A map with, for each MBean, the ObjectName string as key |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
114 |
* and the MBean as value. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
115 |
*/ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
116 |
public Map<String, T> nameToMBeanMap(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
117 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
118 |
/** |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
119 |
* An ObjectName pattern uniquely identifies the MBeans |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
120 |
* modeled by this {@code PlatformComponent}. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
121 |
* If this instance models a singleton MBean, this must be |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
122 |
* the {@link |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
123 |
* javax.management.ObjectName#getCanonicalName() canonical name} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
124 |
* of that singleton MBean. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
125 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
126 |
* @return An ObjectName pattern uniquely identifies the MBeans |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
127 |
* modeled by this instance. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
128 |
*/ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
129 |
public String getObjectNamePattern(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
130 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
131 |
/** |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
132 |
* Returns {@code true} if this {@code PlatformComponent} models |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
133 |
* a singleton MBean. By default, {@code true} is assumed. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
134 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
135 |
* @return {@code true} if this instance models a singleton MBean. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
136 |
*/ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
137 |
public default boolean isSingleton() { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
138 |
return true; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
139 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
140 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
141 |
/** |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
142 |
* Returns {@code true} if the MBeans modeled by this {@code PlatformComponent} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
143 |
* should automatically be registered in the {@link |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
144 |
* java.lang.management.ManagementFactory#getPlatformMBeanServer() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
145 |
* Platform MBeanServer}. By default, {@code true} is assumed. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
146 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
147 |
* @return {@code true} if the MBeans modeled by this instance should |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
148 |
* automatically be registered in the Platform MBeanServer. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
149 |
*/ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
150 |
public default boolean shouldRegister() { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
151 |
return true; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
152 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
153 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
154 |
/** |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
155 |
* The set of interfaces implemented by the MBeans modeled |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
156 |
* by this {@code PlatformComponent}. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
157 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
158 |
* @implNote |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
159 |
* {@link java.lang.management.ManagementFactory#getPlatformManagementInterfaces() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
160 |
* ManagementFactory.getPlatformManagementInterfaces()} calls this |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
161 |
* method to find the management interfaces supported by the platform. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
162 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
163 |
* @return The set of interfaces implemented by the MBeans modeled |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
164 |
* by this instance |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
165 |
*/ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
166 |
public Set<Class<? extends T>> mbeanInterfaces(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
167 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
168 |
/** |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
169 |
* Return the list of MBeans that implement the given {@code mbeanIntf} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
170 |
* modeled by this {@code PlatformComponent}. This method returns an |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
171 |
* empty list if no MBean implements the given {@code mbeanIntf}. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
172 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
173 |
* @implNote This method will be called when {@link |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
174 |
* java.lang.management.ManagementFactory#getPlatformMXBean(java.lang.Class) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
175 |
* ManagementFactory.getPlatformMXBean(mbeanIntf)} or {@link |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
176 |
* java.lang.management.ManagementFactory#getPlatformMXBeans(java.lang.Class) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
177 |
* ManagementFactory.getPlatformMXBeans(mbeanIntf)} are invoked. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
178 |
* By default it first checks whether the specified {@code mbeanIntf} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
179 |
* name is contained in the returned list from the {@link #mbeanInterfaceNames()} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
180 |
* method. If yes, it proceeds and calls |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
181 |
* {@link #mbeans().values()} and filters out all |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
182 |
* MBeans which are not instances of the given {@code mbeanIntf}. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
183 |
* Otherwise, it returns an empty list. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
184 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
185 |
* @param mbeanIntf A management interface. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
186 |
* @return A (possibly empty) list of MBeans implementing the given |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
187 |
* {@code mbeanIntf}. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
188 |
*/ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
189 |
public default <I> List<? extends I> getMBeans(Class<I> mbeanIntf) { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
190 |
List<I> list; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
191 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
192 |
if (!mbeanInterfaceNames().contains(mbeanIntf.getName())) { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
193 |
list = Collections.emptyList(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
194 |
} else { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
195 |
list = nameToMBeanMap().values().stream() |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
196 |
.filter(mbeanIntf::isInstance) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
197 |
.map(mbeanIntf::cast) |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
198 |
.collect(Collectors.toList()); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
199 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
200 |
return list; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
201 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
202 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
203 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
204 |
/** |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
205 |
* Instantiates a new PlatformMBeanProvider. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
206 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
207 |
* @throws SecurityException if the subclass (and calling code) does not |
30355
e37c7eba132f
8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents:
28775
diff
changeset
|
208 |
* have {@code RuntimePermission("sun.management.spi.PlatformMBeanProvider.subclass")} |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
209 |
*/ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
210 |
protected PlatformMBeanProvider () { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
211 |
this(checkSubclassPermission()); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
212 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
213 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
214 |
private PlatformMBeanProvider(Void unused) { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
215 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
216 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
217 |
/** |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
218 |
* Returns a list of PlatformComponent instances describing the Platform |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
219 |
* MBeans provided by this provider. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
220 |
* |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
221 |
* @return a list of PlatformComponent instances describing the Platform |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
222 |
* MBeans provided by this provider. |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
223 |
*/ |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
224 |
public abstract List<PlatformComponent<?>> getPlatformComponentList(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
225 |
|
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
226 |
private static Void checkSubclassPermission() { |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
227 |
SecurityManager sm = System.getSecurityManager(); |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
228 |
if (sm != null) { |
30355
e37c7eba132f
8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents:
28775
diff
changeset
|
229 |
sm.checkPermission(new RuntimePermission(PlatformMBeanProvider.class.getName()+".subclass")); |
28775
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
230 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
231 |
return null; |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
232 |
} |
d786aae24263
8065213: Specify and implement PlatformMBeanProvider for looking for all platform MBeans
sjiang
parents:
diff
changeset
|
233 |
} |