Java Reference
In-Depth Information
The ObjectInstance getObjectInstance( ObjectName name ) method
The
getObjectInstance()
method returns the
ObjectInstance
object for the
MBean corresponding to the supplied
ObjectName
instance. The
ObjectInstance
class contains both the
ObjectName
value and classname of a particular MBean.
This method only throws an
InstanceNotFoundException
exception.
The boolean isInstanceOf( ObjectName name, String classname ) method
To determine if a particular MBean is an instance of a particular class, use the
isInstanceOf()
method. This method takes an
ObjectName
instance of a particu-
lar MBean in the MBean server, and the
String
parameter specifies the class-
name in question. Only an
InstanceNotFoundException
exception is thrown from
this method.
8.2.5
MBean server information
Some methods declared in the
MBeanServer
interface are for informational pur-
poses. Two of these methods are declared in order to provide information about
the MBean server.
The Integer getMBeanCount() method
This method returns the number of MBeans registered in the MBean server.
The value is returned as an
Integer
object.
The String getDefaultDomain() method
The
getDefaultDomain()
method returns the domain name that identifies this
MBean server.
8.2.6
Other methods
In addition to all the methods covered in the previous sections, there are some
remaining methods that don't fall into any category. The following are utility
methods for deserializing data and instantiating objects.
The java.io.ObjectInputStream deserialize( ObjectName name,
byte[] data ) methods
The
MBeanServer
interface actually declares three
deserialize()
methods, tak-
ing various additional parameters. The
deserialize()
methods take an array of
byte
data and the name of a registered class loader. The result is returned in an
ObjectInputStream
stream. This method is a useful utility for deserializing
objects. For instance, you could use this method if you needed to load a persisted
state from a serialized object file.