src/share/classes/java/lang/management/ManagementFactory.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 27,36 **** --- 27,37 ---- import javax.management.DynamicMBean; import javax.management.MBeanServer; import javax.management.MBeanServerConnection; import javax.management.MBeanServerFactory; import javax.management.MBeanServerPermission; + import javax.management.MXBean; import javax.management.NotificationEmitter; import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException;
*** 40,49 **** --- 41,51 ---- import javax.management.StandardEmitterMBean; import javax.management.StandardMBean; import java.util.Collections; import java.util.List; import java.util.Set; + import java.util.HashMap; import java.util.HashSet; import java.security.AccessController; import java.security.Permission; import java.security.PrivilegedAction; import java.security.PrivilegedActionException;
*** 480,490 **** --- 482,497 ---- if (!platformMBeanServer.isRegistered(o.getObjectName())) { addMXBean(platformMBeanServer, o); } } } + HashMap<ObjectName, DynamicMBean> dynmbeans = + ManagementFactoryHelper.getPlatformDynamicMBeans(); + for (ObjectName on : dynmbeans.keySet()) { + addDynamicMBean(platformMBeanServer, dynmbeans.get(on), on); } + } return platformMBeanServer; } /** * Returns a proxy for a platform MXBean interface of a
*** 823,828 **** --- 830,855 ---- } catch (PrivilegedActionException e) { throw new RuntimeException(e.getException()); } } + /** + * Registers a DynamicMBean. + */ + private static void addDynamicMBean(final MBeanServer mbs, + final DynamicMBean dmbean, + final ObjectName on) { + try { + AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() { + @Override + public Void run() throws InstanceAlreadyExistsException, + MBeanRegistrationException, + NotCompliantMBeanException { + mbs.registerMBean(dmbean, on); + return null; + } + }); + } catch (PrivilegedActionException e) { + throw new RuntimeException(e.getException()); + } + } }