diff options
author | Bhupendra Bhusman Bhardwaj <bhupendrab@apache.org> | 2006-12-29 15:38:05 +0000 |
---|---|---|
committer | Bhupendra Bhusman Bhardwaj <bhupendrab@apache.org> | 2006-12-29 15:38:05 +0000 |
commit | 3ddb2f328dc6b6fc92c18bcfaaee65daf290b9da (patch) | |
tree | 65e73c8283b28780933853a28e4d51f6b8cf62f5 /java | |
parent | 601d2090d1c1326bed5a2d74a83c5bc5039993bd (diff) | |
download | qpid-python-3ddb2f328dc6b6fc92c18bcfaaee65daf290b9da.tar.gz |
QPID-213
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@491029 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
4 files changed, 217 insertions, 33 deletions
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java index adb20b1cd9..479dc05a68 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java @@ -34,6 +34,7 @@ public class Constants public final static String DOMAIN = "domain"; public final static String TYPE = "mbeantype"; public final static String MBEAN = "mbean"; + public final static String ATTRIBUTE = "Attribute"; public final static String ATTRIBUTES = "Attributes"; public final static String NOTIFICATION = "Notifications"; public final static String RESULT = "Result"; diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java index 0beeda84dd..eabd8abeb6 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java @@ -24,6 +24,7 @@ package org.apache.qpid.management.ui; import java.util.List; import org.apache.qpid.management.ui.jmx.ClientListener; +import org.apache.qpid.management.ui.model.ManagedAttributeModel; import org.apache.qpid.management.ui.model.NotificationObject; import org.apache.qpid.management.ui.model.OperationDataModel; @@ -51,6 +52,21 @@ public abstract class ServerRegistry _managedServer = server; } + public abstract void addManagedObject(ManagedBean key); + + public abstract void removeManagedObject(ManagedBean mbean); + + public List<ManagedBean> getObjectsToBeAdded() + { + return null; + } + public List<ManagedBean> getObjectsToBeRemoved() + { + return null; + } + + public abstract ManagedAttributeModel getAttributeModel(ManagedBean mbean); + public abstract Object getServerConnection(); public abstract void closeServerConnection() throws Exception; @@ -61,6 +77,8 @@ public abstract class ServerRegistry public abstract String[] getExchangeNames(); + public abstract String[] getConnectionNames(); + public abstract List<NotificationObject> getNotifications(ManagedBean mbean); public abstract boolean hasSubscribedForNotifications(ManagedBean mbean, String name, String type); diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java index 9bc3ea1b0f..c13b02794e 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java @@ -50,21 +50,38 @@ public class JMXServerRegistry extends ServerRegistry private JMXConnector _jmxc = null; private MBeanServerConnection _mbsc = null; + // When a new mbean is added on the mbean server, then the notification listener + // will add the mbean in this list. private List<ManagedBean> _mbeansToBeAdded = new ArrayList<ManagedBean>(); + // When an mbean gets remoevd from mbena server, then the notification listener + // will add that mbean in this list. private List<ManagedBean> _mbeansToBeRemoved = new ArrayList<ManagedBean>(); private List<String> _queues = new ArrayList<String>(); private List<String> _exchanges = new ArrayList<String>(); + private List<String> _connections = new ArrayList<String>(); - private HashMap<String, ManagedBean> _mbeansMap = new HashMap<String, ManagedBean>(); + // Map containing all managed beans and ampped with unique mbean name + private HashMap<String, ManagedBean> _mbeansMap = new HashMap<String, ManagedBean>(); + // Map containing MBeanInfo for all mbeans and mapped with unique mbean name private HashMap<String, MBeanInfo> _mbeanInfoMap = new HashMap<String, MBeanInfo>(); + // Map containing attribute model for all mbeans and mapped with unique mbean name private HashMap<String, ManagedAttributeModel> _attributeModelMap = new HashMap<String, ManagedAttributeModel>(); + // Map containing operation model for all mbeans and mapped with unique mbean name private HashMap<String, OperationDataModel> _operationModelMap = new HashMap<String, OperationDataModel>(); + // Map containing NotificationInfo for all mbeans and mapped with unique mbean name private HashMap<String, List<NotificationInfoModel>> _notificationInfoMap = new HashMap<String, List<NotificationInfoModel>>(); + // Map containing all notifications sent for all mbeans, which are registered for notification private HashMap<String, List<NotificationObject>> _notificationsMap = new HashMap<String, List<NotificationObject>>(); + // For mbeans which have subscribed for a notification type + // mbean unique name mapped with notification map. Notification map contains list of notification type + // mapped with notification name. Notification type list contains those notification types, + // which are subscribed for notification. private HashMap<String, HashMap<String, List<String>>> _subscribedNotificationMap = new HashMap<String, HashMap<String, List<String>>>(); + // listener for registration or unregistratioj of mbeans on mbean server private ClientNotificationListener _notificationListener = null; + // listener for server connection. Receives notification if server connection goes down private ClientListener _clientListener = null; public JMXServerRegistry(ManagedServer server) throws Exception @@ -117,6 +134,8 @@ public class JMXServerRegistry extends ServerRegistry _queues.add(key.getName()); else if (Constants.EXCHANGE.equals(key.getType())) _exchanges.add(key.getName()); + else if (Constants.CONNECTION.equals(key.getType())) + _connections.add(key.getName()); _mbeansMap.put(key.getUniqueName(), key); } @@ -127,6 +146,8 @@ public class JMXServerRegistry extends ServerRegistry _queues.remove(mbean.getName()); else if (Constants.EXCHANGE.equals(mbean.getType())) _exchanges.remove(mbean.getName()); + else if (Constants.CONNECTION.equals(mbean.getType())) + _connections.remove(mbean.getName()); _mbeansMap.remove(mbean.getUniqueName()); } @@ -323,6 +344,11 @@ public class JMXServerRegistry extends ServerRegistry { return _exchanges.toArray(new String[0]); } + + public String[] getConnectionNames() + { + return _connections.toArray(new String[0]); + } public ClientNotificationListener getNotificationListener() { diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java index 4b044c2e13..e5d5e1ed64 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java @@ -25,8 +25,9 @@ import java.util.HashMap; import org.apache.qpid.management.ui.ApplicationRegistry; import org.apache.qpid.management.ui.Constants; import org.apache.qpid.management.ui.ManagedBean; +import org.apache.qpid.management.ui.ManagedServer; +import org.apache.qpid.management.ui.ServerRegistry; import org.apache.qpid.management.ui.exceptions.InfoRequiredException; -import org.apache.qpid.management.ui.jmx.JMXServerRegistry; import org.apache.qpid.management.ui.jmx.MBeanUtility; import org.apache.qpid.management.ui.model.AttributeData; import org.apache.qpid.management.ui.model.OperationData; @@ -38,7 +39,6 @@ import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.TabFolder; @@ -49,14 +49,22 @@ import org.eclipse.ui.forms.widgets.Form; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.part.ViewPart; - +/** + * MBean View create appropriate view based on the user selection on the Navigation View. + * Create TabFolder for all MBeans and displays the attribtues and method tabs. + * @author Bhupendra Bhardwaj + * + */ public class MBeanView extends ViewPart { public static final String ID = "org.apache.qpid.management.ui.mbeanView"; private FormToolkit _toolkit = null; private Form _form = null; + private static ManagedServer _server = null; + private TreeObject _selectedNode = null; private ManagedBean _mbean = null; + // This map contains a TabFolder for each kind of MBean. TabFolder is mapped with mbeantype(eg Connection, Queue etc) private HashMap<String, TabFolder> tabFolderMap = new HashMap<String, TabFolder>(); private ISelectionListener selectionListener = new SelectionListenerImpl(); @@ -64,7 +72,8 @@ public class MBeanView extends ViewPart private static final String OPERATIONS_CONTROL = "OperationsTabControl"; private static final String NOTIFICATIONS_CONTROL = "NotificationsTabControl"; - + // TabFolder to list all the mbeans for a given mbeantype(eg Connection, Queue, Exchange) + private TabFolder typeTabFolder = null; /* * Listener for the selection events in the navigation view */ @@ -76,37 +85,82 @@ public class MBeanView extends ViewPart return; IStructuredSelection ss = (IStructuredSelection) sel; - TreeObject node = (TreeObject)ss.getFirstElement(); - showSelectedMBean(node); + _selectedNode = (TreeObject)ss.getFirstElement(); + if (_selectedNode == null) + return; + + // mbean should be set to null. A selection done on the navigation view can be either an mbean or + // an mbeantype. For mbeantype selection(eg Connection, Queue, Exchange) _mbean will remain null. + _mbean = null; + setInvisible(); + _form.setText(Constants.APPLICATION_NAME); + setServer(); + try + { + if (Constants.TYPE.equals(_selectedNode.getType())) + { + if (typeTabFolder == null) + createTypeTabFolder(); + + refreshTypeTabFolder(_selectedNode.getName()); + } + else + { + showSelectedMBean(); + } + _form.layout(); + } + catch(Exception ex) + { + MBeanUtility.handleException(_mbean, ex); + } } } - public void showSelectedMBean(TreeObject node) + /** + * Sets the managedServer based on the selection in the navigation view + * At any given time MBeanView will be displaying information for an mbean of mbeantype + * for a specifiv managed server. This server information will be used by the tab controllers + * to get server registry. + */ + private void setServer() { - _mbean = null; - setInvisible(); - - if (node == null) + if (Constants.SERVER.equals(_selectedNode.getType())) { - _form.setText(Constants.APPLICATION_NAME); - return; + _server = (ManagedServer)_selectedNode.getManagedObject(); } - - if (Constants.NOTIFICATION.equals(node.getType())) + else { - _mbean = (ManagedBean)node.getParent().getManagedObject(); + TreeObject parent = _selectedNode.getParent(); + while (!parent.getType().equals(Constants.SERVER)) + { + parent = parent.getParent(); + } + + _server = (ManagedServer)parent.getManagedObject(); + } + } + + public static ManagedServer getServer() + { + return _server; + } + + private void showSelectedMBean() throws Exception + { + if (Constants.NOTIFICATION.equals(_selectedNode.getType())) + { + _mbean = (ManagedBean)_selectedNode.getParent().getManagedObject(); } - else if (Constants.MBEAN.equals(node.getType())) + else if (Constants.MBEAN.equals(_selectedNode.getType())) { - _mbean = (ManagedBean)node.getManagedObject(); + _mbean = (ManagedBean)_selectedNode.getManagedObject(); } else { - _form.setText(Constants.APPLICATION_NAME); return; } - setFocus(); try { MBeanUtility.getMBeanInfo(_mbean); @@ -130,20 +184,17 @@ public class MBeanView extends ViewPart } _form.setText(text); int tabIndex = 0; - if (Constants.NOTIFICATION.equals(node.getType())) + if (Constants.NOTIFICATION.equals(_selectedNode.getType())) { tabIndex = tabFolder.getItemCount() -1; } TabItem tab = tabFolder.getItem(tabIndex); - // refreshTab(tab); // If folder is being set as visible after tab refresh, then the tab - // doesn't have the focus. - + // doesn't have the focus. tabFolder.setSelection(tabIndex); refreshTab(tab); setVisible(tabFolder); - _form.layout(); } public void createPartControl(Composite parent) @@ -185,7 +236,6 @@ public class MBeanView extends ViewPart layoutData.right = new FormAttachment(100); layoutData.bottom = new FormAttachment(100); tabFolder.setLayoutData(layoutData); - tabFolder.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); tabFolder.setVisible(false); createAttributesTab(tabFolder); @@ -201,7 +251,7 @@ public class MBeanView extends ViewPart } }); - tabFolderMap.put(_mbean.getType(), tabFolder); + tabFolderMap.put(_mbean.getType(), tabFolder); return tabFolder; } @@ -209,7 +259,7 @@ public class MBeanView extends ViewPart { // We can avoid refreshing the attributes tab because it's control // already contains the required values. But it is added for now and - // will remove if there is any perfornce or any such issue. + // will remove if there is any performance issue or any other issue. // The operations control should be refreshed because there is only one // controller for all operations tab. // The Notifications control needs to refresh with latest set of notifications @@ -218,6 +268,7 @@ public class MBeanView extends ViewPart return; TabFolder tabFolder = tab.getParent(); + // If an operation tab is selected, the operation data is attached with the tab if (tab.getData() != null && (tab.getData() instanceof OperationData)) { // Refresh selected operation tab @@ -259,7 +310,7 @@ public class MBeanView extends ViewPart private void createAttributesTab(TabFolder tabFolder) { - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(_mbean); + ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean); if (serverRegistry.getAttributeModel(_mbean).getCount() == 0) { return; @@ -269,12 +320,12 @@ public class MBeanView extends ViewPart tab.setText(Constants.ATTRIBUTES); AttributesTabControl control = new AttributesTabControl(tabFolder); tab.setControl(control.getControl()); - tabFolder.setData(ATTRIBUTES_CONTROL, control); + tabFolder.setData(ATTRIBUTES_CONTROL, control); } private void createOperationTabs(TabFolder tabFolder) { - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(_mbean); + ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean); int operationsCount = serverRegistry.getOperationModel(_mbean).getCount(); if (operationsCount == 0) { @@ -314,7 +365,7 @@ public class MBeanView extends ViewPart throw new InfoRequiredException("Please select the managed object and then attribute to be edited"); String name = (_mbean.getName() != null) ? _mbean.getName() : _mbean.getType(); - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(_mbean); + ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean); if (serverRegistry.getAttributeModel(_mbean).getCount() == 0) { throw new InfoRequiredException("There are no attributes to be edited for " + name); @@ -336,6 +387,89 @@ public class MBeanView extends ViewPart tabControl.createDetailsPopup(attribute); } + /** + * Creates TabFolder and tabs for each mbeantype (eg Connection, Queue, Exchange) + */ + private void createTypeTabFolder() + { + typeTabFolder = new TabFolder(_form.getBody(), SWT.NONE); + FormData layoutData = new FormData(); + layoutData.left = new FormAttachment(0); + layoutData.top = new FormAttachment(0); + layoutData.right = new FormAttachment(100); + layoutData.bottom = new FormAttachment(100); + typeTabFolder.setLayoutData(layoutData); + typeTabFolder.setVisible(false); + + MBeanTypeTabControl controller = new MBeanTypeTabControl(typeTabFolder); + typeTabFolder.setData("CONTROLLER", controller); + + TabItem tab = new TabItem(typeTabFolder, SWT.NONE); + tab.setText(Constants.CONNECTION); + tab.setControl(controller.getControl()); + + tab = new TabItem(typeTabFolder, SWT.NONE); + tab.setText(Constants.EXCHANGE); + tab.setControl(controller.getControl()); + + tab = new TabItem(typeTabFolder, SWT.NONE); + tab.setText(Constants.QUEUE); + tab.setControl(controller.getControl()); + + typeTabFolder.addListener(SWT.Selection, new Listener() + { + public void handleEvent(Event evt) + { + TabItem tab = (TabItem)evt.item; + try + { + refreshTypeTabFolder(tab); + } + catch (Exception ex) + { + MBeanUtility.handleException(ex); + } + } + }); + } + + /** + * Refreshes the Selected mbeantype tab. The control lists all the available mbeans + * for an mbeantype(eg Queue, Exchange etc) + * @param tab + * @throws Exception + */ + private void refreshTypeTabFolder(TabItem tab) throws Exception + { + if (tab == null) + { + int index = typeTabFolder.getSelectionIndex(); + if (index == -1) + return; + + tab = typeTabFolder.getItem(index); + } + typeTabFolder.setSelection(tab); + MBeanTypeTabControl controller = (MBeanTypeTabControl)typeTabFolder.getData("CONTROLLER"); + controller.refresh(tab.getText()); + typeTabFolder.setVisible(true); + } + + private void refreshTypeTabFolder(String type) throws Exception + { + if (Constants.CONNECTION.equals(type)) + { + refreshTypeTabFolder(typeTabFolder.getItem(0)); + } + else if (Constants.EXCHANGE.equals(type)) + { + refreshTypeTabFolder(typeTabFolder.getItem(1)); + } + else if (Constants.QUEUE.equals(type)) + { + refreshTypeTabFolder(typeTabFolder.getItem(2)); + } + } /** * hides other folders and makes the given one visible. @@ -358,6 +492,11 @@ public class MBeanView extends ViewPart { folder.setVisible(false); } + + if (typeTabFolder != null) + { + typeTabFolder.setVisible(false); + } } } |