Author: bhupendrab
Date: Thu Dec 14 10:12:07 2006
New Revision: 487285

URL: http://svn.apache.org/viewvc?view=rev&rev=487285
Log:
updated for handling MBeanException. Added some java-doc and comments in the 
code

Added:
    
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/exceptions/ManagementConsoleException.java
   (with props)
Modified:
    
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Activator.java
    
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Application.java
    
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
    
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationWorkbenchWindowAdvisor.java
    
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
    
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java
    
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedObject.java
    
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java
    
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Perspective.java
    
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java
    
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java
    
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java

Modified: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Activator.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Activator.java?view=diff&rev=487285&r1=487284&r2=487285
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Activator.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Activator.java
 Thu Dec 14 10:12:07 2006
@@ -26,6 +26,7 @@
 
 /**
  * The activator class controls the plug-in life cycle
+ * @author Bhupendra Bhardwaj
  */
 public class Activator extends AbstractUIPlugin
 {
@@ -44,7 +45,6 @@
        }
 
        /*
-        * (non-Javadoc)
         * @see 
org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
         */
        public void start(BundleContext context) throws Exception
@@ -53,7 +53,6 @@
        }
 
        /*
-        * (non-Javadoc)
         * @see 
org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
         */
        public void stop(BundleContext context) throws Exception
@@ -67,18 +66,19 @@
         *
         * @return the shared instance
         */
-       public static Activator getDefault() {
+       public static Activator getDefault()
+    {
                return plugin;
        }
 
        /**
-        * Returns an image descriptor for the image file at the given
-        * plug-in relative path
+        * Returns an image descriptor for the image file at the given plug-in 
relative path
         *
         * @param path the path
         * @return the image descriptor
         */
-       public static ImageDescriptor getImageDescriptor(String path) {
+       public static ImageDescriptor getImageDescriptor(String path)
+    {
                return imageDescriptorFromPlugin(PLUGIN_ID, path);
        }
 }

Modified: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Application.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Application.java?view=diff&rev=487285&r1=487284&r2=487285
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Application.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Application.java
 Thu Dec 14 10:12:07 2006
@@ -34,8 +34,8 @@
     static Shell shell = null;
 
     /*
-     * (non-Javadoc)
-     * 
+     * The call to createAndRunWorkbench will not return until the workbench 
is closed.
+     * The SWT event loop and other low-level logistics are handled inside 
this method.
      * @see org.eclipse.core.runtime.IPlatformRunnable#run(java.lang.Object)
      */
     public Object run(Object args) throws Exception

Modified: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java?view=diff&rev=487285&r1=487284&r2=487285
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
 Thu Dec 14 10:12:07 2006
@@ -33,6 +33,10 @@
 import org.eclipse.ui.ISharedImages;
 import org.eclipse.ui.PlatformUI;
 
+/**
+ * Main Application Registry, which contains shared resources and map to all 
connected servers.
+ * @author Bhupendra Bhardwaj
+ */
 public abstract class ApplicationRegistry
 {
     private static ImageRegistry imageRegistry = new ImageRegistry();

Modified: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationWorkbenchWindowAdvisor.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationWorkbenchWindowAdvisor.java?view=diff&rev=487285&r1=487284&r2=487285
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationWorkbenchWindowAdvisor.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationWorkbenchWindowAdvisor.java
 Thu Dec 14 10:12:07 2006
@@ -28,6 +28,10 @@
 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
 
+/**
+ * 
+ * @author Bhupendra Bhardwaj
+ */
 public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor
 {
     public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer 
configurer)
@@ -49,7 +53,7 @@
         configurer.setShowCoolBar(true);
         configurer.setShowStatusLine(false);
         
-        configurer.setTitle("Qpid Management Console");
+        configurer.setTitle(Constants.APPLICATION_NAME);
     }  
     
     public void postWindowCreate()

Modified: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java?view=diff&rev=487285&r1=487284&r2=487285
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
 Thu Dec 14 10:12:07 2006
@@ -20,6 +20,11 @@
  */
 package org.apache.qpid.management.ui;
 
+/**
+ * Contains constants for the application
+ * @author Bhupendra Bhardwaj
+ *
+ */
 public class Constants
 {
     public final static String APPLICATION_NAME = "Qpid Management Console";

Modified: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java?view=diff&rev=487285&r1=487284&r2=487285
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java
 Thu Dec 14 10:12:07 2006
@@ -22,6 +22,11 @@
 
 import java.util.HashMap;
 
+/**
+ * Class representing a managed bean on the managed server
+ * @author Bhupendra Bhardwaj
+ *
+ */
 public abstract class ManagedBean extends ManagedObject
 {
     private String _uniqueName = "";

Modified: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedObject.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedObject.java?view=diff&rev=487285&r1=487284&r2=487285
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedObject.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedObject.java
 Thu Dec 14 10:12:07 2006
@@ -20,6 +20,10 @@
  */
 package org.apache.qpid.management.ui;
 
+/**
+ * Abstract class representing a managed object
+ * @author Bhupendra Bhardwaj
+ */
 public abstract class ManagedObject
 {
     private String _name;

Modified: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java?view=diff&rev=487285&r1=487284&r2=487285
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java
 Thu Dec 14 10:12:07 2006
@@ -20,6 +20,10 @@
  */
 package org.apache.qpid.management.ui;
 
+/**
+ * Class representing a server being managed eg. MBeanServer
+ * @author Bhupendra Bhardwaj
+ */
 public class ManagedServer extends ManagedObject
 {
     private String host;

Modified: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Perspective.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Perspective.java?view=diff&rev=487285&r1=487284&r2=487285
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Perspective.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Perspective.java
 Thu Dec 14 10:12:07 2006
@@ -25,6 +25,10 @@
 import org.eclipse.ui.IPageLayout;
 import org.eclipse.ui.IPerspectiveFactory;
 
+/**
+ * 
+ * @author Bhupendra Bhardwaj
+ */
 public class Perspective implements IPerspectiveFactory
 {
        public void createInitialLayout(IPageLayout layout)
@@ -32,20 +36,9 @@
                String editorArea = layout.getEditorArea();
                layout.setEditorAreaVisible(false);
         
-               // standalone view meaning it can't be docked or stacked with 
other views,
-        // and it doesn't have a title bar.
-        
-               layout.addStandaloneView(NavigationView.ID,
-                                 true,
-                                 IPageLayout.LEFT,
-                                 0.25f,
-                                 editorArea);
-        
-        layout.addStandaloneView(MBeanView.ID,
-                true,
-                IPageLayout.RIGHT,
-                0.75f,
-                editorArea);
+               // standalone view meaning it can't be docked or stacked with 
other views, and it doesn't have a title bar.        
+               layout.addStandaloneView(NavigationView.ID, true, 
IPageLayout.LEFT, 0.25f, editorArea);
+        layout.addStandaloneView(MBeanView.ID, true, IPageLayout.RIGHT, 0.75f, 
editorArea);
                
                layout.getViewLayout(NavigationView.ID).setCloseable(false);
         layout.getViewLayout(MBeanView.ID).setCloseable(false);       

Added: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/exceptions/ManagementConsoleException.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/exceptions/ManagementConsoleException.java?view=auto&rev=487285
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/exceptions/ManagementConsoleException.java
 (added)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/exceptions/ManagementConsoleException.java
 Thu Dec 14 10:12:07 2006
@@ -0,0 +1,10 @@
+package org.apache.qpid.management.ui.exceptions;
+
[EMAIL PROTECTED]("serial")
+public class ManagementConsoleException extends Exception
+{
+    public ManagementConsoleException(String message)
+    {
+        super(message);
+    }
+}

Propchange: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/exceptions/ManagementConsoleException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java?view=diff&rev=487285&r1=487284&r2=487285
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java
 Thu Dec 14 10:12:07 2006
@@ -41,6 +41,7 @@
 import org.apache.qpid.management.ui.ApplicationRegistry;
 import org.apache.qpid.management.ui.ManagedBean;
 import org.apache.qpid.management.ui.ManagedServer;
+import org.apache.qpid.management.ui.exceptions.ManagementConsoleException;
 import org.apache.qpid.management.ui.model.AttributeData;
 import org.apache.qpid.management.ui.model.ManagedAttributeModel;
 import org.apache.qpid.management.ui.model.NotificationInfoModel;
@@ -49,31 +50,47 @@
 import org.apache.qpid.management.ui.model.ParameterData;
 import org.apache.qpid.management.ui.views.ViewUtility;
 
-
+/**
+ * Utility class for all mbeanserver related operations. Keeps all JMX code 
out from view and model classes
+ * @author Bhupendra Bhardwaj
+ */
 public class MBeanUtility
 {
-
-    public static MBeanInfo getMBeanInfo(ManagedBean mbean)
-        throws IOException, JMException
+    /**
+     * Retrieves the MBeanInfo from MBeanServer and stores in the application 
registry
+     * @param mbean  managed bean
+     * @return MBeanInfo
+     * @throws Exception, if server connection is null or if server throws 
Exception
+     */
+    public static MBeanInfo getMBeanInfo(ManagedBean mbean) throws Exception
     {
         ManagedServer server = mbean.getServer();
         JMXServerRegistry serverRegistry = 
(JMXServerRegistry)ApplicationRegistry.getServerRegistry(server);
 
         MBeanServerConnection mbsc = serverRegistry.getServerConnection();
         if (mbsc == null)
-            System.out.println("MBeanServerConnection does not exist in the 
Application registry.");
+        {
+            throw new ManagementConsoleException("Server connection is 
broken");
+        }
         
         JMXManagedObject jmxbean = (JMXManagedObject)mbean;
         MBeanInfo mbeanInfo = mbsc.getMBeanInfo(jmxbean.getObjectName());
         serverRegistry.putMBeanInfo(mbean, mbeanInfo);
         
+        // populate the server registry with attribute and operation info
         getAttributes(mbean);
         getOperations(mbean);
         
         return mbeanInfo;
     }
     
-    
+    /**
+     * executes the MBean operation
+     * @param mbean
+     * @param opData
+     * @return MBean operation return value
+     * @throws Exception if server connection is broken or if operation 
execution fails on the mbean server
+     */
     public static Object execute(ManagedBean mbean, OperationData opData) 
throws Exception
     {
         String opName = opData.getName();
@@ -89,7 +106,6 @@
             {
                 signature[i] = params.get(i).getType();
                 values[i] = params.get(i).getValue();
-                System.out.println(params.get(i).getName() +  " : " + 
params.get(i).getValue());
             }
         }
         
@@ -99,48 +115,27 @@
         MBeanServerConnection mbsc = serverRegistry.getServerConnection();
         if (mbsc == null)
         {
-            System.out.println("MBeanServerConnection doesn't exist in the 
Application registry.");
+            throw new ManagementConsoleException("Server connection is 
broken");
             // TODO
-            // throw exception to check if the server is added 
-            // Or try and get the connection again if it was disconnected
-            return null;
+            // try and get the connection again if it was disconnected
         }
         JMXManagedObject jmxbean = (JMXManagedObject)mbean;
         return mbsc.invoke(jmxbean.getObjectName(), opName, values, signature);
-        
-        /*
-        try
-        {
-            
-        }
-        catch(MBeanException ex)
-        {
-            ex.printStackTrace();
-            
-        } 
-        catch(OperationsException ex)
-        {
-            ex.printStackTrace();
-            
-        }
-        catch(JMException ex)
-        {
-            ex.printStackTrace();
-            ViewUtility.popupError(new Exception(ex), "Operation failed");
-        }
-        catch(IOException ex)
-        {
-            ex.printStackTrace();
-            ViewUtility.popupError(new Exception(ex), "Operation failed");
-        }
-        */
     }
     
+    /**
+     * @see MBeanUtility#handleException(ManagedBean, Exception)
+     */
     public static void handleException(Exception ex)
     {
         handleException(null, ex);
     }
     
+    /**
+     * handels the exception received. Shows the exception to the user in best 
suitable way
+     * @param mbean managed bean
+     * @param ex   Exception
+     */
     public static void handleException(ManagedBean mbean, Exception ex)
     {
         if (mbean == null)
@@ -161,17 +156,35 @@
         }
         else if (ex instanceof MBeanException)
         {
-            ViewUtility.popupInfoMessage(mbean.getName(), ex.getMessage());
+            String cause = 
((MBeanException)ex).getTargetException().getMessage();
+            if (cause == null)
+                cause = ex.getMessage();
+            ViewUtility.popupInfoMessage(mbean.getName(), cause);
         }
-        else
+        else if (ex instanceof JMException)
+        {
+            ViewUtility.popupErrorMessage(mbean.getName(), ex.getMessage());
+        }
+        else if (ex instanceof ManagementConsoleException)
+        {
+            ViewUtility.popupErrorMessage(mbean.getName(), ex.getMessage());
+        }
+        else 
         {
             ViewUtility.popupError(mbean.getName(), "Error occured", ex);
         }
-        ex.printStackTrace();
+        //ex.printStackTrace();
     }
     
+    /**
+     * Registers the notification listener with the MBeanServer
+     * @param mbean   managed bean
+     * @param name    notification name
+     * @param type    notification type
+     * @throws Exception  if server connection is broken or if listener could 
not be created 
+     */
     public static void createNotificationlistener(ManagedBean mbean, String 
name, String type)
-        throws IOException, Exception
+        throws Exception
     {
         JMXManagedObject jmxbean = (JMXManagedObject)mbean;
         JMXServerRegistry serverRegistry = 
(JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean);
@@ -180,23 +193,15 @@
         
         if (mbsc == null)
         {
-            throw new Exception("MBeanServer connection is broken");
+            throw new ManagementConsoleException("Server connection is 
broken");
         }
         mbsc.addNotificationListener(jmxbean.getObjectName(), 
serverRegistry.getNotificationListener(), null, null);
-        System.out.println("Listener created : " + jmxbean.getObjectName());
     }
     
     public static void removeNotificationListener(ManagedBean mbean, String 
name, String type) throws Exception
     {
-        //JMXManagedObject jmxbean = (JMXManagedObject)mbean;
         JMXServerRegistry serverRegistry = 
(JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean);
         serverRegistry.removeNotificationListener(mbean, name, type);
-        //MBeanServerConnection mbsc = serverRegistry.getServerConnection();
-        
-        //if (mbsc != null)
-        //{
-          //  mbsc.removeNotificationListener(jmxbean.getObjectName(), 
serverRegistry.getNotificationListener());
-        //}
     }
     
     public static int refreshAttribute(ManagedBean mbean, String attribute) 
throws Exception
@@ -205,7 +210,9 @@
         MBeanServerConnection mbsc = serverRegistry.getServerConnection();
         
         if (mbsc == null)
-            throw new Exception("Server connection is not available for " + 
mbean.getUniqueName());
+        {
+            throw new ManagementConsoleException("Server connection is 
broken");
+        }
         
         Object value = 
mbsc.getAttribute(((JMXManagedObject)mbean).getObjectName(), attribute);
         
@@ -214,7 +221,13 @@
         return Integer.parseInt(String.valueOf(value));
     }
     
-    public static ManagedAttributeModel getAttributes(ManagedBean mbean)
+    /**
+     * Retrieves the attribute values from MBeanSever and stores in the server 
registry.
+     * @param mbean
+     * @return the attribute model
+     * @throws Exception if attributes can not be retrieved from MBeanServer
+     */
+    public static ManagedAttributeModel getAttributes(ManagedBean mbean) 
throws Exception
     {
         ObjectName objName = ((JMXManagedObject)mbean).getObjectName();
         String[] attributes = null;
@@ -243,29 +256,28 @@
             attributes = attributeModel.getAttributeNames().toArray(new 
String[0]);
         }
         
-        try
+        if (attributes.length != 0)
         {
-            if (attributes.length != 0)
+            list = mbsc.getAttributes(objName, attributes);
+            for (Iterator itr = list.iterator(); itr.hasNext();)
             {
-                list = mbsc.getAttributes(objName, attributes);
-                for (Iterator itr = list.iterator(); itr.hasNext();)
-                {
-                    Attribute attrib = (Attribute)itr.next();
-                    attributeModel.setAttributeValue(attrib.getName(), 
attrib.getValue());
-                }
+                Attribute attrib = (Attribute)itr.next();
+                attributeModel.setAttributeValue(attrib.getName(), 
attrib.getValue());
             }
-        }
-        catch (Exception ex)
-        {
-            ex.printStackTrace();
         }               
         
-        serverRegistry.setAttributeModel(mbean, attributeModel);
-        
+        serverRegistry.setAttributeModel(mbean, attributeModel);       
         return attributeModel;
     }
     
-    public static void updateAttribute(ManagedBean mbean, AttributeData 
attribute, String value)
+    /**
+     * Updates the attribute value of an MBean
+     * @param mbean
+     * @param attribute
+     * @param value
+     * @throws Exception if MBeanServer throws exception in updating the 
attribute value
+     */
+    public static void updateAttribute(ManagedBean mbean, AttributeData 
attribute, String value) throws Exception
     {
         JMXManagedObject jmxbean = (JMXManagedObject)mbean;
         JMXServerRegistry serverRegistry = 
(JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean);
@@ -273,11 +285,7 @@
         MBeanServerConnection mbsc = serverRegistry.getServerConnection();
         
         Object newValue = value;
-        if (attribute.getDataType().equals(String.class.getName()))
-        {
-            
-        }
-        else if (attribute.getDataType().equals(Long.class.getName()))
+        if (attribute.getDataType().equals(Long.class.getName()))
         {
             newValue = new Long(Long.parseLong(value));
         }
@@ -286,24 +294,20 @@
             newValue = new Integer(Integer.parseInt(value));
         }
         
-        try
-        {
-            mbsc.setAttribute(jmxbean.getObjectName(), new 
Attribute(attribute.getName(), newValue));
-            
-            // Update the value in the registry, to avoid refreshing from mbsc
-            ManagedAttributeModel attributeModel = 
serverRegistry.getAttributeModel(mbean);
-            attributeModel.setAttributeValue(attribute.getName(), newValue);
-        }
-        catch(Exception ex)
-        {
-            ex.printStackTrace();
-        }
+        mbsc.setAttribute(jmxbean.getObjectName(), new 
Attribute(attribute.getName(), newValue));           
+        // Update the value in the registry, to avoid refreshing from mbsc
+        ManagedAttributeModel attributeModel = 
serverRegistry.getAttributeModel(mbean);
+        attributeModel.setAttributeValue(attribute.getName(), newValue);
     }
     
+    /**
+     * populates the operation data model in server registry for given mbean
+     * @param mbean
+     * @return operation data model
+     */
     public static OperationDataModel getOperations(ManagedBean mbean)
     {
         JMXServerRegistry serverRegistry = 
(JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean);
-
         OperationDataModel dataModel = serverRegistry.getOperationModel(mbean);
         if (dataModel == null)
         {
@@ -322,6 +326,11 @@
         return dataModel;
     }
     
+    /**
+     * populates the notification in the server registry for given mbean
+     * @param mbean
+     * @return notification info model
+     */
     public static NotificationInfoModel[] getNotificationInfo(ManagedBean 
mbean)
     {
         

Modified: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java?view=diff&rev=487285&r1=487284&r2=487285
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java
 Thu Dec 14 10:12:07 2006
@@ -277,8 +277,16 @@
             {
                 public void widgetSelected(SelectionEvent e)
                 {
-                    // refresh the attributes list                
-                    refresh(_mbean);
+                    try
+                    {
+                        // refresh the attributes list                
+                        refresh(_mbean);
+                    }
+                    catch (Exception ex)
+                    {
+                        MBeanUtility.handleException(_mbean, ex);
+                    }
+                    
                 }
             });
     }
@@ -582,12 +590,19 @@
             {
                 public void widgetSelected(SelectionEvent event)
                 {
-                    Button button = (Button)event.widget;
-                    Text text = (Text)button.getData();
-                    AttributeData data = 
(AttributeData)button.getParent().getData();
-                    MBeanUtility.updateAttribute(_mbean, data, text.getText());
-                    button.getShell().close();
-                    refresh();
+                    try
+                    {
+                        Button button = (Button)event.widget;
+                        Text text = (Text)button.getData();
+                        AttributeData data = 
(AttributeData)button.getParent().getData();
+                        MBeanUtility.updateAttribute(_mbean, data, 
text.getText());
+                        button.getShell().close();
+                        refresh();
+                    }
+                    catch (Exception ex)
+                    {
+                        MBeanUtility.handleException(_mbean, ex);
+                    }
                 }
             });
         
@@ -612,7 +627,15 @@
             _tableViewer.setInput(null);
             return;
         }
-        ManagedAttributeModel attributesList = 
MBeanUtility.getAttributes(mbean);
+        ManagedAttributeModel attributesList = null;
+        try
+        {
+            attributesList = MBeanUtility.getAttributes(mbean);
+        }
+        catch(Exception ex)
+        {
+            MBeanUtility.handleException(_mbean, ex);
+        }
         _tableViewer.setInput(attributesList);
         _table.setItemCount(attributesList.getCount());
        

Modified: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java?view=diff&rev=487285&r1=487284&r2=487285
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
 Thu Dec 14 10:12:07 2006
@@ -595,15 +595,6 @@
         else
         {
             ViewUtility.disposeChildren(_resultsComposite);
-            /*
-            if (_resultsComposite == null || _resultsComposite.isDisposed())
-            {
-                _resultsComposite = _toolkit.createComposite(_form.getBody(), 
SWT.NONE);
-                GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, 
true);
-                layoutData.verticalIndent = 20;
-                _resultsComposite.setLayoutData(layoutData);
-                _resultsComposite.setLayout(new GridLayout());
-            }*/
             populateResults(result, _resultsComposite);
             _resultsComposite.layout();
             _form.layout();


Reply via email to