HelloWorld

 1 package mbeanTest;
 2 
 3 import javax.management.Notification;
 4 import javax.management.NotificationBroadcasterSupport;
 5 
 6 public class HelloWorld extends NotificationBroadcasterSupport implements
 7         HelloWorldMBean
 8 {
 9 
10     public String hello;
11 
12     private long seq = 0l;
13 
14     public HelloWorld()
15     {
16         this.hello = "Hello World! I am a Standard MBean";
17     }
18 
19     public HelloWorld(String hello)
20     {
21         this.hello = hello;
22     }
23 
24     public String getHello()
25     {
26         return hello+": 调用方法getHello()";
27     }
28 
29     @Override
30     public Object getInstance()
31     {
32         return new Object();
33     }
34 
35     /*
36      * 当执行message的时候,发送一个消息(事件)
37      * 
38      * @see test.jmx.HelloWorldMBean#message(java.lang.String)
39      */
40     @Override
41     public String message(String ms)
42     {
43         Notification notice = new Notification("type1", this, seq++,
44                 " the message metheod is invoked,the argument ms: " + ms);
45         sendNotification(notice);
46         return " the message :  ";
47     }
48 
49     @Override
50     public void setHello(String hello)
51     {
52         this.hello = hello;
53     }
54 }

 

转载于:https://www.cnblogs.com/wangyonglong/p/7427181.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值