当前位置: 首页>>代码示例>>Java>>正文


Java RuntimeMXBean.getSystemProperties方法代码示例

本文整理汇总了Java中java.lang.management.RuntimeMXBean.getSystemProperties方法的典型用法代码示例。如果您正苦于以下问题:Java RuntimeMXBean.getSystemProperties方法的具体用法?Java RuntimeMXBean.getSystemProperties怎么用?Java RuntimeMXBean.getSystemProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.management.RuntimeMXBean的用法示例。


在下文中一共展示了RuntimeMXBean.getSystemProperties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: beforeClass

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
  // Print detail on jvm so we know what is different should below test fail.
  RuntimeMXBean b = ManagementFactory.getRuntimeMXBean();
  LOG.info("name=" + b.getName()); 
  LOG.info("specname=" + b.getSpecName()); 
  LOG.info("specvendor=" + b.getSpecVendor()); 
  LOG.info("vmname=" + b.getVmName()); 
  LOG.info("vmversion=" + b.getVmVersion()); 
  LOG.info("vmvendor=" + b.getVmVendor()); 
  Map<String, String> p = b.getSystemProperties();
  LOG.info("properties=" + p);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:TestHeapSize.java

示例2: runTest

import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
private static void runTest() throws Exception {
    RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean();

    // Print all system properties
    Map<String,String> props = mbean.getSystemProperties();
    printProperties(props);

    // Add new system properties
    System.setProperty(KEY1, VALUE1);
    System.setProperty(KEY2, VALUE2);

    Map<String,String> props1 = mbean.getSystemProperties();
    String value1 = props1.get(KEY1);
    if (value1 == null || !value1.equals(VALUE1)) {
        throw new RuntimeException(KEY1 + " property found" +
             " with value = " + value1 +
             " but expected to be " + VALUE1);
    }

    String value2 = props1.get(KEY2);
    if (value2 == null || !value2.equals(VALUE2)) {
        throw new RuntimeException(KEY2 + " property found" +
             " with value = " + value2 +
             " but expected to be " + VALUE2);
    }

    String value3 = props1.get(KEY3);
    if (value3 != null) {
        throw new RuntimeException(KEY3 + " property found" +
             " but should not exist" );
    }

    // Add new system properties but are not Strings
    Properties sp = System.getProperties();
    sp.put(KEY3, VALUE3);
    sp.put(KEY4, VALUE4);

    Map<String,String> props2 = mbean.getSystemProperties();
    // expect the system properties returned should be
    // same as the one before adding KEY3 and KEY4
    if (!props1.equals(props2)) {
        throw new RuntimeException("Two copies of system properties " +
            "are expected to be equal");
    }

    System.out.println("Test passed.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:48,代码来源:GetSystemProperties.java


注:本文中的java.lang.management.RuntimeMXBean.getSystemProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。