Team-FLY Presents - JMX: Managing J2EE with Java™ Management Extensions JMX: Managing J2EE with Java™ Management Extensions By Juha Lindfors Publisher : Sams Publishing Pub Date : January 31, 2002 ISBN : 0-672-32288-9 Pages : 408 JMX: Managing J2EE with Java Management Extensions leads you through the JMX API with thorough coverage of Standard MBeans, Dynamic MBeans, Model MBeans, the MBean server, and standard agent services. With the help of detailed code examples, you will learn how to create management systems with JMX, create MBeans and services, and use the MBean server. This book also offers working examples of JMX Connectors and agent discovery, a model MBean implementation, a view of the J2EE Management specification, and a JMX use case using the JBoss application server. JMX: Managing J2EE with Java™ Management Extensions TOC Table of Content Copyright About the Authors Acknowledgments Tell Us What You Think! Introduction What is JMX? Why JMX for J2EE? Part I: Java Management Extensions Specification Part II: JMX in the J2EE Platform Part I. Java Management Extensions Specification Chapter 1. Getting Started MBean Component Types Writing Your First MBean Deploying the HelloMBean Summary Chapter 2. Architecture History Overview Instrumentation Level Agent Level Invocation Mechanism Distributed Services Level Summary Chapter 3. Standard MBeans MBean Definition Implementing Standard MBeans Inheritance Patterns MBean Notification Mechanism Summary Chapter 4. Dynamic MBeans DynamicMBean Interface MBean Metadata Classes Inheritance Patterns DynamicUser Example -1- Bought to you by Team-FLY® JMX: Managing J2EE with Java™ Management Extensions TOC Hot Deploying Resources Summary Chapter 5. Model MBeans ModelMBean Interface Descriptors Model MBean Metadata Attribute Caching Model MBean Example Summary Chapter 6. MBean Server Invocation Mechanism ObjectName class MBeanServerFactory Class MBeanServer Interface MBeanRegistration Interface MBeanServerDelegate Queries Summary Chapter 7. Standard Agent Services M-Let Service Timer Service Monitoring Service Relation Service Summary Part II. JMX in the J2EE Platform Chapter 8. XMBean: Model MBean Implementation ModelMBean Interface Implementation MBeanRegistration Interface DynamicMBean Interface Persistence ModelMBeanNotificationBroadcaster Implementation Metadata Generation Summary Chapter 9. Connectors and Protocol Adaptors RMI Connector SNMP Adaptor Summary -2- Bought to you by Team-FLY® JMX: Managing J2EE with Java™ Management Extensions TOC Chapter 10. JMX Distribution Layer with J2EE Services Location Transparency SOAP Connector Asynchronous JMS Connector Summary Chapter 11. JMX for the Administrator Management of Server Farms JSR-77? 2EE Management Summary Chapter 12. JMX Use Case: The JBoss Server Microkernel Architecture The Server Spine Configuration Service Remote Management Extending the JBoss Server Integration and Development Process Summary Part III. Appendixes Appendix A. Environment Setup Java SDK Installation Sun JMX Reference Implementation Installation IBM Tivoli JMX Implementation Example Source Code JBoss Setup SOAP Configuration JDOM Configuration SNMP Configuration Appendix B. Open MBeans Overview of Open MBeans Predefined Data Types Summary Appendix C. References and Resources Appendix D. JBossMX Project Goals Summary Index -3- Bought to you by Team-FLY® JMX: Managing J2EE with Java™ Management Extensions Copyright Copyright Copyright ©2002 by Sams Publishing All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein. Library of Congress Catalog Card Number: 2001092343 Printed in the United States of America First Printing: Month, 2000 03 02 01 00 4 3 2 1 Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Warning and Disclaimer Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an "as is" basis. The authors and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book. Executive Editor Michael Stephens Development Editor -1- Bought to you by Team-FLY® JMX: Managing J2EE with Java™ Management Extensions Copyright Christy A. Franklin Managing Editor Matt Purcell Project Editor George E. Nedeff Copy Editor Pat Kinyon Indexer Ginny Bess Proofreader Kay Hoskin Technical Editor Kevin Farnham Team Coordinator Pamalee Nelson Interior Designer Anne Jones Cover Designer Aren Howell Production Brad Lenser Dedication To my Mom. -2- Bought to you by Team-FLY® JMX: Managing J2EE with Java™ Management Extensions About the Authors About the Authors Juha Lindfors got involved with the JBoss J2EE application server in early 2000. While digging into the source, he got a crash course in the JMX API, which was already part of the server core. Today, apart from trying to learn to write, he spends a lot of his time writing free software and training people in JMX and J2EE. The rest of his time is spent trying to figure out what to do when he grows up while studying Computer Science at the University of Helsinki, Finland. Marc Fleury, Ph.D., was born in Paris in 1968. Marc started in Sales at Sun Microsystems France. A graduate of the Ecole Polytechnique, France's top engineering school, and an ex-Lieutenant in the paratroopers, he has a master in Theoretical Physics from the ENS ULM and a Ph.D in Physics for work he did as a visiting scientist at MIT (X-Ray Lasers). Marc currently serves as the President of the JBoss Group, LLC? n elite services company based out of Atlanta, GA. The JBoss Group LLC, is a service company dedicated to support, training, and consulting around the free JBoss platform. Based in Atlanta, GA, this LLC regroups core JBoss programmers around the world. JBoss is an open-source, standards-compliant, J2EE application server implemented in 100 percent pure Java. The JBoss/Server and complement of products are delivered under a public license. With 50,000+ downloads per month, JBoss is arguably the most downloaded J2EE-based server in the industry. -3- Bought to you by Team-FLY® JMX: Managing J2EE with Java™ Management Extensions Acknowledgments Acknowledgments I'd like to thank Marc Fleury for his excellent insights into JMX and for kicking my arse to keep me moving. I also much thank Andreas Schaefer for h is help in covering some of the difficult parts of the book. My thanks to all the folks at Sams who made this book real, especially Christy Franklin for her help and comments to get the chapters finished, and the Technical Editor, Kevin Farnham, for putting up with my buggy Java command-line instructions. To Mikko and Tuomo, thanks for dragging me out for an occasional movie or a game of squash. There are numerous other people to thank I can't remember right now. JBoss developers should be proud of your work. And of course, I would like to thank the Academy. -4- Bought to you by Team-FLY® JMX: Managing J2EE with Java™ Management Extensions Tell US Tell Us What You Think! As the reader of this book, you are our most important critic and commentator. We value your opinion and want to know what we're doing right, what we could do better, what areas you'd like to see us publish in, and any other words of wisdom you're willing to pass our way. As an Executive Editor for Sams Publishing, I welcome your comments. You can fax, e-mail, or write me directly to let me know what you did or didn't like about this books well as what we can do to make our books stronger. Please note that I cannot help you with technical problems related to the topic of this book, and that due to the high volume of mail I receive, I might not be able to reply to every message. When you write, please be sure to include this book's title and author as well as your name and phone or fax number. I will carefully review your comments and share them with the author and editors who worked on the book. Fax: 317-581-4770 E-mail: [email protected] Mail: Michael Stephens Executive Editor Sams Publishing 201 West 103rd Street Indianapolis, IN 46290 USA -5- Bought to you by Team-FLY® JMX: Managing J2EE with Java™ Management Extensions Introduction Introduction The Java Management Extensions defines architecture for software and network management in the Java programming language. This book will cover the JMX specification and show you how resources can be managed using JMX. What is JMX? JMX is a unified framework to instrument the disparate pieces of Java code in a modern IT infrastructure. Before JMX, there was no standardized approach in the Java programming language to start, manage, monitor, and stop different software components or applications. Management of software has been achieved through an ad-hoc collection of procedures and custom management code. JMX promises to remove the need for expensive application-specific management solutions by defining an architecture that allows more generic management applications to be built. Why JMX for J2EE? The Java 2 Enterprise Edition is a complex, distributed, service-based enterprise platform. It consists of many different kinds of resources that are dynamically created, distributed, moved across nodes, redeployed, and destroyed. The management of such a platform calls for an isolation layer between the management applications and the managed resources. The management architecture must be generic enough to allow a wide variety of different kinds of resources and components to be managed. The management architecture must be able to cope with the dynamics and distribution of the platform and provide a management model that allows increasingly long uptimes and 24x7 services. JMX can provide all this. Part I: Java Management Extensions Specification The first part of this book will cover all the aspects of the JMX specification. Several examples will be implemented to demonstrate how to build management components, discuss the different types of components the JMX specification defines, and look at the management architecture established by the JMX implementations. -6- Bought to you by Team-FLY®