zoukankan      html  css  js  c++  java
  • 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....

  • 相关阅读:
    北京南天软件java工程师面试题
    祝福自己
    致青春——IT之路
    PL/SQL devloper 常用设置
    CENTOS LINUX查询内存大小、频率
    centOS安装openoffice
    echo > 和 echo >>的区别
    sqoop job 增量导入
    sqoop job从创建到执行
    sqoop导入增量数据
  • 原文地址:https://www.cnblogs.com/niulang85/p/3937471.html
Copyright © 2011-2022 走看看