Class MBeanHelper

java.lang.Object
clazzfish.monitor.jmx.MBeanHelper

@Deprecated(forRemoval=true) public class MBeanHelper extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
replaced by MBeanFinder
This class simplifies the use of JMX and MBeans a little bit. Originally it was part of the PatternTesting project.
Author:
oliver
  • Method Summary

    Modifier and Type
    Method
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a TabularDataSupport object.
    static ObjectName
    getAsObjectName(Class<?> mbeanClass)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets a class as ObjectName.
    static ObjectName
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets a class as ObjectName.
    static Object
    getAttribute(String mbeanName, String attributeName)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the attribute.
    static Object
    getAttribute(ObjectName mbean, String attributeName)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the attribute.
    static String
    Deprecated, for removal: This API element is subject to removal in a future version.
    Converts the class name into a MBean name.
    static String
    getMBeanName(Class<?> cl, int level)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Converts the class name into a MBean name.
    static String
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets an MBean name for the given object.
    static String
    getMBeanName(Object mbean, int level)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets an MBean name for the given object.
    static String
    Deprecated, for removal: This API element is subject to removal in a future version.
    Because it is not so easy to construct a correct MBean name.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the object instance.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the object instance.
    static boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Checks if is registered.
    static boolean
    isRegistered(String mbeanName)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Checks if is registered.
    static boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Checks if is registered.
    static void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Register the given object as MBean.
    static void
    registerMBean(String mbeanName, Object mbean)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Register the given object as MBean.
    static void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Register m bean.
    static void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Unregister an MBean.
    static void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Unregister an MBean.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getMBeanName

      public static String getMBeanName(Object mbean)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets an MBean name for the given object.
      Parameters:
      mbean - the mbean
      Returns:
      the name of the MBean
    • getMBeanName

      public static String getMBeanName(Object mbean, int level)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets an MBean name for the given object.
      Parameters:
      mbean - the mbean
      level - the level
      Returns:
      the name of the MBean
      Since:
      1.4.3
    • getMBeanName

      public static String getMBeanName(Class<?> cl)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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 "2" (see getMBeanName(Object, int). This means you will find all MBeans from PatternTesting Runtime under the node "clazzfish.monitor" if you open your JMX console (e.g. the 'jconsole' from the JDK).

      Parameters:
      cl - 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)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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.
      Returns:
      a valid MBean name e.g. "my.good:type=bye,name=World"
      Since:
      1.4.3
    • getMBeanName

      public static String getMBeanName(String name)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets a class as ObjectName.
      Parameters:
      name - the name
      Returns:
      name as object name
      Since:
      1.6
    • getAsObjectName

      public static ObjectName getAsObjectName(Class<?> mbeanClass)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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) throws JMException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Register the given object as MBean.
      Parameters:
      mbean - the mbean
      Throws:
      JMException - if registration fails
    • registerMBean

      public static void registerMBean(String mbeanName, Object mbean)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Register the given object as MBean.
      Parameters:
      mbeanName - the mbean name
      mbean - the mbean
    • registerMBean

      public static void registerMBean(ObjectName name, Object mbean)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Register m bean.
      Parameters:
      name - the name
      mbean - the mbean
    • unregisterMBean

      public static void unregisterMBean(String mbeanName)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Unregister an MBean.
      Parameters:
      mbeanName - the mbean name
    • unregisterMBean

      public static void unregisterMBean(ObjectName name)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Unregister an MBean.
      Parameters:
      name - the name
    • isRegistered

      public static boolean isRegistered(String mbeanName)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Checks if is registered.
      Parameters:
      mbeanName - the mbean name
      Returns:
      true, if is registered
    • isRegistered

      public static boolean isRegistered(ObjectName name)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Checks if is registered.
      Parameters:
      name - the name
      Returns:
      true, if is registered
      Since:
      1.6
    • isRegistered

      public static boolean isRegistered(Object obj)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Checks if is registered.
      Parameters:
      obj - the obj
      Returns:
      true, if is registered
    • getObjectInstance

      public static ObjectInstance getObjectInstance(String name) throws InstanceNotFoundException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the object instance.
      Parameters:
      name - the name
      Returns:
      the object instance
      Throws:
      InstanceNotFoundException - the instance not found exception
    • getObjectInstance

      public static ObjectInstance getObjectInstance(ObjectName mbeanName) throws InstanceNotFoundException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the object instance.
      Parameters:
      mbeanName - the mbean name
      Returns:
      the object instance
      Throws:
      InstanceNotFoundException - the instance not found exception
    • getAttribute

      public static Object getAttribute(String mbeanName, String attributeName) throws JMException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the attribute.
      Parameters:
      mbeanName - the mbean name
      attributeName - the attribute name
      Returns:
      the attribute
      Throws:
      InstanceNotFoundException - the instance not found exception
      JMException - the jM exception
    • getAttribute

      public static Object getAttribute(ObjectName mbean, String attributeName) throws JMException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the attribute.
      Parameters:
      mbean - the mbean
      attributeName - the attribute name
      Returns:
      the attribute
      Throws:
      InstanceNotFoundException - the instance not found exception
      JMException - the jM exception
    • createTabularDataSupport

      public static TabularDataSupport createTabularDataSupport(CompositeType rowType, String[] itemNames) throws OpenDataException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a TabularDataSupport object.
      Parameters:
      rowType - the row type
      itemNames - the item names
      Returns:
      the tabular data support
      Throws:
      OpenDataException - the open data exception