Enum MBeans

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static MBeanServer getMBeanServer()
      Returns the first registered MBean server, or the platform MBean server if there is none.
      static boolean isRegistered​(String objectName)
      Returns true if an MBean identified by the specified object name is already registered with the first MBean server, or the platform MBean server if there is no explicitly registered MBean server; false otherwise.
      static <T> boolean registerMBean​(String objectName, T mbean)
      Registers the given MBean under the given object name to the first registered MBean server, or the platform MBean server if there is no explicitly registered MBean server.
      static <T> boolean unregisterMBean​(String objectName)
      Unregisters the MBean under the given object name to the first MBean server, or the platform MBean server if there is no explicitly registered MBean server.
      static MBeans valueOf​(String name)
      Returns the enum constant of this type with the specified name.
      static MBeans[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
    • Method Detail

      • values

        public static MBeans[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (MBeans c : MBeans.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static MBeans valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • registerMBean

        public static <T> boolean registerMBean​(String objectName,
                                                T mbean)
                                         throws MBeanRegistrationException
        Registers the given MBean under the given object name to the first registered MBean server, or the platform MBean server if there is no explicitly registered MBean server.
        Returns:
        true if the registration succeeded, or false if an MBean already exists under the given object name.
        Throws:
        MBeanRegistrationException - The preRegister (MBeanRegistration interface) method of the MBean has thrown an exception. The MBean will not be registered.
      • unregisterMBean

        public static <T> boolean unregisterMBean​(String objectName)
                                           throws MBeanRegistrationException
        Unregisters the MBean under the given object name to the first MBean server, or the platform MBean server if there is no explicitly registered MBean server.
        Returns:
        true if the unregistration succeeded, or false if the MBean doesn't exist under the given object name.
        Throws:
        MBeanRegistrationException - Wraps exceptions thrown by the preRegister(), preDeregister() methods of the MBeanRegistration interface.
      • isRegistered

        public static boolean isRegistered​(String objectName)
        Returns true if an MBean identified by the specified object name is already registered with the first MBean server, or the platform MBean server if there is no explicitly registered MBean server; false otherwise.
      • getMBeanServer

        public static MBeanServer getMBeanServer()
        Returns the first registered MBean server, or the platform MBean server if there is none.