首先把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