The XMOJO Project
<< Prev Chapter 3.1 MBeanServer Next >>

What is an MBeanServer ?


An MBeanServer is a repository which contains all the list of MBeans registered with it. It is the heart of the JMX agent level.  JMX 1.0 Specification provides an interface called javax.management.MBeanServer.  All management operations performed on the MBeans are done through the MBeanServer. Using the MBeanServer instance, you can manage all the MBeans.  Each MBean has a unique identity, called ObjectName.

 What is an ObjectName ? 

ObjectName (javax.management.ObjectName) is a Class which uniquely identifies an MBean within an MBeanServer.  This object name is used by the management applications to identify the MBean so that operations can be invoked on appropriate MBean.  A object name consists of two parts.  They are
  1. A domain name
  2. An unordered set of one or more key properties
The domain name is a case-sensitive string.  The string may contain any characters except  : , = * ?
The domain name part may be omitted in an object name, in which case, the MBeanServer is capable of providing a default domain name. The default domain name will be DefaultDomain

The key property list forms the second part of the object name.  A key property is a name-value pair, where the name need not correspond to any of the attributes or operations of that MBean.  The key property list must contain at least one key property.  It may contain any number of key properties, whose order is not significant.

For example, if we represent a dolphin as a MBean, then a suitable object name can be

Animals:name=dolphin,kind=fish

In the above object name, the String Animals form the domain name , and the key property list is represented by two key properties: name and kind whose values are dolphin and fish respectively.

The object names are generally represented using a String which follows the syntax

[domain name]:property=value[,property=value]

If the domain name is omitted, the MBeanServer will provide a default domain name [DefaultDomain].  At least one key property is a must.  Any number of additional key properties may be added.

 Creating an MBeanServer Instance 

MBeanServer instance can be obtained using the methods provided in the MBeanServerFactory class.  The MBeanServerFactory class provides the following methods to obtain an MBeanServer instance :

public static MBeanServer createMBeanServer()

public static MBeanServer createMBeanServer(String domain)

public static MBeanServer newMBeanServer()

public static MBeanServer newMBeanServer(String domain)

In the above method declarations, the string domain represents the domain part of the object name.  The createMBeanServer and newMBeanServer methods return an MBeanServer instance.  The difference between the two methods is that the createMBeanServer methods return an MBeanServer instance and keep a reference of that instance so that the MBeanServer instance can be accessed later using the findMBeanServer method, whereas the newMBeanServer methods will not keep any reference of the MBeanServer instance created.

If one argument constructor is used to create an MBeanServer instance, then the String argument passed will be the domain name for that MBeanServer instance.  If no argument constructor is used, then the domain name would be a String with the value DefaultDomain

 Finding an MBeanServer Instance 

MBeanServerFactory class provides a method called findMBeanServer using which a specific MBeanServer instance or all the MBeanServer instances can be obtained.  The method declaration is

public static ArrayList findMBeanServer(String id)

Here the string id represents the identifier of the MBeanServer.   If this string is passed null, then all the registered MBeanServers in that JVM will be returned.  If a specific MBeanServer instance has to be obtained, then the corresponding string id for that MBeanServer has to be passed.   This string id can be obtained from the StringId attribute of the MBeanServerDelegateMBean.

 MBeanServerDelegate MBean 

Whenever an MBeanServer is instantiated, the MBeanServerDelegate class is registered as one of the MBeans with the object name JMImplementation:type=MBeanServerDelegate.  This MBean provides information about the MBean Server.  The MBeanServerDelegate MBean has seven read-only attributes, namely MBeanServerId, SpecificationName, SpecificationVersion, SpecificationVendor, ImplementationName, ImplementationVersion and ImplementationVendor.

The default values of the attributes provided with the MBeanServerDelegate MBean of the XMOJO Project 5 are as follows :

AttributeName
AttributeValue
SpecificationVersion 1.0, Final Release
SpecificationVendor Sun Microsystems Inc.
ImplementationVersion 5
ImplementationVendor XMOJO (sponsered by AdventNet Inc.)
ImplementationName The XMOJO Project
MBeanServerId <hostname>_1
SpecificationName Java Management Extensions Instrumentation and Agent Specification



The MBeanServerDelegate MBean is responsible for broadcasting the notifications emitted by the MBeanServer.  Whenever an MBean is registered or deregistered, the MBeanServerDelegate MBean broadcasts the notifications of type jmx.mbean.created and jmx.mbean.deleted respectively to all the registered listeners.

Points to Remember
  1. MBeanServer maintains a registry of MBean.  Each MBean is identified by a unique naming pattern, called object name.
  2. MBeanServer instance can be obtained using the static methods available in the MBeanServerFactory class.
  3. MBeanServerDelegate MBean is a representation of the MBeanServer and also the broadcaster for notifications emitted by the MBeanServer.

<< Prev Home Next >>
Agent Level MBean Registration