當前位置: 首頁>>代碼示例>>Java>>正文


Java Notification.getSource方法代碼示例

本文整理匯總了Java中javax.management.Notification.getSource方法的典型用法代碼示例。如果您正苦於以下問題:Java Notification.getSource方法的具體用法?Java Notification.getSource怎麽用?Java Notification.getSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.management.Notification的用法示例。


在下文中一共展示了Notification.getSource方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:DefaultMBeanServerInterceptor.java

示例2: checkNotifs

import javax.management.Notification; //導入方法依賴的package包/類
/**
 * Check received notifications
 */
public int checkNotifs(int size,
                       List<Notification> received,
                       List<ObjectName> expected) {
    if (received.size() != size) {
        echo("Error: expecting " + size + " notifications, got " +
                received.size());
        return 1;
    } else {
        for (Notification n : received) {
            echo("Received notification: " + n);
            if (!n.getType().equals("nb")) {
                echo("Notification type must be \"nb\"");
                return 1;
            }
            ObjectName o = (ObjectName) n.getSource();
            int index = (int) n.getSequenceNumber();
            ObjectName nb = expected.get(index);
            if (!o.equals(nb)) {
                echo("Notification source must be " + nb);
                return 1;
            }
        }
    }
    return 0;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:29,代碼來源:NotificationAccessControllerTest.java

示例3: checkNotifs

import javax.management.Notification; //導入方法依賴的package包/類
public int checkNotifs(int size,
                       List<Notification> received,
                       List<ObjectName> expected) {
    if (received.size() != size) {
        echo("Error: expecting " + size + " notifications, got " +
                received.size());
        return 1;
    } else {
        for (Notification n : received) {
            echo("Received notification: " + n);
            if (!n.getType().equals("nb")) {
                echo("Notification type must be \"nb\"");
                return 1;
            }
            ObjectName o = (ObjectName) n.getSource();
            int index = (int) n.getSequenceNumber();
            ObjectName nb = expected.get(index);
            if (!o.equals(nb)) {
                echo("Notification source must be " + nb);
                return 1;
            }
        }
    }
    return 0;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:26,代碼來源:NotificationEmissionTest.java

示例4: processNotification

import javax.management.Notification; //導入方法依賴的package包/類
public static void processNotification(MBeanServerConnection connection, Notification notification) {
    echo("\n<notification>");
    echo("\t<currentDatetime>" + DATE_FORMAT.format(Calendar.getInstance().getTime()) + "</currentDatetime>");
    echo("\t<notificationTime timestamp='" + notification.getTimeStamp() + "'>" + DATE_FORMAT.format(new Date(notification.getTimeStamp())) + "</notificationTime>");
    echo("\t<className>" + notification.getClass().getName() + "</className>");
    echo("\t<source>" + notification.getSource() + "</source>");
    echo("\t<type>" + notification.getType() + "</type>");
    echo("\t<message>" + notification.getMessage() + "</message>");
    if (notification instanceof AttributeChangeNotification) {
        echo("\t<attributeChanges>");
        AttributeChangeNotification acn = (AttributeChangeNotification) notification;
        echo("\t\t<attributeName>" + acn.getAttributeName() + "</attributeName>");
        echo("\t\t<attributeType>" + acn.getAttributeType() + "</attributeType>");
        echo("\t\t<newValue>" + acn.getNewValue() + "</newValue>");
        echo("\t\t<oldValue>" + acn.getOldValue() + "</oldValue>");
        echo("\t</attributeChanges>");
    }

    if (notification.getSource() instanceof ObjectName) {
        GarbageCollectorMXBean gcBean = JMX.newMXBeanProxy(connection, (ObjectName) notification.getSource(), GarbageCollectorMXBean.class);
        echo("\t<gcInfo>");
        echo("\t\t<collectionTime>" + gcBean.getCollectionTime() + "</collectionTime>");
        echo("\t\t<collectionCount>" + gcBean.getCollectionCount() + "</collectionCount>");
        GcInfo gcInfo = gcBean.getLastGcInfo();
        echo("\t\t<startTime>" + gcInfo.getStartTime() + "</startTime>");
        echo("\t\t<endTime>"   + gcInfo.getEndTime()   + "</endTime>");
        echo("\t\t<duration>"  + gcInfo.getDuration()  + "</duration>");
        outputMemoryUsages(gcInfo.getMemoryUsageBeforeGc(), "memoryUsageBeforeGC");
        outputMemoryUsages(gcInfo.getMemoryUsageAfterGc(), "memoryUsageAfterGC");
        echo("\t</gcInfo>");
    }

    echo("\n</notification>");
}
 
開發者ID:breakEval13,項目名稱:rocketmq-flink-plugin,代碼行數:35,代碼來源:JMXGarbageCollectorNotificationClient.java

示例5: handleNotification

import javax.management.Notification; //導入方法依賴的package包/類
public void handleNotification(
        Notification notification, Object handback) {
    if (notification.getSource() == userMBean)
        notification.setSource(name);
    userListener.handleNotification(notification, handback);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:7,代碼來源:OldMBeanServerTest.java

示例6: 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);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:13,代碼來源:ModelMBeanNotificationPublisher.java


注:本文中的javax.management.Notification.getSource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。