qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgr...@apache.org
Subject svn commit: r493771 [1/2] - in /incubator/qpid/branches/new_persistence/java: ./ broker/etc/ broker/src/main/java/org/apache/qpid/server/protocol/ client/example/bin/ common/src/main/java/org/apache/qpid/framing/ distribution/src/main/assembly/ distrib...
Date Sun, 07 Jan 2007 17:03:19 GMT
Author: rgreig
Date: Sun Jan  7 09:03:17 2007
New Revision: 493771

URL: http://svn.apache.org/viewvc?view=rev&rev=493771
Log:
Merge from trunk rev 493060

Added:
    incubator/qpid/branches/new_persistence/java/client/example/bin/
      - copied from r493060, incubator/qpid/trunk/qpid/java/client/example/bin/
    incubator/qpid/branches/new_persistence/java/client/example/bin/set_classpath.bat
      - copied unchanged from r493060, incubator/qpid/trunk/qpid/java/client/example/bin/set_classpath.bat
    incubator/qpid/branches/new_persistence/java/client/example/bin/set_classpath.sh
      - copied unchanged from r493060, incubator/qpid/trunk/qpid/java/client/example/bin/set_classpath.sh
    incubator/qpid/branches/new_persistence/java/distribution/src/main/release/LICENSE.txt
      - copied unchanged from r493060, incubator/qpid/trunk/qpid/java/distribution/src/main/release/LICENSE.txt
    incubator/qpid/branches/new_persistence/java/distribution/src/main/release/NOTICE.txt
      - copied unchanged from r493060, incubator/qpid/trunk/qpid/java/distribution/src/main/release/NOTICE.txt
    incubator/qpid/branches/new_persistence/java/distribution/src/main/release/README.txt
      - copied unchanged from r493060, incubator/qpid/trunk/qpid/java/distribution/src/main/release/README.txt
    incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java   (with props)
Removed:
    incubator/qpid/branches/new_persistence/java/ReadMe.txt
Modified:
    incubator/qpid/branches/new_persistence/java/broker/etc/config.xml
    incubator/qpid/branches/new_persistence/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java
    incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQType.java
    incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java
    incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
    incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java
    incubator/qpid/branches/new_persistence/java/distribution/src/main/assembly/bin.xml
    incubator/qpid/branches/new_persistence/java/distribution/src/main/assembly/client-bin.xml
    incubator/qpid/branches/new_persistence/java/distribution/src/main/assembly/src.xml
    incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/bin/qpidmc.sh
    incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
    incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java
    incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java
    incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java
    incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java
    incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ManagedAttributeModel.java
    incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java
    incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java
    incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java
    incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java
    incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java

Modified: incubator/qpid/branches/new_persistence/java/broker/etc/config.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/broker/etc/config.xml?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/broker/etc/config.xml (original)
+++ incubator/qpid/branches/new_persistence/java/broker/etc/config.xml Sun Jan  7 09:03:17 2007
@@ -64,7 +64,7 @@
                         <class>org.apache.qpid.server.security.auth.amqplain.AmqPlainInitialiser</class>
                         <principal-database>passwordfile</principal-database>
                     </initialiser>
-                </mechanism>-->
+                </mechanism>
                 <mechanism>
                     <initialiser>
                         <class>org.apache.qpid.server.security.auth.plain.PlainInitialiser</class>

Modified: incubator/qpid/branches/new_persistence/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java (original)
+++ incubator/qpid/branches/new_persistence/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java Sun Jan  7 09:03:17 2007
@@ -164,17 +164,14 @@
                 _minor = pi.protocolMinor;
                 String mechanisms = ApplicationRegistry.getInstance().getAuthenticationManager().getMechanisms();
                 String locales = "en_US";
-                // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
-                // TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
-                // Be aware of possible changes to parameter order as versions change.
+                // Interfacing with generated code - be aware of possible changes to parameter order as versions change.
                 AMQFrame response = ConnectionStartBody.createAMQFrame((short) 0,
-            		(byte)8, (byte)0,	// AMQP version (major, minor)
+            		_major, _minor,	// AMQP version (major, minor)
                     locales.getBytes(),	// locales
                     mechanisms.getBytes(),	// mechanisms
                     null,	// serverProperties
-                	(short)8,	// versionMajor
-                    (short)0	// versionMinor
-                    );
+                	(short)_major,	// versionMajor
+                    (short)_minor);	// versionMinor
                 _minaProtocolSession.write(response);
             }
             catch (AMQException e)

Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQType.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQType.java?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQType.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQType.java Sun Jan  7 09:03:17 2007
@@ -28,35 +28,39 @@
 
     //AMQP FieldTable Wire Types
 
-    DECIMAL('D')
+    LONG_STRING('S')
     {
-
         public int getEncodingSize(Object value)
         {
-            // TODO : fixme
-            throw new UnsupportedOperationException();
+            return EncodingUtils.encodedLongStringLength((String) value);
         }
 
-        public Object toNativeValue(Object value)
+
+        public String toNativeValue(Object value)
         {
-            // TODO : fixme
-            throw new UnsupportedOperationException();
+            if (value != null)
+            {
+                return value.toString();
+            }
+            else
+            {
+                throw new NullPointerException("Cannot convert: null to String.");
+            }
         }
 
         public void writeValueImpl(Object value, ByteBuffer buffer)
         {
-            // TODO : fixme
-            throw new UnsupportedOperationException();
+            EncodingUtils.writeLongStringBytes(buffer, (String) value);
         }
 
         public Object readValueFromBuffer(ByteBuffer buffer)
         {
-            // TODO : fixme
-            throw new UnsupportedOperationException();
+            return EncodingUtils.readLongString(buffer);
         }
+
     },
 
-    UNSIGNED_SHORT('S')
+    INTEGER('I')
     {
 
         public int getEncodingSize(Object value)
@@ -65,6 +69,7 @@
             throw new UnsupportedOperationException();
         }
 
+
         public Object toNativeValue(Object value)
         {
             // TODO : fixme
@@ -82,10 +87,9 @@
             // TODO : fixme
             throw new UnsupportedOperationException();
         }
-
     },
 
-    UNSIGNED_INT('I')
+    DECIMAL('D')
     {
 
         public int getEncodingSize(Object value)
@@ -94,7 +98,6 @@
             throw new UnsupportedOperationException();
         }
 
-
         public Object toNativeValue(Object value)
         {
             // TODO : fixme
@@ -114,7 +117,7 @@
         }
     },
 
-    UNSIGNED_LONG('L')
+    TIMESTAMP('T')
     {
 
         public int getEncodingSize(Object value)
@@ -124,7 +127,7 @@
         }
 
 
-        public Long toNativeValue(Object value)
+        public Object toNativeValue(Object value)
         {
             // TODO : fixme
             throw new UnsupportedOperationException();
@@ -143,9 +146,8 @@
         }
     },
 
-    EXTTENDED('D')
+    FIELD_TABLE('F')
     {
-
         public int getEncodingSize(Object value)
         {
             // TODO : fixme
@@ -172,35 +174,39 @@
         }
     },
 
-    TIMESTAMP('T')
+    VOID('V')
     {
-
         public int getEncodingSize(Object value)
         {
-            // TODO : fixme
-            throw new UnsupportedOperationException();
+            return 0;
         }
 
 
         public Object toNativeValue(Object value)
         {
-            // TODO : fixme
-            throw new UnsupportedOperationException();
+            if (value == null)
+            {
+                return null;
+            }
+            else
+            {
+                throw new NumberFormatException("Cannot convert: " + value + "(" +
+                                                value.getClass().getName() + ") to null String.");
+            }
         }
 
         public void writeValueImpl(Object value, ByteBuffer buffer)
         {
-            // TODO : fixme
-            throw new UnsupportedOperationException();
         }
 
         public Object readValueFromBuffer(ByteBuffer buffer)
         {
-            // TODO : fixme
-            throw new UnsupportedOperationException();
+            return null;
         }
     },
 
+    // Extended types
+
     BINARY('x')
     {
         public int getEncodingSize(Object value)
@@ -299,38 +305,6 @@
         }
     },
 
-    NULL_STRING('n')
-    {
-
-        public int getEncodingSize(Object value)
-        {
-            return 0;
-        }
-
-
-        public String toNativeValue(Object value)
-        {
-            if (value == null)
-            {
-                return null;
-            }
-            else
-            {
-                throw new NumberFormatException("Cannot convert: " + value + "(" +
-                                                value.getClass().getName() + ") to null String.");
-            }
-        }
-
-        public void writeValueImpl(Object value, ByteBuffer buffer)
-        {
-        }
-
-        public Object readValueFromBuffer(ByteBuffer buffer)
-        {
-            return null;
-        }
-    },
-
     BOOLEAN('t')
     {
         public int getEncodingSize(Object value)
@@ -368,77 +342,77 @@
         }
     },
 
-    BYTE('b')
+    ASCII_CHARACTER('k')
     {
         public int getEncodingSize(Object value)
         {
-            return EncodingUtils.encodedByteLength();
+            return EncodingUtils.encodedCharLength();
         }
 
 
-        public Byte toNativeValue(Object value)
+        public Character toNativeValue(Object value)
         {
-            if (value instanceof Byte)
+            if (value instanceof Character)
             {
-                return (Byte) value;
+                return (Character) value;
             }
-            else if ((value instanceof String) || (value == null))
+            else if (value == null)
             {
-                return Byte.valueOf((String)value);
+                throw new NullPointerException("Cannot convert null into char");
             }
             else
             {
                 throw new NumberFormatException("Cannot convert: " + value + "(" +
-                                                value.getClass().getName() + ") to byte.");
+                                                value.getClass().getName() + ") to char.");
             }
         }
 
         public void writeValueImpl(Object value, ByteBuffer buffer)
         {
-            EncodingUtils.writeByte(buffer, (Byte) value);
+            EncodingUtils.writeChar(buffer, (Character) value);
         }
 
         public Object readValueFromBuffer(ByteBuffer buffer)
         {
-            return EncodingUtils.readByte(buffer);
+            return EncodingUtils.readChar(buffer);
         }
+
     },
 
-    ASCII_CHARACTER('k')
+    BYTE('b')
     {
         public int getEncodingSize(Object value)
         {
-            return EncodingUtils.encodedCharLength();
+            return EncodingUtils.encodedByteLength();
         }
 
 
-        public Character toNativeValue(Object value)
+        public Byte toNativeValue(Object value)
         {
-            if (value instanceof Character)
+            if (value instanceof Byte)
             {
-                return (Character) value;
+                return (Byte) value;
             }
-            else if (value == null)
+            else if ((value instanceof String) || (value == null))
             {
-                throw new NullPointerException("Cannot convert null into char");
+                return Byte.valueOf((String)value);
             }
             else
             {
                 throw new NumberFormatException("Cannot convert: " + value + "(" +
-                                                value.getClass().getName() + ") to char.");
+                                                value.getClass().getName() + ") to byte.");
             }
         }
 
         public void writeValueImpl(Object value, ByteBuffer buffer)
         {
-            EncodingUtils.writeChar(buffer, (Character) value);
+            EncodingUtils.writeByte(buffer, (Byte) value);
         }
 
         public Object readValueFromBuffer(ByteBuffer buffer)
         {
-            return EncodingUtils.readChar(buffer);
+            return EncodingUtils.readByte(buffer);
         }
-
     },
 
     SHORT('s')

Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java Sun Jan  7 09:03:17 2007
@@ -37,7 +37,12 @@
 
     public static AMQType getType(Byte identifier)
     {
-        return _reverseTypeMap.get(identifier);
+        AMQType result = _reverseTypeMap.get(identifier);
+        if (result == null) {
+            throw new IllegalArgumentException
+                ("no such type code: " + Integer.toHexString(identifier.intValue()));
+        }
+        return result;
     }
 
 }

Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java Sun Jan  7 09:03:17 2007
@@ -257,7 +257,7 @@
         checkPropertyName(string);
         if (value == null)
         {
-            return _properties.put(string, AMQType.NULL_STRING.asTypedValue(null));
+            return _properties.put(string, AMQType.VOID.asTypedValue(null));
         }
         else
         {
@@ -344,7 +344,7 @@
     public boolean isNullStringValue(String name)
     {
         AMQTypedValue value = _properties.get(name);
-        return (value != null) && (value.getType() == AMQType.NULL_STRING);
+        return (value != null) && (value.getType() == AMQType.VOID);
     }
 
     // ***** Methods

Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java Sun Jan  7 09:03:17 2007
@@ -146,18 +146,6 @@
             throw new AMQProtocolInstanceException("Protocol instance " + CURRENT_PROTOCOL_INSTANCE + " was expected; received " +
                     protocolInstance);
         }
-        /*
-        if (protocolMajor != CURRENT_PROTOCOL_VERSION_MAJOR)
-        {
-            throw new AMQProtocolVersionException("Protocol major version " + CURRENT_PROTOCOL_VERSION_MAJOR +
-                    " was expected; received " + protocolMajor);
-        }
-        if (protocolMinor != CURRENT_PROTOCOL_VERSION_MINOR)
-        {
-            throw new AMQProtocolVersionException("Protocol minor version " + CURRENT_PROTOCOL_VERSION_MINOR +
-                    " was expected; received " + protocolMinor);
-        }
-        */
         
         /* Look through list of available protocol versions */
         boolean found = false;

Modified: incubator/qpid/branches/new_persistence/java/distribution/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/distribution/src/main/assembly/bin.xml?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/distribution/src/main/assembly/bin.xml (original)
+++ incubator/qpid/branches/new_persistence/java/distribution/src/main/assembly/bin.xml Sun Jan  7 09:03:17 2007
@@ -31,14 +31,17 @@
       <directory>src/main/release</directory>
       <outputDirectory>qpid-${qpid.version}</outputDirectory>
       <includes>
-    <include>DISCLAIMER</include>
+          <include>DISCLAIMER</include>
+          <include>LICENSE.txt</include>
+          <include>NOTICE.txt</include>
+          <include>README.txt</include>
       </includes>
     </fileSet>
     <fileSet>
       <directory>..</directory>
       <outputDirectory>qpid-${qpid.version}</outputDirectory>
       <includes>
-    <include>*.txt</include>
+          <include>*.txt</include>
       </includes>
     </fileSet>
     <fileSet>
@@ -53,14 +56,14 @@
       <directory>src/main/release/docs</directory>
       <outputDirectory>qpid-${qpid.version}/docs</outputDirectory>
       <includes>
-    <include>RELEASE_NOTES.txt</include>
+          <include>RELEASE_NOTES.txt</include>
       </includes>
     </fileSet>
     <fileSet>
       <directory>target</directory>
       <outputDirectory>qpid-${qpid.version}/lib</outputDirectory>
       <includes>
-    <include>qpid-incubating.jar</include>
+          <include>qpid-incubating.jar</include>
       </includes>
     </fileSet>
   </fileSets>

Modified: incubator/qpid/branches/new_persistence/java/distribution/src/main/assembly/client-bin.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/distribution/src/main/assembly/client-bin.xml?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/distribution/src/main/assembly/client-bin.xml (original)
+++ incubator/qpid/branches/new_persistence/java/distribution/src/main/assembly/client-bin.xml Sun Jan  7 09:03:17 2007
@@ -43,6 +43,9 @@
           <outputDirectory>qpid-${qpid.version}</outputDirectory>
           <includes>
               <include>DISCLAIMER</include>
+              <include>LICENSE.txt</include>
+              <include>NOTICE.txt</include>
+              <include>README.txt</include>
           </includes>
       </fileSet>
       <fileSet>

Modified: incubator/qpid/branches/new_persistence/java/distribution/src/main/assembly/src.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/distribution/src/main/assembly/src.xml?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/distribution/src/main/assembly/src.xml (original)
+++ incubator/qpid/branches/new_persistence/java/distribution/src/main/assembly/src.xml Sun Jan  7 09:03:17 2007
@@ -32,10 +32,10 @@
       <outputDirectory>qpid-${qpid.version}-src</outputDirectory>
       <includes>
         <include>DISCLAIMER</include>
-        <include>LICENSE</include>
+        <include>LICENSE.txt</include>
         <include>licenses/*.*</include>
-        <include>NOTICE</include>
-        <include>README</include>
+        <include>NOTICE.txt</include>
+        <include>README.txt</include>
         <include>BUILDING.txt</include>
       </includes>
     </fileSet>

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/bin/qpidmc.sh
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/bin/qpidmc.sh?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/bin/qpidmc.sh (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/bin/qpidmc.sh Sun Jan  7 09:03:17 2007
@@ -1,3 +1,13 @@
 #!/bin/bash
 
+if [ "$JAVA_HOME" == "" ]; then
+    echo "The JAVA_HOME environment variable is not defined";
+    exit 0;
+fi
+
+if [ "$QPIDMC_HOME" == "" ]; then
+    echo "The QPIDMC_HOME environment variable is not defined correctly";
+    exit 0;
+fi
+
 "$JAVA_HOME/bin/java" -Xms40m -Xmx256m -Declipse.consoleLog=false -jar $QPIDMC_HOME/eclipse/startup.jar org.eclipse.core.launcher.Main -launcher $QPIDMC_HOME/eclipse/eclipse -name "Qpid Management Console" -showsplash 600 -configuration "file:$QPIDMC_HOME/configuration"

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java Sun Jan  7 09:03:17 2007
@@ -34,9 +34,12 @@
     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";
+    
+    public final static String ATTRIBUTE_QUEUE_DEPTH = "QueueDepth"; 
     
     public final static String ALL = "All";
     

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java Sun Jan  7 09:03:17 2007
@@ -21,15 +21,23 @@
 package org.apache.qpid.management.ui;
 
 
+import java.util.ArrayList;
 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;
 
 public abstract class ServerRegistry
 {
     private ManagedServer _managedServer = null;
+    // list of all Connection mbeans
+    protected List<ManagedBean> _connections = new ArrayList<ManagedBean>();
+    // list of all exchange mbeans
+    protected List<ManagedBean> _exchanges = new ArrayList<ManagedBean>();
+    // list of all queue mbenas
+    protected List<ManagedBean> _queues = new ArrayList<ManagedBean>();
     
     public ServerRegistry()
     {
@@ -51,6 +59,64 @@
         _managedServer = server;
     }
     
+    protected void addConnectionMBean(ManagedBean mbean)
+    {
+        _connections.add(mbean);
+    }
+    
+    protected void addExchangeMBean(ManagedBean mbean)
+    {
+        _exchanges.add(mbean);
+    }
+    
+    protected void addQueueMBean(ManagedBean mbean)
+    {
+        _queues.add(mbean);
+    }
+    
+    protected void removeConnectionMBean(ManagedBean mbean)
+    {
+        _connections.remove(mbean);
+    }
+    
+    protected void removeExchangeMBean(ManagedBean mbean)
+    {
+        _exchanges.remove(mbean);
+    }
+    
+    protected void removeQueueMBean(ManagedBean mbean)
+    {
+        _queues.remove(mbean);
+    }
+    
+    public List<ManagedBean> getConnections()
+    {
+        return _connections;
+    }
+    
+    public List<ManagedBean> getExchanges()
+    {
+        return _exchanges;
+    }
+    
+    public List<ManagedBean> getQueues()
+    {
+        return _queues;
+    }
+    
+    public abstract void addManagedObject(ManagedBean key);
+    
+    public abstract List<ManagedBean> getMBeans();
+    
+    public abstract void removeManagedObject(ManagedBean mbean);
+   
+    public List<ManagedBean> getObjectsToBeRemoved()
+    {
+        return null;
+    }
+    
+    public abstract ManagedAttributeModel getAttributeModel(ManagedBean mbean);
+    
     public abstract Object getServerConnection();
     
     public abstract void closeServerConnection() throws Exception;
@@ -60,6 +126,8 @@
     public abstract String[] getQueueNames();
     
     public abstract String[] getExchangeNames();
+    
+    public abstract String[] getConnectionNames();
     
     public abstract List<NotificationObject> getNotifications(ManagedBean mbean);
     

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java Sun Jan  7 09:03:17 2007
@@ -20,6 +20,7 @@
  */
 package org.apache.qpid.management.ui.actions;
 
+import org.apache.qpid.management.ui.jmx.MBeanUtility;
 import org.apache.qpid.management.ui.views.MBeanView;
 import org.apache.qpid.management.ui.views.NavigationView;
 import org.eclipse.jface.action.IAction;
@@ -27,6 +28,10 @@
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
 
+/**
+ * This action refreshes both the views -Navigation and MBeanView
+ * @author Bhupendra Bhardwaj
+ */
 public class Refresh implements IWorkbenchWindowActionDelegate
 {
     private IWorkbenchWindow _window;
@@ -71,7 +76,14 @@
             view.refresh();
             
             MBeanView mbeanview = (MBeanView)_window.getActivePage().findView(MBeanView.ID);
-            mbeanview.refreshMBeanView();
+            try
+            {
+                mbeanview.refreshMBeanView();
+            }
+            catch (Exception ex)
+            {
+                MBeanUtility.handleException(ex);
+            }
         }
     }
 }

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java Sun Jan  7 09:03:17 2007
@@ -26,6 +26,7 @@
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
+import javax.management.ListenerNotFoundException;
 import javax.management.MBeanInfo;
 import javax.management.MBeanServerConnection;
 import javax.management.Notification;
@@ -50,21 +51,31 @@
     private JMXConnector _jmxc = null;
     private MBeanServerConnection _mbsc = null;
     
-    private List<ManagedBean> _mbeansToBeAdded   = new ArrayList<ManagedBean>();
+    // When an mbean gets removed from mbean 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 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
@@ -93,16 +104,23 @@
      */
     public void closeServerConnection() throws Exception
     {
-        if (_jmxc != null)
-            _jmxc.removeConnectionNotificationListener(_clientListener);
-        
-        if (_mbsc != null)
-            _mbsc.removeNotificationListener(_serverObjectName, _clientListener);
-        
-        // remove mbean notification listeners
-        for (String mbeanName : _subscribedNotificationMap.keySet())
+        try
+        {
+            if (_jmxc != null)
+                _jmxc.removeConnectionNotificationListener(_clientListener);
+
+            if (_mbsc != null)
+                _mbsc.removeNotificationListener(_serverObjectName, _clientListener);
+
+            // remove mbean notification listeners
+            for (String mbeanName : _subscribedNotificationMap.keySet())
+            {
+                _mbsc.removeNotificationListener(new ObjectName(mbeanName), _notificationListener);
+            }
+        }
+        catch (ListenerNotFoundException ex)
         {
-            _mbsc.removeNotificationListener(new ObjectName(mbeanName), _notificationListener);
+            System.out.println(ex.toString());
         }
     }
     
@@ -111,22 +129,32 @@
         return _mbeansMap.get(uniqueName);
     }
     
-    public void addManagedObject(ManagedBean key)
+    public void addManagedObject(ManagedBean mbean)
     {
-        if (Constants.QUEUE.equals(key.getType()))
-            _queues.add(key.getName());
-        else if (Constants.EXCHANGE.equals(key.getType()))
-            _exchanges.add(key.getName());
+        if (Constants.QUEUE.equals(mbean.getType()) && !mbean.getName().startsWith("tmp_"))
+        {
+            addQueueMBean(mbean);
+        }
+        else if (Constants.EXCHANGE.equals(mbean.getType()))
+        {
+            addExchangeMBean(mbean);
+        }
+        else if (Constants.CONNECTION.equals(mbean.getType()))
+        {
+            addConnectionMBean(mbean);
+        }
         
-        _mbeansMap.put(key.getUniqueName(), key);
+        _mbeansMap.put(mbean.getUniqueName(), mbean);
     }
 
     public void removeManagedObject(ManagedBean mbean)
     {
         if (Constants.QUEUE.equals(mbean.getType()))
-            _queues.remove(mbean.getName());
+            removeQueueMBean(mbean);
         else if (Constants.EXCHANGE.equals(mbean.getType()))
-            _exchanges.remove(mbean.getName());
+            removeExchangeMBean(mbean);
+        else if (Constants.CONNECTION.equals(mbean.getType()))
+            removeConnectionMBean(mbean);
         
         _mbeansMap.remove(mbean.getUniqueName());
     }
@@ -140,6 +168,11 @@
         return _mbeanInfoMap.get(mbean.getUniqueName());
     }
     
+    public List<ManagedBean> getMBeans()
+    {
+        return new ArrayList<ManagedBean>(_mbeansMap.values());
+    }
+    
     public void setNotificationInfo(ManagedBean mbean, List<NotificationInfoModel>value)
     {
         _notificationInfoMap.put(mbean.getUniqueName(), value);
@@ -259,27 +292,15 @@
     public void registerManagedObject(ObjectName objName)
     {
         JMXManagedObject managedObject = new JMXManagedObject(objName);
+        
         managedObject.setServer(getManagedServer());
-        _mbeansToBeAdded.add(managedObject);
+        addManagedObject(managedObject);
     }
     
     public void unregisterManagedObject(ObjectName objName)
     {
-        JMXManagedObject managedObject = new JMXManagedObject(objName);
-        managedObject.setServer(getManagedServer());
-        _mbeansToBeRemoved.add(managedObject);
-    }
-    
-    public List<ManagedBean> getObjectsToBeAdded()
-    {
-        if (_mbeansToBeAdded.isEmpty())
-            return null;
-        else
-        {
-            List<ManagedBean> list = _mbeansToBeAdded;
-            _mbeansToBeAdded = new ArrayList<ManagedBean>();
-            return list;
-        }
+        ManagedBean mbean = _mbeansMap.get(objName.toString());
+        _mbeansToBeRemoved.add(mbean);
     }
 
     public List<ManagedBean> getObjectsToBeRemoved()
@@ -316,12 +337,35 @@
     
     public String[] getQueueNames()
     {
-        return _queues.toArray(new String[0]);
+        String[] queues = new String[_queues.size()];
+        int i = 0;
+        for (ManagedBean mbean : _queues)
+        {
+            queues[i++] = mbean.getName();
+        }
+        return queues;
     }
     
     public String[] getExchangeNames()
     {
-        return _exchanges.toArray(new String[0]);
+        String[] exchanges = new String[_exchanges.size()];
+        int i = 0;
+        for (ManagedBean mbean : _exchanges)
+        {
+            exchanges[i++] = mbean.getName();
+        }
+        return exchanges;
+    }
+    
+    public String[] getConnectionNames()
+    {
+        String[] connections = new String[_connections.size()];
+        int i = 0;
+        for (ManagedBean mbean : _connections)
+        {
+            connections[i++] = mbean.getName();
+        }
+        return connections;
     }
 
     public ClientNotificationListener getNotificationListener()

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java Sun Jan  7 09:03:17 2007
@@ -22,8 +22,10 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import javax.management.Attribute;
 import javax.management.AttributeList;
@@ -35,6 +37,7 @@
 import javax.management.MBeanNotificationInfo;
 import javax.management.MBeanOperationInfo;
 import javax.management.MBeanServerConnection;
+import javax.management.ObjectInstance;
 import javax.management.ObjectName;
 import javax.management.ReflectionException;
 
@@ -140,30 +143,30 @@
     {
         if (mbean == null)
         {
-            ViewUtility.popupErrorMessage("Error", ex.getMessage());
+            ViewUtility.popupErrorMessage("Error", "Managed Object is null \n" + ex.toString());
         }
         else if (ex instanceof IOException)
         {
-            ViewUtility.popupErrorMessage(mbean.getName(), ex.getMessage());
+            ViewUtility.popupErrorMessage(mbean.getName(), "IO Error occured \n" + ex.toString());
         }
         else if (ex instanceof ReflectionException)
         {
-            ViewUtility.popupErrorMessage(mbean.getName(), ex.getMessage());
+            ViewUtility.popupErrorMessage(mbean.getName(), "Server has thrown error \n" + ex.toString());
         }
         else if (ex instanceof InstanceNotFoundException)
         {
-            ViewUtility.popupErrorMessage(mbean.getName(), ex.getMessage());
+            ViewUtility.popupErrorMessage(mbean.getName(), "Managed Object Not Found \n" + ex.toString());
         }
         else if (ex instanceof MBeanException)
         {
-            String cause = ((MBeanException)ex).getTargetException().getMessage();
+            String cause = ((MBeanException)ex).getTargetException().toString();
             if (cause == null)
-                cause = ex.getMessage();
+                cause = ex.toString();
             ViewUtility.popupInfoMessage(mbean.getName(), cause);
         }
         else if (ex instanceof JMException)
         {
-            ViewUtility.popupErrorMessage(mbean.getName(), ex.getMessage());
+            ViewUtility.popupErrorMessage(mbean.getName(), "Management Exception occured \n" + ex.toString());
         }
         else if (ex instanceof ManagementConsoleException)
         {
@@ -171,9 +174,9 @@
         }
         else 
         {
-            ViewUtility.popupError(mbean.getName(), "Error occured", ex);
+            ViewUtility.popupErrorMessage(mbean.getName(), ex.toString());
         }
-        //ex.printStackTrace();
+        ex.printStackTrace();
     }
     
     /**
@@ -204,7 +207,36 @@
         serverRegistry.removeNotificationListener(mbean, name, type);
     }
     
-    public static int refreshAttribute(ManagedBean mbean, String attribute) throws Exception
+    /**
+     * Checks if the server registry contains attribute information for this mbean. If not then it queries the
+     * mbean server for complete mbean information, else it gets the latest value of the given attribute
+     * from mbean server.
+     * @return attribute data for the given mbean attribute
+     */
+    public static AttributeData getAttributeData(ManagedBean mbean, String attribute) throws Exception
+    {
+        JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean);
+        ManagedAttributeModel attributeModel = serverRegistry.getAttributeModel(mbean);
+        if (attributeModel == null)
+        {
+            // If process is here, it means the mbeanInfo is not retrieved from mbean server even once for this mbean
+            getMBeanInfo(mbean);
+        }
+        else
+        {
+            // refresh attribute value from mbean server
+            refreshAttribute(mbean, attribute);
+        }
+        attributeModel = serverRegistry.getAttributeModel(mbean);
+        return attributeModel.getAttribute(attribute);
+    }
+    
+    /**
+     * Retrieves the latest attribute value from mbean server for the given mbean attribute
+     * and also sets that value in the attribute model in the server registry
+     * @return latest attribute value for the given mbean attribute
+     */
+    public static Object refreshAttribute(ManagedBean mbean, String attribute) throws Exception
     {
         JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean);
         MBeanServerConnection mbsc = serverRegistry.getServerConnection();
@@ -215,10 +247,10 @@
         }
         
         Object value = mbsc.getAttribute(((JMXManagedObject)mbean).getObjectName(), attribute);
-        
+        // update the attribute data in server registry for this attribute
         ManagedAttributeModel attributeModel = serverRegistry.getAttributeModel(mbean);
         attributeModel.setAttributeValue(attribute, value);
-        return Integer.parseInt(String.valueOf(value));
+        return value;
     }
     
     /**
@@ -237,9 +269,12 @@
         MBeanServerConnection mbsc = serverRegistry.getServerConnection();
         MBeanAttributeInfo[] attributesInfo = null;
         ManagedAttributeModel attributeModel = serverRegistry.getAttributeModel(mbean);
-        // If retrieving attributeInfo for the first time.
+        
         if (attributeModel == null)
         {
+            // If the process is here, then it means the attribute values are not retrieved from mbean server
+            // even once for this mbean. Create attribute model, retrieve values from mbean server and 
+            // set the attribute model in server registry for this mbean
             attributeModel = new ManagedAttributeModel();
             attributesInfo = serverRegistry.getMBeanInfo(mbean).getAttributes();
             attributes = new String[attributesInfo.length];
@@ -311,8 +346,8 @@
         OperationDataModel dataModel = serverRegistry.getOperationModel(mbean);
         if (dataModel == null)
         {
-            MBeanInfo mbeanInfo = serverRegistry.getMBeanInfo(mbean);
-            MBeanOperationInfo[] operationsInfo = mbeanInfo.getOperations();
+            // Create operation model and set it in server registry for this mbean
+            MBeanOperationInfo[] operationsInfo = serverRegistry.getMBeanInfo(mbean).getOperations();
             dataModel = new OperationDataModel();
             
             for (int i = 0; i < operationsInfo.length; i++)
@@ -322,7 +357,6 @@
             
             serverRegistry.setOperationModel(mbean, dataModel);
         }
-        
         return dataModel;
     }
     
@@ -333,15 +367,15 @@
      */
     public static NotificationInfoModel[] getNotificationInfo(ManagedBean mbean)
     {
-        
         JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean);
         MBeanNotificationInfo[] info = serverRegistry.getMBeanInfo(mbean).getNotifications();
         
+        // Check if this mbean sends any notification
         if (info == null || info.length == 0)
             return null;
         
+        // Create notification model if not already set in the server registry for this mbean
         List<NotificationInfoModel> list = serverRegistry.getNotificationInfo(mbean);
-        
         if (list != null) 
             return list.toArray(new NotificationInfoModel[0]);
         else
@@ -351,8 +385,43 @@
         {
             list.add(new NotificationInfoModel(info[i].getName(), info[i].getDescription(), info[i].getNotifTypes()));
         }
-        serverRegistry.setNotificationInfo(mbean, list);
         
+        // Set the notification model in the server registry for this mbean
+        serverRegistry.setNotificationInfo(mbean, list);
         return list.toArray(new NotificationInfoModel[0]);
+    }
+    
+    /**
+     * Retrieves all the MBeans from mbean server for a given domain
+     * @return list of ManagedBeans
+     */
+    public static List<ManagedBean> getManagedObjectsForDomain(ManagedServer server, String domain) throws Exception
+    {
+        List<ManagedBean> mbeans = new ArrayList<ManagedBean>();
+        JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(server);
+        MBeanServerConnection mbsc = serverRegistry.getServerConnection();
+        ObjectName objName = new ObjectName(domain + ":*"); 
+        Set objectInstances = mbsc.queryMBeans(objName, null);
+
+        for (Iterator itr = objectInstances.iterator(); itr.hasNext();)
+        {
+            ObjectInstance instance = (ObjectInstance)itr.next();
+            ManagedBean obj = new JMXManagedObject(instance.getObjectName());
+            mbeans.add(obj);
+        }
+        
+        return mbeans;
+    }
+    
+    /**
+     * Returns all the domains for the given server. This method can be removed as now this RCP is specific to 
+     * Qpid and domain is also fixed
+     */
+    public static List<String> getAllDomains(ManagedServer server) throws Exception
+    {
+        JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(server);
+        MBeanServerConnection mbsc = serverRegistry.getServerConnection();
+        String[] domains = mbsc.getDomains();
+        return Arrays.asList(domains);
     }
 }

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ManagedAttributeModel.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ManagedAttributeModel.java?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ManagedAttributeModel.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ManagedAttributeModel.java Sun Jan  7 09:03:17 2007
@@ -106,6 +106,11 @@
         return _attributeMap.values().toArray(new AttributeData[0]);
     }
     
+    public AttributeData getAttribute(String name)
+    {
+        return _attributeMap.get(name);
+    }
+    
     public int getCount()
     {
         return _attributeMap.size();

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java Sun Jan  7 09:03:17 2007
@@ -126,7 +126,7 @@
         _tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
         _tableComposite.setLayout(new GridLayout());
         _buttonsComposite = _toolkit.createComposite(_form.getBody());
-        _tableComposite.setLayoutData(new GridData());
+        _buttonsComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
         _buttonsComposite.setLayout(new GridLayout());
         
         image = Display.getCurrent().getSystemImage(SWT.ICON_INFORMATION);
@@ -175,7 +175,6 @@
     
     /**
      * Creates tableviewer for the attribute's table
-     *
      */
     private void createTableViewer()
     {
@@ -200,7 +199,7 @@
         // Create and configure the button for attribute details
         _detailsButton = _toolkit.createButton(_buttonsComposite, Constants.BUTTON_DETAILS, SWT.PUSH | SWT.CENTER);
         _detailsButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON));
-        GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
+        GridData gridData = new GridData(SWT.CENTER, SWT.TOP, false, false);
         gridData.widthHint = 80;
         _detailsButton.setLayoutData(gridData);
         _detailsButton.addSelectionListener(new SelectionAdapter()
@@ -225,7 +224,7 @@
         // Create and configure the button for editing attribute
         _editButton = _toolkit.createButton(_buttonsComposite, Constants.BUTTON_EDIT_ATTRIBUTE, SWT.PUSH | SWT.CENTER);
         _editButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON));
-        GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
+        GridData gridData = new GridData(SWT.CENTER, SWT.TOP, false, false);
         gridData.widthHint = 80;
         _editButton.setLayoutData(gridData);
         _editButton.addSelectionListener(new SelectionAdapter()
@@ -247,7 +246,7 @@
     {
         _graphButton = _toolkit.createButton(_buttonsComposite, Constants.BUTTON_GRAPH, SWT.PUSH | SWT.CENTER);
         _graphButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON));
-        GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
+        GridData gridData = new GridData(SWT.CENTER, SWT.TOP, false, false);
         gridData.widthHint = 80;
         _graphButton.setLayoutData(gridData);
         _graphButton.addSelectionListener(new SelectionAdapter()
@@ -270,7 +269,7 @@
         _refreshButton = _toolkit.createButton(_buttonsComposite, Constants.BUTTON_REFRESH, SWT.PUSH | SWT.CENTER);
 
         _refreshButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON));
-        GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
+        GridData gridData = new GridData(SWT.CENTER, SWT.TOP, false, false);
         gridData.widthHint = 80;
         _refreshButton.setLayoutData(gridData);
         _refreshButton.addSelectionListener(new SelectionAdapter()
@@ -429,12 +428,14 @@
         }
         
         Display display = Display.getCurrent();
-        Shell shell = ViewUtility.createPopupShell("Attribute", width, height);
+        Shell shell = ViewUtility.createPopupShell(Constants.ATTRIBUTE, width, height);
         createDetailsPopupContents(shell, data);
 
         shell.open();
-        while (!shell.isDisposed()) {
-            if (!display.readAndDispatch()) {
+        while (!shell.isDisposed())
+        {
+            if (!display.readAndDispatch())
+            {
                 display.sleep();
             }
         }
@@ -818,7 +819,8 @@
     private void animate(Canvas canvas, AttributeData data) throws Exception
     {
         String attribute = data.getName();
-        int value = MBeanUtility.refreshAttribute(_mbean, attribute);
+        Object valueObj = MBeanUtility.refreshAttribute(_mbean, attribute);
+        int value = Integer.parseInt(String.valueOf(valueObj));
         Object canvasData = canvas.getData(GRAPH_VALUES);
         long[] graphValues = (long[]) canvasData;
         

Added: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java?view=auto&rev=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java (added)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java Sun Jan  7 09:03:17 2007
@@ -0,0 +1,327 @@
+package org.apache.qpid.management.ui.views;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+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.ServerRegistry;
+import org.apache.qpid.management.ui.jmx.MBeanUtility;
+import org.apache.qpid.management.ui.model.AttributeData;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * Class to create widgets and control display for mbeantype(eg Connection, Queue, Exchange) selection
+ * on the navigation view.
+ * @author Bhupendra Bhardwaj
+ *
+ */
+public class MBeanTypeTabControl
+{
+    private FormToolkit  _toolkit = null;
+    private Form _form = null;
+    private TabFolder _tabFolder = null;
+    private Composite _composite = null;
+    private Composite _listComposite = null;
+    private Composite _buttonsComposite = null;
+    private Label _labelName = null;
+    private Label _labelDesc = null;
+    private Label _labelList = null;
+    
+    private org.eclipse.swt.widgets.List _list = null;
+    private Button _refreshButton = null;
+    private Button _addButton = null;
+    private Button _sortBySizeButton = null;
+    
+    private String _type = null;
+    
+    // maps an mbean name with the mbean object. Required to get mbean object when an mbean
+    // is to be added to the navigation view. 
+    private HashMap<String, ManagedBean> _objectsMap = new HashMap<String, ManagedBean>();
+    // Map required for sorting queues based on attribute values
+    private Map<AttributeData, ManagedBean> _queueMap = new LinkedHashMap<AttributeData, ManagedBean>();
+    
+    private Sorter _sorterByName = new Sorter();
+    private ComparatorImpl _sorterByQueueDepth = new ComparatorImpl();
+    
+    public MBeanTypeTabControl(TabFolder tabFolder)
+    {
+        _tabFolder = tabFolder;
+        _toolkit = new FormToolkit(_tabFolder.getDisplay());
+        _form = _toolkit.createForm(_tabFolder);
+        createWidgets();
+        addListeners();
+    }
+    
+    public Control getControl()
+    {
+        return _form;
+    }
+    
+    /**
+     * Adds listeners to all the buttons
+     */
+    private void addListeners()
+    {
+        _addButton.addSelectionListener(new SelectionAdapter(){
+            public void widgetSelected(SelectionEvent e)
+            {
+                if (_list.getSelectionCount() == 0)
+                    return;
+                
+                String[] selectedItems = _list.getSelection();
+                for (int i = 0; i < selectedItems.length; i++)
+                {
+                    String name = selectedItems[i];;
+                    if (Constants.QUEUE.equals(_type))
+                    {
+                        int endIndex = name.lastIndexOf("(");
+                        name = name.substring(0, endIndex -1);
+                    }
+                    // pass the ManagedBean to the navigation view to be added
+                    ManagedBean mbean = _objectsMap.get(name);
+                    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); 
+                    NavigationView view = (NavigationView)window.getActivePage().findView(NavigationView.ID);
+                    try
+                    {
+                        view.addManagedBean(mbean);
+                    }
+                    catch (Exception ex)
+                    {
+                        MBeanUtility.handleException(mbean, ex);
+                    }
+                }
+            }
+        });
+        
+        _refreshButton.addSelectionListener(new SelectionAdapter(){
+            public void widgetSelected(SelectionEvent e)
+            {
+                try
+                {
+                    refresh(_type);
+                }
+                catch (Exception ex)
+                {
+                    MBeanUtility.handleException(ex);
+                }
+            }
+        });
+        
+        _sortBySizeButton.addSelectionListener(new SelectionAdapter(){
+            public void widgetSelected(SelectionEvent e)
+            {
+                try
+                {
+                    sortQueueByQueueDepth();
+                }
+                catch (Exception ex)
+                {
+                    MBeanUtility.handleException(ex);
+                }
+            }
+        });
+    }
+    
+    private void createWidgets()
+    {
+        _form.getBody().setLayout(new GridLayout());
+        _composite = _toolkit.createComposite(_form.getBody(), SWT.NONE);
+        _composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        GridLayout layout = new GridLayout(2, true);
+        layout.verticalSpacing = 10;
+        layout.horizontalSpacing = 0;
+        _composite.setLayout(layout);
+        
+        _labelName = _toolkit.createLabel(_composite, "Type:", SWT.NONE);
+        GridData gridData = new GridData(SWT.CENTER, SWT.TOP, true, false, 2, 1);
+        _labelName.setLayoutData(gridData);
+        _labelName.setFont(ApplicationRegistry.getFont(Constants.FONT_BOLD));
+        
+        _labelDesc = _toolkit.createLabel(_composite, " ", SWT.NONE);
+        _labelDesc.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false, 2, 1));
+        _labelDesc.setFont(ApplicationRegistry.getFont(Constants.FONT_ITALIC));
+        
+        _addButton = _toolkit.createButton(_composite, "<- Add to Navigation", SWT.PUSH);
+        gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
+        _addButton.setLayoutData(gridData);
+        
+        _refreshButton = _toolkit.createButton(_composite, Constants.BUTTON_REFRESH, SWT.PUSH);
+        gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
+        gridData.widthHint = 80;
+        _refreshButton.setLayoutData(gridData);
+        
+        // Composite to contain the item list 
+        _listComposite = _toolkit.createComposite(_composite);
+        gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+        _listComposite.setLayoutData(gridData);
+        layout = new GridLayout();
+        layout.verticalSpacing = 0;
+        _listComposite.setLayout(layout);
+        
+        // Label for item name
+        _labelList = _toolkit.createLabel(_listComposite, " ", SWT.NONE);
+        _labelList.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
+        _labelList.setFont(ApplicationRegistry.getFont(Constants.FONT_NORMAL));
+        
+        _list = new List(_listComposite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+        gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+        _list.setLayoutData(gridData);
+        
+        
+        // Composite to contain buttons like - Sort by size
+        _buttonsComposite = _toolkit.createComposite(_composite);
+        gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+        _buttonsComposite.setLayoutData(gridData);
+        _buttonsComposite.setLayout(new GridLayout());
+        
+        _sortBySizeButton = _toolkit.createButton(_buttonsComposite, "Sort by Queue Depth", SWT.PUSH);
+        gridData = new GridData(SWT.CENTER, SWT.CENTER, true, false);
+        _sortBySizeButton.setLayoutData(gridData);
+        
+    }
+    
+    public void refresh(String typeName) throws Exception
+    {
+        _type = typeName;
+        setHeader();
+        populateList();
+        
+        _listComposite.layout();
+        _composite.layout();
+        _form.layout();
+    }
+    
+    private void setHeader()
+    {
+        _labelName.setText("Type : " + _type);        
+        _labelDesc.setText("Select the " + _type + "(s) to add in the Navigation View");
+        _labelList.setText("-- List of " + _type + "s --");
+    }
+    
+    /**
+     * populates the map with mbean name and the mbean object.
+     * @throws Exception
+     */
+    private void populateList() throws Exception
+    {
+        // map should be cleared before populating it with new values
+        _objectsMap.clear();
+        _queueMap.clear();
+        ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer());
+        String[] items = null;
+        java.util.List<ManagedBean> list = null;
+        
+        // populate the map and list with appropriate mbeans
+        if (_type.equals(Constants.QUEUE))
+        {
+            list = serverRegistry.getQueues();
+            items = getQueueItems(list);
+            _sortBySizeButton.setVisible(true);
+        }
+        else if (_type.equals(Constants.EXCHANGE))
+        {
+            list = serverRegistry.getExchanges();
+            items = getItems(list);
+            _sortBySizeButton.setVisible(false);
+        }
+        else if (_type.equals(Constants.CONNECTION))
+        {
+            list = serverRegistry.getConnections();
+            items = getItems(list);
+            _sortBySizeButton.setVisible(false);
+        }
+        else
+        {
+            throw new Exception("Unknown mbean type " + _type);
+        }
+        
+        _list.setItems(items);
+    }
+    
+    // sets the map with appropriate mbean and name
+    private String[] getItems(java.util.List<ManagedBean> list)
+    {
+        Collections.sort(list, _sorterByName);
+        String[] items = new String[list.size()];
+        int i = 0;
+        for (ManagedBean mbean : list)
+        {
+            items[i++] = mbean.getName();
+            _objectsMap.put(mbean.getName(), mbean);
+        }
+        return items;
+    }
+    
+    private String[] getQueueItems(java.util.List<ManagedBean> list) throws Exception
+    {
+        // Sort the list. It will keep the mbeans in sorted order in the _queueMap, which is required for
+        // sorting the queue according to size etc
+        Collections.sort(list, _sorterByName);
+        String[] items = new String[list.size()];
+        int i = 0;
+        for (ManagedBean mbean : list)
+        {
+            AttributeData data = MBeanUtility.getAttributeData(mbean, Constants.ATTRIBUTE_QUEUE_DEPTH);
+            String value = data.getValue().toString();
+            items[i] = mbean.getName() + " (" + value + " KB)";
+            _objectsMap.put(mbean.getName(), mbean);
+            _queueMap.put(data, mbean);
+            i++;
+        }
+        return items;
+    }
+    
+    private void sortQueueByQueueDepth() throws Exception
+    {
+        // Queues are already in the alphabetically sorted order in _queueMap, now sort for queueDepth
+        java.util.List<AttributeData> list = new ArrayList<AttributeData>(_queueMap.keySet());
+        Collections.sort(list, _sorterByQueueDepth);
+        
+        String[] items = new String[list.size()];
+        int i = 0;
+        for (AttributeData data : list)
+        {
+            ManagedBean mbean = _queueMap.get(data);
+            String value = data.getValue().toString();
+            items[i++] = mbean.getName() + " (" + value + " KB)";
+        }
+        _list.setItems(items);
+    }
+    
+    private class ComparatorImpl implements java.util.Comparator<AttributeData>
+    {
+        public int compare(AttributeData data1, AttributeData data2)
+        {
+            Integer int1 = Integer.parseInt(data1.getValue().toString());
+            Integer int2 = Integer.parseInt(data2.getValue().toString());
+            return int1.compareTo(int2) * -1;
+        }
+    }
+    
+    private class Sorter implements java.util.Comparator<ManagedBean>
+    {
+        public int compare(ManagedBean mbean1, ManagedBean mbean2)
+        {
+            return mbean1.getName().compareTo(mbean2.getName());
+        }
+    }
+}

Propchange: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java?view=diff&rev=493771&r1=493770&r2=493771
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java Sun Jan  7 09:03:17 2007
@@ -25,8 +25,9 @@
 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.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.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 @@
     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,89 @@
                 return;
 
             IStructuredSelection ss = (IStructuredSelection) sel;
-            TreeObject node = (TreeObject)ss.getFirstElement();
-            showSelectedMBean(node);
+            _selectedNode = (TreeObject)ss.getFirstElement();
+            
+            
+            // 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);
+            
+            // If a selected node(mbean) gets unregistered from mbena server, mbenaview should should 
+            // make the tabfolber for that mbean invisible
+            if (_selectedNode == null)            
+                return;
+            
+            setServer();
+            try
+            {
+                if (Constants.TYPE.equals(_selectedNode.getType()))
+                {
+                    refreshTypeTabFolder(_selectedNode.getName());
+                }
+                else if (Constants.DOMAIN.equals(_selectedNode.getType()))
+                {
+                    refreshTypeTabFolder(typeTabFolder.getItem(0));
+                }
+                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
+        {
+            TreeObject parent = _selectedNode.getParent();
+            while (parent != null && !parent.getType().equals(Constants.SERVER))
+            {
+                parent = parent.getParent();
+            }
+            
+            if (parent != null && parent.getType().equals(Constants.SERVER))
+                _server = (ManagedServer)parent.getManagedObject();
+        }
+    }
+    
+    public static ManagedServer getServer()
+    {
+        return _server;
+    }
+    
+    private void showSelectedMBean() throws Exception
+    {     
+        if (Constants.NOTIFICATION.equals(_selectedNode.getType()))
         {
-            _mbean = (ManagedBean)node.getParent().getManagedObject();                
+            _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 +191,17 @@
         }
         _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)
@@ -156,23 +214,38 @@
         
         // Add selection listener for selection events in the Navigation view
         getSite().getPage().addSelectionListener(NavigationView.ID, selectionListener); 
+        
+        // Add mbeantype TabFolder. This will list all the mbeans under a mbeantype (eg Queue, Exchange).
+        // Using this list mbeans will be added in the navigation view
+        createTypeTabFolder();
     }
     
-    public void refreshMBeanView()
+    public void refreshMBeanView() throws Exception
     {
+        int tabIndex = 0;
+        TabItem tab = null;
         if (_mbean == null)
-            return;
-        
-        TabFolder tabFolder = tabFolderMap.get(_mbean.getType());
-        if (tabFolder == null)
-            return;
-        
-        int index = tabFolder.getSelectionIndex();
-        TabItem tab = tabFolder.getItem(index);
-        if (tab == null)
-            return;
-                
-        refreshTab(tab);
+        {
+            tabIndex = typeTabFolder.getSelectionIndex();
+            if (tabIndex == -1)
+                return;
+
+            tab = typeTabFolder.getItem(tabIndex);
+            refreshTypeTabFolder(tab);
+        }
+        else
+        {
+            TabFolder tabFolder = tabFolderMap.get(_mbean.getType());
+            if (tabFolder == null)
+                return;
+
+            tabIndex = tabFolder.getSelectionIndex();
+            tab = tabFolder.getItem(tabIndex);
+            if (tab == null)
+                return;
+
+            refreshTab(tab);
+        }
         _form.layout();
     }
     
@@ -185,7 +258,6 @@
         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 +273,7 @@
             }
         });
         
-        tabFolderMap.put(_mbean.getType(), tabFolder);               
+        tabFolderMap.put(_mbean.getType(), tabFolder);
         return tabFolder;
     }
     
@@ -209,7 +281,7 @@
     {
         // 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 +290,7 @@
             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 +332,7 @@
     
     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 +342,12 @@
         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 +387,7 @@
            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 +409,85 @@
        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)
+        {
+            return;
+        }
+        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.
@@ -357,6 +509,11 @@
         for (TabFolder folder : tabFolderMap.values())
         {
             folder.setVisible(false);
+        }
+        
+        if (typeTabFolder != null)
+        {
+            typeTabFolder.setVisible(false);
         }
     }
     



Mime
View raw message