Sun Microsystems, Inc.
4150 Network Circle
Santa Clara, CA 95054
U.S.A.
Java
TM
Management Extensions
(JMX
TM
) Remote API Tutorial
Version 1.0
October 2003
Please
Recycle
Copyright 2003 Sun Microsystems,Inc.,4150Netwrok Circle • Santa Clara, CA 95045 USA. All rights reserved.
This productordocumentisprotected by copyright and distributed under licenses restricting its use, copying, distribution, and decompilation.
No part of this productordocumentmaybereproduced in any form by any means without prior written authorization of Sun and its licensors,
if any. Third-partysoftware, including font technology, is copyrighted and licensed from Sun suppliers.
Parts of the productmaybederivedfrom Berkeley BSD systems, licensed from the University of California. UNIX is a registered trademark in
the U.S. and other countries, exclusively licensed throughX/OpenCompany,Ltd.ForNetscapeCommunicator™,thefollowingnoticeapplies:
Copyright 1995 Netscape Communications Corporation. All rights reserved.
Sun, Sun Microsystems,theSunlogo,AnswerBook2,docs.sun.com,Java,Javadoc,JavaNamingandDirectory Interface, Jini, Java Community
Process,J2SE,J2EE,JMX,JVM,JCP, and Solaris are trademarks, registeredtrademarks,orservicemarksofSunMicrosystems, Inc. in the U.S.
and other countries. All SPARC trademarks are used under license and aretrademarksorregistered trademarks of SPARC International, Inc. in
the U.S. and other countries. ProductsbearingSPARC trademarks arebaseduponanarchitecture developed by Sun Microsystems,Inc.
The OPEN LOOK and Sun™ Graphical User Interface was developed by Sun Microsystems,Inc.foritsusersandlicensees.Sunacknowledges
the pioneering effortsofXerox in researchinganddevelopingtheconceptofvisualorgraphicaluserinterfacesforthecomputerindustry.Sun
holds a non-exclusive license fromXerox to the XeroxGraphical UserInterface,which license alsocoversSun’s licenseeswhoimplement OPEN
LOOK GUIs and otherwise comply with Sun’s written license agreements.
RESTRICTEDRIGHTS: Use, duplication, or disclosure by the U.S. Government is subject to restrictions of FAR 52.227-14(g)(2)(6/87)and
FAR52.227-19(6/87),orDFAR 252.227-7015(b)(6/95) and DFAR 227.7202-3(a).
DOCUMENTATION IS PROVIDED “AS IS” AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-
INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
Copyright 2003 Sun Microsystems,Inc.,4150Netwrok Circle • Santa Clara, CA 95045 Etats-Unis. Tous droits réservés.
Ce produitoudocumentestprotégé par un copyright et distribué avec des licences qui en restreignentl’utilisation,lacopie,ladistribution,etla
décompilation. Aucune partie de ce produitoudocumentnepeutêtre reproduitesousaucuneforme,parquelquemoyenquecesoit,sans
l’autorisation préalable et écrite de Sun et de ses bailleurs de licence, s’il y en a. Le logiciel détenu par des tiers, et qui comprendlatechnologie
relativeauxpolicesdecaractères, est protégépar un copyright et licencié par des fournisseurs de Sun.
Des parties de ce produitpourront être dérivées des systèmes Berkeley BSD licenciés par l’Université de Californie. UNIX est une marque
déposée aux Etats-Unis et dans d’autrespaysetlicenciéeexclusivementparX/OpenCompany,Ltd.Lanoticesuivanteestapplicableà
Netscape Communicator™: Copyright 1995 Netscape Communications Corporation. Tous droits réservés.
Sun, Sun Microsystems,theSunlogo,AnswerBook2,docs.sun.com,Java,Javadoc,JavaNamingandDirectory Interface, Jini, Java Community
Process,J2SE,J2EE,JMX,JVM,JCP, et Solaris sont des marques de fabrique ou des marquesdéposées,oumarquesdeservice,deSun
Microsystems,Inc.auxEtats-Unisetdansd’autres pays. Toutes lesmarques SPARC sont utilisées sous licence et sont des marques de fabrique
ou des marquesdéposéesdeSPARC International, Inc. aux Etats-Unis et dans d’autrespays.Lesproduitsportantlesmarques SPARC sont
basés sur une architecture développée par Sun Microsystems, Inc.
L’interfaced’utilisationgraphiqueOPENLOOKetSun™aétédéveloppéeparSunMicrosystems, Inc. pour ses utilisateurs et licenciés. Sun
reconnaîtlesefforts de pionniers de Xerox pour la recherche et le développement du concept des interfaces d’utilisation visuelle ou graphique
pour l’industrie de l’informatique. Sun détient une licence non exclusive de Xeroxsurl’interfaced’utilisationgraphiqueXerox,cettelicence
couvrant également les licenciés de Sun qui mettent en place l’interface d’utilisation graphique OPEN LOOK et qui en outreseconformentaux
licences écrites de Sun.
CETTE PUBLICATION EST FOURNIE "EN L’ETAT" ET AUCUNE GARANTIE, EXPRESSE OU IMPLICITE, N’EST ACCORDEE, Y COMPRIS
DES GARANTIES CONCERNANT LA VALEUR MARCHANDE, L’APTITUDE DE LA PUBLICATION A REPONDRE A UNE UTILISATION
PARTICULIERE, OU LE FAIT QU’ELLE NE SOIT PAS CONTREFAISANTE DE PRODUIT DE TIERS. CE DENI DE GARANTIE NE
S’APPLIQUERAIT PAS, DANS LA MESURE OU IL SERAIT TENU JURIDIQUEMENT NUL ET NON AVENU.
Contents 3
Contents
Preface 9
1. Getting Started 15
1.1 Required Version of the JMX Specification 15
1.2 Platform Information 15
1.3 Examples Directory 16
1.4 Working Directory 16
1.5 Paths 17
2. Connectors 19
2.1 RMI Connector 19
2.1.1 Analyzing the Example Classes 20
2.1.1.1 Server.java 20
2.1.1.2 ClientListener.java 21
2.1.1.3 SimpleStandardMBean.java21
2.1.1.4 SimpleStandard.java 22
2.1.1.5 Client.java 23
2.1.2 Running the RMI Connector Example 25
2.2 JMXMP Connector 26
2.2.1 Analyzing the Example Classes 26
2.2.1.1 Server.java 27
4 Java Management Extensions (JMX) Remote API Tutorial • Version 1.0 • October 2003
2.2.1.2 ClientListener.java 28
2.2.1.3 SimpleStandardMBean.java 28
2.2.1.4 SimpleStandard.java 28
2.2.1.5 Client.java 28
2.2.2 Running the JMXMP Connector Example 29
3. Lookup Services 31
3.1 Initial Configuration 31
3.1.1 External RMI Registry 32
3.1.2 External CORBA Naming Service 33
3.1.3 External LDAP Registry 33
3.2 Service Location Protocol (SLP) Lookup Service 34
3.2.1 Analyzing the Example Classes 35
3.2.1.1 Server.java 36
3.2.1.2 Client.java 38
3.2.2 Running the SLP Lookup Service Example 41
3.2.2.1 Setting up the SLP Lookup Service Example 41
3.2.2.2 Running the SLP Lookup Service Example With an RMI
Connector 42
3.2.2.3 Running the SLP Lookup Service Example With a
JMXMP Connector 45
3.3 Jini Lookup Service 46
3.3.1 Analyzing the Example Classes 47
3.3.1.1 Server.java 47
3.3.1.2 Client.java 49
3.3.1.3 java.policy.template 51
3.3.1.4 jini.properties.template 51
3.3.2 Running the Jini Lookup Service Example 51
3.3.2.1 Setting up the Jini Lookup Service Example 51
3.3.2.2 Running the Jini Lookup Service Example With an RMI
Connector 53
Contents 5
3.3.2.3 Running the Jini Lookup Service Example With a
JMXMP Connector 57
3.4 Java Naming and Directory Interface (JNDI) / LDAP Lookup Service 58
3.4.1 Analyzing the Example Classes 59
3.4.1.1 Server.java 59
3.4.1.2 Client.java 62
3.4.1.3 jmx-schema.txt 64
3.4.1.4 60jmx-schema.ldif 64
3.4.2 Running the JNDI/LDAP Lookup Service Example 64
3.4.2.1 Setting up the JNDI/LDAP Lookup Service Example
65
3.4.2.2 RunningtheJNDI/LDAP Lookup ServiceExampleWith
an RMI Connector 65
3.4.2.3 RunningtheJNDI/LDAP Lookup ServiceExampleWith
a JMXMP Connector 69
4. Security 71
4.1 Simple Security 71
4.1.1 RMI Connectors With Simple Security 72
4.1.1.1 RMISSLServerSocketFactory.java 72
4.1.1.2 RMISSLClientSocketFactory.java 73
4.1.1.3 Server.java 74
4.1.1.4 SimpleStandardMBean.java 75
4.1.1.5 SimpleStandard.java 75
4.1.1.6 ClientListener.java 75
4.1.1.7 Client.java 76
4.1.2 Running the RMI Connector Example With Simple Security 77
4.1.3 JMXMP Connectors With Simple Security 78
4.1.3.1 Server.java 79
4.1.3.2 PropertiesFileCallbackHandler.java 81
4.1.3.3 SimpleStandardMBean.java 81
4.1.3.4 SimpleStandard.java 81
4.1.3.5 ClientListener.java 81