Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/classes/sun/management/ManagementFactoryHelper.java
          +++ new/src/share/classes/sun/management/ManagementFactoryHelper.java
   1    1  /*
   2      - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
        2 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
   3    3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4    4   *
   5    5   * This code is free software; you can redistribute it and/or modify it
   6    6   * under the terms of the GNU General Public License version 2 only, as
   7    7   * published by the Free Software Foundation.  Oracle designates this
   8    8   * particular file as subject to the "Classpath" exception as provided
   9    9   * by Oracle in the LICENSE file that accompanied this code.
  10   10   *
  11   11   * This code is distributed in the hope that it will be useful, but WITHOUT
  12   12   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
↓ open down ↓ 7 lines elided ↑ open up ↑
  20   20   *
  21   21   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22   22   * or visit www.oracle.com if you need additional information or have any
  23   23   * questions.
  24   24   */
  25   25  
  26   26  package sun.management;
  27   27  
  28   28  import java.lang.management.*;
  29   29  
       30 +import javax.management.DynamicMBean;
  30   31  import javax.management.InstanceAlreadyExistsException;
  31   32  import javax.management.InstanceNotFoundException;
  32   33  import javax.management.MBeanServer;
  33   34  import javax.management.MBeanRegistrationException;
  34   35  import javax.management.NotCompliantMBeanException;
  35   36  import javax.management.ObjectName;
  36   37  import javax.management.RuntimeOperationsException;
  37   38  import java.security.AccessController;
  38   39  import java.security.PrivilegedActionException;
  39   40  import java.security.PrivilegedExceptionAction;
  40   41  
  41   42  import sun.util.logging.LoggingSupport;
  42   43  
  43   44  import java.util.ArrayList;
  44   45  import java.util.Collections;
       46 +import java.util.HashMap;
  45   47  import java.util.List;
       48 +import com.sun.management.DiagnosticCommandMBean;
  46   49  import com.sun.management.OSMBeanFactory;
  47   50  import com.sun.management.HotSpotDiagnosticMXBean;
  48   51  
  49   52  import static java.lang.management.ManagementFactory.*;
  50   53  
  51   54  /**
  52   55   * ManagementFactoryHelper provides static factory methods to create
  53   56   * instances of the management interface.
  54   57   */
  55   58  public class ManagementFactoryHelper {
↓ open down ↓ 200 lines elided ↑ open up ↑
 256  259              }
 257  260          };
 258  261      }
 259  262  
 260  263      private static HotSpotDiagnostic hsDiagMBean = null;
 261  264      private static HotspotRuntime hsRuntimeMBean = null;
 262  265      private static HotspotClassLoading hsClassMBean = null;
 263  266      private static HotspotThread hsThreadMBean = null;
 264  267      private static HotspotCompilation hsCompileMBean = null;
 265  268      private static HotspotMemory hsMemoryMBean = null;
      269 +    private static DiagnosticCommandImpl hsDiagCommandMBean = null;
 266  270  
 267  271      public static synchronized HotSpotDiagnosticMXBean getDiagnosticMXBean() {
 268  272          if (hsDiagMBean == null) {
 269  273              hsDiagMBean = new HotSpotDiagnostic();
 270  274          }
 271  275          return hsDiagMBean;
 272  276      }
 273  277  
 274  278      /**
 275  279       * This method is for testing only.
↓ open down ↓ 28 lines elided ↑ open up ↑
 304  308      /**
 305  309       * This method is for testing only.
 306  310       */
 307  311      public static synchronized HotspotMemoryMBean getHotspotMemoryMBean() {
 308  312          if (hsMemoryMBean == null) {
 309  313              hsMemoryMBean = new HotspotMemory(jvm);
 310  314          }
 311  315          return hsMemoryMBean;
 312  316      }
 313  317  
      318 +    public static synchronized DiagnosticCommandMBean getDiagnosticCommandMBean() {
      319 +        // Remote Diagnostic Commands may not be supported
      320 +        if (hsDiagCommandMBean == null && jvm.isRemoteDiagnosticCommandsSupported()) {
      321 +            hsDiagCommandMBean = new DiagnosticCommandImpl(jvm);
      322 +        }
      323 +        return hsDiagCommandMBean;
      324 +    }
      325 +
 314  326      /**
 315  327       * This method is for testing only.
 316  328       */
 317  329      public static synchronized HotspotCompilationMBean getHotspotCompilationMBean() {
 318  330          if (hsCompileMBean == null) {
 319  331              hsCompileMBean = new HotspotCompilation(jvm);
 320  332          }
 321  333          return hsCompileMBean;
 322  334      }
 323  335  
↓ open down ↓ 34 lines elided ↑ open up ↑
 358  370  
 359  371      private final static String HOTSPOT_MEMORY_MBEAN_NAME =
 360  372          "sun.management:type=HotspotMemory";
 361  373  
 362  374      private static final String HOTSPOT_RUNTIME_MBEAN_NAME =
 363  375          "sun.management:type=HotspotRuntime";
 364  376  
 365  377      private final static String HOTSPOT_THREAD_MBEAN_NAME =
 366  378          "sun.management:type=HotspotThreading";
 367  379  
      380 +    final static String HOTSPOT_DIAGNOSTIC_COMMAND_MBEAN_NAME =
      381 +        "com.sun.management:type=DiagnosticCommand";
      382 +
      383 +    public static HashMap<ObjectName, DynamicMBean> getPlatformDynamicMBeans() {
      384 +        HashMap<ObjectName, DynamicMBean> map = new HashMap<>();
      385 +        if (getDiagnosticCommandMBean() != null) {
      386 +            map.put(Util.newObjectName(HOTSPOT_DIAGNOSTIC_COMMAND_MBEAN_NAME), getDiagnosticCommandMBean());
      387 +        }
      388 +        return map;
      389 +    }
      390 +
 368  391      static void registerInternalMBeans(MBeanServer mbs) {
 369  392          // register all internal MBeans if not registered
 370  393          // No exception is thrown if a MBean with that object name
 371  394          // already registered
 372  395          addMBean(mbs, getHotspotClassLoadingMBean(),
 373  396              HOTSPOT_CLASS_LOADING_MBEAN_NAME);
 374  397          addMBean(mbs, getHotspotMemoryMBean(),
 375  398              HOTSPOT_MEMORY_MBEAN_NAME);
 376  399          addMBean(mbs, getHotspotRuntimeMBean(),
 377  400              HOTSPOT_RUNTIME_MBEAN_NAME);
↓ open down ↓ 76 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX