What is an MBean?

JMX (Java Management Extensions) is a framework that embeds management functions for applications, devices, and systems. JMX can span a series of heterogeneous operating system platforms, system architectures, and network transmission protocols to flexibly develop seamlessly integrated system, network, and service management applications.

JMX

Right!
JMX (Java Management Extensions) is a program for applications, devices, systems, etc.
JMX defines applications and network management and monitoring in the Java programming language
The JMX architecture is divided into the following four levels:
Device layer
Equipment level (Instrumentation Level): mainly defines the information model. In JMX, various management objects start with
This layer defines the specification of how to implement JMX management resources. A JMX management resource can be a Java application, a service, or a device. They can be developed in Java, or at least can be packaged in Java, and can be placed in the JMX framework, thereby becoming a JMX
The proxy layer is one that runs in Java
Currently, SUN does not give specific specifications for this layer, what is given below is only a brief description.
This layer specifies the interface that implements the JMX application management platform. This layer defines the management interfaces and components that can operate on the agent layer. These components can:
1) Provide an interface for the management application so that it can transparently interact with the agent layer or JMX management resources through a connector.
2) Provides a view of the JMX agent and all manageable components through the mapping of various protocols (such as SNMP, HTML, etc.).
3) Distribute management information in order to construct a
This layer provides some APIs to support some existing management protocols.
These additional protocol APIs do not define the functions of the management application, or the management platform.
Since the JMX specification was released by SUN, many large companies have taken action to implement the specification or implement the corresponding JMX-based
This article details the JMX specification. JMX
JMX should be said to be a framework for network application management. If you develop a more complex system, you will undoubtedly provide its own management system. More applications of JMX are reflected in Server. If you want to use Java to develop a Server or complex application systems, then it is recommended that you develop based on the JMX architecture. JBoss 3.0 weblogic is server software based on JMX that complies with the J2EE specification.
Understanding JMX can give you an in-depth understanding of the J2EE server. Why do we usually say that "EJB" is a "Weight" solution choice? One of the reasons is that the J2EE server software itself is also part of your system. It acts as a container for your system. The system has a vital role. If you cannot directly intervene in management or "tweak" it, then there is undoubtedly a hidden danger in your system itself. Now, with JMX, you can now go deep into the management of your J2EE container. . (It seems that the first own J2ee server appeared in China. I don't know if it was developed based on JMX?)
J2EE can't summarize all application fields, such as games or stock quotes that require high speed and performance, and need to develop servers directly. If it can be developed based on JMX, it can be said that the efficiency of writing management programs is greatly improved You can turn your module into a JMX MBean. You can initialize and restart your MBean module and set parameters in the program through the Agent or through the WEB management page.
The benefits of JMX are: it can easily integrate and connect with existing Java technologies, such as JNDI JDBC JTS and others. In particular, Jini's query discovery mechanism and protocol can be used. We know that Jini provides a service query and discovery mechanism. These services can be managed through JMX.
Sun Corporation's JMX prescribed architecture diagram
Now we begin to understand JMX:
1. Go to the JMX page of the java.sun homepage and download the JMX regulations and Samples program.
2. Follow the JMX instructions for a tutorial to learn how to add, delete, and configure an MBean. The Tutorial uses SimpleMBean as an example. Can we create our own MBean?
Let's make a Hello MBean. Here is a small key point. There is a rule for your class name. It needs to end with MBean. For example, we name it HelloMbean:
public interface HelloMBean {
// management attributes
public String getName ();
public void setName (String name);
// management operations
public void print ();
}
In this Class, there is an implicit attributes: name, which provides methods for set and get, as well as an operation method print ():
Define a concrete class:
public class Hello implements HelloMBean {
private String name = "";
public String getName () {
return name;
}
public void setName (String name) {
}
public void print () {
System.out.println ("Hello," + name + "!!");
}
}
Such a simple MBean is ready, we can join this Hello through the admin interface,
Then press Tutorial to start the BaseAgent, and refer to Simple in the Agent Administration:
Domain: Standard_Hello_MBeans
Keys: name = Hello, number = 1
Java Class: Hello
The Create Successful message appears. Enter the MBean View to assign a value to Name, click Apply, and then press print. This is the method in your Hello. You will see the output in the console.
Is it very surprising that the attributes and operations in Hello can be dynamically accessed and controlled? Already vaguely feel the principle of JMX architecture?
Let's dig into some concepts further:
The above HelloMBean resources are managed through the HTTP WEB interface such as admin. This method of managing resources belongs to the distributed service layer of JMX. JMX can deploy and manage MBean resources through the distributed layer. Just like the example above, the HelloMBean is maintained and managed through the HTTP WEB interface provided by HtmlAdaptor.
So can we automatically manage and deploy my MBeans in the program? Of course, this is done through the Agent layer. Now we have this layer, the resource layer where the MBeans are located,
The outermost Distributed service layer, the Distributed service layer accesses MBean resources through the Agent layer.
Agent Level (Agent layer) includes MBean Server and Agent Services, then let's make an Agent of the above example HelloMBean:
// CREATE the MBeanServer
//
System.out.println ("\ n \ tCREATE the MBeanServer.");
MBeanServer server = MBeanServerFactory.createMBeanServer ();
// CREATE Registe HelloMBean
//
System.out.println ("\ n \ tCREATE, REGISTER a new Hello Standard_MBean:");
HelloMBean helloMBean = new Hello ();
ObjectName hello_name = null;
try {
hello_name = new ObjectName ("Standard_Hello_MBeans: name = Hello, number = 1");
System.out.println ("\ tOBJECT NAME =" + hello_name);
// Register HelloMBean to MBeanServer
server.registerMBean (helloMBean, hello_name);
}
catch (Exception e) {
e.printStackTrace ();
return;
}
After registering with MBeanServer, JMX will know that there is this HelloMBean resource.
Managing an MBean resource of an agent or using the services it provides must pass a protocol adaptor or connector, adapter or connector belonging to the Distributed layer level (Distributed service layer). In our example, managing HelloMBean through the HTTP WEB interface means that the browser uses the adapter via HtmlAdaptor To achieve.
JMX framework

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?