Imagine that you just built the next killer Java application, and it's selling like hotcakes. However, even though (being a good developer), you built in enough debug and tracing information to monitor the state of your live application units, you're missing the ability to monitor each and every class and their attributes. Although you could build monitoring services as part of your application, it takes the focus away from your core business, the application itself. It would be nice if you could monitor your application for the state of its classes, attributes, and operations. Java Management Extensions (JMX) lets you do just that. However, this article isn't about JMX, it's about how to easily configure JMX using the Jakarta Commons Modeler component. Specifically, it's about how to use the Modeler component to create model MBeans, which are used to monitor resources in your application.
The Modeler component was created from source code taken from Tomcat 4 development. Recognizing that creating metadata information about managed resources in code is a tedious process, the Tomcat developers extracted this information from code to an external XML-based file. They further realized that this extraction could easily be made useful for other managed components—not only server-based projects like Tomcat but any place that needed to use model MBeans. Therefore, they created the Modeler package to make this service available across the board.
As an application developer, it's nice to know at a glance the services that Modeler provides. The following list shows these services:
ModelMBeanInfo objects from this information.
RequiredModelMBean object, which is a default implementation of the ModelMBean interface in JMX. This alternate is called BaseModelMBean. However, this alternate only supports management of objects that are of type objectReference (as opposed to RequiredModelMBean, which supports other types such as EJBHandle and RMIReference).
Let's see these services in action with the help of some examples. We'll start with the transfer of ModelMBeanInfo information from code to XML file.
Modeler makes it easy to manage application components by combining the flexibility of model MBeans with the ease of writing XML configuration information about modeled components. The information about modeled components, which we also call metadata, describes these components for the model MBeans that are registered in the MBeanServer. This allows management of these components via JMX. Information from JMX agents passes to the model MBeans and on to the actual managed components through the mapping provided by this metadata information. This information can get very complex if done in code.
Archived Discussions (Read only)