< prev index next >

src/jdk.management/share/classes/com/sun/management/internal/PlatformMBeanProviderImpl.java

Print this page

148                 return threadMXBeanInterfaceNames;
149             }
150 
151             @Override
152             public String getObjectNamePattern() {
153                 return ManagementFactory.THREAD_MXBEAN_NAME;
154             }
155 
156             @Override
157             public synchronized Map<String, java.lang.management.ThreadMXBean> nameToMBeanMap() {
158                 if (threadMBean == null) {
159                     threadMBean = new HotSpotThreadImpl(ManagementFactoryHelper.getVMManagement());
160                 }
161                 return Collections.singletonMap(
162                         ManagementFactory.THREAD_MXBEAN_NAME,
163                         threadMBean);
164             }
165         });
166 
167         /**
168          * VirtualThreadSchedulerMXBean.
169          */
170         initMBeanList.add(new PlatformComponent<VirtualThreadSchedulerMXBean>() {
171             private final Set<Class<? extends VirtualThreadSchedulerMXBean>> mbeanInterfaces =
172                     Set.of(VirtualThreadSchedulerMXBean.class);
173             private final Set<String> mbeanInterfaceNames =
174                     Set.of(VirtualThreadSchedulerMXBean.class.getName());
175             private VirtualThreadSchedulerMXBean impl;
176 
177             @Override
178             public Set<Class<? extends VirtualThreadSchedulerMXBean>> mbeanInterfaces() {
179                 return mbeanInterfaces;
180             }



181 
182             @Override
183             public Set<String> mbeanInterfaceNames() {
184                 return mbeanInterfaceNames;
185             }
186 
187             @Override
188             public String getObjectNamePattern() {
189                 return "jdk.management:type=VirtualThreadScheduler";
190             }
191 
192             @Override
193             public Map<String, VirtualThreadSchedulerMXBean> nameToMBeanMap() {
194                 VirtualThreadSchedulerMXBean impl = this.impl;
195                 if (impl == null) {
196                     this.impl = impl = VirtualThreadSchedulerImpls.create();


197                 }
198                 return Map.of("jdk.management:type=VirtualThreadScheduler", impl);
199             }
200         });
201 
202         /**
203          * OperatingSystemMXBean
204          */
205         initMBeanList.add(new PlatformComponent<OperatingSystemMXBean>() {
206             private final Set<String> operatingSystemMXBeanInterfaceNames
207                     = Collections.unmodifiableSet(
208                             Stream.of("java.lang.management.OperatingSystemMXBean",
209                                     "com.sun.management.OperatingSystemMXBean",
210                                     "com.sun.management.UnixOperatingSystemMXBean")
211                             .collect(Collectors.toSet()));
212 
213             @Override
214             public Set<Class<? extends OperatingSystemMXBean>> mbeanInterfaces() {
215                 return Stream.of(java.lang.management.OperatingSystemMXBean.class,
216                         com.sun.management.OperatingSystemMXBean.class,
217                         com.sun.management.UnixOperatingSystemMXBean.class)
218                         .collect(Collectors.toSet());
219             }
220 

148                 return threadMXBeanInterfaceNames;
149             }
150 
151             @Override
152             public String getObjectNamePattern() {
153                 return ManagementFactory.THREAD_MXBEAN_NAME;
154             }
155 
156             @Override
157             public synchronized Map<String, java.lang.management.ThreadMXBean> nameToMBeanMap() {
158                 if (threadMBean == null) {
159                     threadMBean = new HotSpotThreadImpl(ManagementFactoryHelper.getVMManagement());
160                 }
161                 return Collections.singletonMap(
162                         ManagementFactory.THREAD_MXBEAN_NAME,
163                         threadMBean);
164             }
165         });
166 
167         /**
168          * VirtualThreadSchedulerMXBean registered when using JDK's virtual thread scheduler.
169          */
170         PrivilegedAction<String> pa = () -> System.getProperty("jdk.virtualThreadScheduler.implClass");
171         String value = AccessController.doPrivileged(pa);
172         if (value == null) {
173             initMBeanList.add(new PlatformComponent<VirtualThreadSchedulerMXBean>() {
174                 private final Set<Class<? extends VirtualThreadSchedulerMXBean>> mbeanInterfaces =
175                         Set.of(VirtualThreadSchedulerMXBean.class);
176                 private final Set<String> mbeanInterfaceNames =
177                         Set.of(VirtualThreadSchedulerMXBean.class.getName());
178                 private VirtualThreadSchedulerMXBean impl;
179 
180                 @Override
181                 public Set<Class<? extends VirtualThreadSchedulerMXBean>> mbeanInterfaces() {
182                     return mbeanInterfaces;
183                 }
184 
185                 @Override
186                 public Set<String> mbeanInterfaceNames() {
187                     return mbeanInterfaceNames;
188                 }
189 
190                 @Override
191                 public String getObjectNamePattern() {
192                     return "jdk.management:type=VirtualThreadScheduler";
193                 }
194 
195                 @Override
196                 public Map<String, VirtualThreadSchedulerMXBean> nameToMBeanMap() {
197                     VirtualThreadSchedulerMXBean impl = this.impl;
198                     if (impl == null) {
199                         this.impl = impl = VirtualThreadSchedulerImpls.create();
200                     }
201                     return Map.of("jdk.management:type=VirtualThreadScheduler", impl);
202                 }
203             });
204         }

205 
206         /**
207          * OperatingSystemMXBean
208          */
209         initMBeanList.add(new PlatformComponent<OperatingSystemMXBean>() {
210             private final Set<String> operatingSystemMXBeanInterfaceNames
211                     = Collections.unmodifiableSet(
212                             Stream.of("java.lang.management.OperatingSystemMXBean",
213                                     "com.sun.management.OperatingSystemMXBean",
214                                     "com.sun.management.UnixOperatingSystemMXBean")
215                             .collect(Collectors.toSet()));
216 
217             @Override
218             public Set<Class<? extends OperatingSystemMXBean>> mbeanInterfaces() {
219                 return Stream.of(java.lang.management.OperatingSystemMXBean.class,
220                         com.sun.management.OperatingSystemMXBean.class,
221                         com.sun.management.UnixOperatingSystemMXBean.class)
222                         .collect(Collectors.toSet());
223             }
224 
< prev index next >