Class JmxUtil


  • public class JmxUtil
    extends java.lang.Object
    Class containing JMX related utility methods.
    Since:
    5.0
    Author:
    Galder Zamarreño
    • Constructor Summary

      Constructors 
      Constructor Description
      JmxUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String buildJmxDomain​(java.lang.String domain, javax.management.MBeanServer mBeanServer, java.lang.String groupName)
      Build the JMX domain name.
      static javax.management.MBeanServer lookupMBeanServer​(MBeanServerLookup lookup, java.util.Properties properties)
      Looks up the MBeanServer instance.
      static void registerMBean​(java.lang.Object mbean, javax.management.ObjectName objectName, javax.management.MBeanServer mBeanServer)
      Register the given dynamic JMX MBean.
      static void unregisterMBean​(javax.management.ObjectName objectName, javax.management.MBeanServer mBeanServer)
      Unregister the MBean located under the given ObjectName
      static int unregisterMBeans​(java.lang.String filter, javax.management.MBeanServer mBeanServer)
      Unregister all mbeans whose object names match a given filter.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JmxUtil

        public JmxUtil()
    • Method Detail

      • lookupMBeanServer

        public static javax.management.MBeanServer lookupMBeanServer​(MBeanServerLookup lookup,
                                                                     java.util.Properties properties)
        Looks up the MBeanServer instance.
        Parameters:
        lookup - instance of MBeanServerLookup to use for obtaining the MBeanServer
        properties - any properties required by the MBeanServerLookup implementation
        Returns:
        an instance of MBeanServer
      • buildJmxDomain

        public static java.lang.String buildJmxDomain​(java.lang.String domain,
                                                      javax.management.MBeanServer mBeanServer,
                                                      java.lang.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​(java.lang.Object mbean,
                                         javax.management.ObjectName objectName,
                                         javax.management.MBeanServer mBeanServer)
                                  throws java.lang.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:
        java.lang.Exception - If registration could not be completed.
      • unregisterMBean

        public static void unregisterMBean​(javax.management.ObjectName objectName,
                                           javax.management.MBeanServer mBeanServer)
                                    throws java.lang.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:
        java.lang.Exception - If unregistration could not be completed.
      • unregisterMBeans

        public static int unregisterMBeans​(java.lang.String filter,
                                           javax.management.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