Java Reference
In-Depth Information
Up to this point in the topic, you have used methods of the MBean server as
necessary. However, you should have a good understanding of the entire set of
methods available in the MBeanServer class. The methods available for use in any
MBean server are declared by the MBeanServer interface. This interface declares
methods for creating, registering, manipulating, and finding MBeans (and more).
Each of the following sections will cover one method, set of overloaded methods,
or set of related methods. Objects used as input parameters and return types are in
the javax.management or java.lang package unless otherwise specified.
Rather than show the entire interface in a single diagram, the next several
sections focus on a few specific methods that are related. After learning about the
majority of methods in this chapter, you should look at the available javadoc API
for overloaded or additional methods not covered.
8.2.1
Registration methods
The first set of methods we'll discuss deals with registering an MBean that you
have created but not registered in the MBean server. For example, you used the
registerMBean() method in chapter 2 to register your HelloWorld MBean.
Table 8.1 summarizes the registration methods.
Table 8.1
MBean registration-related methods of the MBeanServer interface
Method
Purpose
Registers an already created MBean in the MBean
server
registerMBean (Object mbean,
ObjectName name )
Checks to see if a particular MBean is registered on
the MBean server
isRegistered( ObjectName name )
Removes an MBean from the MBean server
unregisterMBean( ObjectName name )
The registerMBean() method for existing objects
This method is intended for use when you have already created an MBean man-
ually in code. It is useful if you have objects that serve as application components
but also happen to be MBeans. At some point in their lifecycle, you might want
to expose them for management by registering them in an MBean server.
The registerMBean() method takes the constructed MBean and an appropri-
ate ObjectName instance for parameters. If the MBean conforms to the MBean
rules and the ObjectName instance is valid, the MBean server will register the
incoming MBean. For information on creating the different types of MBeans,
look back at chapters 4, 5, and 7.
Search WWH ::




Custom Search