Class JmxUtil


  • public class JmxUtil
    extends Object
    Class containing JMX related utility methods.
    Since:
    5.0
    Author:
    Galder ZamarreƱo
    • Constructor Detail

      • JmxUtil

        public JmxUtil()
    • Method Detail

      • buildJmxDomain

        public static String buildJmxDomain​(String domain,
                                            MBeanServer mBeanServer,
                                            String groupName)
        Build the JMX domain name.
        Parameters:
        domain - The JMX domain name
        mBeanServer - the MBeanServer where to check whether the JMX domain is allowed or not.
        groupName - String containing the group name for the JMX MBean
        Returns:
        A string that combines the allowed JMX domain and the group name
      • registerMBean

        public static void registerMBean​(Object mbean,
                                         ObjectName objectName,
                                         MBeanServer mBeanServer)
                                  throws Exception
        Register the given dynamic JMX MBean.
        Parameters:
        mbean - Dynamic MBean to register
        objectName - ObjectName under which to register the MBean.
        mBeanServer - MBeanServer where to store the MBean.
        Throws:
        Exception - If registration could not be completed.
      • unregisterMBean

        public static void unregisterMBean​(ObjectName objectName,
                                           MBeanServer mBeanServer)
                                    throws Exception
        Unregister the MBean located under the given ObjectName
        Parameters:
        objectName - ObjectName where the MBean is registered
        mBeanServer - MBeanServer from which to unregister the MBean.
        Throws:
        Exception - If unregistration could not be completed.
      • unregisterMBeans

        public static int unregisterMBeans​(String filter,
                                           MBeanServer mBeanServer)
        Unregister all mbeans whose object names match a given filter.
        Parameters:
        filter - ObjectName-style formatted filter
        mBeanServer - mbean server from which to unregister mbeans
        Returns:
        number of mbeans unregistered