Package java.lang.management

Provides the management interfaces for monitoring and management of the Java virtual machine and other components in the Java runtime.

See: Description

  • Interface Summary 
    Interface Description
    BufferPoolMXBean
    The management interface for a buffer pool, for example a pool of direct or mapped buffers.
    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.
    PlatformLoggingMXBean
    The management interface for the logging facility.
    PlatformManagedObject
    A platform managed object is a JMX MXBean for monitoring and managing a component in the Java platform.
    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 
    Class Description
    LockInfo
    Information about a lock.
    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.
    MonitorInfo
    Information about an object monitor lock.
    ThreadInfo
    Thread information.

      

  • Enum Summary 
    Enum Description
    MemoryType
    Types of memory pools.

      

Package java.lang.management Description

Provides the management interfaces for monitoring and management of the Java virtual machine and other components in the Java runtime. It allows both local and remote monitoring and management of the running Java virtual machine.

Platform MXBean

A platform MXBean is a managed bean that conforms to the JMX Instrumentation Specification and only uses a set of basic data types. Each platform MXBean is a PlatformManagedObject with a unique name.

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. Each platform MXBean is registered with a unique name defined in the specification of the management interface. 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. See the MXBean specification for details.

Ways to Access MXBeans

An application can monitor the instrumentation of the Java virtual machine and the runtime in the following ways:

1. Direct access to an MXBean interface

  • Get an MXBean instance locally in the running Java virtual machine:

       RuntimeMXBean mxbean = ManagementFactory.getRuntimeMXBean();
    
       // Get the standard attribute "VmVendor"
       String vendor = mxbean.getVmVendor();
    

    Or by calling the getPlatformMXBean or getPlatformMXBeans method:

       RuntimeMXBean mxbean = ManagementFactory.getPlatformMXBean(RuntimeMXBean.class);
    
       // Get the standard attribute "VmVendor"
       String vendor = mxbean.getVmVendor();
    

  • Construct an MXBean proxy instance that forwards the method calls to a given MBeanServer:

       MBeanServerConnection mbs;
    
       // Connect to a running JVM (or itself) and get MBeanServerConnection
       // that has the JVM MBeans registered in it
       ...
    
       // Get a MBean proxy for RuntimeMXBean interface
       RuntimeMXBean proxy =
           ManagementFactory.getPlatformMXBean(mbs,
                                               RuntimeMXBean.class);
       // Get standard attribute "VmVendor"
       String vendor = proxy.getVmVendor();
    

    A proxy is typically used to access an MXBean in a remote Java virtual machine. An alternative way to create an MXBean proxy is:

       RuntimeMXBean proxy =
           ManagementFactory.newPlatformMXBeanProxy(mbs,
                                                    ManagementFactory.RUNTIME_MXBEAN_NAME,
                                                    RuntimeMXBean.class);
    

2. Indirect access to an MXBean interface via MBeanServer

  • 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.

       MBeanServerConnection mbs;
    
       // Connect to a running JVM (or itself) and get MBeanServerConnection
       // that has the JVM MXBeans registered in it
       ...
    
       try {
           // Assuming the RuntimeMXBean has been registered in mbs
           ObjectName oname = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
    
           // Get standard attribute "VmVendor"
           String vendor = (String) mbs.getAttribute(oname, "VmVendor");
       } catch (....) {
           // Catch the exceptions thrown by ObjectName constructor
           // and MBeanServer.getAttribute method
           ...
       }
    

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 MXBeans 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 an attribute from the platform extension:

1) Direct access to the Oracle-specific MXBean interface

   List<com.sun.management.GarbageCollectorMXBean> mxbeans =
       ManagementFactory.getPlatformMXBeans(com.sun.management.GarbageCollectorMXBean.class);

   for (com.sun.management.GarbageCollectorMXBean gc : mxbeans) {
       // Get the standard attribute "CollectionCount"
       String count = mxbean.getCollectionCount();

       // Get the platform-specific attribute "LastGcInfo"
       GcInfo gcinfo = gc.getLastGcInfo();
       ...
   }

2) Access the Oracle-specific MXBean interface via MBeanServer through proxy

   MBeanServerConnection mbs;

   // Connect to a running JVM (or itself) and get MBeanServerConnection
   // that has the JVM MXBeans registered in it
   ...

   List<com.sun.management.GarbageCollectorMXBean> mxbeans =
       ManagementFactory.getPlatformMXBeans(mbs, com.sun.management.GarbageCollectorMXBean.class);

   for (com.sun.management.GarbageCollectorMXBean gc : mxbeans) {
       // Get the standard attribute "CollectionCount"
       String count = mxbean.getCollectionCount();

       // Get the platform-specific attribute "LastGcInfo"
       GcInfo gcinfo = gc.getLastGcInfo();
       ...
   }

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.

The java.lang.management API is thread-safe.

Since:
1.5
See Also:
JMX Specification.

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-java/lang/management/package-summary.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : https://docs.oracle.com

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut