當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。