本文整理汇总了Java中javax.management.Notification.setSource方法的典型用法代码示例。如果您正苦于以下问题:Java Notification.setSource方法的具体用法?Java Notification.setSource怎么用?Java Notification.setSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.Notification
的用法示例。
在下文中一共展示了Notification.setSource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleNotification
import javax.management.Notification; //导入方法依赖的package包/类
public void handleNotification(Notification notification,
Object handback) {
if (notification != null) {
if (notification.getSource() == mbean)
notification.setSource(name);
}
/*
* Listeners are not supposed to throw exceptions. If
* this one does, we could remove it from the MBean. It
* might indicate that a connector has stopped working,
* for instance, and there is no point in sending future
* notifications over that connection. However, this
* seems rather drastic, so instead we propagate the
* exception and let the broadcaster handle it.
*/
listener.handleNotification(notification, handback);
}
示例2: handleNotification
import javax.management.Notification; //导入方法依赖的package包/类
public void handleNotification(
Notification notification, Object handback) {
if (notification.getSource() == userMBean)
notification.setSource(name);
userListener.handleNotification(notification, handback);
}
示例3: replaceNotificationSourceIfNecessary
import javax.management.Notification; //导入方法依赖的package包/类
/**
* From the {@link Notification javadoc}:
* <p><i>"It is strongly recommended that notification senders use the object name
* rather than a reference to the MBean object as the source."</i>
* @param notification the {@link Notification} whose
* {@link javax.management.Notification#getSource()} might need massaging
*/
private void replaceNotificationSourceIfNecessary(Notification notification) {
if (notification.getSource() == null || notification.getSource().equals(this.managedResource)) {
notification.setSource(this.objectName);
}
}