public class MBeanServerNotification extends Notification
接受mbeanservernotifications,你需要的是代表MBeanServer MBeanServerDelegate MBean登记侦听器。该mbeanserverdelegate objectName是MBeanServerDelegate.DELEGATE_NAME,这是JMImplementation:type=MBeanServerDelegate。
下面的代码会打印一条消息每次MBean注册或未注册的MBean服务器mbeanServer:
私有静态最终notificationlistener printlistener =新notificationlistener() {公共void handleNotification(通知N,Object handback){如果(!(N是mbeanservernotification)){系统。出来。println(忽略通知类“+,getclass()。getname());返回;}mbeanservernotification mbsn =(mbeanservernotification)n;字符串是什么;如果(N. gettype()。等于(mbeanservernotification。registration_notification))什么=“MBean注册”;如果(N. gettype()。等于(mbeanservernotification。unregistration_notification))什么=“MBean注册”;其他的什么=“未知类型”gettype() + n.;系统。出来。println(“收到MBean服务器通知:“+什么+“:”+mbsn getmbeanname());}};…addnotificationlistener(MBeanServer。mbeanserverdelegate.delegate_name,printlistener,null,null);
MBean不是MBeanServerDelegate也可以发出mbeanservernotifications。特别是,有MBeans发出一组MBean的mbeanservernotification公约。
一个mbeanservernotification发出表示一组MBeans注册或注销具有以下特点:
"JMX.mbean.registered.group"或"JMX.mbean.unregistered.group",也可以写REGISTRATION_NOTIFICATION+ ".group"或UNREGISTRATION_NOTIFICATION+ ".group"。MBeans发出这些集团注册/注销通知将在他们的MBeanNotificationInfo声明。
| Modifier and Type | Field and Description |
|---|---|
static String |
REGISTRATION_NOTIFICATION
通知类型表示MBean已注册。
|
static String |
UNREGISTRATION_NOTIFICATION
通知类型表示MBean已注册。
|
source| Constructor and Description |
|---|
MBeanServerNotification(String type, Object source, long sequenceNumber, ObjectName objectName)
创建一个mbeanservernotification指定导致通知和指定的通知类型的MBean对象名称。
|
| Modifier and Type | Method and Description |
|---|---|
ObjectName |
getMBeanName()
返回导致通知MBean对象名称。
|
String |
toString()
返回此通知的字符串表示形式。
|
getMessage, getSequenceNumber, getTimeStamp, getType, getUserData, setSequenceNumber, setSource, setTimeStamp, setUserDatagetSourcepublic static final String REGISTRATION_NOTIFICATION
public static final String UNREGISTRATION_NOTIFICATION
public MBeanServerNotification(String type, Object source, long sequenceNumber, ObjectName objectName)
type -一个字符串表示通知的类型。设置这些值之一:
REGISTRATION_NOTIFICATION,
UNREGISTRATION_NOTIFICATION。
source - mbeanservernotification对象MBean服务器负责转发通知。
sequenceNumber -序列号,可用于订单收到通知。
objectName -导致通知MBean对象名称。
public ObjectName getMBeanName()
public String toString()
Notification
toString 方法重写,继承类
Notification
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.