ManagementFactory.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:freeVM 作者:
/**
 * Returns a reference to the virtual machine's platform
 * <code>MBeanServer</code>. This <code>MBeanServer</code> will have
 * all of the platform <code>MXBean</code> s registered with it including
 * any dynamic <code>MXBean</code> s (e.g. instances of
 * {@link GarbageCollectorMXBean}that may be unregistered and destroyed at
 * a later time.
 * <p>
 * In order to simplify the process of distribution and discovery of managed
 * beans it is good practice to register all managed beans (in addition to
 * the platform <code>MXBean</code>s) with this server.
 * </p>
 * <p>
 * A custom <code>MBeanServer</code> can be created by this method if the
 * System property <code>javax.management.builder.initial</code> has been
 * set with the fully qualified name of a subclass of
 * {@link javax.management.MBeanServerBuilder}.
 * </p>
 * 
 * @return the platform <code>MBeanServer</code>.
 * @throws SecurityException
 *             if there is a Java security manager in operation and the
 *             caller of this method does not have
 *             &quot;createMBeanServer&quot;
 *             <code>MBeanServerPermission</code>.
 * @see MBeanServer
 * @see javax.management.MBeanServerPermission
 */
public static MBeanServer getPlatformMBeanServer() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new MBeanServerPermission(
                "createMBeanServer"));
    }

    synchronized (ManagementFactory.class) {
        if (platformServer == null) {
            platformServer = MBeanServerFactory.createMBeanServer();

            AccessController.doPrivileged(new PrivilegedAction<Object>() {
                public Object run() {
                    registerPlatformBeans(platformServer);
                    return null;
                }// end method run
            });
        }
    }// end synchronized
    return platformServer;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号