Basic JMX Technology

Source: Internet
Author: User
JMX is slightly different on J2SE5 and J2SE6 platforms. We learn JMX Based on J2SE6. JMX is part of the successful Java2 Platform. Its goal is to dynamically manage and monitor resources you are interested in, such as applications, devices, services, and JVMs. JMX supports local and remote access to manage and monitor related resources. JMX only

JMX is slightly different on J2SE 5 and J2SE 6 platforms. We learn JMX Based on J2SE 6. JMX is already part of the successful Java 2 platform. Its goal is to dynamically manage and monitor resources you are interested in, such as applications, devices, services, and JVMs. JMX supports local and remote access to manage and monitor related resources. JMX is only an extension of application management, not a mandatory one. What are the benefits if we choose to implement the JMX management function for the system?

1. managing existing Java applications based on JMX can be easily implemented based on Java technology without additional investment;

2. JMX defines a specification and a set of standard APIs. The industry has incorporated JMX technology into its own products, such as JBoss and Weblogic;

Third, JMX has a set of standardsArchitectureMakes management dynamic, flexible, scalable, and stable;

Fourth, JMX can be easily integrated with other management solutions, such as accessing the proxy Server (MBean Server) through a browser ).

 

Next, let's take a look at the technical architecture of JMX, which can be divided into three layers:

1. device layer

This layer defines the resources to be managed, such as applications, devices, services, and networks. These resources are exposed as Java objects in MBean mode, such as standard MBean, define management interfaces with names containing MBean suffixes to associate these interfaces with the resources to be managed, and then register these Java objects to the proxy Server (MBean Server) to achieve remote management and monitoring.

For example, we have defined a standard MBean Management Interface (for other mbeans, refer to the relevant documentation ):

  1. PackageOrg. shirdrn. java. jmx. standardmbean;
  2. Public InterfaceMyObjectMBean {
  3. Public LongGetId ();
  4. PublicSTrIng getName ();
  5. Public VoId SetName (String name );
  6. PublicString show ();
  7. }

MBean implementation example is as follows:

  1. PackageOrg. shirdrn. java. jmx. standardmbean;
  2. ImportOrg. apache. log4j. Logger;
  3. Public ClassMyObjectImplementsMyObjectMBean {
  4. Private StatIc FinalLogger LOG = Logger. getLogger (MyObject.Class);
  5. Private LongId;
  6. PrivateString name;
  7. PublicMyObject (){
  8. SuPer();
  9. }
  10. PublicMyObject (LongId, String name ){
  11. Super();
  12. This. Id = id;
  13. This. Name = name;
  14. }
  15. Public LongGetId (){
  16. ReturnId;
  17. }
  18. Public VoidSetId (LongId ){
  19. This. Id = id;
  20. }
  21. PublicString getName (){
  22. ReturnName;
  23. }
  24. Public VoidSetName (String name ){
  25. This. Name = name;
  26. }
  27. PublicString show (){
  28. StringBuffer sb =NewStringBuffer (). append (\ "Id = \"). Append (id). append (\ ", Name = \")
  29. . Append (name );
  30. LOG.info (\ "Show () = \"+ Sb. toString ());
  31. ReturnSb. toString ();
  32. }
  33. }

As you can see, the management interface exposes four methods. You can view but cannot modify the id. You can view and modify the name and call the show method.

Note that for standard mbeans, if the MBean management interface is defined as xxxMBean, the implementation must be xxx. Otherwise, the corresponding resources cannot be found through the MBean Server.

2. Proxy Layer

The proxy layer provides a container for objects to be managed (such as Java objects that implement standard MBean management interfaces). Only objects that meet the requirements and are registered in the container can implement JMX management. The main component of the proxy layer is MBean Server, which acts as a proxy for management in our application system.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.