API java : java.lang.management


Package java.lang.management

Provides the management interface for monitoring and management of the Java virtual machine as well as the operating system on which the Java virtual machine is running.

See:
          Description

Interface Summary
ClassLoadingMXBean The management interface for the class loading system of the Java virtual machine.
CompilationMXBean The management interface for the compilation system of the Java virtual machine.
GarbageCollectorMXBean The management interface for the garbage collection of the Java virtual machine.
MemoryManagerMXBean The management interface for a memory manager.
MemoryMXBean The management interface for the memory system of the Java virtual machine.
MemoryPoolMXBean The management interface for a memory pool.
OperatingSystemMXBean The management interface for the operating system on which the Java virtual machine is running.
RuntimeMXBean The management interface for the runtime system of the Java virtual machine.
ThreadMXBean The management interface for the thread system of the Java virtual machine.
 

Class Summary
ManagementFactory The ManagementFactory class is a factory class for getting managed beans for the Java platform.
ManagementPermission The permission which the SecurityManager will check when code that is running with a SecurityManager calls methods defined in the management interface for the Java platform.
MemoryNotificationInfo The information about a memory notification.
MemoryUsage A MemoryUsage object represents a snapshot of memory usage.
ThreadInfo Thread information.
 

Enum Summary
MemoryType Types of memory pools.
 

Package java.lang.management Description

Provides the management interface for monitoring and management of the Java virtual machine as well as the operating system on which the Java virtual machine is running. It allows both local and remote monitoring and management of the running Java virtual machine.

Platform MXBeans

This package defines the management interface of the following components:

Management Interface

Description

ClassLoadingMXBean Class loading system of the Java virtual machine.
CompilationMXBean Compilation system of the Java virtual machine.
MemoryMXBean Memory system of the Java virtual machine.
ThreadMXBean Threads system of the Java virtual machine.
RuntimeMXBean Runtime system of the Java virtual machine.
OperatingSystemMXBean Operating system on which the Java virtual machine is running.
GarbageCollectorMXBean Garbage collector in the Java virtual machine.
MemoryManagerMXBean Memory manager in the Java virtual machine.
MemoryPoolMXBean Memory pool in the Java virtual machine.

A platform MXBean is a managed bean that defines the management interface for one component for the platform and is specified in the ManagementFactory class.

An application can monitor the instrumentation of the Java virtual machine and manage certain characteristics in the following ways:

  • Direct access to an MXBean interface
    1. Get the MXBean instance through the static factory method and access the MXBean interface locally of the running virtual machine.
    2. Construct an MXBean proxy instance that forwards the method calls to a given MBeanServer by calling ManagementFactory.newPlatformMXBeanProxy. A proxy is typically constructed to remotely access an MXBean of another running virtual machine.
  • Indirect access via MBeanServer interface
    1. Go through the platform MBeanServer to access MXBeans locally or a specific MBeanServerConnection to access MXBeans remotely. The attributes and operations of an MXBean use only JMX open types which include basic data types, CompositeData, and TabularData defined in OpenType.
Below shows a few examples of different ways to access MXBeans.

ManagementFactory

The ManagementFactory class is the management factory class for the Java platform. This class provides a set of static factory methods to obtain the MXBeans for the Java platform to allow an application to access the MXBeans directly.

A platform MBeanServer can be accessed with the getPlatformMBeanServer method. On the first call to this method, it creates the platform MBeanServer and registers all platform MXBeans including platform MXBeans defined in other packages such as LoggingMXBean. Each platform MXBean is registered with a unique name defined in the ManagementFactory class for constructing ObjectName. This is a single MBeanServer that can be shared by different managed components running within the same Java virtual machine.

Interoperability

A management application and a platform MBeanServer of a running virtual machine can interoperate without requiring classes used by the platform MXBean interfaces. The data types being transmitted between the JMX connector server and the connector client are JMX open types and this allows interoperation across versions.

A data type used by the MXBean interfaces are mapped to an open type when being accessed via MBeanServer interface. The data type mapping is specified in the ManagementFactory class.

Ways to Access MXBeans

There are three different ways to access the management interfaces.

  1. Call the methods in the MXBean directly within the same Java virtual machine.
    1. RuntimeMXBean mxbean = ManagementFactory.getRuntimeMXBean();
    2.  
    3. // Get the standard attribute "VmVendor"
    4. String vendor = mxbean.getVmVendor();
  2. Go through a MBeanServerConnection connecting to the platform MBeanServer of a running virtual machine.
    1.  
    2. // Connect to a running JVM (or itself) and get MBeanServerConnection
    3. // that has the JVM MXBeans registered in it
    4. ...
    5.  
    6. try {
    7. // Assuming the RuntimeMXBean has been registered in mbs
    8. ObjectName oname = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
    9.  
    10. // Get standard attribute "VmVendor"
    11. String vendor = (String) mbs.getAttribute(oname, "VmVendor");
    12. } catch (....) {
    13. // Catch the exceptions thrown by ObjectName constructor
    14. // and MBeanServer.getAttribute method
    15. ...
    16. }
  3. Use MXBean proxy.
    1.  
    2. // Connect to a running JVM (or itself) and get MBeanServerConnection
    3. // that has the JVM MBeans registered in it
    4. ...
    5.  
    6. // Get a MBean proxy for RuntimeMXBean interface
    7. RuntimeMXBean proxy =
    8. ManagementFactory.newPlatformMXBeanProxy(mbs,
    9. ManagementFactory.RUNTIME_MXBEAN_NAME,
    10. RuntimeMXBean.class);
    11. // Get standard attribute "VmVendor"
    12. String vendor = proxy.getVmVendor();

Platform Extension

A Java virtual machine implementation may add its platform extension to the management interface by defining platform-dependent interfaces that extend the standard management interfaces to include platform-specific metrics and management operations. The static factory methods in the ManagementFactory class will return the MBeans with the platform extension.

It is recommended to name the platform-specific attributes with a vendor-specific prefix such as the vendor's name to avoid collisions of the attribute name between the future extension to the standard management interface and the platform extension. If the future extension to the standard management interface defines a new attribute for a management interface and the attribute name is happened to be same as some vendor-specific attribute's name, the applications accessing that vendor-specific attribute would have to be modified to cope with versioning and compatibility issues.

Below is an example showing how to access a platform-specific attribute from Sun's implementation of the RuntimeMXBean.

1) Direct access to the Sun-specific MXBean interface

  1. com.sun.management.RuntimeMXBean mxbean =
  2. (com.sun.management.RuntimeMXBean) ManagementFactory.getRuntimeMXBean();
  3.  
  4. // Get the standard attribute "VmVendor"
  5. String vendor = mxbean.getVmVendor();
  6.  
  7. // Get the platform-specific attribute "Bar"
  8. BarType bar = mxbean.getBar();

2) Access the Sun-specific MXBean interface via MBeanServer

  1.  
  2. // Connect to a running JVM (or itself) and get MBeanServerConnection
  3. // that has the JVM MXBeans registered in it
  4. ...
  5.  
  6. try {
  7. // Assuming the RuntimeMXBean has been registered in mbs
  8. ObjectName oname = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
  9.  
  10. // Get standard attribute "VmVendor"
  11. String vendor = (String) mbs.getAttribute(oname, "VmVendor");
  12.  
  13. // Check if this MXBean contains Sun's extension
  14. if (mbs.isInstanceOf(oname, "com.sun.management.RuntimeMXBean")) {
  15. // Get platform-specific attribute "Bar"
  16. BarType bar = (String) mbs.getAttribute(oname, "Bar");
  17. }
  18. } catch (....) {
  19. // Catch the exceptions thrown by ObjectName constructor
  20. // and MBeanServer methods
  21. ...
  22. }

Unless otherwise noted, passing a null argument to a constructor or method in any class or interface in this package will cause a NullPointerException to be thrown.

Since:
1.5
See Also:
JMX Specification.

Ces informations proviennent du site de http://java.sun.com

Remarques

Contenu

Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :

Quels sont les motivations de cette démarche?

Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.

Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.

Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.

Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.

Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

8 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-825
Document créé le 04/08/06 10:20, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-java/lang/management/package-summary.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
1,23 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Les humains ont un don pour désirer ce qui leur fait le plus de mal.

J. K. Rowling [Extrait de Harry Potter à l'école des sorciers]
 
l'infobrol
Nous sommes le Vendredi 01 Juin 2012, 17:29, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)