143 return threadMXBeanInterfaceNames;
144 }
145
146 @Override
147 public String getObjectNamePattern() {
148 return ManagementFactory.THREAD_MXBEAN_NAME;
149 }
150
151 @Override
152 public synchronized Map<String, java.lang.management.ThreadMXBean> nameToMBeanMap() {
153 if (threadMBean == null) {
154 threadMBean = new HotSpotThreadImpl(ManagementFactoryHelper.getVMManagement());
155 }
156 return Collections.singletonMap(
157 ManagementFactory.THREAD_MXBEAN_NAME,
158 threadMBean);
159 }
160 });
161
162 /**
163 * VirtualThreadSchedulerMXBean.
164 */
165 initMBeanList.add(new PlatformComponent<VirtualThreadSchedulerMXBean>() {
166 private final Set<Class<? extends VirtualThreadSchedulerMXBean>> mbeanInterfaces =
167 Set.of(VirtualThreadSchedulerMXBean.class);
168 private final Set<String> mbeanInterfaceNames =
169 Set.of(VirtualThreadSchedulerMXBean.class.getName());
170 private VirtualThreadSchedulerMXBean impl;
171
172 @Override
173 public Set<Class<? extends VirtualThreadSchedulerMXBean>> mbeanInterfaces() {
174 return mbeanInterfaces;
175 }
176
177 @Override
178 public Set<String> mbeanInterfaceNames() {
179 return mbeanInterfaceNames;
180 }
181
182 @Override
183 public String getObjectNamePattern() {
184 return "jdk.management:type=VirtualThreadScheduler";
185 }
186
187 @Override
188 public Map<String, VirtualThreadSchedulerMXBean> nameToMBeanMap() {
189 VirtualThreadSchedulerMXBean impl = this.impl;
190 if (impl == null) {
191 this.impl = impl = VirtualThreadSchedulerImpls.create();
192 }
193 return Map.of("jdk.management:type=VirtualThreadScheduler", impl);
194 }
195 });
196
197 /**
198 * OperatingSystemMXBean
199 */
200 initMBeanList.add(new PlatformComponent<OperatingSystemMXBean>() {
201 private final Set<String> operatingSystemMXBeanInterfaceNames
202 = Collections.unmodifiableSet(
203 Stream.of("java.lang.management.OperatingSystemMXBean",
204 "com.sun.management.OperatingSystemMXBean",
205 "com.sun.management.UnixOperatingSystemMXBean")
206 .collect(Collectors.toSet()));
207
208 @Override
209 public Set<Class<? extends OperatingSystemMXBean>> mbeanInterfaces() {
210 return Stream.of(java.lang.management.OperatingSystemMXBean.class,
211 com.sun.management.OperatingSystemMXBean.class,
212 com.sun.management.UnixOperatingSystemMXBean.class)
213 .collect(Collectors.toSet());
214 }
215
|
143 return threadMXBeanInterfaceNames;
144 }
145
146 @Override
147 public String getObjectNamePattern() {
148 return ManagementFactory.THREAD_MXBEAN_NAME;
149 }
150
151 @Override
152 public synchronized Map<String, java.lang.management.ThreadMXBean> nameToMBeanMap() {
153 if (threadMBean == null) {
154 threadMBean = new HotSpotThreadImpl(ManagementFactoryHelper.getVMManagement());
155 }
156 return Collections.singletonMap(
157 ManagementFactory.THREAD_MXBEAN_NAME,
158 threadMBean);
159 }
160 });
161
162 /**
163 * VirtualThreadSchedulerMXBean registered when using JDK's virtual thread scheduler.
164 */
165 String value = System.getProperty("jdk.virtualThreadScheduler.implClass");
166 if (value == null) {
167 initMBeanList.add(new PlatformComponent<VirtualThreadSchedulerMXBean>() {
168 private final Set<Class<? extends VirtualThreadSchedulerMXBean>> mbeanInterfaces =
169 Set.of(VirtualThreadSchedulerMXBean.class);
170 private final Set<String> mbeanInterfaceNames =
171 Set.of(VirtualThreadSchedulerMXBean.class.getName());
172 private VirtualThreadSchedulerMXBean impl;
173
174 @Override
175 public Set<Class<? extends VirtualThreadSchedulerMXBean>> mbeanInterfaces() {
176 return mbeanInterfaces;
177 }
178
179 @Override
180 public Set<String> mbeanInterfaceNames() {
181 return mbeanInterfaceNames;
182 }
183
184 @Override
185 public String getObjectNamePattern() {
186 return "jdk.management:type=VirtualThreadScheduler";
187 }
188
189 @Override
190 public Map<String, VirtualThreadSchedulerMXBean> nameToMBeanMap() {
191 VirtualThreadSchedulerMXBean impl = this.impl;
192 if (impl == null) {
193 this.impl = impl = VirtualThreadSchedulerImpls.create();
194 }
195 return Map.of("jdk.management:type=VirtualThreadScheduler", impl);
196 }
197 });
198 }
199
200 /**
201 * OperatingSystemMXBean
202 */
203 initMBeanList.add(new PlatformComponent<OperatingSystemMXBean>() {
204 private final Set<String> operatingSystemMXBeanInterfaceNames
205 = Collections.unmodifiableSet(
206 Stream.of("java.lang.management.OperatingSystemMXBean",
207 "com.sun.management.OperatingSystemMXBean",
208 "com.sun.management.UnixOperatingSystemMXBean")
209 .collect(Collectors.toSet()));
210
211 @Override
212 public Set<Class<? extends OperatingSystemMXBean>> mbeanInterfaces() {
213 return Stream.of(java.lang.management.OperatingSystemMXBean.class,
214 com.sun.management.OperatingSystemMXBean.class,
215 com.sun.management.UnixOperatingSystemMXBean.class)
216 .collect(Collectors.toSet());
217 }
218
|