Class MBeanFinder

java.lang.Object
clazzfish.monitor.jmx.MBeanFinder

public class MBeanFinder extends Object
This class simplifies the use of JMX and MBeans a little bit. It replaces the old MBeanHelper class from PatternTesting.
Since:
2.3
Author:
oliver
  • Method Details

    • getMBeanName

      public static String getMBeanName(Object mbean)
      Gets an MBean name for the given object.
      Parameters:
      mbean - the mbean
      Returns:
      the name of the MBean
    • getMBeanName

      public static String getMBeanName(Class<?> cl)
      Converts the class name into a MBean name. For a hierachical structure of the registered MBeans take a look at Java Management Extensions (JMX) - Best Practices.

      The default level for an MBean is since 1.4.3 now set to "1". This means you will find all MBeans ClazzFish under the node "clazzfish" if you open your JMX console (e.g. the 'jconsole' from the JDK).

      Parameters:
      cl - a class, e.g. my.good.bye.World
      Returns:
      a valid MBean name, e.g. "my:type=good,good=bye,name=World"
      See Also:
    • getMBeanName

      public static String getMBeanName(Class<?> cl, int level)
      Converts the class name into a MBean name. For a hierachical structure of the registered MBeans take a look at Java Management Extensions (JMX) - Best Practices.

      With the 2nd parameter (level) you can control the root element. If you set it i.e. to 2 the result in the jconsole would look like:

       my.good
           bye
               World
       

      if the given class is "my.good.by.World".

      Parameters:
      cl - e.g. my.good.bye.World
      level - the level, e.g. 2
      Returns:
      a valid MBean name e.g. "my.good:type=bye,name=World"
    • getMBeanName

      public static String getMBeanName(String name)
      Because it is not so easy to construct a correct MBean name. So this method helps to translate a simple name into an MBean name.

      If the given name is already a a valid MBean name it will be returned untouched.

      Parameters:
      name - e.g. "one.two.For"
      Returns:
      e.g. "one:type=two,name=For"
      Since:
      1.6
    • getAsObjectName

      public static ObjectName getAsObjectName(String name)
      Gets a class as ObjectName.
      Parameters:
      name - the name
      Returns:
      name as object name
      Since:
      1.6
    • getAsObjectName

      public static ObjectName getAsObjectName(Class<?> mbeanClass)
      Gets a class as ObjectName.
      Parameters:
      mbeanClass - the mbean class
      Returns:
      class as object name
      Since:
      1.6
    • registerMBean

      public static void registerMBean(Object mbean)
      Register the given object as MBean.
      Parameters:
      mbean - the MBean for registration
    • registerMBean

      public static void registerMBean(String mbeanName, Object mbean)
      Register the given object as MBean.
      Parameters:
      mbeanName - the mbean name
      mbean - the mbean
    • registerMBean

      public static void registerMBean(ObjectName name, Object mbean)
      Register m bean.
      Parameters:
      name - the name
      mbean - the mbean
    • unregisterMBean

      public static void unregisterMBean(ObjectName name)
      Unregister an MBean.
      Parameters:
      name - the name
    • isRegistered

      public static boolean isRegistered(String mbeanName)
      Checks if is registered.
      Parameters:
      mbeanName - the mbean name
      Returns:
      true, if is registered
    • isRegistered

      public static boolean isRegistered(ObjectName name)
      Checks if is registered.
      Parameters:
      name - the name
      Returns:
      true, if is registered
      Since:
      1.6
    • createTabularDataSupport

      public static TabularDataSupport createTabularDataSupport(CompositeType rowType, String[] itemNames) throws OpenDataException
      Creates a TabularDataSupport object.
      Parameters:
      rowType - the row type
      itemNames - the item names
      Returns:
      the tabular data support
      Throws:
      OpenDataException - if an element's value of itemNames is not an item name defined in rowType.
    • findMBean

      public static ObjectInstance findMBean(String... mbeanNames)
      Finds an MBean with the given names.
      Parameters:
      mbeanNames - names of the MBeans to be looked for
      Returns:
      an instance of the MBean or null if no one is found