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


Java ClassLoadingMXBean.isVerbose方法代码示例

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


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

示例1: main

import java.lang.management.ClassLoadingMXBean; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    ClassLoadingMXBean classMXBean = ManagementFactory
            .getClassLoadingMXBean();
    if (!classMXBean.isVerbose()) {
        fail();
    }
    Class.forName(args[0]);
    classMXBean.setVerbose(false);
    if (classMXBean.isVerbose()) {
        fail();
    }
    System.out.println(args[1]);
    Class.forName(args[2]);
    classMXBean.setVerbose(true);
    if (!classMXBean.isVerbose()) {
        fail();
    }
    System.out.println(args[3]);
    System.exit(77);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:Test.java

示例2: testNewPlatformMXBeanProxy_ClassLoadingMXBean

import java.lang.management.ClassLoadingMXBean; //导入方法依赖的package包/类
public void testNewPlatformMXBeanProxy_ClassLoadingMXBean()
        throws Exception {
    ClassLoadingMXBean proxy = ManagementFactory.newPlatformMXBeanProxy(
            ManagementFactory.getPlatformMBeanServer(),
            "java.lang:type=ClassLoading", ClassLoadingMXBean.class);
    assertNotNull(proxy);
    ClassLoadingMXBean classLoadingMXBean = ManagementFactory
            .getClassLoadingMXBean();
    assertEquals(proxy.getLoadedClassCount(), classLoadingMXBean
            .getLoadedClassCount());
    assertEquals(proxy.getTotalLoadedClassCount(), classLoadingMXBean
            .getTotalLoadedClassCount());
    assertEquals(proxy.getUnloadedClassCount(), classLoadingMXBean
            .getUnloadedClassCount());
    assertEquals(proxy.isVerbose(), classLoadingMXBean.isVerbose());

    boolean initialVal = proxy.isVerbose();
    proxy.setVerbose(!initialVal);
    assertTrue(proxy.isVerbose() != initialVal);
    proxy.setVerbose(initialVal);
    assertEquals(initialVal, proxy.isVerbose());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:ManagementFactoryTest.java

示例3: main

import java.lang.management.ClassLoadingMXBean; //导入方法依赖的package包/类
public static void main(String[] args)
  throws Exception
{
  System.out.println("Testing locally...");
  ClassLoadingMXBean bean = ManagementFactory.getClassLoadingMXBean();
  System.out.println("Bean: " + bean);
  System.out.println("Loaded classes: " + bean.getLoadedClassCount());
  System.out.println("Unloaded classes: " + bean.getUnloadedClassCount());
  System.out.println("Total loaded classes: " + bean.getTotalLoadedClassCount());
  boolean verbosity = bean.isVerbose();
  System.out.println("Verbose class output: " + (verbosity ? "yes" : "no"));
  System.out.println("Changing verbose setting...");
  bean.setVerbose(!verbosity);
  System.out.println("Verbose class output: " + (bean.isVerbose() ? "yes" : "no"));
  System.out.println("Testing via the server...");
  MBeanServer server = ManagementFactory.getPlatformMBeanServer();
  ObjectName classBean = new ObjectName(CLASS_LOADING_MXBEAN_NAME);
  System.out.println("Bean: " + classBean);
  System.out.println("Loaded classes: " + server.getAttribute(classBean, "LoadedClassCount"));
  System.out.println("Unloaded classes: " + server.getAttribute(classBean,
                                                                "UnloadedClassCount"));
  System.out.println("Total loaded classes: " + server.getAttribute(classBean,
                                                                    "TotalLoadedClassCount"));
  verbosity = (Boolean) server.getAttribute(classBean, "Verbose");
  System.out.println("Verbose class output: " + (verbosity ? "yes" : "no"));
  System.out.println("Changing verbose setting...");
  server.setAttribute(classBean, new Attribute("Verbose", !verbosity));
  System.out.println("Verbose class output: " + ((Boolean)
                                                 server.getAttribute(classBean, "Verbose") ?
                                                 "yes" : "no"));
  System.out.println("Testing via the proxy...");
  bean = ManagementFactory.newPlatformMXBeanProxy(server, CLASS_LOADING_MXBEAN_NAME,
                                                  ClassLoadingMXBean.class);
  System.out.println("Bean: " + bean);
  System.out.println("Loaded classes: " + bean.getLoadedClassCount());
  System.out.println("Unloaded classes: " + bean.getUnloadedClassCount());
  System.out.println("Total loaded classes: " + bean.getTotalLoadedClassCount());
  verbosity = bean.isVerbose();
  System.out.println("Verbose class output: " + (verbosity ? "yes" : "no"));
  System.out.println("Changing verbose setting...");
  bean.setVerbose(!verbosity);
  System.out.println("Verbose class output: " + (bean.isVerbose() ? "yes" : "no"));
}
 
开发者ID:vilie,项目名称:javify,代码行数:44,代码来源:TestClassLoading.java

示例4: main

import java.lang.management.ClassLoadingMXBean; //导入方法依赖的package包/类
public static void main(String[] args)
  throws Exception
{
  System.out.println("Testing locally...");
  ClassLoadingMXBean bean = ManagementFactory.getClassLoadingMXBean();
  System.out.println("Bean: " + bean);
  System.out.println("Loaded classes: " + bean.getLoadedClassCount());
  System.out.println("Unloaded classes: " + bean.getUnloadedClassCount());
  System.out.println("Total loaded classes: " + bean.getTotalLoadedClassCount());
  boolean verbosity = bean.isVerbose();
  System.out.println("Verbose class output: " + (verbosity ? "yes" : "no"));
  System.out.println("Changing verbose setting...");
  bean.setVerbose(!verbosity);
  System.out.println("Verbose class output: " + (bean.isVerbose() ? "yes" : "no"));
  System.out.println("Testing via the server...");
  MBeanServer server = ManagementFactory.getPlatformMBeanServer();
  ObjectName classBean = new ObjectName(CLASS_LOADING_MXBEAN_NAME);
  System.out.println("Bean: " + classBean);
  System.out.println("Loaded classes: " + server.getAttribute(classBean, "LoadedClassCount"));
  System.out.println("Unloaded classes: " + server.getAttribute(classBean,
						  "UnloadedClassCount"));
  System.out.println("Total loaded classes: " + server.getAttribute(classBean,
						      "TotalLoadedClassCount"));
  verbosity = (Boolean) server.getAttribute(classBean, "Verbose");
  System.out.println("Verbose class output: " + (verbosity ? "yes" : "no"));
  System.out.println("Changing verbose setting...");
  server.setAttribute(classBean, new Attribute("Verbose", !verbosity));
  System.out.println("Verbose class output: " + ((Boolean)
				   server.getAttribute(classBean, "Verbose") ?
				   "yes" : "no"));
  System.out.println("Testing via the proxy...");
  bean = ManagementFactory.newPlatformMXBeanProxy(server, CLASS_LOADING_MXBEAN_NAME,
				    ClassLoadingMXBean.class);
  System.out.println("Bean: " + bean);
  System.out.println("Loaded classes: " + bean.getLoadedClassCount());
  System.out.println("Unloaded classes: " + bean.getUnloadedClassCount());
  System.out.println("Total loaded classes: " + bean.getTotalLoadedClassCount());
  verbosity = bean.isVerbose();
  System.out.println("Verbose class output: " + (verbosity ? "yes" : "no"));
  System.out.println("Changing verbose setting...");
  bean.setVerbose(!verbosity);
  System.out.println("Verbose class output: " + (bean.isVerbose() ? "yes" : "no"));
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:44,代码来源:TestClassLoading.java


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