Java Reference
In-Depth Information
In this chapter, we will discuss the simplest type of MBean: the Standard MBean.
You created this type of MBean in chapter 2. Standard MBeans are intended for
resources that have well-known, stable interfaces. This chapter shows how you
can use Standard MBeans to configure application resources (a log utility and
application properties) and to break applications into components. If you need
the quickest way to implement a resource, the Standard MBean is for you. Stan-
dard MBeans expose a resource with an explicitly declared management inter-
face that is unchanging.
In addition, because this is the first of three chapters on MBean types, we also
discuss some of the common construction rules of all types of MBeans. After
completing this chapter, you will know much more about Standard MBeans,
including how to write them and when to use them.
4.1 L aying the MBean groundwork
As we just hinted, before diving into a discussion about writing Standard MBeans,
we first need to describe certain traits that are required across all MBean types.
Whether you are coding a Standard or Dynamic MBean, you must follow certain
rules. After covering these common rules, we will explore the unique traits of a
Standard MBean.
4.1.1
Common coding rules for all MBeans
When developing any MBean, you must adhere to the following rules:
An MBean must be a concrete Java class. A concrete class is a Java class that is
not abstract, and can therefore be instantiated. Remember from chapter 2
that you dynamically loaded the HelloWorld MBean into your simple JMX
agent using the HTML adapter. For the agent to successfully create the
MBean using reflection, the class name you used had to correspond to a
concrete class.
An MBean must have a public constructor. No additional rules apply to the
constructor other than that it must be public. It can have arguments—and
the class can contain as many constructors as needed.
An MBean must implement either its own MBean interface or the javax.man-
agement.DynamicMBean interface. An MBean interface is any interface that
follows a naming scheme ClassNameMBean . We will cover MBean interfaces
thoroughly in this chapter. MBeans using an MBean interface are Stan-
dard MBeans.
Search WWH ::




Custom Search