Top Description Methods
javax.management

public Interface MBeanServer

extends MBeanServerConnection
Known Direct Subinterfaces
javax.management.remote.MBeanServerForwarder, com.sun.jmx.interceptor.MBeanServerInterceptor, com.sun.jmx.mbeanserver.SunJmxMBeanServer
Imports
java.util.Set, java.io.ObjectInputStream, javax.management.loading.ClassLoaderRepository

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 javax.management.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.

An object obtained from the createMBeanServer or newMBeanServer 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 no className.

Since
1.5

Method Summary

Modifier and TypeMethod and Description
public void
addNotificationListener(ObjectName
The name of the MBean on which the listener should be added.
name
,
NotificationListener
The listener object which will handle the notifications emitted by the registered MBean.
listener
,
NotificationFilter
The filter object. If filter is null, no filtering will be performed before handling notifications.
filter
,
Object
The context to be sent to the listener when a notification is emitted.
handback
)

Redeclares javax.management.MBeanServerConnection.addNotificationListener.

Adds a listener to a registered MBean.

public void
addNotificationListener(ObjectName
The name of the MBean on which the listener should be added.
name
,
ObjectName
The object name of the listener which will handle the notifications emitted by the registered MBean.
listener
,
NotificationFilter
The filter object. If filter is null, no filtering will be performed before handling notifications.
filter
,
Object
The context to be sent to the listener when a notification is emitted.
handback
)

Redeclares javax.management.MBeanServerConnection.addNotificationListener.

Adds a listener to a registered MBean.

public ObjectInstance
createMBean(String
The class name of the MBean to be instantiated.
className
,
ObjectName
The object name of the MBean. May be null.
name
)

Redeclares javax.management.MBeanServerConnection.createMBean.

Instantiates and registers an MBean in the MBean server.

public ObjectInstance
createMBean(String
The class name of the MBean to be instantiated.
className
,
ObjectName
The object name of the MBean. May be null.
name
,
ObjectName
The object name of the class loader to be used.
loaderName
)

Redeclares javax.management.MBeanServerConnection.createMBean.

Instantiates and registers an MBean in the MBean server.

public ObjectInstance
createMBean(String
The class name of the MBean to be instantiated.
className
,
ObjectName
The object name of the MBean. May be null.
name
,
Object[]
An array containing the parameters of the constructor to be invoked.
params
,
String[]
An array containing the signature of the constructor to be invoked.
signature
)

Redeclares javax.management.MBeanServerConnection.createMBean.

Instantiates and registers an MBean in the MBean server.

public ObjectInstance
createMBean(String
The class name of the MBean to be instantiated.
className
,
ObjectName
The object name of the MBean. May be null.
name
,
ObjectName
The object name of the class loader to be used.
loaderName
,
Object[]
An array containing the parameters of the constructor to be invoked.
params
,
String[]
An array containing the signature of the constructor to be invoked.
signature
)

Redeclares javax.management.MBeanServerConnection.createMBean.

Instantiates and registers an MBean in the MBean server.

public default ObjectInputStream

Returns:

The de-serialized object stream.
deserialize
(ObjectName
The name of the MBean whose class loader should be used for the de-serialization.
name
,
byte[]
The byte array to be de-sererialized.
data
)
Deprecated since 1.5. Use getClassLoaderFor to obtain the appropriate class loader for deserialization.

De-serializes a byte array in the context of the class loader of an MBean.

public default ObjectInputStream

Returns:

The de-serialized object stream.
deserialize
(String
The name of the class whose class loader should be used for the de-serialization.
className
,
byte[]
The byte array to be de-sererialized.
data
)
Deprecated since 1.5. Use getClassLoaderRepository to obtain the class loader repository and use it to deserialize.

De-serializes a byte array in the context of a given MBean class loader.

public default ObjectInputStream

Returns:

The de-serialized object stream.
deserialize
(String
The name of the class whose class loader should be used for the de-serialization.
className
,
ObjectName
The name of the class loader to be used for loading the specified class. If null, the MBean Server's class loader will be used.
loaderName
,
byte[]
The byte array to be de-sererialized.
data
)
Deprecated since 1.5. Use getClassLoader to obtain the class loader for deserialization.

De-serializes a byte array in the context of a given MBean class loader.

public Object
getAttribute(ObjectName
The object name of the MBean from which the attribute is to be retrieved.
name
,
String
A String specifying the name of the attribute to be retrieved.
attribute
)

Redeclares javax.management.MBeanServerConnection.getAttribute.

Gets the value of a specific attribute of a named MBean.

public AttributeList
getAttributes(ObjectName
The object name of the MBean from which the attributes are retrieved.
name
,
String[]
A list of the attributes to be retrieved.
attributes
)

Redeclares javax.management.MBeanServerConnection.getAttributes.

Retrieves the values of several attributes of a named MBean.

public ClassLoader

Returns:

The named ClassLoader. If l is the actual ClassLoader with that name, and r is the returned value, then either: What this means is that the ClassLoader may be wrapped in another ClassLoader for security or other reasons.
getClassLoader
(ObjectName
The ObjectName of the ClassLoader. May be null, in which case the MBean server's own ClassLoader is returned.
loaderName
)

Return the named java.lang.ClassLoader.

public ClassLoader

Returns:

The ClassLoader used for that MBean. If l is the MBean's actual ClassLoader, and r is the returned value, then either: What this means is that the ClassLoader may be wrapped in another ClassLoader for security or other reasons.
getClassLoaderFor
(ObjectName
The ObjectName of the MBean.
mbeanName
)

Return the java.lang.ClassLoader that was used for loading the class of the named MBean.

public ClassLoaderRepository

Returns:

The ClassLoaderRepository for this MBeanServer.
getClassLoaderRepository
()

Return the ClassLoaderRepository for this MBeanServer.

public String
getDefaultDomain()

Redeclares javax.management.MBeanServerConnection.getDefaultDomain.

Returns the default domain used for naming the MBean.

public String[]
getDomains()

Redeclares javax.management.MBeanServerConnection.getDomains.

Returns the list of domains in which any MBean is currently registered.

public Integer

Returns:

the number of registered MBeans, wrapped in an Integer. If the caller's permissions are restricted, this number may be greater than the number of MBeans the caller can access.
getMBeanCount
()

Redeclares javax.management.MBeanServerConnection.getMBeanCount.

Returns the number of MBeans registered in the MBean server.

public MBeanInfo
getMBeanInfo(ObjectName
The name of the MBean to analyze
name
)

Redeclares javax.management.MBeanServerConnection.getMBeanInfo.

This method discovers the attributes and operations that an MBean exposes for management.

public ObjectInstance
getObjectInstance(ObjectName
The object name of the MBean.
name
)

Redeclares javax.management.MBeanServerConnection.getObjectInstance.

Gets the ObjectInstance for a given MBean registered with the MBean server.

public Object

Returns:

The newly instantiated object.
instantiate
(String
The class name of the object to be instantiated.
className
)

Instantiates an object using the list of all class loaders registered in the MBean server's Class Loader Repository.

public Object

Returns:

The newly instantiated object.
instantiate
(String
The class name of the MBean to be instantiated.
className
,
ObjectName
The object name of the class loader to be used.
loaderName
)

Instantiates an object using the class Loader specified by its ObjectName.

public Object

Returns:

The newly instantiated object.
instantiate
(String
The class name of the object to be instantiated.
className
,
Object[]
An array containing the parameters of the constructor to be invoked.
params
,
String[]
An array containing the signature of the constructor to be invoked.
signature
)

Instantiates an object using the list of all class loaders registered in the MBean server Class Loader Repository.

public Object

Returns:

The newly instantiated object.
instantiate
(String
The class name of the object to be instantiated.
className
,
ObjectName
The object name of the class loader to be used.
loaderName
,
Object[]
An array containing the parameters of the constructor to be invoked.
params
,
String[]
An array containing the signature of the constructor to be invoked.
signature
)

Instantiates an object.

public Object
invoke(ObjectName
The object name of the MBean on which the method is to be invoked.
name
,
String
The name of the operation to be invoked.
operationName
,
Object[]
An array containing the parameters to be set when the operation is invoked
params
,
String[]
An array containing the signature of the operation, an array of class names in the format returned by Class#getName(). The class objects will be loaded using the same class loader as the one used for loading the MBean on which the operation was invoked.
signature
)

Redeclares javax.management.MBeanServerConnection.invoke.

Invokes an operation on an MBean.

public boolean
isInstanceOf(ObjectName
The ObjectName of the MBean.
name
,
String
The name of the class.
className
)

Redeclares javax.management.MBeanServerConnection.isInstanceOf.

Returns true if the MBean specified is an instance of the specified class, false otherwise.

public boolean
isRegistered(ObjectName
The object name of the MBean to be checked.
name
)

Redeclares javax.management.MBeanServerConnection.isRegistered.

Checks whether an MBean, identified by its object name, is already registered with the MBean server.

public Set<ObjectInstance>
queryMBeans(ObjectName
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.
name
,
QueryExp
The query expression to be applied for selecting MBeans. If null no query expression will be applied for selecting MBeans.
query
)

Redeclares javax.management.MBeanServerConnection.queryMBeans.

Gets MBeans controlled by the MBean server.

public Set<ObjectName>
queryNames(ObjectName
The object name pattern identifying the MBean names to be retrieved. If null or no domain and key properties are specified, the name of all registered MBeans will be retrieved.
name
,
QueryExp
The query expression to be applied for selecting MBeans. If null no query expression will be applied for selecting MBeans.
query
)

Redeclares javax.management.MBeanServerConnection.queryNames.

Gets the names of MBeans controlled by the MBean server.

public ObjectInstance

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().
registerMBean
(Object
The MBean to be registered as an MBean.
object
,
ObjectName
The object name of the MBean. May be null.
name
)

Registers a pre-existing object as an MBean with the MBean server.

public void
removeNotificationListener(ObjectName
The name of the MBean on which the listener should be removed.
name
,
ObjectName
The object name of the listener to be removed.
listener
)

Redeclares javax.management.MBeanServerConnection.removeNotificationListener.

Removes a listener from a registered MBean.

public void
removeNotificationListener(ObjectName
The name of the MBean on which the listener should be removed.
name
,
ObjectName
The object name of the listener to be removed.
listener
,
NotificationFilter
The filter that was specified when the listener was added.
filter
,
Object
The handback that was specified when the listener was added.
handback
)

Redeclares javax.management.MBeanServerConnection.removeNotificationListener.

Removes a listener from a registered MBean.

public void
removeNotificationListener(ObjectName
The name of the MBean on which the listener should be removed.
name
,
NotificationListener
The listener to be removed.
listener
)

Redeclares javax.management.MBeanServerConnection.removeNotificationListener.

Removes a listener from a registered MBean.

public void
removeNotificationListener(ObjectName
The name of the MBean on which the listener should be removed.
name
,
NotificationListener
The listener to be removed.
listener
,
NotificationFilter
The filter that was specified when the listener was added.
filter
,
Object
The handback that was specified when the listener was added.
handback
)

Redeclares javax.management.MBeanServerConnection.removeNotificationListener.

Removes a listener from a registered MBean.

public void
setAttribute(ObjectName
The name of the MBean within which the attribute is to be set.
name
,
Attribute
The identification of the attribute to be set and the value it is to be set to.
attribute
)

Redeclares javax.management.MBeanServerConnection.setAttribute.

Sets the value of a specific attribute of a named MBean.

public AttributeList
setAttributes(ObjectName
The object name of the MBean within which the attributes are to be set.
name
,
AttributeList
A list of attributes: The identification of the attributes to be set and the values they are to be set to.
attributes
)

Redeclares javax.management.MBeanServerConnection.setAttributes.

Sets the values of several attributes of a named MBean.

public void
unregisterMBean(ObjectName
The object name of the MBean to be unregistered.
name
)

Redeclares javax.management.MBeanServerConnection.unregisterMBean.

Unregisters an MBean from the MBean server.