diff options
| author | Robert Gemmell <robbie@apache.org> | 2009-07-22 10:48:30 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2009-07-22 10:48:30 +0000 |
| commit | 888d59cee82f47404ca850bf8970712debeaaea1 (patch) | |
| tree | a5e4e40a62230fe02ece435336609bb466ae049a /qpid/java | |
| parent | 21340fcedf4be6033b83c8480cf06af4ab2e9cac (diff) | |
| download | qpid-python-888d59cee82f47404ca850bf8970712debeaaea1.tar.gz | |
QPID-1999: ensure the Clear button in each VirtualHost Notifications area only clears the Notifications for that VirtualHost instead of all Notifications for the entire server. Add synchronized blocks to protect from concurrent modifications by the update thread and the clear action.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@796663 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
3 files changed, 69 insertions, 26 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 f280e20fdd..575b98d48a 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 @@ -255,6 +255,11 @@ public class JMXServerRegistry extends ServerRegistry //iterate over all the notification lists for mbeans with subscribed notifications for (List<NotificationObject> list : _notificationsMap.values()) { + if(list == null || list.isEmpty()) + { + continue; + } + //Check the source vhost of the first notification NotificationObject notification = list.get(0); diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java index 516b0b3bbf..926bfa2a48 100644 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java @@ -28,6 +28,7 @@ import static org.apache.qpid.management.ui.Constants.FONT_ITALIC; import static org.apache.qpid.management.ui.Constants.SUBSCRIBE_BUTTON; import static org.apache.qpid.management.ui.Constants.UNSUBSCRIBE_BUTTON; +import java.util.ArrayList; import java.util.List; import org.apache.qpid.management.ui.ApplicationRegistry; @@ -163,8 +164,8 @@ public class NotificationsTabControl extends VHNotificationsTabControl protected void addButtons() { Composite composite = _toolkit.createComposite(_form.getBody(), SWT.NONE); - composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); + composite.setLayout(new GridLayout(2,false)); // Add Clear Button _clearButton = _toolkit.createButton(composite, BUTTON_CLEAR, SWT.PUSH | SWT.CENTER); @@ -173,17 +174,36 @@ public class NotificationsTabControl extends VHNotificationsTabControl gridData.widthHint = 80; _clearButton.setLayoutData(gridData); _clearButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - if (_mbean == null) - return; - - IStructuredSelection ss = (IStructuredSelection)_tableViewer.getSelection(); - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean); + { + public void widgetSelected(SelectionEvent e) + { + if (_mbean == null) + { + return; + } + + ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer()); + IStructuredSelection ss = (IStructuredSelection)_tableViewer.getSelection(); + if(!ss.isEmpty()) + { serverRegistry.clearNotifications(_mbean, ss.toList()); } - }); + else if(_notifications != null) + { + synchronized(this) + { + List<NotificationObject> newList = new ArrayList<NotificationObject>(); + newList.addAll(_notifications); + serverRegistry.clearNotifications(_mbean, newList); + } + } + + refresh(); + } + }); + //add description + Label desc = _toolkit.createLabel(composite,"Clears the selected Notifications, or all if none are selected"); + desc.setLayoutData(new GridData(SWT.LEFT,SWT.CENTER, false, false)); } @Override @@ -348,8 +368,10 @@ public class NotificationsTabControl extends VHNotificationsTabControl { ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean); List<NotificationObject> newList = serverRegistry.getNotifications(_mbean); - _notifications = newList; - - _tableViewer.setInput(_notifications); + synchronized(this) + { + _notifications = newList; + _tableViewer.setInput(_notifications); + } } } 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 691ceedcf4..5ebe0013bf 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 @@ -119,8 +119,8 @@ public class VHNotificationsTabControl extends TabControl protected void addButtons() { Composite composite = _toolkit.createComposite(_form.getBody(), SWT.NONE); - composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); + composite.setLayout(new GridLayout(2,false)); // Add Clear Button _clearButton = _toolkit.createButton(composite, BUTTON_CLEAR, SWT.PUSH | SWT.CENTER); @@ -129,16 +129,29 @@ public class VHNotificationsTabControl extends TabControl gridData.widthHint = 80; _clearButton.setLayoutData(gridData); _clearButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - //TODO : Get selected rows and clear those - IStructuredSelection ss = (IStructuredSelection)_tableViewer.getSelection(); - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer()); + { + public void widgetSelected(SelectionEvent e) + { + ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer()); + IStructuredSelection ss = (IStructuredSelection)_tableViewer.getSelection(); + if(!ss.isEmpty()) + { serverRegistry.clearNotifications(null, ss.toList()); - refresh(); } - }); + else if(_notifications != null) + { + synchronized(this) + { + serverRegistry.clearNotifications(null, _notifications); + } + } + + refresh(); + } + }); + //add description + Label desc = _toolkit.createLabel(composite,"Clears the selected Notifications, or all if none are selected"); + desc.setLayoutData(new GridData(SWT.LEFT,SWT.CENTER, false, false)); } /** @@ -446,9 +459,12 @@ public class VHNotificationsTabControl extends TabControl ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer()); List<NotificationObject> newList = serverRegistry.getNotifications(virtualhost); - _notifications = newList; - _tableViewer.setInput(_notifications); + synchronized(this) + { + _notifications = newList; + _tableViewer.setInput(_notifications); + } } } |
