3 Instrumenting Your Resources for JMX Technology

This chapter outlines the concepts behind instrumenting resources for management by using JMX technology in the following sections:

Manageable Resources

Different types of resources can be managed using JMX technology, for example an application, an implementation of a service, a device, or a user. For a given resource to be managed by JMX technology, it must be developed in the Java language, or at least offer a Java language wrapper. The resource must also be instrumented by one or more Java objects known as managed beans (MBeans), in compliance with the JMX Specification.

Developers of applications and devices can choose the granularity of objects that are instrumented as MBeans. An MBean might represent the smallest object in an application, or it could represent the entire application. Application components designed with their management interface in mind can typically be written as MBeans. MBeans can be used as wrappers for legacy code without a management interface or as proxies for code with a legacy management interface.

Managed Beans (MBeans)

The Java objects that implement resources and their instrumentation are called managed beans (MBeans). MBeans must follow the design patterns and interfaces defined in Java Management Extensions (JMX) Specification, version 1.4 to ensure that all MBeans provide the instrumentation of managed resources in a standardized way.

The instrumentation of a given resource is provided by one or more MBeans that are either standard or dynamic. Standard MBeans are Java objects that conform to certain design patterns derived from the JavaBeans component model. Dynamic MBeans conform to a specific interface that offers more flexibility at runtime. MXBeans reference only a predefined set of types.

The instrumentation of a resource allows it to be manageable through the agent level described in Using JMX Agents. MBeans do not require knowledge of the JMX agent with which they operate.

MBeans are designed to be flexible, simple, and easy to implement. Existing objects can easily be evolved to produce standard MBeans or wrapped as dynamic MBeans, thus making existing resources manageable with minimum effort. With MBeans, developers of applications, services, or devices can make their products manageable in a standard way without having to understand or invest in complex management systems.

The instrumentation level specifies a notification mechanism which enables MBeans to generate and propagate notification events to components of the other levels.

The management interface of an MBean consists of:

  • Named and typed attributes that can be read and/or written
  • Named and typed operations that can be invoked
  • Typed notifications that can be emitted by the MBean

The Java class of a standard MBean exposes the resource to be managed directly through its attributes and operations. Attributes are internal entities that are exposed through getter and setter methods. Operations are the other methods of the class that are available to managers. All these methods are static methods in the MBean interface and are visible to a JMX agent through introspection. This is the most straightforward way of making a new resource manageable.

A dynamic MBean defines its management interface at runtime. For example, a configuration MBean could determine the names and types of the attributes it exposes by parsing an XML file.

An MXBean is a type of MBean that provides a simple way to code an MBean that only references a pre-defined set of types. In this way, you can be sure that your MBean will be usable by any client, including remote clients, without any requirement that the client have access to model-specific classes representing the types of your MBeans.

JVM Instrumentation

The JVM is highly instrumented using JMX technology. You can easily start a JMX agent to access the built-in JVM instrumentation, and thereby monitor and manage the JVM remotely by JMX technology.

To find out more about using JMX technology to monitor and manage the JVM, see the Java Platform, Standard Edition Monitoring and Management Guide.