MBeanServer (Java SE 15 & JDK 15) (original) (raw)

All Superinterfaces:

[MBeanServerConnection](MBeanServerConnection.html "interface in javax.management")

All Known Subinterfaces:

[MBeanServerForwarder](remote/MBeanServerForwarder.html "interface in javax.management.remote")


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 theObjectName of the MBeanServerDelegate. ThisObjectName is:
JMImplementation:type=MBeanServerDelegate.

An object obtained from the createMBeanServer ornewMBeanServer methods of the MBeanServerFactory class applies security checks to its methods, as follows.

First, if there is no security manager (System.getSecurityManager() is null), then an implementation of this interface is free not to make any checks.

Assuming that there is a security manager, or that the implementation chooses to make checks anyway, the checks are made as detailed below. In what follows, and unless otherwise specified,className is the string returned by MBeanInfo.getClassName() for the target MBean.

If a security check fails, the method throws SecurityException.

For methods that can throw InstanceNotFoundException, this exception is thrown for a non-existent MBean, regardless of permissions. This is because a non-existent MBean has noclassName.

Since:

1.5

Modifier and Type Method Description
void addNotificationListener​(ObjectName name,NotificationListener listener,NotificationFilter filter,Object handback) Adds a listener to a registered MBean.
void addNotificationListener​(ObjectName name,ObjectName listener,NotificationFilter filter,Object handback) Adds a listener to a registered MBean.
ObjectInstance createMBean​(String className,ObjectName name) Instantiates and registers an MBean in the MBean server.
ObjectInstance createMBean​(String className,ObjectName name,Object[] params,String[] signature) Instantiates and registers an MBean in the MBean server.
ObjectInstance createMBean​(String className,ObjectName name,ObjectName loaderName) Instantiates and registers an MBean in the MBean server.
ObjectInstance createMBean​(String className,ObjectName name,ObjectName loaderName,Object[] params,String[] signature) Instantiates and registers an MBean in the MBean server.
default ObjectInputStream deserialize​(String className, byte[] data) Deprecated.
default ObjectInputStream deserialize​(String className,ObjectName loaderName, byte[] data) Deprecated.
default ObjectInputStream deserialize​(ObjectName name, byte[] data) Deprecated.
Object getAttribute​(ObjectName name,String attribute) Gets the value of a specific attribute of a named MBean.
AttributeList getAttributes​(ObjectName name,String[] attributes) Retrieves the values of several attributes of a named MBean.
ClassLoader getClassLoader​(ObjectName loaderName) Return the named ClassLoader.
ClassLoader getClassLoaderFor​(ObjectName mbeanName) Return the ClassLoader that was used for loading the class of the named MBean.
ClassLoaderRepository getClassLoaderRepository() Return the ClassLoaderRepository for this MBeanServer.
Integer getMBeanCount() Returns the number of MBeans registered in the MBean server.
Object instantiate​(String className) Instantiates an object using the list of all class loaders registered in the MBean server's Class Loader Repository.
Object instantiate​(String className,Object[] params,String[] signature) Instantiates an object using the list of all class loaders registered in the MBean server Class Loader Repository.
Object instantiate​(String className,ObjectName loaderName) Instantiates an object using the class Loader specified by itsObjectName.
Object instantiate​(String className,ObjectName loaderName,Object[] params,String[] signature) Instantiates an object.
boolean isRegistered​(ObjectName name) Checks whether an MBean, identified by its object name, is already registered with the MBean server.
Set<ObjectInstance> queryMBeans​(ObjectName name,QueryExp query) Gets MBeans controlled by the MBean server.
Set<ObjectName> queryNames​(ObjectName name,QueryExp query) Gets the names of MBeans controlled by the MBean server.
ObjectInstance registerMBean​(Object object,ObjectName name) Registers a pre-existing object as an MBean with the MBean server.
void setAttribute​(ObjectName name,Attribute attribute) Sets the value of a specific attribute of a named MBean.
AttributeList setAttributes​(ObjectName name,AttributeList attributes) Sets the values of several attributes of a named MBean.
void unregisterMBean​(ObjectName name) Unregisters an MBean from the MBean server.