本文整理汇总了Java中java.lang.management.ClassLoadingMXBean.setVerbose方法的典型用法代码示例。如果您正苦于以下问题:Java ClassLoadingMXBean.setVerbose方法的具体用法?Java ClassLoadingMXBean.setVerbose怎么用?Java ClassLoadingMXBean.setVerbose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.management.ClassLoadingMXBean
的用法示例。
在下文中一共展示了ClassLoadingMXBean.setVerbose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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());
}
示例3: testClassLoadingMXBean
import java.lang.management.ClassLoadingMXBean; //导入方法依赖的package包/类
@Test
public void testClassLoadingMXBean() throws IOException {
DescribedResource describedResource = basicResourceTest("class-loading", null);
ClassLoadingMXBean mbean = ManagementFactory.getClassLoadingMXBean();
boolean verbose = describedResource.resource.get("verbose").asBoolean();
Assert.assertEquals(mbean.isVerbose(), verbose);
ModelNode op = getOperation("write-attribute", "class-loading", null);
op.get("name").set("verbose");
op.get("value").set(!verbose);
executeOp(op, false);
Assert.assertEquals(mbean.isVerbose(), !verbose);
// Restore
mbean.setVerbose(verbose);
}
示例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"));
}
示例5: 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"));
}