javax.management

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » management » javax.management 
javax.management
javax.management package

Provides the core classes for the Java Management Extensions.

The Java Management Extensions (JMXTM) API is a standard API for management and monitoring. Typical uses include:

  • consulting and changing application configuration
  • accumulating statistics about application behavior and making them available
  • notifying of state changes and erroneous conditions.

The JMX API can also be used as part of a solution for managing systems, networks, and so on.

The API includes remote access, so a remote management program can interact with a running application for these purposes.

MBeans

The fundamental notion of the JMX API is the MBean. An MBean is a named managed object representing a resource. It has a management interface consisting of:

  • named and typed attributes that can be read and/or written
  • named and typed operations that can be invoked
  • typed notifications that can be emitted by the MBean.

For example, an MBean representing an application's configuration could have attributes representing the different configuration items. Reading the CacheSize attribute would return the current value of that item. Writing it would update the item, potentially changing the behavior of the running application. An operation such as save could store the current configuration persistently. A notification such as ConfigurationChangedNotification could be sent every time the configuration is changed.

In the standard usage of the JMX API, MBeans are implemented as Java objects. However, as explained below, these objects are not usually referenced directly.

Standard MBeans

To make MBean implementation simple, the JMX API includes the notion of Standard MBeans. A Standard MBean is one whose attributes and operations are deduced from a Java interface using certain naming patterns, similar to those used by JavaBeansTM. For example, consider an interface like this:

    public interface ConfigurationMBean {
	public int getCacheSize();
	public void setCacheSize(int size);
	public long getLastChangedTime();
	public void save();
    }
      

The methods getCacheSize and setCacheSize define a read-write attribute of type int called CacheSize (with an initial capital, unlike the JavaBeans convention).

The method getLastChangedTime defines an attribute of type long called LastChangedTime. This is a read-only attribute, since there is no method setLastChangedTime.

The method save defines an operation called save. It is not an attribute, since its name does not begin with get, set, or is.

The exact naming patterns for Standard MBeans are detailed in the JMX Specification.

There are two ways to make a Java object that is an MBean with this management interface. One is for the object to be of a class that has exactly the same name as the Java interface but without the MBean suffix. So in the example the object would be of the class Configuration, in the same Java package as ConfigurationMBean. The second way is to use the {@link javax.management.StandardMBean StandardMBean} class.

MXBeans

An MXBean is a variant of Standard MBean where complex types are mapped to a standard set of types defined in the {@link javax.management.openmbean} package. MXBeans are appropriate if you would otherwise need to reference application-specific classes in your MBean interface. They are described in detail in the specification for {@link javax.management.MXBean MXBean}.

Dynamic MBeans

A Dynamic MBean is an MBean that defines its management interface at run-time. For example, a configuration MBean could determine the names and types of the attributes it exposes by parsing an XML file.

Any Java object of a class that implements the {@link javax.management.DynamicMBean DynamicMBean} interface is a Dynamic MBean.

Open MBeans

An Open MBean is a kind of Dynamic MBean where the types of attributes and of operation parameters and return values are built using a small set of predefined Java classes. Open MBeans facilitate operation with remote management programs that do not necessarily have access to application-specific types, including non-Java programs. Open MBeans are defined by the package javax.management.openmbean.

Model MBeans

A Model MBean is a kind of Dynamic MBean that acts as a bridge between the management interface and the underlying managed resource. Both the management interface and the managed resource are specified as Java objects. The same Model MBean implementation can be reused many times with different management interfaces and managed resources, and it can provide common functionality such as persistence and caching. Model MBeans are defined by the package javax.management.modelmbean.

MBean Server

To be useful, an MBean must be registered in an MBean Server. An MBean Server is a repository of MBeans. Usually the only access to the MBeans is through the MBean Server. In other words, code no longer accesses the Java object implementing the MBean directly, but instead accesses the MBean by name through the MBean Server. Each MBean has a unique name within the MBean Server, defined by the {@link javax.management.ObjectName ObjectName} class.

An MBean Server is an object implementing the interface {@link javax.management.MBeanServer MBeanServer}. The most convenient MBean Server to use is the Platform MBean Server. This is a single MBean Server that can be shared by different managed components running within the same Java Virtual Machine. The Platform MBean Server is accessed with the method {@link java.lang.management.ManagementFactory#getPlatformMBeanServer()}.

Application code can also create a new MBean Server, or access already-created MBean Servers, using the {@link javax.management.MBeanServerFactory MBeanServerFactory} class.

Creating MBeans in the MBean Server

There are two ways to create an MBean. One is to construct a Java object that will be the MBean, then use the {@link javax.management.MBeanServer#registerMBean registerMBean} method to register it in the MBean Server. The other is to create and register the MBean in a single operation using one of the {@link javax.management.MBeanServer#createMBean(String, javax.management.ObjectName) createMBean} methods.

The registerMBean method is simpler for local use, but cannot be used remotely. The createMBean method can be used remotely, but sometimes requires attention to class loading issues.

An MBean can perform actions when it is registered in or unregistered from an MBean Server if it implements the {@link javax.management.MBeanRegistration MBeanRegistration} interface.

Accessing MBeans in the MBean Server

Given an ObjectName name and an MBeanServer mbs, you can access attributes and operations as in this example:

    int cacheSize = mbs.getAttribute(name, "CacheSize");
    {@link javax.management.Attribute Attribute} newCacheSize =
    	new Attribute("CacheSize", new Integer(2000));
    mbs.setAttribute(name, newCacheSize);
    mbs.invoke(name, "save", new Object[0], new Class[0]);
      

Alternatively, if you have a Java interface that corresponds to the management interface for the MBean, you can use an MBean proxy like this:

    ConfigurationMBean conf =
        {@link javax.management.JMX#newMBeanProxy
            JMX.newMBeanProxy}(mbs, name, ConfigurationMBean.class);
    int cacheSize = conf.getCacheSize();
    conf.setCacheSize(2000);
    conf.save();
      

Using an MBean proxy is just a convenience. The second example ends up calling the same MBeanServer operations as the first one.

An MBean Server can be queried for MBeans whose names match certain patterns and/or whose attributes meet certain constraints. Name patterns are constructed using the {@link javax.management.ObjectName ObjectName} class and constraints are constructed using the {@link javax.management.Query Query} class. The methods {@link javax.management.MBeanServer#queryNames queryNames} and {@link javax.management.MBeanServer#queryMBeans queryMBeans} then perform the query.

Notifications

A notification is an instance of the {@link javax.management.Notification Notification} class or a subclass. In addition to its Java class, it has a type string that can distinguish it from other notifications of the same class.

An MBean that will emit notifications must implement the {@link javax.management.NotificationBroadcaster NotificationBroadcaster} or {@link javax.management.NotificationEmitter NotificationEmitter} interface. Usually, it does this by subclassing {@link javax.management.NotificationBroadcasterSupport NotificationBroadcasterSupport} or by delegating to an instance of that class.

Notifications can be received by a listener, which is an object that implements the {@link javax.management.NotificationListener NotificationListener} interface. You can add a listener to an MBean with the method {@link javax.management.MBeanServer#addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object)}. You can optionally supply a filter to this method, to select only notifications of interest. A filter is an object that implements the {@link javax.management.NotificationFilter NotificationFilter} interface.

An MBean can be a listener for notifications emitted by other MBeans in the same MBean Server. In this case, it implements {@link javax.management.NotificationListener NotificationListener} and the method {@link javax.management.MBeanServer#addNotificationListener(ObjectName, ObjectName, NotificationFilter, Object)} is used to listen.

Remote Access to MBeans

An MBean Server can be accessed remotely through a connector. A connector allows a remote Java application to access an MBean Server in essentially the same way as a local one. The package javax.management.remote defines connectors.

The JMX specification also defines the notion of an adaptor. An adaptor translates between requests in a protocol such as SNMP or HTML and accesses to an MBean Server. So for example an SNMP GET operation might result in a getAttribute on the MBean Server.

@see Java SE 6 Platform documentation on JMX technology in particular the JMX Specification, version 1.4(pdf). @since 1.5

Java Source File NameTypeComment
AndQueryExp.javaClass This class is used by the query building mechanism to represent conjunctions of relational expressions.
Attribute.javaClass Represents an MBean attribute by associating its name with its value.
AttributeChangeNotification.javaClass Provides definitions of the attribute change notifications sent by MBeans.
AttributeChangeNotificationFilter.javaClass This class implements of the javax.management.NotificationFilter NotificationFilter interface for the javax.management.AttributeChangeNotification attribute change notification .
AttributeList.javaClass Represents a list of values for attributes of an MBean.
AttributeNotFoundException.javaClass The specified attribute does not exist or cannot be retrieved.
AttributeValueExp.javaClass Represents attributes used as arguments to relational constraints.
BadAttributeValueExpException.javaClass Thrown when an invalid MBean attribute is passed to a query constructing method.
BadBinaryOpValueExpException.javaClass Thrown when an invalid expression is passed to a method for constructing a query.
BadStringOperationException.javaClass Thrown when an invalid string operation is passed to a method for constructing a query.
BetweenQueryExp.javaClass This class is used by the query-building mechanism to represent binary relations.
BinaryOpValueExp.javaClass This class is used by the query-building mechanism to represent binary operations.
BinaryRelQueryExp.javaClass This class is used by the query-building mechanism to represent binary operations.
BooleanValueExp.javaClass This class represents a boolean value.
ClassAttributeValueExp.javaClass This class represents the name of the Java implementation class of the MBean.
DefaultLoaderRepository.javaClass

Keeps the list of Class Loaders registered in the MBean Server. It provides the necessary methods to load classes using the registered Class Loaders.

This deprecated class is maintained for compatibility.

Descriptor.javaInterface

Additional metadata for a JMX element.

DescriptorAccess.javaInterface This interface is used to gain access to descriptors of the Descriptor class which are associated with a JMX component, i.e.
DescriptorKey.javaAnnotation

Meta-annotation that describes how an annotation element relates to a field in a Descriptor .

DescriptorRead.javaInterface Interface to read the Descriptor of a management interface element such as an MBeanInfo.
DynamicMBean.javaInterface Defines the methods that should be implemented by a Dynamic MBean (MBean that exposes a dynamic management interface).
ImmutableDescriptor.javaClass An immutable descriptor.
InQueryExp.javaClass This class is used by the query-building mechanism to represent binary operations.
InstanceAlreadyExistsException.javaClass The MBean is already registered in the repository.
InstanceNotFoundException.javaClass The specified MBean does not exist in the repository.
InstanceOfQueryExp.javaClass This class is used by the query building mechanism for isInstanceOf expressions.
IntrospectionException.javaClass An exception occurred during the introspection of an MBean.
InvalidApplicationException.javaClass Thrown when an attempt is made to apply either of the following: A subquery expression to an MBean or a qualified attribute expression to an MBean of the wrong class.
InvalidAttributeValueException.javaClass The value specified is not valid for the attribute.
JMException.javaClass Exceptions thrown by JMX implementations.
JMRuntimeException.javaClass Runtime exceptions emitted by JMX implementations.
JMX.javaClass Static methods from the JMX API.
ListenerNotFoundException.javaClass The specified MBean listener does not exist in the repository.
MalformedObjectNameException.javaClass The format of the string does not correspond to a valid ObjectName.
MatchQueryExp.javaClass This class is used by the query-building mechanism to represent binary relations.
MBeanAttributeInfo.javaClass Describes an MBean attribute exposed for management.
MBeanConstructorInfo.javaClass Describes a constructor exposed by an MBean.
MBeanException.javaClass Represents "user defined" exceptions thrown by MBean methods in the agent.
MBeanFeatureInfo.javaClass

Provides general information for an MBean descriptor object. The feature described can be an attribute, an operation, a parameter, or a notification.

MBeanInfo.javaClass

Describes the management interface exposed by an MBean; that is, the set of attributes and operations which are available for management operations.

MBeanNotificationInfo.javaClass

The MBeanNotificationInfo class is used to describe the characteristics of the different notification instances emitted by an MBean, for a given Java class of notification.

MBeanOperationInfo.javaClass Describes a management operation exposed by an MBean.
MBeanParameterInfo.javaClass Describes an argument of an operation exposed by an MBean. Instances of this class are immutable.
MBeanPermission.javaClass

Permission controlling access to MBeanServer operations.

MBeanRegistration.javaInterface Can be implemented by an MBean in order to carry out operations before and after being registered or unregistered from the MBean server.
MBeanRegistrationException.javaClass Wraps exceptions thrown by the preRegister(), preDeregister() methods of the MBeanRegistration interface.
MBeanServer.javaInterface

This is the interface for MBean manipulation on the agent side.

MBeanServerBuilder.javaClass

This class represents a builder that creates a default javax.management.MBeanServer implementation.

MBeanServerConnection.javaInterface This interface represents a way to talk to an MBean server, whether local or remote.
MBeanServerDelegate.javaClass Represents the MBean server from the management point of view.
MBeanServerDelegateMBean.javaInterface Defines the management interface of an object of class MBeanServerDelegate.
MBeanServerFactory.javaClass

Provides MBean server references.

MBeanServerInvocationHandler.javaClass

InvocationHandler that forwards methods in an MBean's management interface through the MBean server to the MBean.

Given an MBeanServerConnection , the ObjectName of an MBean within that MBean server, and a Java interface Intf that describes the management interface of the MBean using the patterns for a Standard MBean or an MXBean, this class can be used to construct a proxy for the MBean.

MBeanServerNotification.javaClass Represents a notification emitted by the MBean server through the MBeanServerDelegate MBean.
MBeanServerPermission.javaClass A Permission to perform actions related to MBeanServers. The name of the permission specifies the operation requested or granted by the permission.
MBeanTrustPermission.javaClass This permission represents "trust" in a signer or codebase.

MBeanTrustPermission contains a target name but no actions list. A single target name, "register", is defined for this permission. The target "*" is also allowed, permitting "register" and any future targets that may be defined. Only the null value or the empty string are allowed for the action to allow the policy object to create the permissions specified in the policy file.

If a signer, or codesource is granted this permission, then it is considered a trusted source for MBeans.

MXBean.javaAnnotation
NotCompliantMBeanException.javaClass Exception which occurs when trying to register an object in the MBean server that is not a JMX compliant MBean.
Notification.javaClass

The Notification class represents a notification emitted by an MBean.

NotificationBroadcaster.javaInterface

Interface implemented by an MBean that emits Notifications.

NotificationBroadcasterSupport.javaClass

Provides an implementation of javax.management.NotificationEmitter NotificationEmitter interface.

NotificationEmitter.javaInterface

Interface implemented by an MBean that emits Notifications.

NotificationFilter.javaInterface To be implemented by a any class acting as a notification filter.
NotificationFilterSupport.javaClass Provides an implementation of the javax.management.NotificationFilter interface. The filtering is performed on the notification type attribute.

Manages a list of enabled notification types. A method allows users to enable/disable as many notification types as required.

Then, before sending a notification to a listener registered with a filter, the notification broadcaster compares this notification type with all notification types enabled by the filter.

NotificationListener.javaInterface Should be implemented by an object that wants to receive notifications.
NotQueryExp.javaClass This class is used by the query-building mechanism to represent negations of relational expressions.
NumericValueExp.javaClass This class represents numbers that are arguments to relational constraints.
ObjectInstance.javaClass Used to represent the object name of an MBean and its class name.
ObjectName.javaClass

Represents the object name of an MBean, or a pattern that can match the names of several MBeans.

OperationsException.javaClass Represents exceptions thrown in the MBean server when performing operations on MBeans.
OrQueryExp.javaClass This class is used by the query-building mechanism to represent disjunctions of relational expressions.
PersistentMBean.javaInterface This class is the interface to be implemented by MBeans that are meant to be persistent.
QualifiedAttributeValueExp.javaClass This class represents indexed attributes used as arguments to relational constraints.
Query.javaClass

Constructs query object constraints.

QueryEval.javaClass Allows a query to be performed in the context of a specific MBean server.
QueryExp.javaInterface

Represents relational constraints that can be used in database query "where clauses".

ReflectionException.javaClass Represents exceptions thrown in the MBean server when using the java.lang.reflect classes to invoke methods on MBeans.
RuntimeErrorException.javaClass When a java.lang.Error occurs in the agent it should be caught and re-thrown as a RuntimeErrorException.
RuntimeMBeanException.javaClass Represents runtime exceptions thrown by MBean methods in the agent.
RuntimeOperationsException.javaClass Represents runtime exceptions thrown in the agent when performing operations on MBeans.
ServiceNotFoundException.javaClass Represents exceptions raised when a requested service is not supported.
StandardEmitterMBean.javaClass

An MBean whose management interface is determined by reflection on a Java interface, and that emits notifications.

The following example shows how to use the public constructor StandardEmitterMBean.StandardEmitterMBean(Object,Class,NotificationEmitter) StandardEmitterMBean(implementation, mbeanInterface, emitter) to create an MBean emitting notifications with any implementation class name Impl, with a management interface defined (as for current Standard MBeans) by any interface Intf, and with any implementation of the interface NotificationEmitter .

StandardMBean.javaClass

An MBean whose management interface is determined by reflection on a Java interface.

This class brings more flexibility to the notion of Management Interface in the use of Standard MBeans.

StringValueExp.javaClass Represents strings that are arguments to relational constraints.
ValueExp.javaInterface Represents values that can be passed as arguments to relational expressions.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.