Interface MBeanServer

All Superinterfaces:
MBeanServerConnection
All Known Subinterfaces:
MBeanServerForwarder

public interface MBeanServer extends MBeanServerConnection

This is the interface for MBean manipulation on the agent side. It contains the methods necessary for the creation, registration, and deletion of MBeans as well as the access methods for registered MBeans. This is the core component of the JMX infrastructure.

User code does not usually implement this interface. Instead, an object that implements this interface is obtained with one of the methods in the MBeanServerFactory class.

Every MBean which is added to the MBean server becomes manageable: its attributes and operations become remotely accessible through the connectors/adaptors connected to that MBean server. A Java object cannot be registered in the MBean server unless it is a JMX compliant MBean.

When an MBean is registered or unregistered in the MBean server a MBeanServerNotification Notification is emitted. To register an object as listener to MBeanServerNotifications you should call the MBean server method addNotificationListener with ObjectName the ObjectName of the MBeanServerDelegate. This ObjectName is:
JMImplementation:type=MBeanServerDelegate.

Methods of MBeanServer and its subclasses may throw SecurityException if the implementation doesn't authorize access to the underlying resource.

Since:
1.5
  • Method Details

    • createMBean

      Instantiates and registers an MBean in the MBean server. The MBean server will use its Default Loader Repository to load the class of the MBean. An object name is associated with the MBean. If the object name given is null, the MBean must provide its own name by implementing the MBeanRegistration interface and returning the name from the preRegister method.

      This method is equivalent to createMBean(className, name, (Object[]) null, (String[]) null).

      If this method successfully creates an MBean, a notification is sent as described above.

      Specified by:
      createMBean in interface MBeanServerConnection
      Parameters:
      className - The class name of the MBean to be instantiated.
      name - The object name of the MBean. May be null.
      Returns:
      An ObjectInstance, containing the ObjectName and the Java class name of the newly instantiated MBean. If the contained ObjectName is n, the contained Java class name is getMBeanInfo(n).getClassName().
      Throws:
      RuntimeOperationsException - Wraps a java.lang.IllegalArgumentException: The className passed in parameter is null, the ObjectName passed in parameter contains a pattern or no ObjectName is specified for the MBean.
      RuntimeMBeanException - If the MBean's constructor or its preRegister or postRegister method threw a RuntimeException. If the postRegister (MBeanRegistration interface) method of the MBean throws a RuntimeException, the createMBean method will throw a RuntimeMBeanException, although the MBean creation and registration succeeded. In such a case, the MBean will be actually registered even though the createMBean method threw an exception. Note that RuntimeMBeanException can also be thrown by preRegister, in which case the MBean will not be registered.
      RuntimeErrorException - If the postRegister (MBeanRegistration interface) method of the MBean throws an Error, the createMBean method will throw a RuntimeErrorException, although the MBean creation and registration succeeded. In such a case, the MBean will be actually registered even though the createMBean method threw an exception. Note that RuntimeErrorException can also be thrown by preRegister, in which case the MBean will not be registered.
      ReflectionException - Wraps a java.lang.ClassNotFoundException or a java.lang.Exception that occurred when trying to invoke the MBean's constructor.
      InstanceAlreadyExistsException - The MBean is already under the control of the MBean server.
      MBeanRegistrationException - The preRegister (MBeanRegistration interface) method of the MBean has thrown an exception. The MBean will not be registered.
      MBeanException - The constructor of the MBean has thrown an exception
      NotCompliantMBeanException - This class is not a JMX compliant MBean
      See Also:
    • createMBean

      Instantiates and registers an MBean in the MBean server. The class loader to be used is identified by its object name. An object name is associated with the MBean. If the object name of the loader is null, the ClassLoader that loaded the MBean server will be used. If the MBean's object name given is null, the MBean must provide its own name by implementing the MBeanRegistration interface and returning the name from the preRegister method.

      This method is equivalent to createMBean(className, name, loaderName, (Object[]) null, (String[]) null).

      If this method successfully creates an MBean, a notification is sent as described above.

      Specified by:
      createMBean in interface MBeanServerConnection
      Parameters:
      className - The class name of the MBean to be instantiated.
      name - The object name of the MBean. May be null.
      loaderName - The object name of the class loader to be used.
      Returns:
      An ObjectInstance, containing the ObjectName and the Java class name of the newly instantiated MBean. If the contained ObjectName is n, the contained Java class name is getMBeanInfo(n).getClassName().
      Throws:
      RuntimeOperationsException - Wraps a java.lang.IllegalArgumentException: The className passed in parameter is null, the ObjectName passed in parameter contains a pattern or no ObjectName is specified for the MBean.
      RuntimeMBeanException - If the MBean's constructor or its preRegister or postRegister method threw a RuntimeException. If the postRegister (MBeanRegistration interface) method of the MBean throws a RuntimeException, the createMBean method will throw a RuntimeMBeanException, although the MBean creation and registration succeeded. In such a case, the MBean will be actually registered even though the createMBean method threw an exception. Note that RuntimeMBeanException can also be thrown by preRegister, in which case the MBean will not be registered.
      RuntimeErrorException - If the postRegister (MBeanRegistration interface) method of the MBean throws an Error, the createMBean method will throw a RuntimeErrorException, although the MBean creation and registration succeeded. In such a case, the MBean will be actually registered even though the createMBean method threw an exception. Note that RuntimeErrorException can also be thrown by preRegister, in which case the MBean will not be registered.
      ReflectionException - Wraps a java.lang.ClassNotFoundException or a java.lang.Exception that occurred when trying to invoke the MBean's constructor.
      InstanceAlreadyExistsException - The MBean is already under the control of the MBean server.
      MBeanRegistrationException - The preRegister (MBeanRegistration interface) method of the MBean has thrown an exception. The MBean will not be registered.
      MBeanException - The constructor of the MBean has thrown an exception
      NotCompliantMBeanException - This class is not a JMX compliant MBean
      InstanceNotFoundException - The specified class loader is not registered in the MBean server.
      See Also:
    • createMBean

      Instantiates and registers an MBean in the MBean server. The MBean server will use its Default Loader Repository to load the class of the MBean. An object name is associated with the MBean. If the object name given is null, the MBean must provide its own name by implementing the MBeanRegistration interface and returning the name from the preRegister method.

      If this method successfully creates an MBean, a notification is sent as described above.

      Specified by:
      createMBean in interface MBeanServerConnection
      Parameters:
      className - The class name of the MBean to be instantiated.
      name - The object name of the MBean. May be null.
      params - An array containing the parameters of the constructor to be invoked.
      signature - An array containing the signature of the constructor to be invoked.
      Returns:
      An ObjectInstance, containing the ObjectName and the Java class name of the newly instantiated MBean. If the contained ObjectName is n, the contained Java class name is getMBeanInfo(n).getClassName().
      Throws:
      RuntimeOperationsException - Wraps a java.lang.IllegalArgumentException: The className passed in parameter is null, the ObjectName passed in parameter contains a pattern or no ObjectName is specified for the MBean.
      RuntimeMBeanException - If the MBean's constructor or its preRegister or postRegister method threw a RuntimeException. If the postRegister (MBeanRegistration interface) method of the MBean throws a RuntimeException, the createMBean method will throw a RuntimeMBeanException, although the MBean creation and registration succeeded. In such a case, the MBean will be actually registered even though the createMBean method threw an exception. Note that RuntimeMBeanException can also be thrown by preRegister, in which case the MBean will not be registered.
      RuntimeErrorException - If the postRegister (MBeanRegistration interface) method of the MBean throws an Error, the createMBean method will throw a RuntimeErrorException, although the MBean creation and registration succeeded. In such a case, the MBean will be actually registered even though the createMBean method threw an exception. Note that RuntimeErrorException can also be thrown by preRegister, in which case the MBean will not be registered.
      ReflectionException - Wraps a java.lang.ClassNotFoundException or a java.lang.Exception that occurred when trying to invoke the MBean's constructor.
      InstanceAlreadyExistsException - The MBean is already under the control of the MBean server.
      MBeanRegistrationException - The preRegister (MBeanRegistration interface) method of the MBean has thrown an exception. The MBean will not be registered.
      MBeanException - The constructor of the MBean has thrown an exception
      NotCompliantMBeanException - This class is not a JMX compliant MBean
      See Also:
    • createMBean

      Instantiates and registers an MBean in the MBean server. The class loader to be used is identified by its object name. An object name is associated with the MBean. If the object name of the loader is not specified, the ClassLoader that loaded the MBean server will be used. If the MBean object name given is null, the MBean must provide its own name by implementing the MBeanRegistration interface and returning the name from the preRegister method.

      If this method successfully creates an MBean, a notification is sent as described above.

      Specified by:
      createMBean in interface MBeanServerConnection
      Parameters:
      className - The class name of the MBean to be instantiated.
      name - The object name of the MBean. May be null.
      loaderName - The object name of the class loader to be used.
      params - An array containing the parameters of the constructor to be invoked.
      signature - An array containing the signature of the constructor to be invoked.
      Returns:
      An ObjectInstance, containing the ObjectName and the Java class name of the newly instantiated MBean. If the contained ObjectName is n, the contained Java class name is getMBeanInfo(n).getClassName().
      Throws:
      RuntimeOperationsException - Wraps a java.lang.IllegalArgumentException: The className passed in parameter is null, the ObjectName passed in parameter contains a pattern or no ObjectName is specified for the MBean.
      RuntimeMBeanException - The MBean's constructor or its preRegister or postRegister method threw a RuntimeException. If the postRegister (MBeanRegistration interface) method of the MBean throws a RuntimeException, the createMBean method will throw a RuntimeMBeanException, although the MBean creation and registration succeeded. In such a case, the MBean will be actually registered even though the createMBean method threw an exception. Note that RuntimeMBeanException can also be thrown by preRegister, in which case the MBean will not be registered.
      RuntimeErrorException - If the postRegister method (MBeanRegistration interface) method of the MBean throws an Error, the createMBean method will throw a RuntimeErrorException, although the MBean creation and registration succeeded. In such a case, the MBean will be actually registered even though the createMBean method threw an exception. Note that RuntimeErrorException can also be thrown by preRegister, in which case the MBean will not be registered.
      ReflectionException - Wraps a java.lang.ClassNotFoundException or a java.lang.Exception that occurred when trying to invoke the MBean's constructor.
      InstanceAlreadyExistsException - The MBean is already under the control of the MBean server.
      MBeanRegistrationException - The preRegister (MBeanRegistration interface) method of the MBean has thrown an exception. The MBean will not be registered.
      MBeanException - The constructor of the MBean has thrown an exception
      NotCompliantMBeanException - This class is not a JMX compliant MBean
      InstanceNotFoundException - The specified class loader is not registered in the MBean server.
      See Also:
    • registerMBean

      Registers a pre-existing object as an MBean with the MBean server. If the object name given is null, the MBean must provide its own name by implementing the MBeanRegistration interface and returning the name from the preRegister method.

      If this method successfully registers an MBean, a notification is sent as described above.

      Parameters:
      object - The MBean to be registered as an MBean.
      name - The object name of the MBean. May be null.
      Returns:
      An ObjectInstance, containing the ObjectName and the Java class name of the newly registered MBean. If the contained ObjectName is n, the contained Java class name is getMBeanInfo(n).getClassName().
      Throws:
      InstanceAlreadyExistsException - The MBean is already under the control of the MBean server.
      MBeanRegistrationException - The preRegister (MBeanRegistration interface) method of the MBean has thrown an exception. The MBean will not be registered.
      RuntimeMBeanException - If the postRegister (MBeanRegistration interface) method of the MBean throws a RuntimeException, the registerMBean method will throw a RuntimeMBeanException, although the MBean registration succeeded. In such a case, the MBean will be actually registered even though the registerMBean method threw an exception. Note that RuntimeMBeanException can also be thrown by preRegister, in which case the MBean will not be registered.
      RuntimeErrorException - If the postRegister (MBeanRegistration interface) method of the MBean throws an Error, the registerMBean method will throw a RuntimeErrorException, although the MBean registration succeeded. In such a case, the MBean will be actually registered even though the registerMBean method threw an exception. Note that RuntimeErrorException can also be thrown by preRegister, in which case the MBean will not be registered.
      NotCompliantMBeanException - This object is not a JMX compliant MBean
      RuntimeOperationsException - Wraps a java.lang.IllegalArgumentException: The object passed in parameter is null or no object name is specified.
      See Also:
    • unregisterMBean

      Unregisters an MBean from the MBean server. The MBean is identified by its object name. Once the method has been invoked, the MBean may no longer be accessed by its object name.

      If this method successfully unregisters an MBean, a notification is sent as described above.

      Specified by:
      unregisterMBean in interface MBeanServerConnection
      Parameters:
      name - The object name of the MBean to be unregistered.
      Throws:
      RuntimeOperationsException - Wraps a java.lang.IllegalArgumentException: The object name in parameter is null or the MBean you are when trying to unregister is the MBeanServerDelegate MBean.
      RuntimeMBeanException - If the postDeregister (MBeanRegistration interface) method of the MBean throws a RuntimeException, the unregisterMBean method will throw a RuntimeMBeanException, although the MBean unregistration succeeded. In such a case, the MBean will be actually unregistered even though the unregisterMBean method threw an exception. Note that RuntimeMBeanException can also be thrown by preDeregister, in which case the MBean will remain registered.
      RuntimeErrorException - If the postDeregister (MBeanRegistration interface) method of the MBean throws an Error, the unregisterMBean method will throw a RuntimeErrorException, although the MBean unregistration succeeded. In such a case, the MBean will be actually unregistered even though the unregisterMBean method threw an exception. Note that RuntimeMBeanException can also be thrown by preDeregister, in which case the MBean will remain registered.
      InstanceNotFoundException - The MBean specified is not registered in the MBean server.
      MBeanRegistrationException - The preDeregister (MBeanRegistration interface) method of the MBean has thrown an exception.
      See Also:
    • getObjectInstance

      ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException
      Description copied from interface: MBeanServerConnection
      Gets the ObjectInstance for a given MBean registered with the MBean server.
      Specified by:
      getObjectInstance in interface MBeanServerConnection
      Parameters:
      name - The object name of the MBean.
      Returns:
      The ObjectInstance associated with the MBean specified by name. The contained ObjectName is name and the contained class name is getMBeanInfo(name).getClassName().
      Throws:
      InstanceNotFoundException - The MBean specified is not registered in the MBean server.
    • queryMBeans

      Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query)
      Gets MBeans controlled by the MBean server. This method allows any of the following to be obtained: All MBeans, a set of MBeans specified by pattern matching on the ObjectName and/or a Query expression, a specific MBean. When the object name is null or no domain and key properties are specified, all objects are to be selected (and filtered if a query is specified). It returns the set of ObjectInstance objects (containing the ObjectName and the Java Class name) for the selected MBeans.
      Specified by:
      queryMBeans in interface MBeanServerConnection
      Parameters:
      name - The object name pattern identifying the MBeans to be retrieved. If null or no domain and key properties are specified, all the MBeans registered will be retrieved.
      query - The query expression to be applied for selecting MBeans. If null no query expression will be applied for selecting MBeans.
      Returns:
      A set containing the ObjectInstance objects for the selected MBeans. If no MBean satisfies the query an empty list is returned.
    • queryNames

      Set<ObjectName> queryNames(