About JMX

原创 2006年05月25日 16:43:00

Some benefits of using JMX in your applications
■ Configuration—Using MBeans to make your applications more configurable.
■ Componentization—Using MBeans to break your applications into components,allowing you to alter or replace component implementations.
■ MBeans using MBeans—Combining both previous concepts, one MBean used another MBean to initialize one of its member variables.

**Using MBean notifications**

  Emitting notifications is a powerful tool and can be used for communication,alerts, and more. Because notifications can contain important information and valuable data, it is a good idea to keep a record of them.

  An MBean wanting to emit Notification objects needs to extend the NotificationBroadcasterSupport class.If the MBean implements the NotificationBroadcaster interface in order to send notifications, then it also defines a method addNotificationListener().Because you have manually created this MBean, you can also invoke its add listener method to add your own listener.

  About notification,you can print it or persist it.

  To persist notifications,you can either create an MBean to act as a listener on every NotificationBroadcaster in the agent, or you can have each MBean manage its own notification persistence.

  About the latter option,you need to use the sendNotification() method, inherited from the NotificationBroadcasterSupport super class.

Example:

import javax.management.*;

public class Polling extends NotificationBroadcasterSupport implements PollingMBean, Runnable{
  private boolean stop = true;
  private long interval = 1000;
  private String info="Notify!";

  public Polling(){
  }

  public void setInterval( long interval ){
    long temp = this.interval;
    this.interval = interval;
    AttributeChangeNotification notif = new AttributeChangeNotification( this, 0, System.currentTimeMillis(), "Attribute Change", "interval", "long", new Long( temp ), new Long( interval ) );
    sendNotification( notif );
  }

  public void start(){
    try
    {
      stop = false;
      Thread t = new Thread( this );
      t.start();
    }
    catch( Exception e ){
      e.printStackTrace();
    }
  }

  public void stop(){
    stop = true;
  }

  public void run(){
    while( !stop ){
      try{
        Thread.sleep( interval );
        System.out.println( "Polling" );
      }
      catch( Exception e ){
        e.printStackTrace();
      }
      Notification notif = new Notification("com.neu.notify.Polling",this,-1,System.currentTimeMillis(),info);
      sendNotification( notif );
    }
  }
  
  public void sendNotification(Notification notify){
   //Save info
   super.sendNotification(notify);
  }

}

 

【JMX】2. JMX通知模型:Notification

复习 JMX构架中的各层及相关的组件 工具层(Instrumentation Level)     (a) MBeans(标准的,动态的,开放的和模型MBeans)     (b) 通知模型:No...
  • vking_wang
  • vking_wang
  • 2013年03月21日 14:16
  • 2096

jmx详解

问题:什么是JMX? 问题:JMX的架构是什么样子的? 问题:JMX以及Mbean中的 概念都有那些? 问题:如何编写一个简单的Standard MBean? 问题:如何编写一...
  • hanxingwang0806
  • hanxingwang0806
  • 2014年05月06日 21:46
  • 1223

JMX-JAVA进程监控利器

Java 管理扩展(Java Management Extension,JMX)是从jdk1.4开始的,但从1.5时才加到jdk里面,并把API放到java.lang.management包里面。 ...
  • chaofanwei2
  • chaofanwei2
  • 2016年05月01日 17:46
  • 4834

linux操作系统,tomcat如何开启JMX

linux操作系统,tomcat如何开启JMX
  • liang_love_java
  • liang_love_java
  • 2016年01月16日 12:40
  • 3575

基于JMX动态配置Log4J日志级别

package com.minxinloan.common.log; import org.apache.log4j.Level; import org.apache.log4j.Logger; i...
  • z2007130205
  • z2007130205
  • 2014年04月17日 09:28
  • 1516

tomcat开启jmx

1.修改JAVA_HOME/jre/lib/management/jmxremote.access monitorRole readonly controlRole readwrit...
  • u010342008
  • u010342008
  • 2015年02月09日 16:07
  • 5818

Java分布式应用学习笔记08JMX规范与常用的监控场景

转自:Java分布式应用学习笔记08JMX规范与常用的监控场景 1.  JMX规范 JMX是“Java管理扩展的”的缩写,它和其他JavaEE类似也是曾经的Sun提出的一种规范(规约),从...
  • guoqmao
  • guoqmao
  • 2016年08月17日 11:08
  • 1204

resin4开启jmx

1.修改JAVA_HOME/jre/lib/management/jmxremote.access monitorRole readonly controlRole readwrite ...
  • u010342008
  • u010342008
  • 2015年01月26日 08:58
  • 1428

linux tomcat8 配置 jmx监控

linux tomcat8 配置 jmx监控linux tomcat8 配置 jmx监控 编辑tomcatbincatalinash 编辑jmxremoteaccess和jmxremotepasswo...
  • pinyitianle
  • pinyitianle
  • 2016年04月17日 10:36
  • 2064

一、JMX官方指导文档 之 JMX概述

JMX概述 JMX(Java Management Exrensions)技术是标准Java平台的一部分。JMX技术从J2SE 5.0发布的时候添加到Java2平台。 JMX提供了一个标准的方法去管理...
  • jiaotuwoaini
  • jiaotuwoaini
  • 2017年05月01日 23:11
  • 431
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:About JMX
举报原因:
原因补充:

(最多只允许输入30个字)