188 */ 189 public default <I> List<? extends I> getMBeans(Class<I> mbeanIntf) { 190 List<I> list; 191 192 if (!mbeanInterfaceNames().contains(mbeanIntf.getName())) { 193 list = Collections.emptyList(); 194 } else { 195 list = nameToMBeanMap().values().stream() 196 .filter(mbeanIntf::isInstance) 197 .map(mbeanIntf::cast) 198 .collect(Collectors.toList()); 199 } 200 return list; 201 } 202 } 203 204 /** 205 * Instantiates a new PlatformMBeanProvider. 206 * 207 * @throws SecurityException if the subclass (and calling code) does not 208 * have {@code RuntimePermission("sun.management.spi.PlatformMBeanProvider", "subclass")} 209 */ 210 protected PlatformMBeanProvider () { 211 this(checkSubclassPermission()); 212 } 213 214 private PlatformMBeanProvider(Void unused) { 215 } 216 217 /** 218 * Returns a list of PlatformComponent instances describing the Platform 219 * MBeans provided by this provider. 220 * 221 * @return a list of PlatformComponent instances describing the Platform 222 * MBeans provided by this provider. 223 */ 224 public abstract List<PlatformComponent<?>> getPlatformComponentList(); 225 226 private static Void checkSubclassPermission() { 227 SecurityManager sm = System.getSecurityManager(); 228 if (sm != null) { 229 sm.checkPermission(new RuntimePermission(PlatformMBeanProvider.class.getName(), "subclass")); 230 } 231 return null; 232 } 233 } | 188 */ 189 public default <I> List<? extends I> getMBeans(Class<I> mbeanIntf) { 190 List<I> list; 191 192 if (!mbeanInterfaceNames().contains(mbeanIntf.getName())) { 193 list = Collections.emptyList(); 194 } else { 195 list = nameToMBeanMap().values().stream() 196 .filter(mbeanIntf::isInstance) 197 .map(mbeanIntf::cast) 198 .collect(Collectors.toList()); 199 } 200 return list; 201 } 202 } 203 204 /** 205 * Instantiates a new PlatformMBeanProvider. 206 * 207 * @throws SecurityException if the subclass (and calling code) does not 208 * have {@code RuntimePermission("sun.management.spi.PlatformMBeanProvider.subclass")} 209 */ 210 protected PlatformMBeanProvider () { 211 this(checkSubclassPermission()); 212 } 213 214 private PlatformMBeanProvider(Void unused) { 215 } 216 217 /** 218 * Returns a list of PlatformComponent instances describing the Platform 219 * MBeans provided by this provider. 220 * 221 * @return a list of PlatformComponent instances describing the Platform 222 * MBeans provided by this provider. 223 */ 224 public abstract List<PlatformComponent<?>> getPlatformComponentList(); 225 226 private static Void checkSubclassPermission() { 227 SecurityManager sm = System.getSecurityManager(); 228 if (sm != null) { 229 sm.checkPermission(new RuntimePermission(PlatformMBeanProvider.class.getName()+".subclass")); 230 } 231 return null; 232 } 233 } |