JMX in Action
Benjamin G. Sullins and Mark B. Whipple
  • September 2002
  • ISBN 9781930110564
  • 424 pages
This title is out of print and no longer for sale.

Written for both new and experienced developers, JMX in Action explains the JMX specification and discusses its use through clean, well-discussed examples. It covers the JMX architecture and how to create all types of MBeans. It includes important advanced topics such as extending the JMX classes, combining with other Java technologies, the MBean relation service, dynamic MBean loading, and creating your own protocol adapters.

Table of Contents detailed table of contents



about this book

about the cover illustration

Part 1 Getting started

1. Resource management and JMX

1.1. Resource management

1.1.1. Today’s management environment

1.1.2. The ideal management environment

1.1.3. Management for the real world

1.2. Providing a Java solution: Java Management Extensions

1.2.1. Benefits of using JMX

1.2.2. Essential JMX terms

1.3. The JMX architecture

1.3.1. Example: managing the bicycle shop server

1.3.2. The distributed layer

1.3.3. The agent layer

1.3.4. The instrumentation layer

1.3.5. Notifications

1.4. Using JMX as an application architecture

1.5. JMX in use today

1.6. Developing with JMX

1.7. Summary

2. 'Hello World,' the JMX way

2.1. Getting started

2.1.1. A JMX architecture refresher

2.1.2. Setting up the development environment

2.2. Managing your first resource

2.2.1. Writing the HelloWorld MBean

2.3. Creating a JMX agent

2.3.1. Writing the HelloAgent class

2.3.2. More about object names

2.4. Running the agent

2.4.1. Compiling the agent

2.4.2. Running the agent

2.4.3. Contacting the agent

2.5. Working with the HTML adapter

2.5.1. Agent View

2.5.2. MBean View

2.5.3. Admin View

2.5.4. Registering/unregistering MBeans on the HelloAgent

2.6. Using MBean notifications

2.6.1. Adding notification code to the HelloWorld MBean

2.6.2. Changes to the HelloAgent class

2.7. Summary

3. Building a foundation

3.1. The scope of the agent

3.1.1. Using the HTML adapter

3.1.2. Using the RMI connector

3.2. Writing the JMXBookAgent class

3.2.1. Class definition and constructor

3.2.2. Adding agent connectivity

3.2.3. Finishing with a main() method

3.3. Writing the RMIClientFactory class

3.4. Writing the ExceptionUtil class

3.5. Running the agent

3.5.1. Connecting to the agent with the browser

3.5.2. Connecting to the agent with an RMI client

3.6. Summary

Part 2 Instrumenting manageable resources

4. MBeans for stable resources

4.1. Laying the MBean groundwork

4.1.1. Common coding rules for all MBeans

4.1.2. Using Standard MBeans

4.2. Composing the standard management interface

4.2.1. Components of the management interface

4.2.2. Example: a printer MBean interface

4.3. Standard MBean inheritance patterns

4.3.1. Direct implementation of an MBean interface

4.3.2. Inheriting the management interface

4.3.3. Overriding the management interface

4.3.4. Extending the management interface

4.3.5. Combination of extending and overriding

4.3.6. Extending a non-MBean interface

4.4. Standard MBeans in action

4.4.1. Making applications easily configurable

4.4.2. Breaking applications into components

4.4.3. MBeans using other MBeans

4.5. Handling MBean errors

4.5.1. Throwing exceptions

4.5.2. Runtime exceptions

4.6. Summary

5. MBeans for changing resources

5.1. Working with the DynamicMBean interface

5.2. Examining the DynamicMBean interface

5.2.1. Acquiring the dynamic management interface

5.2.2. Working with dynamic MBean attributes

5.2.3. Invoking operations

5.3. Understanding the MBeanInfo class

5.3.1. Metadata of the MBeanInfo class

5.3.2. The MBeanFeatureInfo and MBeanParameterInfo classes

5.3.3. The MBeanConstructorInfo class

5.3.4. The MBeanAttributeInfo class

5.3.5. The MBeanOperationInfo class

5.3.6. The MBeanNotificationInfo class

5.4. Inheritance patterns

5.5. Dynamic MBeans in action

5.5.1. Managing a Jini service

5.5.2. Rebuilding a management interface at runtime

5.6. Creating utility classes

5.6.1. Creating a dynamic MBean super class

5.7. Summary

6. Communication with MBeans using notifications

6.1. Using MBean notifications

6.2. Components of the JMX notification model

6.2.1. Being a notification broadcaster

6.2.2. Describing notifications as part of a management interface

6.2.3. The Notification class

6.2.4. Being a notification listener

6.2.5. Filtering notifications

6.3. A notification polling example

6.4. Capturing MBean attribute changes

6.4.1. Filtering attribute change notifications

6.4.2. Revising the Polling MBean

6.4.3. Testing the Polling MBean

6.5. Registering as a notification listener

6.5.1. Registering with an MBean

6.5.2. Registering with the MBean server

6.6. Persisting MBean notifications

6.7. Notifications from the MBean server

6.7.1. Notification types sent from the MBean server

6.8. Summary

7. MBeans on-the-fly

7.1. Working with the Model MBean

7.2. Features of the Model MBean

7.2.1. MBean persistence

7.2.2. Notification logging

7.2.3. Attribute value caching

7.2.4. Operation delegation

7.2.5. Generic notifications

7.3. Examining the ModelMBean interface

7.3.1. Configuring a Model MBean

7.3.2. Acquiring and using the management interface

7.3.3. Registering for notifications

7.3.4. MBean persistence

7.4. Understanding the Model MBean metadata

7.4.1. Using descriptors

7.4.2. Constructing a ModelMBeanInfoSupport object

7.4.3. The ModelMBeanAttributeInfo class

7.4.4. The ModelMBeanOperationInfo class

7.4.5. The ModelMBeanConstructorInfo class

7.4.6. The ModelMBeanNotificationInfo class

7.5. Model MBeans in action

7.5.1. Building ModelMBeanInfo objects

7.5.2. Modeling with Model MBeans

7.6. Summary

Part 3 The JMX agent and distributed layers

8. Working with an MBean server

8.1. JMX agent architecture in review

8.1.1. Using protocol adapters and connectors

8.2. The MBeanServer interface

8.2.1. Registration methods

8.2.2. Creation and registration methods

8.2.3. Notification methods

8.2.4. MBean manipulation

8.2.5. MBean server information

8.2.6. Other methods

8.3. Querying for MBeans

8.3.1. The MBeanServer query methods

8.3.2. Creating query expressions

8.3.3. Constructing examples

8.4. Summary

9. Communicating with JMX agents

9.1. Comparing connectors and protocol adapters

9.2. Connecting by using RMI

9.2.1. Using the RMI connector

9.2.2. Creating the RMI server MBean

9.2.3. Connecting to the RMI server

9.2.4. Additional uses for the RMI connector

9.3. Connecting to agents using Jini

9.3.1. Components of the Jini connector

9.3.2. Writing the Jini connector

9.3.3. Outstanding issues

9.3.4. Testing the Jini connector

9.4. JMX and SNMP

9.4.1. What is SNMP?

9.4.2. Using an SNMP protocol adapter

9.5. Connecting by using a TCP adapter

9.5.1. Writing the code

9.5.2. Testing the TCP adapter

9.6. Summary

10. Advanced MBean loading

10.1. Understanding the M-let service

10.2. Using the M-let service

10.2.1. Writing M-let files

10.2.2. Examining the MLet MBean

10.3. Using the M-let service to load MBeans

10.3.1. Adding to the JMXBookAgent class

10.3.2. Example: using an M-let file

10.3.3. Example: expanding the agent’s codebase

10.4. Wrapping the M-let service to provide notifications

10.4.1. Writing the MLetNotification class

10.4.2. Writing the MLetWrapper MBean

10.4.3. Using the MLetWrapper MBean

10.5. Summary

11. Working with the relation service

11.1. Using the JMX relation service

11.1.1. Components of the relation service

11.2. Using the relation service to manage a phone system

11.2.1. Defining the scenario

11.2.2. The phone system management example

11.2.3. Defining an external relationship with an MBean

11.3. Constructing the MBean relationship

11.3.1. Creating the MBeans

11.3.2. Defining the relation

11.3.3. Creating the role objects

11.3.4. Creating the Relation MBean

11.3.5. Adding the relation service to the JMXBookAgent class

11.3.6. Adding a new relation to the relation service

11.3.7. The RelationMain main() method

11.4. Running the example

11.4.1. Viewing the MBeans

11.4.2. Viewing exposed methods

11.4.3. Disabling a phone card

11.5. Summary

12. More agent services: monitors and timers

12.1. Monitoring MBean attributes with JMX

12.1.1. The monitoring foundation

12.1.2. Monitoring String values

12.1.3. Monitoring a value range

12.1.4. Monitoring a counted value

12.2. Monitor examples

12.2.1. Creating the example agent and MBean

12.2.2. Testing the String monitor

12.2.3. Testing the Gauge monitor

12.2.4. Testing the Counter monitor

12.3. Taking corrective measures

12.4. Sending dated notifications: the timer service

12.4.1. Examining the timer

12.5. Using the timer service

12.5.1. Testing the timer service

12.6. Summary

Part 4 Using JMX with the J2EE platform

13. Using JMX with the Java Message Service

13.1. The Java Message Service

13.2. Combining JMX with JMS

13.3. Driving a home theater system

13.3.1. Writing the example

13.4. Running the example

13.4.1. Starting and configuring the JBoss server

13.4.2. Starting the agent and registering the MBean

13.4.3. Running the debugger subscriber

13.4.4. Publishing the control messages

13.5. Summary

14. Using JMX with Enterprise JavaBeans

14.1. An EJB review

14.1.1. The EJB model

14.1.2. Why combine JMX with EJBs?

14.1.3. Accessing enterprise data with JMX

14.2. Example: managing user logins

14.2.1. The problem

14.2.2. The JMX solution

14.3. Developing the login monitor

14.3.1. Constructing the user information entity bean

14.3.2. Constructing the user information management MBean

14.3.3. Writing the user login client test class

14.4. Running the Login Monitor

14.4.1. Deploying your entity bean in the JBoss server

14.4.2. Registering with the agent

14.4.3. Counting user login attempts

14.4.4. Removing login privileges

14.5. Example: managing EJBs

14.5.1. Constructing the workflow entity bean

14.5.2. Constructing the WorkflowManager MBean

14.5.3. Running the workflow manager

14.5.4. Generating EJB managers

14.6. Summary

Appendix A: Open MBeans

A.1. What is an Open MBean?

A.2. Basic data types

A.3. Creating more complex data structures

A.4. Describing Open MBean data types

A.5. Open MBean metadata

A.6. Summary

Appendix B: Using Ant

B.1. Downloading and installing Ant

B.2. Setting up the build file


About the Technology

With Java Management Extensions (JMX), you can configure, manage and monitor your Java applications at run-time, as well as break your applications into components that can be swapped out. JMX provides a window into an application's state and its behavior, and a protocol-independent way of altering both state and behavior. It lets you expose portions of your application in just a few lines of code.

What's inside

  • Manage and monitor your Java applications
  • Combine JMX with J2EE technologies (EJB and JMS)
  • Make use of Sun's RMI adapter
  • Create protocol adapters for TCP and Jini
  • Extend JMX to make it more powerful
  • Best practices for the use of MBeans

About the reader

Written for both new and experienced developers.

About the authors

Ben Sullins is a senior Java developer with both server- and client-side experience. He has extensive JMX experience. Ben lives in the Denver area.

A fifteen-year veteran, Mark Whipple has focused on networked applications, including monitoring applications with SNMP and JMX. He holds multiple software patents and has been a member of several standards bodies, including the IETF. He lives in Dallas, TX.