Java Reference
In-Depth Information
the public constructors exposed by the MBean. Constructors are included in the
definition of the management interface because a particular constructor could
define specific behavior over the life of the MBean object. For instance, one con-
structor may tell the MBean to log all of its actions, and another may make it
silent. Any way of altering the behavior of an MBean is included as part of its
management interface. For Standard MBeans, agents must use introspection to
discover the public constructors.
Attributes
Attributes are a vital part of the management interface of an MBean. The
attributes describe the manageable resource. Remember, a manageable resource
is some application or resource exposed for management by an MBean. For
instance, an MBean managing a device such as a printer might have attributes
for the number of paper trays, job counts, and so forth.
With Standard MBeans, you expose attributes by declaring getter and setter
methods. For an attribute JobCount of a printer MBean, there would be a method
getJobCount() . Recall from chapter 2 that getter methods define read access to
an attribute, and setter methods define write access. If both a setter and a getter
exist, the MBean grants read/write access to that attribute.
Operations
Operations correspond to actions that can be initiated on the manageable
resource. For Standard MBeans, exposed operations are simply the remaining
operations that are not getters or setters. Staying with the printer example, in an
MBean managing a printer, you might find an operation like cancelPrintJob() .
Operations are methods like any other; they can have multiple parameters and
optionally return a value.
Notifications
Notifications allow MBeans to communicate with registered listeners. You
encountered them in chapter 2 when you added a notification to the Hello-
World example.
In order to emit notifications, an MBean must implement the javax.manage-
ment.NotificationBroadcaster interface. This interface provides methods for
sending notifications, as well as methods for other objects to register as listeners
on the implementing MBean. We will skip notifications for now, but we cover
them in detail in chapter 6.
Search WWH ::




Custom Search