首页 > 代码库 > JMX示例
JMX示例
HelloJMXMBean.java
package jmx;/** * Created by george on 14-8-21. */public interface HelloJMXMBean { public String getName(); public void setName(String name); public void printHello(); public void printHello(String whoName);}
HelloJMX.java
package jmx;import javax.management.MBeanServer;import javax.management.ObjectName;import java.lang.management.ManagementFactory;/** * Created by george on 14-8-21. */public class HelloJMX implements HelloJMXMBean { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public void printHello() { System.out.println("HelloJMX, " + name); } public void printHello(String whoName) { System.out.println("HelloJMX, it is " + whoName); } public static void main(String[] args) throws Exception { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); ObjectName helloName = new ObjectName("george:name=HelloJMX"); server.registerMBean(new HelloJMX(), helloName); Thread.sleep(Long.MAX_VALUE); }}
1. run....
2. jconsole....
JMX示例
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。