The JBoss application server was the first J2EE application server to embrace the Java Management Extensions (JMX) API, more than two years ago. JMX promises to become the solution for managing complex software systems such as J2EE application servers, and is making its way to both J2SE and J2EE platforms in the form of a standard extension. The JMX specification defines instrumentation of services as MBeans, an agent architecture and standard services. The contract for MBeans is simple, easy to implement, and unobtrusive for managed resources, making the adoption of JMX possible also for existing applications. Furthermore, the architecture set in the specification decouples the management clients from the managed resources, increasing the reusability of JMX-based management tools. The JMX specification is protocol-agnostic (and model-agnostic through adaptors), allowing existing management solutions (such as SNMP and WBEM) to integrate with JMX-based solutions.
Indirection and non-typed invocation make the JMX architecture resilient to changing requirements and evolving interfaces. Services constructed as MBeans may register or unregister from the server in accordance with their respective lifecycles, and their interfaces may evolve without having to disconnect the clients. These properties are the cornerstone for the JBoss JMX-based microkernel architecture, which we'll peek at next in this article.
JMX in J2EE
Many of today's popular J2EE application servers include JMX as part of their ever-growing collection of supported APIs. Depending on the application server and the level of commitment to JMX from your chosen vendor, you can achieve various levels of functionality by invoking MBeans residing in the application server. The functionality may range from reading basic configuration values to monitoring the attribute state changes all the way up to configuring and installing individual services of the J2EE platform.
Once the various services of the J2EE platform have been exposed as MBeans, it's possible to build tools that perform customized tasks on the application server. These include simple configuration scripts that you can run remotely, or more sophisticated web- or Swing-based management clients. It's also possible to build generic management tools that access the management attributes and operations of the application server and expose these to the system administrators, deployers, and bean developers.
Figure 1 shows one such generic management tool, an HTML adaptor from Sun's JMX Reference Implementation. It shows a result of listThreadDump management operation on a ServerInfo MBean in JBoss application server. The ServerInfo is an MBean that lists the number and information of threads currently running in the server's JVM. This type of information is often useful for administrators and developers to resolve configuration or performance problems in the server. Using JMX, the thread information is trivially available via a web interface. Note that the code generating the web pages in this case is not in any way specific to the application server in use. The HTML adaptor shown in the figure is a generic management tool that works similarly with any Java object that exposes a management interface.
Figure 1 Browser view to thread info in JBoss server.
Similarly, operations to deploy J2EE applications or individual EJBs can be exposed as a management operation. JSR-77, "J2EE Management," defines a common set of management interfaces that all J2EE servers should expose.