qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgr...@apache.org
Subject svn commit: r523245 - in /incubator/qpid/branches/M2/java: broker/src/main/java/org/apache/log4j/ integrationtests/src/main/java/org/apache/qpid/util/ management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/
Date Wed, 28 Mar 2007 09:30:51 GMT
Author: rgreig
Date: Wed Mar 28 02:30:49 2007
New Revision: 523245

URL: http://svn.apache.org/viewvc?view=rev&rev=523245
Log:
Reversed accidental replacing of the word 'initialize' in comments to 'establishConnection' through a method refactoring.

Modified:
    incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java
    incubator/qpid/branches/M2/java/integrationtests/src/main/java/org/apache/qpid/util/ClasspathScanner.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java

Modified: incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java?view=diff&rev=523245&r1=523244&r2=523245
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java (original)
+++ incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java Wed Mar 28 02:30:49 2007
@@ -1,44 +1,45 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
  *
- *    http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.log4j;
 
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.helpers.CountingQuietWriter;
-import org.apache.log4j.helpers.LogLog;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.qpid.framing.FieldTable;
-
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.Writer;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.zip.GZIPOutputStream;
-import java.text.SimpleDateFormat;
-import java.io.IOException;
-import java.io.Writer;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
+
+import org.apache.log4j.helpers.CountingQuietWriter;
+import org.apache.log4j.helpers.LogLog;
+import org.apache.log4j.helpers.OptionConverter;
+import org.apache.log4j.spi.LoggingEvent;
+
+import org.apache.qpid.framing.FieldTable;
 
 /**
  * <p>CompositeRollingAppender combines RollingFileAppender and DailyRollingFileAppender<br> It can function as either
@@ -83,7 +84,7 @@
     static final int BY_DATE = 2;
     static final int BY_COMPOSITE = 3;
 
-    //Not currently used
+    // Not currently used
     static final String S_BY_SIZE = "Size";
     static final String S_BY_DATE = "Date";
     static final String S_BY_COMPOSITE = "Composite";
@@ -146,7 +147,6 @@
     /** FileName provided in configuration.  Used for rolling properly */
     protected String baseFileName;
 
-
     /** Do we want to .gz our backup files. */
     protected boolean compress = false;
 
@@ -163,15 +163,13 @@
 
     /** The default constructor does nothing. */
     public QpidCompositeRollingAppender()
-    {
-    }
+    { }
 
     /**
      * Instantiate a <code>CompositeRollingAppender</code> and open the file designated by <code>filename</code>. The
      * opened filename will become the ouput destination for this appender.
      */
-    public QpidCompositeRollingAppender(Layout layout, String filename,
-                                        String datePattern) throws IOException
+    public QpidCompositeRollingAppender(Layout layout, String filename, String datePattern) throws IOException
     {
         this(layout, filename, datePattern, true);
     }
@@ -183,8 +181,7 @@
      * <p>If the <code>append</code> parameter is true, the file will be appended to. Otherwise, the file desginated by
      * <code>filename</code> will be truncated before being opened.
      */
-    public QpidCompositeRollingAppender(Layout layout, String filename, boolean append)
-            throws IOException
+    public QpidCompositeRollingAppender(Layout layout, String filename, boolean append) throws IOException
     {
         super(layout, filename, append);
     }
@@ -193,8 +190,8 @@
      * Instantiate a CompositeRollingAppender and open the file designated by <code>filename</code>. The opened filename
      * will become the ouput destination for this appender.
      */
-    public QpidCompositeRollingAppender(Layout layout, String filename,
-                                        String datePattern, boolean append) throws IOException
+    public QpidCompositeRollingAppender(Layout layout, String filename, String datePattern, boolean append)
+        throws IOException
     {
         super(layout, filename, append);
         this.datePattern = datePattern;
@@ -305,7 +302,7 @@
         qw = new CountingQuietWriter(writer, errorHandler);
     }
 
-    //Taken verbatum from DailyRollingFileAppender
+    // Taken verbatum from DailyRollingFileAppender
     int computeCheckPeriod()
     {
         RollingCalendar c = new RollingCalendar();
@@ -319,17 +316,18 @@
                 c.setType(i);
                 Date next = new Date(c.getNextCheckMillis(epoch));
                 String r1 = sdf.format(next);
-                //LogLog.debug("Type = "+i+", r0 = "+r0+", r1 = "+r1);
-                if (r0 != null && r1 != null && !r0.equals(r1))
+                // LogLog.debug("Type = "+i+", r0 = "+r0+", r1 = "+r1);
+                if ((r0 != null) && (r1 != null) && !r0.equals(r1))
                 {
                     return i;
                 }
             }
         }
+
         return TOP_OF_TROUBLE; // Deliberately head for trouble...
     }
 
-    //Now for the new stuff
+    // Now for the new stuff
     /**
      * Handles append time behavior for CompositeRollingAppender.  This checks if a roll over either by date (checked
      * first) or time (checked second) is need and then appends to the file last.
@@ -351,7 +349,7 @@
 
         if (rollSize)
         {
-            if ((fileName != null) && ((CountingQuietWriter) qw).getCount() >= maxFileSize)
+            if ((fileName != null) && (((CountingQuietWriter) qw).getCount() >= maxFileSize))
             {
                 rollOverSize();
             }
@@ -410,20 +408,24 @@
         rollingStyle = style;
         switch (rollingStyle)
         {
-            case BY_SIZE:
-                rollDate = false;
-                rollSize = true;
-                break;
-            case BY_DATE:
-                rollDate = true;
-                rollSize = false;
-                break;
-            case BY_COMPOSITE:
-                rollDate = true;
-                rollSize = true;
-                break;
-            default:
-                errorHandler.error("Invalid rolling Style, use 1 (by size only), 2 (by date only) or 3 (both)");
+
+        case BY_SIZE:
+            rollDate = false;
+            rollSize = true;
+            break;
+
+        case BY_DATE:
+            rollDate = true;
+            rollSize = false;
+            break;
+
+        case BY_COMPOSITE:
+            rollDate = true;
+            rollSize = true;
+            break;
+
+        default:
+            errorHandler.error("Invalid rolling Style, use 1 (by size only), 2 (by date only) or 3 (both)");
         }
     }
 
@@ -439,7 +441,7 @@
                 rollingStyle = BY_COMPOSITE;
             }
         }
-    */
+     */
     public boolean getStaticLogFileName()
     {
         return staticLogFileName;
@@ -477,11 +479,10 @@
         {
             executor = Executors.newFixedThreadPool(1);
 
-            compressor = new Compressor();            
+            compressor = new Compressor();
         }
     }
 
-
     public boolean getZeroBased()
     {
         return zeroBased;
@@ -504,6 +505,7 @@
         {
             td.mkdirs();
         }
+
         backupFilesToPath = path;
     }
 
@@ -519,9 +521,10 @@
         {
             curSizeRollBackups = -1;
         }
+
         curTimeRollBackups = 0;
 
-        //part A starts here
+        // part A starts here
         String filter;
         if (staticLogFileName || !rollDate)
         {
@@ -556,9 +559,9 @@
                 if (staticLogFileName)
                 {
                     int endLength = files[i].length() - index;
-                    if (baseFileName.length() + endLength != files[i].length())
+                    if ((baseFileName.length() + endLength) != files[i].length())
                     {
-                        //file is probably scheduledFilename + .x so I don't care
+                        // file is probably scheduledFilename + .x so I don't care
                         continue;
                     }
                 }
@@ -574,18 +577,19 @@
                 }
                 catch (Exception e)
                 {
-                    //this happens when file.log -> file.log.yyyy-mm-dd which is normal
-                    //when staticLogFileName == false
+                    // this happens when file.log -> file.log.yyyy-mm-dd which is normal
+                    // when staticLogFileName == false
                     LogLog.debug("Encountered a backup file not ending in .x " + files[i]);
                 }
             }
         }
+
         LogLog.debug("curSizeRollBackups starts at: " + curSizeRollBackups);
-        //part A ends here
+        // part A ends here
 
-        //part B not yet implemented
+        // part B not yet implemented
 
-        //part C
+        // part C
         if (staticLogFileName && rollDate)
         {
             File old = new File(baseFileName);
@@ -600,41 +604,41 @@
                 }
             }
         }
+
         LogLog.debug("curSizeRollBackups after rollOver at: " + curSizeRollBackups);
-        //part C ends here
+        // part C ends here
 
     }
 
     /**
      * Sets initial conditions including date/time roll over information, first check, scheduledFilename, and calls
-     * <code>existingInit</code> to establishConnection the current # of backups.
+     * <code>existingInit</code> to initialize the current # of backups.
      */
     public void activateOptions()
     {
 
-        //REMOVE removed rollDate from boolean to enable Alex's change
+        // REMOVE removed rollDate from boolean to enable Alex's change
         if (datePattern != null)
         {
             now.setTime(System.currentTimeMillis());
             sdf = new SimpleDateFormat(datePattern);
             int type = computeCheckPeriod();
-            //printPeriodicity(type);
+            // printPeriodicity(type);
             rc.setType(type);
-            //next line added as this removes the name check in rollOver
+            // next line added as this removes the name check in rollOver
             nextCheck = rc.getNextCheckMillis(now);
         }
         else
         {
             if (rollDate)
             {
-                LogLog.error("Either DatePattern or rollingStyle options are not set for [" +
-                             name + "].");
+                LogLog.error("Either DatePattern or rollingStyle options are not set for [" + name + "].");
             }
         }
 
         existingInit();
 
-        if (rollDate && fileName != null && scheduledFilename == null)
+        if (rollDate && (fileName != null) && (scheduledFilename == null))
         {
             scheduledFilename = fileName + sdf.format(now);
         }
@@ -662,7 +666,7 @@
 
         this.closeFile(); // keep windows happy.
 
-        //delete the old stuff here
+        // delete the old stuff here
 
         if (staticLogFileName)
         {
@@ -670,23 +674,25 @@
             if (datePattern == null)
             {
                 errorHandler.error("Missing DatePattern option in rollOver().");
+
                 return;
             }
 
-            //is the new file name equivalent to the 'current' one
-            //something has gone wrong if we hit this -- we should only
-            //roll over if the new file will be different from the old
+            // is the new file name equivalent to the 'current' one
+            // something has gone wrong if we hit this -- we should only
+            // roll over if the new file will be different from the old
             String dateFormat = sdf.format(now);
             if (scheduledFilename.equals(fileName + dateFormat))
             {
                 errorHandler.error("Compare " + scheduledFilename + " : " + fileName + dateFormat);
+
                 return;
             }
 
             // close current file, and rename it to datedFilename
             this.closeFile();
 
-            //we may have to roll over a large number of backups here
+            // we may have to roll over a large number of backups here
             String from, to;
             for (int i = 1; i <= curSizeRollBackups; i++)
             {
@@ -709,9 +715,9 @@
         {
             // This will also close the file. This is OK since multiple
             // close operations are safe.
-            curSizeRollBackups = 0; //We're cleared out the old date and are ready for the new
+            curSizeRollBackups = 0; // We're cleared out the old date and are ready for the new
 
-            //new scheduled name
+            // new scheduled name
             scheduledFilename = fileName + sdf.format(now);
             this.setFile(baseFileName, false);
         }
@@ -734,8 +740,10 @@
             {
                 LogLog.debug("Attempting to compress file with same output name.");
             }
+
             return;
         }
+
         File target = new File(to);
         if (target.exists())
         {
@@ -755,10 +763,10 @@
                 file.renameTo(target);
             }
         }
+
         LogLog.debug(from + " -> " + to);
     }
 
-
     protected void compress(String file)
     {
         File f = new File(file);
@@ -773,6 +781,7 @@
             {
                 _compress.offer(new CompressJob(from, target));
             }
+
             startCompression();
         }
         else
@@ -805,7 +814,7 @@
      * <p>If the maximum number of size based backups is reached (<code>curSizeRollBackups == maxSizeRollBackups</code)
      * then the oldest file is deleted -- it's index determined by the sign of countDirection.<br> If
      * <code>countDirection</code> < 0, then files {<code>File.1</code>, ..., <code>File.curSizeRollBackups -1</code>}
-     * are renamed to {<code>File.2</code>, ..., <code>File.curSizeRollBackups</code>}.	 Moreover, <code>File</code> is
+     * are renamed to {<code>File.2</code>, ..., <code>File.curSizeRollBackups</code>}.  Moreover, <code>File</code> is
      * renamed <code>File.1</code> and closed.<br>
      *
      * A new file is created to receive further log output.
@@ -851,20 +860,20 @@
                 // Rename fileName to fileName.1
                 rollFile(fileName, fileName + ".1", compress);
 
-            } //REMOVE This code branching for Alexander Cerna's request
+            } // REMOVE This code branching for Alexander Cerna's request
             else if (countDirection == 0)
             {
-                //rollFile based on date pattern
+                // rollFile based on date pattern
                 curSizeRollBackups++;
                 now.setTime(System.currentTimeMillis());
                 scheduledFilename = fileName + sdf.format(now);
                 rollFile(fileName, scheduledFilename, compress);
             }
             else
-            { //countDirection > 0
-                if (curSizeRollBackups >= maxSizeRollBackups && maxSizeRollBackups > 0)
+            { // countDirection > 0
+                if ((curSizeRollBackups >= maxSizeRollBackups) && (maxSizeRollBackups > 0))
                 {
-                    //delete the first and keep counting up.
+                    // delete the first and keep counting up.
                     int oldestFileIndex = curSizeRollBackups - maxSizeRollBackups + 1;
                     deleteFile(fileName + '.' + oldestFileIndex);
                 }
@@ -930,6 +939,7 @@
             {
                 out.write(buf, 0, len);
             }
+
             in.close();
 
             // Complete the GZIP file
@@ -944,6 +954,7 @@
             {
                 target.delete();
             }
+
             rollFile(from.getPath(), to.getPath(), false);
         }
     }

Modified: incubator/qpid/branches/M2/java/integrationtests/src/main/java/org/apache/qpid/util/ClasspathScanner.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/integrationtests/src/main/java/org/apache/qpid/util/ClasspathScanner.java?view=diff&rev=523245&r1=523244&r2=523245
==============================================================================
--- incubator/qpid/branches/M2/java/integrationtests/src/main/java/org/apache/qpid/util/ClasspathScanner.java (original)
+++ incubator/qpid/branches/M2/java/integrationtests/src/main/java/org/apache/qpid/util/ClasspathScanner.java Wed Mar 28 02:30:49 2007
@@ -33,7 +33,7 @@
  *
  * <p/>In order to test whether a class implements an interface or extends a class, the class must be loaded (unless
  * the class files were to be scanned directly). Using this collector can cause problems when it scans the classpath,
- * because loading classes will establishConnection their statics, which in turn may cause undesired side effects. For this
+ * because loading classes will initialize their statics, which in turn may cause undesired side effects. For this
  * reason, the collector should always be used with a regular expression, through which the class file names are
  * filtered, and only those that pass this filter will be tested. For example, if you define tests in classes that
  * end with the keyword "Test" then use the regular expression "Test$" to match this.
@@ -61,10 +61,10 @@
      * @return All the classes that match this collector.
      */
     public static <T> Collection<Class<? extends T>> getMatches(Class<T> matchingClass, String matchingRegexp,
-                                                                boolean beanOnly)
+        boolean beanOnly)
     {
         log.debug("public static <T> Collection<Class<? extends T>> getMatches(Class<T> matchingClass = " + matchingClass
-                  + ", String matchingRegexp = " + matchingRegexp + ", boolean beanOnly = " + beanOnly + "): called");
+            + ", String matchingRegexp = " + matchingRegexp + ", boolean beanOnly = " + beanOnly + "): called");
 
         // Build a compiled regular expression from the pattern to match.
         Pattern matchPattern = Pattern.compile(matchingRegexp);
@@ -95,11 +95,11 @@
      *       iteration.
      */
     private static <T> void gatherFiles(File classRoot, String classFileName, Map<String, Class<? extends T>> result,
-                                        Pattern matchPattern, Class<? extends T> matchClass)
+        Pattern matchPattern, Class<? extends T> matchClass)
     {
         log.debug("private static <T> void gatherFiles(File classRoot = " + classRoot + ", String classFileName = "
-                  + classFileName + ", Map<String, Class<? extends T>> result, Pattern matchPattern = " + matchPattern
-                  + ", Class<? extends T> matchClass = " + matchClass + "): called");
+            + classFileName + ", Map<String, Class<? extends T>> result, Pattern matchPattern = " + matchPattern
+            + ", Class<? extends T> matchClass = " + matchClass + "): called");
 
         File thisRoot = new File(classRoot, classFileName);
 

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java?view=diff&rev=523245&r1=523244&r2=523245
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java Wed Mar 28 02:30:49 2007
@@ -7,9 +7,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -20,8 +20,6 @@
  */
 package org.apache.qpid.management.ui.views;
 
-import static org.apache.qpid.management.ui.Constants.*;
-
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -29,12 +27,14 @@
 import java.util.List;
 
 import org.apache.qpid.management.ui.ApplicationRegistry;
+import static 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.eclipse.jface.preference.PreferenceStore;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -48,6 +48,7 @@
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerSorter;
+
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.Image;
@@ -62,6 +63,7 @@
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Tree;
 import org.eclipse.swt.widgets.TreeItem;
+
 import org.eclipse.ui.part.ViewPart;
 
 /**
@@ -71,29 +73,29 @@
  */
 public class NavigationView extends ViewPart
 {
-	public static final String ID = "org.apache.qpid.management.ui.navigationView";    
+    public static final String ID = "org.apache.qpid.management.ui.navigationView";
     public static final String INI_FILENAME = System.getProperty("user.home") + File.separator + "qpidManagementConsole.ini";
-    
+
     private static final String INI_SERVERS = "Servers";
     private static final String INI_QUEUES = QUEUE + "s";
     private static final String INI_CONNECTIONS = CONNECTION + "s";
     private static final String INI_EXCHANGES = EXCHANGE + "s";
-    
+
     private TreeViewer _treeViewer = null;
     private TreeObject _rootNode = null;
     private TreeObject _serversRootNode = null;
-    
+
     private PreferenceStore _preferences;
     // Map of connected servers
     private HashMap<ManagedServer, TreeObject> _managedServerMap = new HashMap<ManagedServer, TreeObject>();
-    
+
     private void createTreeViewer(Composite parent)
     {
         _treeViewer = new TreeViewer(parent);
         _treeViewer.setContentProvider(new ContentProviderImpl());
-        _treeViewer.setLabelProvider(new LabelProviderImpl());        
+        _treeViewer.setLabelProvider(new LabelProviderImpl());
         _treeViewer.setSorter(new ViewerSorterImpl());
-        
+
         // layout the tree viewer below the label field, to cover the area
         GridData layoutData = new GridData();
         layoutData = new GridData();
@@ -103,118 +105,124 @@
         layoutData.verticalAlignment = GridData.FILL;
         _treeViewer.getControl().setLayoutData(layoutData);
         _treeViewer.setUseHashlookup(true);
-        
+
         createListeners();
     }
-    
+
     /**
      * Creates listeners for the JFace treeviewer
      */
     private void createListeners()
     {
-        _treeViewer.addDoubleClickListener(new IDoubleClickListener() {
+        _treeViewer.addDoubleClickListener(new IDoubleClickListener()
+            {
                 public void doubleClick(DoubleClickEvent event)
                 {
-                    IStructuredSelection ss = (IStructuredSelection)event.getSelection();
-                    if (ss == null || ss.getFirstElement() == null)
+                    IStructuredSelection ss = (IStructuredSelection) event.getSelection();
+                    if ((ss == null) || (ss.getFirstElement() == null))
                     {
                         return;
                     }
+
                     boolean state = _treeViewer.getExpandedState(ss.getFirstElement());
                     _treeViewer.setExpandedState(ss.getFirstElement(), !state);
                 }
             });
-        
-        _treeViewer.addTreeListener(new ITreeViewerListener() {
-            public void treeExpanded(TreeExpansionEvent event)
-            {
-                _treeViewer.setExpandedState(event.getElement(), true);
-                // Following will cause the selection event to be sent, so commented
-                //_treeViewer.setSelection(new StructuredSelection(event.getElement()));
-                _treeViewer.refresh();
-            }
 
-            public void treeCollapsed(TreeExpansionEvent event)
+        _treeViewer.addTreeListener(new ITreeViewerListener()
             {
-                _treeViewer.setExpandedState(event.getElement(), false);
-                _treeViewer.refresh();
-            }
-        });
-        
+                public void treeExpanded(TreeExpansionEvent event)
+                {
+                    _treeViewer.setExpandedState(event.getElement(), true);
+                    // Following will cause the selection event to be sent, so commented
+                    // _treeViewer.setSelection(new StructuredSelection(event.getElement()));
+                    _treeViewer.refresh();
+                }
+
+                public void treeCollapsed(TreeExpansionEvent event)
+                {
+                    _treeViewer.setExpandedState(event.getElement(), false);
+                    _treeViewer.refresh();
+                }
+            });
+
         // This listener is for popup menu, which pops up if a queue,exchange or connection is selected
         // with right click.
-        _treeViewer.getTree().addListener(SWT.MenuDetect, new Listener () {
-            Display display = getSite().getShell().getDisplay();
-            final Shell shell = new Shell (display);
-            
-            public void handleEvent(Event event)
-            {
-                Tree widget = (Tree)event.widget;
-                TreeItem[] items = widget.getSelection();
-                if (items == null) return;
-                
-                // Get the selected node
-                final TreeObject selectedNode = (TreeObject)items[0].getData();
-                final TreeObject parentNode = selectedNode.getParent();
-                
-                // This popup is only for mbeans and only connection,exchange and queue types
-                if (parentNode == null ||
-                    !MBEAN.equals(selectedNode.getType()) ||
-                    !(CONNECTION.equals(parentNode.getName()) ||
-                      QUEUE.equals(parentNode.getName()) ||
-                      EXCHANGE.equals(parentNode.getName()))
-                     )
+        _treeViewer.getTree().addListener(SWT.MenuDetect, new Listener()
+            {
+                Display display = getSite().getShell().getDisplay();
+                final Shell shell = new Shell(display);
+
+                public void handleEvent(Event event)
                 {
-                    return;
-                }
-                
-                Menu menu = new Menu (shell, SWT.POP_UP);
-                MenuItem item = new MenuItem (menu, SWT.PUSH);
-                // Add the action item, which will remove the node from the tree if selected
-                item.setText(ACTION_REMOVE_MBEANNODE);
-                item.addListener (SWT.Selection, new Listener () {
-                    public void handleEvent (Event e)
+                    Tree widget = (Tree) event.widget;
+                    TreeItem[] items = widget.getSelection();
+                    if (items == null)
                     {
-                        removeManagedObject(parentNode, (ManagedBean)selectedNode.getManagedObject());
-                        _treeViewer.refresh();
-                        // set the selection to the parent node
-                        _treeViewer.setSelection(new StructuredSelection(parentNode));
+                        return;
                     }
-                });
-                menu.setLocation (event.x, event.y);
-                menu.setVisible (true);
-                while (!menu.isDisposed () && menu.isVisible ())
-                {
-                    if (!display.readAndDispatch ())
+
+                    // Get the selected node
+                    final TreeObject selectedNode = (TreeObject) items[0].getData();
+                    final TreeObject parentNode = selectedNode.getParent();
+
+                    // This popup is only for mbeans and only connection,exchange and queue types
+                    if ((parentNode == null) || !MBEAN.equals(selectedNode.getType())
+                            || !(CONNECTION.equals(parentNode.getName()) || QUEUE.equals(parentNode.getName())
+                                || EXCHANGE.equals(parentNode.getName())))
                     {
-                        display.sleep ();
+                        return;
                     }
+
+                    Menu menu = new Menu(shell, SWT.POP_UP);
+                    MenuItem item = new MenuItem(menu, SWT.PUSH);
+                    // Add the action item, which will remove the node from the tree if selected
+                    item.setText(ACTION_REMOVE_MBEANNODE);
+                    item.addListener(SWT.Selection, new Listener()
+                        {
+                            public void handleEvent(Event e)
+                            {
+                                removeManagedObject(parentNode, (ManagedBean) selectedNode.getManagedObject());
+                                _treeViewer.refresh();
+                                // set the selection to the parent node
+                                _treeViewer.setSelection(new StructuredSelection(parentNode));
+                            }
+                        });
+                    menu.setLocation(event.x, event.y);
+                    menu.setVisible(true);
+                    while (!menu.isDisposed() && menu.isVisible())
+                    {
+                        if (!display.readAndDispatch())
+                        {
+                            display.sleep();
+                        }
+                    }
+
+                    menu.dispose();
                 }
-                menu.dispose ();
-            }
-        });
-    }   
-    
+            });
+    }
+
     /**
      * Creates Qpid Server connection using JMX RMI protocol
      * @param server
      * @throws Exception
      */
     private void createRMIServerConnection(ManagedServer server) throws Exception
-    {     
+    {
         try
         {
             // Currently Qpid Management Console only supports JMX MBeanServer
-            ServerRegistry serverRegistry = new JMXServerRegistry(server);  
-            ApplicationRegistry.addServer(server, serverRegistry);         
+            ServerRegistry serverRegistry = new JMXServerRegistry(server);
+            ApplicationRegistry.addServer(server, serverRegistry);
         }
-        catch(Exception ex)
+        catch (Exception ex)
         {
             ex.printStackTrace();
             throw new Exception("Error in connecting to Qpid broker at " + server.getUrl(), ex);
         }
     }
-    
+
     /**
      * Adds a new server node in the navigation view if server connection is successful.
      * @param transportProtocol
@@ -223,15 +231,15 @@
      * @param domain
      * @throws Exception
      */
-    public void addNewServer(String transportProtocol, String host, int port,
-                             String domain, String user, String pwd) throws Exception
+    public void addNewServer(String transportProtocol, String host, int port, String domain, String user, String pwd)
+        throws Exception
     {
         String serverAddress = host + ":" + port;
         String url = null;
         ManagedServer managedServer = new ManagedServer(host, port, domain, user, pwd);
-        
+
         if ("RMI".equals(transportProtocol))
-        {            
+        {
             url = managedServer.getUrl();
             List<TreeObject> list = _serversRootNode.getChildren();
             for (TreeObject node : list)
@@ -242,10 +250,11 @@
                     // Set the server node as selected and then connect it.
                     _treeViewer.setSelection(new StructuredSelection(node));
                     reconnect(user, pwd);
+
                     return;
                 }
             }
-            
+
             // The server is not in the list of already added servers, so now connect and add it.
             managedServer.setName(serverAddress);
             createRMIServerConnection(managedServer);
@@ -254,28 +263,28 @@
         {
             throw new InfoRequiredException(transportProtocol + " transport is not supported");
         }
-        
+
         // Server connection is successful. Now add the server in the tree
         TreeObject serverNode = new TreeObject(serverAddress, NODE_TYPE_SERVER);
         serverNode.setUrl(url);
         serverNode.setManagedObject(managedServer);
         _serversRootNode.addChild(serverNode);
-        
+
         // Add server in the connected server map
         _managedServerMap.put(managedServer, serverNode);
-        
+
         // populate the server tree
-        populateServer(serverNode); 
-        
+        populateServer(serverNode);
+
         // Add the Queue/Exchanges/Connections from config file into the navigation tree
         addConfiguredItems(managedServer);
-        
+
         _treeViewer.refresh();
-        
-        // save server address in file            
+
+        // save server address in file
         addServerInConfigFile(serverAddress);
     }
-    
+
     /**
      * Create the config file, if it doesn't already exist.
      * Exits the application if the file could not be created.
@@ -290,29 +299,29 @@
                 file.createNewFile();
             }
         }
-        catch(IOException ex)
+        catch (IOException ex)
         {
             System.out.println("Could not write to the file " + INI_FILENAME);
             System.out.println(ex);
             System.exit(1);
         }
     }
-    
+
     /**
      * Server addresses are stored in a file. When user launches the application again, the
      * server addresses are picked up from the file and shown in the navigfation view. This method
-     * adds the server address in a file, when a new server is added in the navigation view. 
+     * adds the server address in a file, when a new server is added in the navigation view.
      * @param serverAddress
      */
     private void addServerInConfigFile(String serverAddress)
     {
         // Check if the address already exists
         List<String> list = getServerListFromFile();
-        if (list != null && list.contains(serverAddress))
+        if ((list != null) && list.contains(serverAddress))
         {
             return;
         }
-        
+
         // Get the existing server list and add to that
         String servers = _preferences.getString(INI_SERVERS);
         String value = (servers.length() != 0) ? (servers + "," + serverAddress) : serverAddress;
@@ -321,12 +330,12 @@
         {
             _preferences.save();
         }
-        catch(IOException ex)
+        catch (IOException ex)
         {
             System.err.println("Could not add " + serverAddress + " in " + INI_SERVERS + " (" + INI_FILENAME + ")");
             System.out.println(ex);
         }
-    }  
+    }
 
     /**
      * Adds the item (Queue/Exchange/Connection) to the config file
@@ -337,20 +346,20 @@
      */
     private void addItemInConfigFile(TreeObject node)
     {
-        ManagedBean mbean = (ManagedBean)node.getManagedObject();
+        ManagedBean mbean = (ManagedBean) node.getManagedObject();
         String server = mbean.getServer().getName();
         String virtualhost = mbean.getVirtualHostName();
         String type = node.getParent().getName() + "s";
         String name = node.getName();
         String itemKey = server + "." + virtualhost + "." + type;
-        
+
         // Check if the item already exists in the config file
         List<String> list = getConfiguredItemsFromFile(itemKey);
-        if (list != null && list.contains(name))
+        if ((list != null) && list.contains(name))
         {
             return;
         }
-        
+
         // Add this item to the existing list of items
         String items = _preferences.getString(itemKey);
         String value = (items.length() != 0) ? (items + "," + name) : name;
@@ -359,21 +368,21 @@
         {
             _preferences.save();
         }
-        catch(IOException ex)
+        catch (IOException ex)
         {
             System.err.println("Could not add " + name + " in " + itemKey + " (" + INI_FILENAME + ")");
             System.out.println(ex);
         }
     }
-    
+
     private void removeItemFromConfigFile(TreeObject node)
     {
-        ManagedBean mbean = (ManagedBean)node.getManagedObject();
+        ManagedBean mbean = (ManagedBean) node.getManagedObject();
         String server = mbean.getServer().getName();
         String vHost = mbean.getVirtualHostName();
         String type = node.getParent().getName() + "s";
         String itemKey = server + "." + vHost + "." + type;
-        
+
         List<String> list = getConfiguredItemsFromFile(itemKey);
         if (list.contains(node.getName()))
         {
@@ -383,29 +392,30 @@
             {
                 value += item + ",";
             }
+
             value = (value.lastIndexOf(",") != -1) ? value.substring(0, value.lastIndexOf(",")) : value;
-            
+
             _preferences.putValue(itemKey, value);
             try
             {
                 _preferences.save();
             }
-            catch(IOException ex)
+            catch (IOException ex)
             {
-                System.err.println("Error in updating the config file "+ INI_FILENAME);
+                System.err.println("Error in updating the config file " + INI_FILENAME);
                 System.out.println(ex);
             }
         }
     }
 
     /**
-     * Queries the qpid server for MBeans and populates the navigation view with all MBeans for 
+     * Queries the qpid server for MBeans and populates the navigation view with all MBeans for
      * the given server node.
      * @param serverNode
      */
     private void populateServer(TreeObject serverNode)
     {
-        ManagedServer server = (ManagedServer)serverNode.getManagedObject();
+        ManagedServer server = (ManagedServer) serverNode.getManagedObject();
         String domain = server.getDomain();
         try
         {
@@ -414,29 +424,30 @@
                 TreeObject domainNode = new TreeObject(domain, NODE_TYPE_DOMAIN);
                 domainNode.setParent(serverNode);
 
-                populateDomain(domainNode); 
+                populateDomain(domainNode);
             }
             else
             {
                 List<TreeObject> domainList = new ArrayList<TreeObject>();
-                List<String> domains = MBeanUtility.getAllDomains(server);;           
+                List<String> domains = MBeanUtility.getAllDomains(server);
+                ;
                 for (String domainName : domains)
-                {       
+                {
                     TreeObject domainNode = new TreeObject(domainName, NODE_TYPE_DOMAIN);
                     domainNode.setParent(serverNode);
 
                     domainList.add(domainNode);
-                    populateDomain(domainNode);               
+                    populateDomain(domainNode);
                 }
             }
         }
-        catch(Exception ex)
+        catch (Exception ex)
         {
             System.out.println("\nError in connecting to Qpid broker ");
             ex.printStackTrace();
         }
     }
-    
+
     /**
      * Queries the Qpid Server and populates the given domain node with all MBeans undser that domain.
      * @param domain
@@ -446,19 +457,19 @@
     @SuppressWarnings("unchecked")
     private void populateDomain(TreeObject domain) throws IOException, Exception
     {
-        ManagedServer server = (ManagedServer)domain.getParent().getManagedObject();
-        
+        ManagedServer server = (ManagedServer) domain.getParent().getManagedObject();
+
         // Now populate the mbenas under those types
         List<ManagedBean> mbeans = MBeanUtility.getManagedObjectsForDomain(server, domain.getName());
         for (ManagedBean mbean : mbeans)
         {
             mbean.setServer(server);
             ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(server);
-            serverRegistry.addManagedObject(mbean);     
-            
+            serverRegistry.addManagedObject(mbean);
+
             // Add all mbeans other than Connections, Exchanges and Queues. Because these will be added
-            // manually by selecting from MBeanView           
-            if (!(mbean.isConnection() || mbean.isExchange() || mbean.isQueue()) )
+            // manually by selecting from MBeanView
+            if (!(mbean.isConnection() || mbean.isExchange() || mbean.isQueue()))
             {
                 addManagedBean(domain, mbean);
             }
@@ -471,10 +482,11 @@
             {
                 addDefaultNodes(domain);
             }
+
             break;
         }
     }
-    
+
     /**
      * Add these three types - Connection, Exchange, Queue
      * By adding these, these will always be available, even if there are no mbeans under thse types
@@ -493,7 +505,7 @@
         typeChild.setParent(parent);
         typeChild.setVirtualHost(parent.getVirtualHost());
     }
-    
+
     /**
      * Checks if a particular mbeantype is already there in the navigation view for a domain.
      * This is used while populating domain with mbeans.
@@ -506,24 +518,30 @@
         List<TreeObject> childNodes = parent.getChildren();
         for (TreeObject child : childNodes)
         {
-            if ((NODE_TYPE_MBEANTYPE.equals(child.getType()) || NODE_TYPE_TYPEINSTANCE.equals(child.getType())) &&
-                 typeName.equals(child.getName()))
+            if ((NODE_TYPE_MBEANTYPE.equals(child.getType()) || NODE_TYPE_TYPEINSTANCE.equals(child.getType()))
+                    && typeName.equals(child.getName()))
+            {
                 return child;
+            }
         }
+
         return null;
     }
-    
+
     private boolean doesMBeanNodeAlreadyExist(TreeObject typeNode, String mbeanName)
     {
         List<TreeObject> childNodes = typeNode.getChildren();
         for (TreeObject child : childNodes)
         {
             if (MBEAN.equals(child.getType()) && mbeanName.equals(child.getName()))
+            {
                 return true;
+            }
         }
+
         return false;
     }
-    
+
     /**
      * Adds the given MBean to the given domain node. Creates Notification node for the MBean.
      * sample ObjectNames -
@@ -533,18 +551,18 @@
      * @param mbean
      * @throws Exception
      */
-    private void addManagedBean(TreeObject domain, ManagedBean mbean)// throws Exception
+    private void addManagedBean(TreeObject domain, ManagedBean mbean) // throws Exception
     {
         String name = mbean.getName();
         // Split the mbean type into array of Strings, to create hierarchy
         // eg. type=VirtualHost.VirtualHostManager,VirtualHost=localhost will be:
-        //     localhost->VirtualHostManager 
+        // localhost->VirtualHostManager
         // eg. type=org.apache.qpid:type=VirtualHost.Queue,VirtualHost=test,name=ping will be:
-        //     test->Queue->ping
+        // test->Queue->ping
         String[] types = mbean.getType().split("\\.");
         TreeObject typeNode = null;
         TreeObject parentNode = domain;
-        
+
         // Run this loop till all nodes(hierarchy) for this mbean are created. This loop only creates
         // all the required parent nodes for the mbean
         for (int i = 0; i < types.length; i++)
@@ -554,34 +572,34 @@
             // If value is not null, then there will be a parent node for this mbean
             // eg. for type=VirtualHost the value is "test"
             typeNode = getMBeanTypeNode(parentNode, type);
-            
+
             // create the type node if not already created
             if (typeNode == null)
             {
                 // If the ObjectName doesn't have name property, that means there will be only one instance
                 // of this mbean for given "type". So there will be no type node created for this mbean.
-                if (name == null && (i == types.length -1))
+                if ((name == null) && (i == (types.length - 1)))
                 {
                     break;
                 }
-                
+
                 // create a node for "type"
                 typeNode = createTypeNode(parentNode, type);
                 typeNode.setVirtualHost(mbean.getVirtualHostName());
             }
-            
+
             // now type node create becomes the parent node for next node in hierarchy
             parentNode = typeNode;
-            
-            /* 
+
+            /*
              * Now create instances node for this type if value exists.
              */
-            if (valueOftype == null) 
+            if (valueOftype == null)
             {
-                // No instance node will be created when value is null (eg type=Queue) 
+                // No instance node will be created when value is null (eg type=Queue)
                 break;
-            } 
-            
+            }
+
             // For different virtual hosts, the nodes with given value will be created.
             // eg type=VirtualHost, value=test
             typeNode = getMBeanTypeNode(parentNode, valueOftype);
@@ -589,55 +607,60 @@
             {
                 typeNode = createTypeInstanceNode(parentNode, valueOftype);
                 typeNode.setVirtualHost(mbean.getVirtualHostName());
-                
+
                 // Create default nodes for VHost instances
                 if (type.equals(VIRTUAL_HOST))
                 {
                     addDefaultNodes(typeNode);
                 }
             }
+
             parentNode = typeNode;
         }
-        
+
         if (typeNode == null)
         {
             typeNode = parentNode;
         }
-        
+
         // Check if an MBean is already added
         if (doesMBeanNodeAlreadyExist(typeNode, name))
+        {
             return;
-        
+        }
+
         // Add the mbean node now
         TreeObject mbeanNode = new TreeObject(mbean);
         mbeanNode.setParent(typeNode);
-        
+
         // Add the mbean to the config file
         if (mbean.isQueue() || mbean.isExchange() || mbean.isConnection())
         {
             addItemInConfigFile(mbeanNode);
         }
-        
+
         // Add notification node
         // TODO: show this only if the mbean sends any notification
         TreeObject notificationNode = new TreeObject(NOTIFICATION, NOTIFICATION);
         notificationNode.setParent(mbeanNode);
     }
-    
+
     private TreeObject createTypeNode(TreeObject parent, String name)
     {
         TreeObject typeNode = new TreeObject(name, NODE_TYPE_MBEANTYPE);
         typeNode.setParent(parent);
+
         return typeNode;
     }
-    
+
     private TreeObject createTypeInstanceNode(TreeObject parent, String name)
     {
         TreeObject typeNode = new TreeObject(name, NODE_TYPE_TYPEINSTANCE);
         typeNode.setParent(parent);
+
         return typeNode;
     }
-    
+
     /**
      * Removes all the child nodes of the given parent node. Used when closing a server.
      * @param parent
@@ -649,7 +672,7 @@
         {
             removeManagedObject(child);
         }
-        
+
         list.clear();
     }
 
@@ -666,10 +689,11 @@
         {
             if (MBEAN.equals(child.getType()))
             {
-                String name = mbean.getName() != null ? mbean.getName() : mbean.getType();
+                String name = (mbean.getName() != null) ? mbean.getName() : mbean.getType();
                 if (child.getName().equals(name))
                 {
                     objectToRemove = child;
+
                     break;
                 }
             }
@@ -678,35 +702,39 @@
                 removeManagedObject(child, mbean);
             }
         }
-        
+
         if (objectToRemove != null)
         {
             list.remove(objectToRemove);
             removeItemFromConfigFile(objectToRemove);
         }
-        
+
     }
-    
+
     /**
      * Closes the Qpid server connection
      */
     public void disconnect() throws Exception
     {
-        TreeObject selectedNode = getSelectedServerNode();        
-        ManagedServer managedServer = (ManagedServer)selectedNode.getManagedObject();
+        TreeObject selectedNode = getSelectedServerNode();
+        ManagedServer managedServer = (ManagedServer) selectedNode.getManagedObject();
         if (!_managedServerMap.containsKey(managedServer))
+        {
             return;
+        }
 
         // Close server connection
         ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(managedServer);
-        if (serverRegistry == null)  // server connection is already closed
+        if (serverRegistry == null) // server connection is already closed
+        {
             return;
-        
+        }
+
         serverRegistry.closeServerConnection();
         // Add server to the closed server list and the worker thread will remove the server from required places.
         ApplicationRegistry.serverConnectionClosed(managedServer);
     }
-    
+
     /**
      * Connects the selected server node
      * @throws Exception
@@ -714,27 +742,28 @@
     public void reconnect(String user, String password) throws Exception
     {
         TreeObject selectedNode = getSelectedServerNode();
-        ManagedServer managedServer = (ManagedServer)selectedNode.getManagedObject();
-        if(_managedServerMap.containsKey(managedServer))
+        ManagedServer managedServer = (ManagedServer) selectedNode.getManagedObject();
+        if (_managedServerMap.containsKey(managedServer))
         {
             throw new InfoRequiredException("Server " + managedServer.getName() + " is already connected");
-        }   
+        }
+
         managedServer.setUser(user);
         managedServer.setPassword(password);
         createRMIServerConnection(managedServer);
-        
+
         // put the server in the managed server map
         _managedServerMap.put(managedServer, selectedNode);
-        
+
         // populate the server tree now
         populateServer(selectedNode);
-        
+
         // Add the Queue/Exchanges/Connections from config file into the navigation tree
         addConfiguredItems(managedServer);
-        
-        _treeViewer.refresh();  
+
+        _treeViewer.refresh();
     }
-    
+
     /**
      * Adds the items(queues/exchanges/connectins) from config file to the server tree
      * @param server
@@ -750,13 +779,13 @@
             List<String> items = getConfiguredItemsFromFile(itemKey);
             List<ManagedBean> mbeans = serverRegistry.getQueues(virtualHost);
             addConfiguredItems(items, mbeans);
-            
+
             // Add Exchanges
             itemKey = server.getName() + "." + virtualHost + "." + INI_EXCHANGES;
             items = getConfiguredItemsFromFile(itemKey);
             mbeans = serverRegistry.getExchanges(virtualHost);
             addConfiguredItems(items, mbeans);
-            
+
             // Add Connections
             itemKey = server.getName() + "." + virtualHost + "." + INI_CONNECTIONS;
             items = getConfiguredItemsFromFile(itemKey);
@@ -764,7 +793,7 @@
             addConfiguredItems(items, mbeans);
         }
     }
-    
+
     /**
      * Gets the mbeans corresponding to the items and adds those to the navigation tree
      * @param items
@@ -772,11 +801,11 @@
      */
     private void addConfiguredItems(List<String> items, List<ManagedBean> mbeans)
     {
-        if ((items == null) || items.isEmpty() | (mbeans == null) || mbeans.isEmpty())
+        if ((items == null) || (items.isEmpty() | (mbeans == null)) || mbeans.isEmpty())
         {
             return;
         }
-        
+
         for (String item : items)
         {
             for (ManagedBean mbean : mbeans)
@@ -784,12 +813,13 @@
                 if (item.equals(mbean.getName()))
                 {
                     addManagedBean(mbean);
+
                     break;
                 }
             }
         }
     }
-    
+
     /**
      * Closes the Qpid server connection if not already closed and removes the server node from the navigation view and
      * also from the ini file stored in the system.
@@ -798,9 +828,9 @@
     public void removeServer() throws Exception
     {
         disconnect();
-        
+
         // Remove from the Tree
-        String serverNodeName = getSelectedServerNode().getName();        
+        String serverNodeName = getSelectedServerNode().getName();
         List<TreeObject> list = _serversRootNode.getChildren();
         TreeObject objectToRemove = null;
         for (TreeObject child : list)
@@ -808,46 +838,48 @@
             if (child.getName().equals(serverNodeName))
             {
                 objectToRemove = child;
+
                 break;
             }
         }
-        
+
         if (objectToRemove != null)
         {
             list.remove(objectToRemove);
         }
-        
+
         _treeViewer.refresh();
-        
+
         // Remove from the ini file
         removeServerFromConfigFile(serverNodeName);
     }
-    
+
     private void removeServerFromConfigFile(String serverNodeName)
     {
         List<String> serversList = getServerListFromFile();
         serversList.remove(serverNodeName);
-        
+
         String value = "";
         for (String item : serversList)
         {
             value += item + ",";
         }
+
         value = (value.lastIndexOf(",") != -1) ? value.substring(0, value.lastIndexOf(",")) : value;
-        
+
         _preferences.putValue(INI_SERVERS, value);
-        
+
         try
         {
             _preferences.save();
         }
-        catch(IOException ex)
+        catch (IOException ex)
         {
-            System.err.println("Error in updating the config file "+ INI_FILENAME);
+            System.err.println("Error in updating the config file " + INI_FILENAME);
             System.out.println(ex);
         }
     }
-    
+
     /**
      * @return the server addresses from the ini file
      * @throws Exception
@@ -856,7 +888,7 @@
     {
         return getConfiguredItemsFromFile(INI_SERVERS);
     }
-    
+
     /**
      * Returns the list of items from the config file.
      * sample ini file:
@@ -879,59 +911,60 @@
                 list.add(item);
             }
         }
-        
+
         return list;
     }
-    
+
     public TreeObject getSelectedServerNode() throws Exception
     {
-        IStructuredSelection ss = (IStructuredSelection)_treeViewer.getSelection();
-        TreeObject selectedNode = (TreeObject)ss.getFirstElement();
-        if (ss.isEmpty() || selectedNode == null || (!selectedNode.getType().equals(NODE_TYPE_SERVER)))
+        IStructuredSelection ss = (IStructuredSelection) _treeViewer.getSelection();
+        TreeObject selectedNode = (TreeObject) ss.getFirstElement();
+        if (ss.isEmpty() || (selectedNode == null) || (!selectedNode.getType().equals(NODE_TYPE_SERVER)))
         {
             throw new InfoRequiredException("Please select the server");
         }
 
         return selectedNode;
     }
-	/**
-     * This is a callback that will allow us to create the viewer and establishConnection
+
+    /**
+     * This is a callback that will allow us to create the viewer and initialize
      * it.
      */
-	public void createPartControl(Composite parent)
+    public void createPartControl(Composite parent)
     {
         Composite composite = new Composite(parent, SWT.NONE);
         GridLayout gridLayout = new GridLayout();
         gridLayout.marginHeight = 2;
         gridLayout.marginWidth = 2;
-        gridLayout.horizontalSpacing = 0; 
-        gridLayout.verticalSpacing = 2;        
+        gridLayout.horizontalSpacing = 0;
+        gridLayout.verticalSpacing = 2;
         composite.setLayout(gridLayout);
-        
+
         createTreeViewer(composite);
         _rootNode = new TreeObject("ROOT", "ROOT");
         _serversRootNode = new TreeObject(NAVIGATION_ROOT, "ROOT");
         _serversRootNode.setParent(_rootNode);
-        
+
         _treeViewer.setInput(_rootNode);
         // set viewer as selection event provider for MBeanView
-        getSite().setSelectionProvider(_treeViewer);      
-        
+        getSite().setSelectionProvider(_treeViewer);
+
         // Start worker thread to refresh tree for added or removed objects
-        (new Thread(new Worker())).start();     
- 
+        (new Thread(new Worker())).start();
+
         createConfigFile();
         _preferences = new PreferenceStore(INI_FILENAME);
-        
+
         try
         {
             _preferences.load();
         }
-        catch(IOException ex)
+        catch (IOException ex)
         {
             System.out.println(ex);
         }
-        
+
         // load the list of servers already added from file
         List<String> serversList = getServerListFromFile();
         if (serversList != null)
@@ -945,23 +978,22 @@
                 _serversRootNode.addChild(serverNode);
             }
         }
+
         _treeViewer.refresh();
-        
-	}
 
-	/**
-	 * Passing the focus request to the viewer's control.
-	 */
-	public void setFocus()
-    {
+    }
+
+    /**
+     * Passing the focus request to the viewer's control.
+     */
+    public void setFocus()
+    { }
 
-	}
-    
     public void refresh()
     {
         _treeViewer.refresh();
     }
-    
+
     /**
      * Content provider class for the tree viewer
      */
@@ -971,36 +1003,39 @@
         {
             return getChildren(parent);
         }
-        
+
         public Object[] getChildren(final Object parentElement)
         {
-            final TreeObject node = (TreeObject)parentElement;
+            final TreeObject node = (TreeObject) parentElement;
+
             return node.getChildren().toArray(new TreeObject[0]);
         }
-        
+
         public Object getParent(final Object element)
         {
-            final TreeObject node = (TreeObject)element;
+            final TreeObject node = (TreeObject) element;
+
             return node.getParent();
         }
-        
+
         public boolean hasChildren(final Object element)
         {
             final TreeObject node = (TreeObject) element;
+
             return !node.getChildren().isEmpty();
         }
-        
+
         public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput)
         {
             // Do nothing
         }
-        
+
         public void dispose()
         {
             // Do nothing
         }
     }
-    
+
     /**
      * Label provider class for the tree viewer
      */
@@ -1008,28 +1043,32 @@
     {
         public Image getImage(Object element)
         {
-            TreeObject node = (TreeObject)element;
+            TreeObject node = (TreeObject) element;
             if (node.getType().equals(NOTIFICATION))
             {
                 return ApplicationRegistry.getImage(NOTIFICATION_IMAGE);
             }
             else if (!node.getType().equals(MBEAN))
             {
-               if (_treeViewer.getExpandedState(node))
-                   return ApplicationRegistry.getImage(OPEN_FOLDER_IMAGE);
-               else
-                   return ApplicationRegistry.getImage(CLOSED_FOLDER_IMAGE);
-                   
+                if (_treeViewer.getExpandedState(node))
+                {
+                    return ApplicationRegistry.getImage(OPEN_FOLDER_IMAGE);
+                }
+                else
+                {
+                    return ApplicationRegistry.getImage(CLOSED_FOLDER_IMAGE);
+                }
+
             }
             else
             {
                 return ApplicationRegistry.getImage(MBEAN_IMAGE);
             }
         }
-        
+
         public String getText(Object element)
         {
-            TreeObject node = (TreeObject)element;
+            TreeObject node = (TreeObject) element;
             if (node.getType().equals(NODE_TYPE_MBEANTYPE))
             {
                 return node.getName() + "s";
@@ -1039,35 +1078,42 @@
                 return node.getName();
             }
         }
-        
+
         public Font getFont(Object element)
         {
-            TreeObject node = (TreeObject)element;
+            TreeObject node = (TreeObject) element;
             if (node.getType().equals(NODE_TYPE_SERVER))
             {
                 if (node.getChildren().isEmpty())
+                {
                     return ApplicationRegistry.getFont(FONT_NORMAL);
+                }
                 else
+                {
                     return ApplicationRegistry.getFont(FONT_BOLD);
+                }
             }
+
             return ApplicationRegistry.getFont(FONT_NORMAL);
         }
     } // End of LabelProviderImpl
-    
-    
+
     private class ViewerSorterImpl extends ViewerSorter
     {
         public int category(Object element)
         {
-            TreeObject node = (TreeObject)element;
+            TreeObject node = (TreeObject) element;
             if (node.getType().equals(MBEAN))
+            {
                 return 1;
+            }
+
             return 2;
         }
     }
-            
+
     /**
-     * Worker thread, which keeps looking for new ManagedObjects to be added and 
+     * Worker thread, which keeps looking for new ManagedObjects to be added and
      * unregistered objects to be removed from the tree.
      * @author Bhupendra Bhardwaj
      */
@@ -1075,33 +1121,31 @@
     {
         public void run()
         {
-            while(true)
+            while (true)
             {
                 if (!_managedServerMap.isEmpty())
                 {
-                    refreshRemovedObjects();                               
+                    refreshRemovedObjects();
                     refreshClosedServerConnections();
                 }
-                
+
                 try
                 {
                     Thread.sleep(3000);
                 }
-                catch(Exception ex)
-                {
+                catch (Exception ex)
+                { }
+
+            } // end of while loop
+        } // end of run method.
+    } // end of Worker class
 
-                }                          
-                                                
-            }// end of while loop
-        }// end of run method.        
-    }// end of Worker class
-    
     /**
      * Adds the mbean to the navigation tree
      * @param mbean
      * @throws Exception
      */
-    public void addManagedBean(ManagedBean mbean)// throws Exception
+    public void addManagedBean(ManagedBean mbean) // throws Exception
     {
         TreeObject treeServerObject = _managedServerMap.get(mbean.getServer());
         List<TreeObject> domains = treeServerObject.getChildren();
@@ -1111,22 +1155,25 @@
             if (child.getName().equals(mbean.getDomain()))
             {
                 domain = child;
+
                 break;
             }
         }
-        
+
         addManagedBean(domain, mbean);
         _treeViewer.refresh();
     }
-    
+
     private void refreshRemovedObjects()
     {
         for (ManagedServer server : _managedServerMap.keySet())
         {
             final ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(server);
-            if (serverRegistry == null)  // server connection is closed
+            if (serverRegistry == null) // server connection is closed
+            {
                 continue;
-            
+            }
+
             final List<ManagedBean> removalList = serverRegistry.getObjectsToBeRemoved();
             if (removalList != null)
             {
@@ -1145,19 +1192,22 @@
                                     if (child.getName().equals(mbean.getDomain()))
                                     {
                                         domain = child;
+
                                         break;
                                     }
                                 }
+
                                 removeManagedObject(domain, mbean);
-                                //serverRegistry.removeManagedObject(mbean);
+                                // serverRegistry.removeManagedObject(mbean);
                             }
+
                             _treeViewer.refresh();
                         }
                     });
             }
         }
     }
-    
+
     /**
      * Gets the list of closed server connection from the ApplicationRegistry and then removes
      * the closed server nodes from the navigation view
@@ -1169,20 +1219,20 @@
         {
             Display display = getSite().getShell().getDisplay();
             display.syncExec(new Runnable()
-            {
-                public void run()
                 {
-                    for (ManagedServer server : closedServers)
+                    public void run()
                     {
-                        removeManagedObject(_managedServerMap.get(server));
-                        _managedServerMap.remove(server);
-                        ApplicationRegistry.removeServer(server);
+                        for (ManagedServer server : closedServers)
+                        {
+                            removeManagedObject(_managedServerMap.get(server));
+                            _managedServerMap.remove(server);
+                            ApplicationRegistry.removeServer(server);
+                        }
+
+                        _treeViewer.refresh();
                     }
-                    
-                    _treeViewer.refresh();
-                }
-            });
+                });
         }
     }
-    
-}
\ No newline at end of file
+
+}



Mime
View raw message