0 Replies Latest reply on Nov 24, 2008 8:01 PM by Ben Schofield

    How do display JBoss server name

    Ben Schofield Novice

      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();
       /* 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>");

      The result is that WebSphere returns what I wanted and anticipated by giving the name of the server which we see in the WebSphere admin console and use to administrate the WebSphere environment.

      In JBoss 5.0.0 cr2 I get back this object name: jboss.management.local:name=Local,j2eeType=J2EEServer
      and as you can see the name attribute is "Local" and not "all" as I was hoping.

      So my questions are:
      1) Is there a way to display "default" or "all" in JBoss that aligns with a JEE5 standard?
      2) Should the name attribute of the J2EEServer return "default" or "all" instead of "Local"? If not, what is the reasoning behind using Local?