jmx获取jboss配置信息

首先把jar包下载下来(jboss-4.2.3.GA)

http://download.youkuaiyun.com/detail/u010792467/7753867

把jar包放在lib下面,在eclipse中添加以下代码

Java类

publicstaticvoid main(String[] args)throws Exception {

        //Get RMIAdaptor Object

        Properties pro =new Properties();

        pro.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");

        pro.setProperty("java.naming.provider.url","jnp://localhost:1099");

        pro.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");

        InitialContext ic =new InitialContext(pro);

        RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/rmi/RMIAdaptor");

 

        // Get the MBeanInfo for the JNDIView MBean

        ObjectName name =new ObjectName("jboss:service=JNDIView");

        MBeanInfo info = server.getMBeanInfo(name);

        System.out.println("JNDIView Class: " + info.getClassName());

        MBeanOperationInfo[] opInfo = info.getOperations();

        System.out.println("JNDIView Operations: ");

        for (int o = 0; o < opInfo.length; o++){

            MBeanOperationInfo op = opInfo[o];

            String returnType = op.getReturnType();

            String opName = op.getName();

            System.out.print(" + " + returnType + " " + opName +"(");

            MBeanParameterInfo[] params = op.getSignature();

            for (int p = 0; p < params.length; p++) {

                MBeanParameterInfo paramInfo = params[p];

                String pname = paramInfo.getName();

                String type = paramInfo.getType();

                if (pname.equals(type))

                    System.out.print(type);

                else

                    System.out.print(type +" " + name);

                if (p < params.length - 1)

                    System.out.print("");

            }

            System.out.println(")");

        }

 

        //Get all MBeans

        Set mbSet = server.queryMBeans(null,null);//

        for (Iterator it = mbSet.iterator(); it.hasNext();) {

            ObjectInstance oi = (ObjectInstance) it.next();

            System.out.println(oi.getObjectName());

        }

    }

下面是代码和控制台输出的信息。


作者:儱剑阿攵
转载请注明链接:http://blog.youkuaiyun.com/awenluck/article/details/38560429

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值