Home > Articles > Programming > Java

📄 Contents

  1. Application Management
  2. Java Management Extensions (JMX)
  3. Summary
  4. References
  • Print
  • + Share This
Like this article? We recommend

Java Management Extensions (JMX)

JMX has become a standard for managing java resources. It exposes the application's management information, and management systems can use JMX APIs to generate analysis reports based on this information. JMX enables applications to be monitored and controlled while shielding the application from management protocols.

The architecture that JMX follows is a variation of the architectural pattern called Manager-Agent. The basic components of this architectural pattern are the managed resource, agent, and management system. A managed resource is the application that needs to be managed by exposing appropriate data for use by a management system. For example, if a remote call takes more than five seconds to execute, which is beyond the acceptable limits of performance, the managed application can trigger a notification using JMX. The management system can then interpret it and send a pager message to the appropriate party about the event. A management Agent communicates both with the management system and the application. The Agent is responsible for sending events to the management system and executing commands from the management system onto the application. The management system is responsible for providing the infrastructure to mange the applications. HP OpenView is an example of a management system.

Figure 1 shows the relationship between components of JMX Architecture from Sun Microsystem's JMX 1.2 specification.

Figure 1Figure 1 Relationship between components of JMX from Sun Microsystems' JMX 1.2 specification

The important layers of the JMX architecture are as follows (described in the following sections):

  • Instrumentation Level

  • Agent Level

  • Distributed Services Level

Instrumentation Layer

The Instrumentation Layer provides the specification for implementing manageable resources by any arbitrary management system. Resources that conform to this level are called manageable resources. JMX managed resources are provided by Managed Beans (MBeans). Instrumentation Layer components are shown in Figure 2.

Figure 2Figure 2 Instrumentation Layer components.

The components of the instrumentation layer are

  • Managed Beans

  • Notification Model

  • MBean Metadata Classes

Each of these components is briefly described below.

Managed Beans (MBeans)

JMX-enabled managed resources are provided by MBeans. MBeans come in four flavors: Standard Mbeans, Dynamic Mbeans, Open Mbeans, and Model Mbeans.

Standard MBeans

A Standard MBean explicitly defines its management interface following a lexical design pattern (in other words, a naming convention). The lexical design patterns are used to distinguish MBean attributes from MBean operations. For example, an attribute is identified by the following pattern:

//Attribute Getter 
public AttributeType getAttributeName() {...}


//Attribute Setter
public void setAttributeName(AttributeType someValue){...}

The AttributeType is any Java Type and AttributeName is case-sensitive. If only a getter for an attribute is present, it implies that the attribute is read-only; if only a setter is present, it implies that the attribute is write-only. If both a getter and setter are present for an attribute, it is read and write. If the AttributeType is Boolean, the read-only (that is, getter) can be defined as follows:

public boolean isAttributeName(){..}

OR

public boolean getAttributeName() {..}

Note that one form of read-only is allowed for a Boolean attribute, not both.

The management interface contains the attributes that are exposed through getters and setters, public only constructors, operations, and notification objects that the MBean broadcasts. Operations are those methods defined in the MBean interface that do not match any of the attribute design patterns. Using Standard MBeans is the quickest and easiest way to build instrumentation for manageable resources, and is best-suited when the management information that needs to be exposed is well-defined and unlikely to change over time.

This series presents an example scenario of collecting application metrics in real-time using the Standard MBeans for exposing the management information. The use case is this: A management system records the application performance metrics that is the hostname of the server hosting the application and the response time of a method in an application. This data would be displayed in OpenView Performance Manager/OpenView Performance Insight (OVPM/OVPI). As a developer, you would develop a management interface and write User-Defined Metrics (UDM). A UDM is an XML configuration file that defines the JMX MBeans that will be collected by OVPM. The next article will discuss what is needed to integrate WebLogic Application Server with Hp OVPM. The same steps are applicable to integrating with OVPI. For now, the following is the code for the MBean interface and the standard MBean that will be deployed in WebLogic Application Server.

    //The management interface 

public interface PerformanceMetricsMBean {
  /**
   * Return the name of the server hosting the JVM that this MBean is deployed in.
   * @return the local host name
   */
   public String getHostName();
  /**
   * Return the measured response time 
   * @return the measured response time 
   */
   public String getResponseTime();
}
      

    //The MBean Class

public class PerformanceMetrics implements PerformanceMetricsMBean {
   
   private String hostName;
   private String responseTime;
  
   public String getHostName() {
      return hostName;
   }

  
   public String getResponseTime() {
      return responseTime;
   }
   
   public void setHostName(String value){
      hostName = value;
   }
   
   public void setResponseTime(String value){
      responseTime = value;
   }      

}

The MBean developed above is registered with the MBean Server using a startup servlet.

The following sections give a brief overview of other types of MBeans, but do not have the same detailed overview as that furnished for Standard MBeans. Refer to the References section at the end of this article to learn more.

Dynamic MBeans

When resources are likely to change often over time, Dynamic MBeans are recommended over Standard MBeans because they provide flexibility such as being dynamically determined at runtime.

Dynamic MBeans are resources that are instrumented through a predefined interface that exposes the attributes and operations only at runtime.

Following the JMX 1.2 specification, a Dynamic MBean should implement the interface javax.management.DynamicMBean. The DynamicMBean interface exposes the management information of a resource by using a javax.managemen.MBeanInfo class. The MBeanInfo class describes the set of attributes exposed and operations that can be performed on the managed resource.

Open MBeans

Open MBeans are dynamic MBeans with restricted data types for their attributes, constructors, and operations to Java primitive types. Using these limited basic types enables serialization, and removes the need for class loading and proxy coordination between the MBeanServer and users of the MBeans.

Model MBeans

A model MBean is a fully customizable dynamic MBean. The Model MBean is defined by javax.management.modelmbean.RequiredModelMBean. The RequiredModelMBean class, which implements the ModelMBean interface, is guaranteed to exist on every JMX Agent. A model MBean implements the ModelMBean interface that extends other interfaces, including DynamicMBean, PersistentMBean, and ModelMBeanNotificationBroadcaster.

Notification Model

The JMX Notification Model, which is based on the Java Event Model, lets your MBeans speak to other objects, applications, and other MBean instances. An MBean can send a notification by implementing the JMX NotificationBroadcaster interface, and an MBean can receive notifications by implementing the JMX NotificationListener interface (it must register for notifications). The current version of the JMX specification leaves the process of how the distribution of the notification model is achieved to a future version of the JMX specification.

MBean Metadata Classes

The MBean Metadata classes are used to describe the management interface of an MBean. The metadata classes contain the structures to the attributes, operations, notifications, and constructors of a managed resource. For each of these, the metadata includes a name, a description, and particular characteristics. The different types of Mbeans extend the metadata classes to provide additional information. These classes are used both for the introspection of standard MBeans and for the self-description of all dynamic MBeans.

Agent Level

The Agent Level provides management Agents to control the managed resources exposed by the application. An Agent can run on the same server that hosts the application or on a remote server. A JMX Agent is composed of an MBean Server, a set of MBeans representing the managed resources, agent services implemented as MBeans, and at least one protocol adaptor or connector.

The MBean Server, the core component of the Agent Layer, allows for MBean registration and manipulation. Agent Services are objects (usually Mbeans) that allow themselves to be controlled through the MbeanServer. The Agent Service MBeans provide the following:

  • Dynamic class loading that allows retrieval and instantiation of new classes from an arbitrary location on the network called an m-let service. The m-let service does this by loading an m-let text file that specifies information on the MBeans needed. The information on each MBean is specified using a tag called an MLET tag. The location of the m-let text file is specified by a URL; when loaded, all the classes specified in MLET tags are downloaded, and an instance of each MBean is created and registered.

  • Monitors watch for changes on a target's attributes and can notify about other objects of interest.

  • The Timer Service provides a mechanism to emit user-defined notifications at specific times.

  • The Relation Service defines n-ary associations between MBeans based on predefined relation types.

Connectors and Protocol Adapters make the Agent accessible from remote management systems. Connectors are used to connect an Agent with a JMX-enabled management application. A Protocol Adaptor provides a management view of the JMX Agent through a given protocol. The JMX reference implementation comes with an HTTP adaptor.

Figure 3 depicts the HTML adaptor view, showing the registration of the PerfomanceMetrics MBean developed for this article.

Figure 3Figure 3 HTML adaptor view.

Distributed Services Layer

The Distributed Services Layer provides the interfaces for implementing JMX managers. (JMX Specification 1.2 leaves the detailed definition of the Distributed Services Layer to a future version of the JMX specification.) This level defines management interfaces and components that can operate on Agents or hierarchies of Agents. These components can

  • Provide security.

  • Provide transparent interaction between an Agent and manageable resources through a connector.

  • Provide the distribution of management information from management platforms to JMX Agents.

  • Provide a management view of a JMX Agent and the MBeans registered in the MBean Server by using Hypertext Mark-Up Language (HTML) or Simple Network Management Protocol (SNMP).

  • Provide logical views by gathering management information from JMX Agents.

Management components interact with one another across the network to provide distributed scalable management capabilities. These components can be used to deploy a management application with customized Java-based management capabilities.

  • + Share This
  • 🔖 Save To Your Account

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020