You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by bh...@apache.org on 2007/05/02 16:19:54 UTC

svn commit: r534473 - in /incubator/qpid/branches/M2/java: broker/src/main/java/org/apache/qpid/server/exchange/ management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ management/eclipse-plugin/src/main/java/org/apache/qpid/management/u...

Author: bhupendrab
Date: Wed May  2 07:19:52 2007
New Revision: 534473

URL: http://svn.apache.org/viewvc?view=rev&rev=534473
Log:
Exchange MBeans updated - init method moved to super class. 
Exception handling of management console updated for SecurityException.

Modified:
    incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
    incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java
    incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java
    incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java
    incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java

Modified: incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java?view=diff&rev=534473&r1=534472&r2=534473
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java (original)
+++ incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java Wed May  2 07:19:52 2007
@@ -23,6 +23,13 @@
 import javax.management.MalformedObjectNameException;
 import javax.management.NotCompliantMBeanException;
 import javax.management.ObjectName;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.TabularType;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.SimpleType;
+import javax.management.openmbean.ArrayType;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
@@ -60,9 +67,31 @@
      */
     protected abstract class ExchangeMBean extends AMQManagedObject implements ManagedExchange
     {
+        // open mbean data types for representing exchange bindings
+        protected String[] _bindingItemNames;
+        protected String[] _bindingItemIndexNames;
+        protected OpenType[] _bindingItemTypes;
+        protected CompositeType _bindingDataType;
+        protected TabularType _bindinglistDataType;
+        protected TabularDataSupport _bindingList;
+        
         public ExchangeMBean() throws NotCompliantMBeanException
         {
             super(ManagedExchange.class, ManagedExchange.TYPE);
+        }
+
+        protected void init() throws OpenDataException
+        {
+            _bindingItemNames = new String[]{"Binding Key", "Queue Names"};
+            _bindingItemIndexNames = new String[]{_bindingItemNames[0]};
+            
+            _bindingItemTypes = new OpenType[2];
+            _bindingItemTypes[0] = SimpleType.STRING;
+            _bindingItemTypes[1] = new ArrayType(1, SimpleType.STRING);
+            _bindingDataType = new CompositeType("Exchange Binding", "Binding key and Queue names",
+                                                 _bindingItemNames, _bindingItemNames, _bindingItemTypes);
+            _bindinglistDataType = new TabularType("Exchange Bindings", "Exchange Bindings for " + getName(),
+                                                   _bindingDataType, _bindingItemIndexNames);
         }
 
         public ManagedObject getParentObject()

Modified: incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java?view=diff&rev=534473&r1=534472&r2=534473
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java (original)
+++ incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java Wed May  2 07:19:52 2007
@@ -64,33 +64,12 @@
     @MBeanDescription("Management Bean for Direct Exchange")
     private final class DestNameExchangeMBean extends ExchangeMBean
     {
-        // open mbean data types for representing exchange bindings
-        private String[]   _bindingItemNames = {"Routing Key", "Queue Names"};
-        private String[]   _bindingItemIndexNames = {_bindingItemNames[0]};
-        private OpenType[] _bindingItemTypes = new OpenType[2];
-        private CompositeType      _bindingDataType = null;
-        private TabularType        _bindinglistDataType = null;
-        private TabularDataSupport _bindingList = null;
-
         @MBeanConstructor("Creates an MBean for AMQ direct exchange")
         public DestNameExchangeMBean()  throws JMException
         {
             super();
             _exchangeType = "direct";
             init();
-        }
-
-        /**
-         * initialises the OpenType objects.
-         */
-        private void init() throws OpenDataException
-        {
-            _bindingItemTypes[0] = SimpleType.STRING;
-            _bindingItemTypes[1] = new ArrayType(1, SimpleType.STRING);
-            _bindingDataType = new CompositeType("Exchange Binding", "Routing key and Queue names",
-                                                 _bindingItemNames, _bindingItemNames, _bindingItemTypes);
-            _bindinglistDataType = new TabularType("Exchange Bindings", "Exchange Bindings for " + getName(),
-                                                 _bindingDataType, _bindingItemIndexNames);
         }
 
         public TabularData bindings() throws OpenDataException

Modified: incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java?view=diff&rev=534473&r1=534472&r2=534473
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java (original)
+++ incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java Wed May  2 07:19:52 2007
@@ -61,31 +61,12 @@
     @MBeanDescription("Management Bean for Topic Exchange")
     private final class DestWildExchangeMBean extends ExchangeMBean
     {
-        // open mbean data types for representing exchange bindings
-        private String[] _bindingItemNames = {"Routing Key", "Queue Names"};
-        private String[] _bindingItemIndexNames = {_bindingItemNames[0]};
-        private OpenType[] _bindingItemTypes = new OpenType[2];
-        private CompositeType _bindingDataType = null;
-        private TabularType _bindinglistDataType = null;
-        private TabularDataSupport _bindingList = null;
-
         @MBeanConstructor("Creates an MBean for AMQ topic exchange")
         public DestWildExchangeMBean() throws JMException
         {
             super();
             _exchangeType = "topic";
             init();
-        }
-
-        /** initialises the OpenType objects. */
-        private void init() throws OpenDataException
-        {
-            _bindingItemTypes[0] = SimpleType.STRING;
-            _bindingItemTypes[1] = new ArrayType(1, SimpleType.STRING);
-            _bindingDataType = new CompositeType("Exchange Binding", "Routing key and Queue names",
-                                                 _bindingItemNames, _bindingItemNames, _bindingItemTypes);
-            _bindinglistDataType = new TabularType("Exchange Bindings", "Exchange Bindings for " + getName(),
-                                                   _bindingDataType, _bindingItemIndexNames);
         }
 
         /** returns exchange bindings in tabular form */

Modified: incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java?view=diff&rev=534473&r1=534472&r2=534473
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java (original)
+++ incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java Wed May  2 07:19:52 2007
@@ -41,33 +41,12 @@
     @MBeanDescription("Management Bean for Fanout Exchange")
     private final class FanoutExchangeMBean extends ExchangeMBean
     {
-        // open mbean data types for representing exchange bindings
-        private String[]   _bindingItemNames = {"Routing Key", "Queue Names"};
-        private String[]   _bindingItemIndexNames = {_bindingItemNames[0]};
-        private OpenType[] _bindingItemTypes = new OpenType[2];
-        private CompositeType _bindingDataType = null;
-        private TabularType _bindinglistDataType = null;
-        private TabularDataSupport _bindingList = null;
-
         @MBeanConstructor("Creates an MBean for AMQ fanout exchange")
         public FanoutExchangeMBean()  throws JMException
         {
             super();
             _exchangeType = "fanout";
             init();
-        }
-
-        /**
-         * initialises the OpenType objects.
-         */
-        private void init() throws OpenDataException
-        {
-            _bindingItemTypes[0] = SimpleType.STRING;
-            _bindingItemTypes[1] = new ArrayType(1, SimpleType.STRING);
-            _bindingDataType = new CompositeType("Exchange Binding", "Routing key and Queue names",
-                                                 _bindingItemNames, _bindingItemNames, _bindingItemTypes);
-            _bindinglistDataType = new TabularType("Exchange Bindings", "Exchange Bindings for " + getName(),
-                                                 _bindingDataType, _bindingItemIndexNames);
         }
 
         public TabularData bindings() throws OpenDataException

Modified: incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java?view=diff&rev=534473&r1=534472&r2=534473
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java (original)
+++ incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java Wed May  2 07:19:52 2007
@@ -90,14 +90,6 @@
     @MBeanDescription("Management Bean for Headers Exchange")
     private final class HeadersExchangeMBean extends ExchangeMBean
     {
-        // open mbean data types for representing exchange bindings
-        private String[]   _bindingItemNames = {"S.No.", "Queue Name", "Header Bindings"};
-        private String[]   _bindingItemIndexNames = {_bindingItemNames[0]};
-        private OpenType[] _bindingItemTypes = new OpenType[3];
-        private CompositeType      _bindingDataType = null;
-        private TabularType        _bindinglistDataType = null;
-        private TabularDataSupport _bindingList = null;
-
         @MBeanConstructor("Creates an MBean for AMQ Headers exchange")
         public HeadersExchangeMBean()  throws JMException
         {
@@ -105,11 +97,16 @@
             _exchangeType = "headers";
             init();
         }
+        
         /**
          * initialises the OpenType objects.
          */
-        private void init() throws OpenDataException
+        protected void init() throws OpenDataException
         {
+            _bindingItemNames = new String[]{"Binding No", "Queue  Name", "Queue Bindings"};
+            _bindingItemIndexNames = new String[]{_bindingItemNames[0]};
+
+            _bindingItemTypes = new OpenType[3];
             _bindingItemTypes[0] = SimpleType.INTEGER;
             _bindingItemTypes[1] = SimpleType.STRING;
             _bindingItemTypes[2] = new ArrayType(1, SimpleType.STRING);

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java?view=diff&rev=534473&r1=534472&r2=534473
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java Wed May  2 07:19:52 2007
@@ -106,7 +106,7 @@
     public static ServerRegistry getServerRegistry(ManagedBean mbean)
     {
         ManagedServer server = mbean.getServer();
-        return _serverRegistryMap.get(server);
+        return getServerRegistry(server);
     }
     
     public static boolean isServerConnected(ManagedServer server)
@@ -118,7 +118,7 @@
     public static void serverConnectionClosed(ManagedServer server)
     {
         _closedServerList.add(server);
-        _serverRegistryMap.remove(server);
+        removeServer(server);
     }
     
     /*

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java?view=diff&rev=534473&r1=534472&r2=534473
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java Wed May  2 07:19:52 2007
@@ -22,6 +22,8 @@
 
 import static org.apache.qpid.management.ui.Constants.ERROR_SERVER_CONNECTION;
 
+import java.io.IOException;
+
 import org.apache.qpid.management.ui.ApplicationRegistry;
 import org.apache.qpid.management.ui.ApplicationWorkbenchAdvisor;
 import org.apache.qpid.management.ui.Constants;
@@ -75,8 +77,27 @@
         MBeanUtility.printStackTrace(ex);
         if (msg == null)
         {
-            msg = ex.getMessage();
+            if (ex instanceof IOException)
+            {
+                if ((ex.getMessage() != null) && (ex.getMessage().indexOf(RMI_SASL_ERROR) != -1))
+                {
+                    msg = SECURITY_FAILURE;
+                }
+                else
+                {
+                    msg = SERVER_UNAVAILABLE;
+                }
+            }
+            else if (ex instanceof SecurityException)
+            {
+                msg = SECURITY_FAILURE;
+            }
+            else
+            {
+                msg = ex.getMessage();
+            }
         }
+        
         if ((msg == null) && (ex.getCause() != null))
         {
             msg = ex.getCause().getMessage();

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java?view=diff&rev=534473&r1=534472&r2=534473
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java Wed May  2 07:19:52 2007
@@ -22,8 +22,6 @@
 
 import static org.apache.qpid.management.ui.Constants.*;
 
-import java.io.IOException;
-
 import org.apache.qpid.management.ui.ApplicationRegistry;
 import org.apache.qpid.management.ui.exceptions.InfoRequiredException;
 import org.apache.qpid.management.ui.views.NumberVerifyListener;
@@ -63,36 +61,25 @@
     
     public void run(IAction action)
     {
-        if(_window != null)
-        {   
-            reset();
-            createAddServerPopup();
-            try
-            {
-                if (_addServer)
-                {
-                    getNavigationView().addNewServer(_transport, _host, Integer.parseInt(_port), _domain, _user, _password);
-                }
-            }
-            catch(InfoRequiredException ex)
-            {
-                ViewUtility.popupInfoMessage(ACTION_ADDSERVER, ex.getMessage());
-            }
-            catch (IOException ex)
-            {
-                if ((ex.getMessage() != null) && (ex.getMessage().indexOf(RMI_SASL_ERROR) != -1))
-                {
-                    handleException(ex, null, SECURITY_FAILURE);
-                }
-                else
-                {
-                    handleException(ex, null, SERVER_UNAVAILABLE);
-                }
-            }
-            catch (Exception ex)
+        if(_window == null)
+            return;
+        
+        reset();
+        createAddServerPopup();
+        try
+        {
+            if (_addServer)
             {
-                handleException(ex, null, null);
+                getNavigationView().addNewServer(_transport, _host, Integer.parseInt(_port), _domain, _user, _password);
             }
+        }
+        catch(InfoRequiredException ex)
+        {
+            ViewUtility.popupInfoMessage(ACTION_ADDSERVER, ex.getMessage());
+        }
+        catch (Exception ex)
+        {
+            handleException(ex, null, null);
         }
     }
     

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java?view=diff&rev=534473&r1=534472&r2=534473
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java Wed May  2 07:19:52 2007
@@ -27,8 +27,6 @@
 import static org.apache.qpid.management.ui.Constants.PASSWORD;
 import static org.apache.qpid.management.ui.Constants.USERNAME;
 
-import java.io.IOException;
-
 import org.apache.qpid.management.ui.ApplicationRegistry;
 import org.apache.qpid.management.ui.Constants;
 import org.apache.qpid.management.ui.exceptions.InfoRequiredException;
@@ -58,44 +56,33 @@
     
     public void run(IAction action)
     {
-        if(_window != null)
-        {   
-            try
-            {
-                reset();
-                // Check if a server node is selected to be reconnected.
-                TreeObject serverNode = getNavigationView().getSelectedServerNode();
-                _serverName = serverNode.getName();
-                _title = ACTION_LOGIN + " (" + _serverName + ")";
-                
-                // Get the login details(username/password)
-                createLoginPopup();
-                
-                if (_connect)
-                {
-                    // Connect the server
-                    getNavigationView().reconnect(_user, _password);
-                }
-            }
-            catch(InfoRequiredException ex)
-            {
-                ViewUtility.popupInfoMessage("Reconnect Qpid server", ex.getMessage());
-            }
-            catch (IOException ex)
-            {
-                if ((ex.getMessage() != null) && (ex.getMessage().indexOf(RMI_SASL_ERROR) != -1))
-                {
-                    handleException(ex, null, SECURITY_FAILURE);
-                }
-                else
-                {
-                    handleException(ex, null, SERVER_UNAVAILABLE);
-                }
-            }
-            catch (Exception ex)
+        if(_window == null)
+            return;
+  
+        try
+        {
+            reset();
+            // Check if a server node is selected to be reconnected.
+            TreeObject serverNode = getNavigationView().getSelectedServerNode();
+            _serverName = serverNode.getName();
+            _title = ACTION_LOGIN + " (" + _serverName + ")";
+
+            // Get the login details(username/password)
+            createLoginPopup();
+
+            if (_connect)
             {
-                handleException(ex, null, null);
+                // Connect the server
+                getNavigationView().reconnect(_user, _password);
             }
+        }
+        catch(InfoRequiredException ex)
+        {
+            ViewUtility.popupInfoMessage("Reconnect Qpid server", ex.getMessage());
+        }
+        catch (Exception ex)
+        {
+            handleException(ex, null, null);
         }
     }
     

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java?view=diff&rev=534473&r1=534472&r2=534473
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java Wed May  2 07:19:52 2007
@@ -65,6 +65,7 @@
     private JMXServiceURL _jmxUrl = null;
     private JMXConnector _jmxc = null;
     private MBeanServerConnection _mbsc = null;
+    private Exception _connectionException = null;
     
     private List<String> _usersList;
     // When an mbean gets removed from mbean server, then the notification listener
@@ -175,9 +176,16 @@
         long timeNow = System.currentTimeMillis();
         connectorThread.join(ApplicationRegistry.timeout);
         
-        if (!_connected && (System.currentTimeMillis() - timeNow >= ApplicationRegistry.timeout))
+        if (_connectionException != null)
         {
-            throw new Exception("Qpid server connection timed out");
+            throw _connectionException;
+        }
+        if (!_connected)
+        {
+            if (System.currentTimeMillis() - timeNow >= ApplicationRegistry.timeout)
+                throw new Exception("Qpid server connection timed out");
+            else
+                throw new Exception("Qpid server connection failed");
         }
     }
     
@@ -188,11 +196,14 @@
             try
             {
                 _connected = false;
+                _connectionException = null;
+                
                 _jmxc.connect();
                 _connected = true;
             }
             catch (Exception ex)
             {
+                _connectionException = ex;
                 MBeanUtility.printStackTrace(ex);
             }
         }
@@ -205,10 +216,10 @@
     {
         try
         {
-            if (_jmxc != null)
+            if (_jmxc != null && _clientListener != null)
                 _jmxc.removeConnectionNotificationListener(_clientListener);
 
-            if (_mbsc != null)
+            if (_mbsc != null && _clientListener != null)
                 _mbsc.removeNotificationListener(_serverObjectName, _clientListener);
 
             // remove mbean notification listeners
@@ -219,7 +230,7 @@
         }
         catch (ListenerNotFoundException ex)
         {
-            System.out.println(ex.toString());
+            MBeanUtility.printOutput(ex.toString());
         }
     }