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.
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
.
For the invoke
method, the caller's
permissions must imply MBeanPermission(className, operationName, name, "invoke")
.
For the getAttribute
method, the
caller's permissions must imply MBeanPermission(className, attribute, name, "getAttribute")
.
For the getAttributes
method, the
caller's permissions must imply MBeanPermission(className, null, name, "getAttribute")
.
Additionally, for each attribute a in the AttributeList
, if the caller's permissions do not imply MBeanPermission(className, a, name, "getAttribute")
, the
MBean server will behave as if that attribute had not been in the
supplied list.
For the setAttribute
method, the
caller's permissions must imply MBeanPermission(className, attrName, name, "setAttribute")
, where
attrName
is attribute.
.
For the setAttributes
method, the
caller's permissions must imply MBeanPermission(className, null, name, "setAttribute")
.
Additionally, for each attribute a in the AttributeList
, if the caller's permissions do not imply MBeanPermission(className, a, name, "setAttribute")
, the
MBean server will behave as if that attribute had not been in the
supplied list.
For the addNotificationListener
methods,
the caller's permissions must imply MBeanPermission(className, null, name,
"addNotificationListener")
.
For the removeNotificationListener
methods,
the caller's permissions must imply MBeanPermission(className, null, name,
"removeNotificationListener")
.
For the getMBeanInfo
method, the
caller's permissions must imply MBeanPermission(className, null, name, "getMBeanInfo")
.
For the getObjectInstance
method,
the caller's permissions must imply MBeanPermission(className, null, name, "getObjectInstance")
.
For the isInstanceOf
method, the
caller's permissions must imply MBeanPermission(className, null, name, "isInstanceOf")
.
For the queryMBeans
method, the
caller's permissions must imply MBeanPermission(null, null, null, "queryMBeans")
.
Additionally, for each MBean n that matches name
,
if the caller's permissions do not imply MBeanPermission(className, null, n, "queryMBeans")
, the
MBean server will behave as if that MBean did not exist.
Certain query elements perform operations on the MBean server.
If the caller does not have the required permissions for a given
MBean, that MBean will not be included in the result of the query.
The standard query elements that are affected are Query#attr(String)
, Query#attr(String, String)
, and Query#classattr()
.
For the queryNames
method, the checks
are the same as for queryMBeans
except that
"queryNames"
is used instead of
"queryMBeans"
in the MBeanPermission
objects. Note that a "queryMBeans"
permission implies
the corresponding "queryNames"
permission.
For the getDomains
method, the caller's
permissions must imply MBeanPermission(null, null, null, "getDomains")
. Additionally,
for each domain d in the returned array, if the caller's
permissions do not imply MBeanPermission(null, null, new ObjectName("<var>d</var>:x=x"),
"getDomains")
, the domain is eliminated from the array. Here,
x=x
is any key=value pair, needed to
satisfy ObjectName's constructor but not otherwise relevant.
For the getClassLoader
method, the
caller's permissions must imply MBeanPermission(className, null, loaderName,
"getClassLoader")
.
For the getClassLoaderFor
method,
the caller's permissions must imply MBeanPermission(className, null, mbeanName,
"getClassLoaderFor")
.
For the getClassLoaderRepository
method, the caller's permissions must
imply MBeanPermission(null, null, null, "getClassLoaderRepository")
.
For the deprecated deserialize
methods, the
required permissions are the same as for the methods that replace
them.
For the instantiate
methods, the caller's
permissions must imply MBeanPermission(className, null, null, "instantiate")
,
where className
is the name of the class which is to
be instantiated.
For the registerMBean
method, the
caller's permissions must imply MBeanPermission(className, null, name, "registerMBean")
.
If the MBeanPermission
check succeeds, the MBean's
class is validated by checking that its ProtectionDomain
implies MBeanTrustPermission("register")
.
Finally, if the name
argument is null, another
MBeanPermission
check is made using the
ObjectName
returned by MBeanRegistration.
.
For the createMBean
methods, the caller's
permissions must imply the permissions needed by the equivalent
instantiate
followed by
registerMBean
.
For the unregisterMBean
method,
the caller's permissions must imply MBeanPermission(className, null, name, "unregisterMBean")
.
Modifier and Type | Method 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. 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. 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. 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. 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. 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. Instantiates and registers an MBean in the MBean server. |
public default ObjectInputStream | Returns: The de-serialized object stream.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.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.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. 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. 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:
The ObjectName of the ClassLoader. May be
null, in which case the MBean server's own ClassLoader is
returned. loaderName)Return the named |
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:
The ObjectName of the MBean. mbeanName)Return the |
public ClassLoaderRepository | Returns: The ClassLoaderRepository for this MBeanServer.Return the ClassLoaderRepository for this MBeanServer. |
public String | getDefaultDomain()
Redeclares javax. Returns the default domain used for naming the MBean. |
public String[] | getDomains()
Redeclares javax. 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.Redeclares javax. Returns the number of MBeans registered in the MBean server. |
public MBeanInfo | getMBeanInfo(ObjectName
The name of the MBean to analyze name)Redeclares javax. 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. Gets the |
public Object | Returns: The newly instantiated object.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 |
public Object | Returns: The newly instantiated object.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
|
public Object | Returns: The newly instantiated object.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 |
public Object | Returns: The newly instantiated object.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
signature)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.Redeclares javax. Invokes an operation on an MBean. |
public boolean | isInstanceOf(ObjectName
The name, String ObjectName of the MBean.The name of the class. className)Redeclares javax. 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. Checks whether an MBean, identified by its object name, is already registered with the MBean server. |
public Set | 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. Gets MBeans controlled by the MBean server. |
public Set | 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. Gets the names of MBeans controlled by the MBean server. |
public ObjectInstance | Returns: AnObjectInstance , 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
.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. 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. 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. 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. 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. 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. 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. Unregisters an MBean from the MBean server. |