I need to be able to display the JBoss server name: default, all or any user defined JBoss instance. I need to do this in a vendor nuetral way as the same code will run in WebSphere and JBoss.
JSR 77 seemed to be the answer to my problem and the name attribute of the J2EEServer managed object seemed to be exactly what I needed. So I wrote this code:
Context ctx = new InitialContext(); Object objref = ctx.lookup("ejb/mgmt/MEJB"); ManagementHome home = (ManagementHome)PortableRemoteObject.narrow(objref,ManagementHome.class); Management mejb = home.create(); String domain = mejb.getDefaultDomain(); Set servers = mejb.queryNames( new ObjectName(domain + ":j2eeType=J2EEServer,*"),null); Iterator itr = servers.iterator(); while(itr.hasNext()) { ObjectName objectname = (ObjectName)itr.next(); out.println(objectname+"<BR>"); out.println(objectname.getKeyProperty("name")+"<BR>"); /* get MBeanInfo and print the info */ //MBeanInfo moi = mejb.getMBeanInfo(objectname); out.println("serverVendor: " + mejb.getAttribute(objectname, "serverVendor")+"<BR>"); out.println("serverVersion: " + mejb.getAttribute(objectname, "serverVersion")+"<BR>"); }