From 0a12f1815c7f07b4cdfeb04bf973a18ab0632cf4 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Tue, 21 Jul 2009 09:32:53 +0000 Subject: QPID-1969: restrict the Notifications areas in each VirtualHost tree to only show the notifications from that VirtualHost, instead of those from the entire server. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@796212 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/qpid/management/ui/ServerRegistry.java | 2 ++ .../qpid/management/ui/jmx/JMXServerRegistry.java | 27 ++++++++++++++++++++++ .../management/ui/model/NotificationObject.java | 12 ++++++++++ .../ui/views/VHNotificationsTabControl.java | 10 ++++---- 4 files changed, 46 insertions(+), 5 deletions(-) (limited to 'qpid/java/management/eclipse-plugin/src') diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java index cc44a19781..23879a779c 100644 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java @@ -169,6 +169,8 @@ public abstract class ServerRegistry public abstract List getNotifications(ManagedBean mbean); + public abstract List getNotifications(String virtualhost); + public abstract boolean hasSubscribedForNotifications(ManagedBean mbean, String name, String type); public abstract void clearNotifications(ManagedBean mbean, List list); diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java index bf3e95e308..f280e20fdd 100644 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java @@ -248,6 +248,33 @@ public class JMXServerRegistry extends ServerRegistry } } + public List getNotifications(String virtualhost) + { + List vhostNotificationsList = new ArrayList(); + + //iterate over all the notification lists for mbeans with subscribed notifications + for (List list : _notificationsMap.values()) + { + //Check the source vhost of the first notification + NotificationObject notification = list.get(0); + + if (notification != null) + { + String sourceVhost = notification.getSourceVirtualHost(); + if(sourceVhost != null) + { + if(sourceVhost.equalsIgnoreCase(virtualhost)) + { + //If it matches, add the entire list as they are from the same vhost (same source mbean) + vhostNotificationsList.addAll(list); + } + } + } + } + + return vhostNotificationsList; + } + public void clearNotifications(ManagedBean mbean, List list) { if (mbean == null) diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationObject.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationObject.java index 926e5f0a24..e42b3c53b6 100644 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationObject.java +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationObject.java @@ -26,6 +26,8 @@ import java.util.TimeZone; import javax.management.ObjectName; +import static org.apache.qpid.management.ui.Constants.VIRTUAL_HOST; + public class NotificationObject { @@ -65,6 +67,16 @@ public class NotificationObject return null; } + public String getSourceVirtualHost() + { + if (_source instanceof ObjectName) + { + return ((ObjectName)_source).getKeyProperty(VIRTUAL_HOST); + } + + return null; + } + public String getMessage() { return _message; diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java index be25707bd3..b937c9b29a 100644 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java @@ -466,16 +466,16 @@ public class VHNotificationsTabControl extends TabControl } /** - * Updates the table with new notifications received from mbean server for all mbeans + * Updates the table with new notifications received from mbean server for all mbeans in this virtual host */ protected void updateTableViewer() { - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer()); - List newList = serverRegistry.getNotifications(null); - if (newList == null) - return; + String virtualhost = MBeanView.getVirtualHost(); + ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer()); + List newList = serverRegistry.getNotifications(virtualhost); _notifications = newList; + _tableViewer.setInput(_notifications); _tableViewer.refresh(); } -- cgit v1.2.1