The Mina program's JMX support __apache

Source: Internet
Author: User

Original address: JMX Support

Java Management Extensions (JMX) are used to manage and monitor Java applications. This tutorial will provide you with an example of how to build a jmx-usable mina application. The purpose of this tutorial is to help you integrate the JMX technology with the Mina based application. In this tutorial, we will consolidate the MINA-JMX class to the virtual (imagined) server sample program. Add JMX support

To enable JMX to support the Mina application, we need to do the following: Create/Acquire Mbean (Ioacceptor Iofilter) required for Mbean server instantiation and Mbean Server registration Mbean

The rest of the time we will discuss according to \src\main\java\org\apache\mina\example\imagine\step3\server\imageserver.java. Create or acquire an Mbean service side

Create a JMX MBean server server instance
mbeanserver mbeanserver = Managementfactory.getplatformmbeanserver ();
This line of code is to get an Mbean service-side instance.

instantiating an Mbean (s)

We create an mbean for Ioservice:

Create a jmx-aware bean that wraps a MINA Ioservice object.  In here
//Case, a niosocketacceptor. 
Ioservicembean Acceptormbean = new Ioservicembean (acceptor);
Create a Ioservice MBean. It accepts a sink instance through JMX. Similarly, you can add Iofiltermbean and other custom Mbeans. registering an Mbean through an Mbean server

Create a JMX objectname.  This is has to is in a specific format.  
ObjectName acceptorname = new ObjectName (Acceptor.getclass (). Getpackage (). GetName () +
        ": type=acceptor,name=" + Acceptor.getclass (). Getsimplename ());

Register the Bean on the mbeanserver.  Without this line, no JMX would happen for
//this acceptor.
Mbeanserver.registermbean (Acceptormbean, acceptorname);
We create an object name that needs to be used as a logical name to access the Mbean and an Mbean server that registers the Mbean. JMX is now enabled in our applications. Let's look at its practical application. to start the virtual Mbean server side

If you are using Java 5 or earlier:

Java-dcom.sun.management.jmxremote-classpath <CLASSPATH> Org.apache.mina.example.imagine.step3.server.ImageServer
If you use Java 6:

Java  -classpath <CLASSPATH>}}{{{}org.apache.mina.example.imagine.step3.server.imageserver
Start Jconsole

Start jconsole using the following command:

/bin/jconsole
We can see the different properties and the Mbeans exposed by the operation.

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.