summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBhupendra Bhusman Bhardwaj <bhupendrab@apache.org>2007-01-30 15:03:09 +0000
committerBhupendra Bhusman Bhardwaj <bhupendrab@apache.org>2007-01-30 15:03:09 +0000
commitf8863a085fe62554842fffe56da0635ecb0a32e9 (patch)
tree44df7d9ea8656bbd68dca67d3f082f88ea4d7c8b
parent7a12fe827550815b975e3adda53c6cb43ece08d5 (diff)
downloadqpid-python-f8863a085fe62554842fffe56da0635ecb0a32e9.tar.gz
clearing the subscribed notifications map when notifications are unsubscribed.
Fixed the Widget Disposed exception in OperationTabControl.java git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@501411 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java36
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java2
2 files changed, 34 insertions, 4 deletions
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 9a6d134d12..72c4fa3d9d 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
@@ -212,21 +212,31 @@ public class JMXServerRegistry extends ServerRegistry
_notificationsMap.get(mbean.getUniqueName()).clear();
}
+ /**
+ * Adds notification name and type to the map. The map contains all the notification names,
+ * subscribed for an mbean.
+ * @param mbean
+ * @param name
+ * @param type
+ */
public void addNotificationListener(ManagedBean mbean, String name, String type)
{
- HashMap<String, List<String>> map = _subscribedNotificationMap.get(mbean.getUniqueName());
+ // Get the subscribed notifications map for given mbean. If map is null then create a new one.
+ HashMap<String, List<String>> map = _subscribedNotificationMap.get(mbean.getUniqueName());
if (map == null)
{
map = new HashMap<String, List<String>>();
_subscribedNotificationMap.put(mbean.getUniqueName(),map);
}
+ // Get the list of notification types for given notification name. If null, then create a new list.
List<String> list = map.get(name);
if (list == null)
{
list = new ArrayList<String>();
map.put(name, list);
}
+ // Now add the notification type to the list
if (Constants.ALL.equals(type))
{
List<NotificationInfoModel> infoList = _notificationInfoMap.get(mbean.getUniqueName());
@@ -247,9 +257,12 @@ public class JMXServerRegistry extends ServerRegistry
list.add(type);
}
- System.out.println("Subscribed for notification :" + mbean.getUniqueName());
+ //System.out.println("Subscribed for notification :" + mbean.getUniqueName());
}
+ /**
+ * Checks if the given notification name and type are subscribed for the mbean.
+ */
public boolean hasSubscribedForNotifications(ManagedBean mbean, String name, String type)
{
if (_subscribedNotificationMap.containsKey(mbean.getUniqueName()))
@@ -266,11 +279,20 @@ public class JMXServerRegistry extends ServerRegistry
return false;
}
+ /**
+ * Clears the notification name and type information from the subscribed notifications map
+ * and removes the listener from mbeanserver connection
+ * @param mbean
+ * @param name
+ * @param type
+ * @throws Exception
+ */
public void removeNotificationListener(ManagedBean mbean, String name, String type) throws Exception
{
- System.out.println("Removed notification listener :" + mbean.getUniqueName() + name +type);
+ //System.out.println("Removed notification listener :" + mbean.getUniqueName() + name +type);
if (_subscribedNotificationMap.containsKey(mbean.getUniqueName()))
{
+ // get the notifications map. This map contains the notification name mapped with the notification types
HashMap<String, List<String>> map = _subscribedNotificationMap.get(mbean.getUniqueName());
if (map.containsKey(name))
{
@@ -281,8 +303,16 @@ public class JMXServerRegistry extends ServerRegistry
else if (type != null)
{
map.get(name).remove(type);
+ if (map.get(name).isEmpty())
+ {
+ map.remove(name);
+ }
}
}
+ if (map.size() == 0)
+ {
+ _subscribedNotificationMap.remove(mbean.getUniqueName());
+ }
JMXManagedObject jmxbean = (JMXManagedObject)mbean;
_mbsc.removeNotificationListener(jmxbean.getObjectName(), _notificationListener);
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
index 818ee3a89e..8568ee33bf 100644
--- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
+++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
@@ -503,7 +503,7 @@ public class OperationTabControl extends TabControl
*/
private void clearParameterValues(Composite control)
{
- if (control == null)
+ if (control == null || (control.isDisposed()))
return;
Control[] controls = control.getChildren();