Java Reference
In-Depth Information
To receive notifications from a particular MBean, you simply invoke the
add-
NotificationListener()
method of the client. Because all
Notification
objects
are serializable, they can be transmitted over
RMI
to interested clients.
Connector heartbeat
The
RMI
connector uses a notification system to detect the health of the client
and/or server portions of the connector. When using an
RmiConnectorClient
object, you can add a notification listener for receiving
HeartBeatNotification
objects. A
HeartBeatNotification
object can indicate several conditions about a
connection to the
RMI
connector server, as listed in table 9.2. The values in the
Notification Type column are
public static
members of the
HeartBeatNotifi-
cation
class.
Table 9.2
Notification types used by a
HeartBeatNotification
notification
Notification type
Description
A connection has been made between the client and server.
CONNECTION_ESTABLISHED
A connection has died.
CONNECTION_LOST
CONNECTION_REESTABLISHED
A connection was temporarily unavailable, but is now connected.
The client is trying to reestablish a dead connection.
CONNECTION_RETRYING
The connection has been closed.
CONNECTION_TERMINATED
You acquire the condition value by invoking the
getType()
method of the notifi-
cation.
Client context checking
The last feature of the
RMI
connector covered in this chapter is the concept of a
client context checker. A context checker ensures that a client passes a pre-
defined test before it can invoke any methods on the remote MBean server.
The client must set an
OperationalContext
object into its
RmiConnectorClient
object. The connector client object will pass this context to the
RMI
connector
server, which uses it to decide whether to complete a client's request on an MBean
server. To do so, the server uses an instance of the class
MBeanServerChecker
.
An
MBeanServerChecker
object encapsulates an
MBeanServer
object and con-
tains a check method for every method declared by the
MBeanServer
class. For
instance, for a client that attempted to invoke
create Bean()
on a remote MBean
server, the
MBeanServerChecker
would first invoke the method
checkCreate()
.
This method would verify the client's
OperationalContext
in some way and, if it