public FlagJMXProxy(final ObjectName source, final MBeanServerConnection mbsc, final String flagName) throws MalformedObjectNameException {
ObjectName name = PogamutJMX.getObjectName(source, flagName, PogamutJMX.FLAGS_SUBTYPE);
try {
listener = new NotificationListener() {
@Override
public void handleNotification(Notification notification, Object handback) {
if (notification.getSource().equals(source) && notification.getType().equals(flagName)) {
setFlag((T) notification.getUserData());
}
}
};
// get current value of the flag
T val = (T) mbsc.getAttribute(name, "Flag");
setFlag(val);
/* NOTE filters are send over RMI to the server !!! it is better to
handle filtering in the listener itself.
NotificationFilter nf = new NotificationFilter() {
@Override
public boolean isNotificationEnabled(Notification notification) {
return notification.getSource().equals(source) && notification.getType().equals(flagName);
}
};
*/
mbsc.addNotificationListener(name, listener, null, mbsc);
} catch (Exception ex) {
ex.printStackTrace();
throw new RuntimeException(ex);
}
}
FlagJMXProxy.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:Pogamut3
作者:
评论列表
文章目录