1 package org.jboss.mx.remoting; 2 3 import java.util.ArrayList ; 4 import javax.management.MBeanServer ; 5 import javax.management.MBeanServerFactory ; 6 import javax.management.ObjectName ; 7 8 15 public class JMXUtil 16 { 17 private static ObjectName mbeanserver; 18 19 25 public static MBeanServer getMBeanServer() 26 { 27 ArrayList list = MBeanServerFactory.findMBeanServer(System.getProperty("jboss.remoting.jmxid")); 28 if(list.isEmpty()) 29 { 30 return null; 31 } 32 return (MBeanServer ) list.iterator().next(); 33 } 34 35 41 public static final ObjectName getMBeanServerObjectName() 42 throws Exception 43 { 44 if(mbeanserver == null) 45 { 46 mbeanserver = new ObjectName ("JMImplementation:type=MBeanServerDelegate"); 47 } 48 return mbeanserver; 49 } 50 51 58 public static final String getServerId(MBeanServer server) 59 throws Exception 60 { 61 if(server == null) 62 { 63 throw new NullPointerException ("MBeanServer is null"); 64 } 65 if(mbeanserver == null) 66 { 67 mbeanserver = new ObjectName ("JMImplementation:type=MBeanServerDelegate"); 68 } 69 return (String ) server.getAttribute(mbeanserver, "MBeanServerId"); 70 } 71 72 } 73 | Popular Tags |