felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r922604 - in /felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc: ConfigurationRender.java SystemPropertiesPrinter.java ThreadPrinter.java
Date Sat, 13 Mar 2010 16:50:43 GMT
Author: fmeschbe
Date: Sat Mar 13 16:50:42 2010
New Revision: 922604

URL: http://svn.apache.org/viewvc?rev=922604&view=rev
Log:
FELIX-2199 Extract built-in ConfigurationPrinter classes as top level classes

Added:
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/SystemPropertiesPrinter.java
  (with props)
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadPrinter.java
  (with props)
Modified:
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java?rev=922604&r1=922603&r2=922604&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
Sat Mar 13 16:50:42 2010
@@ -245,11 +245,6 @@ public class ConfigurationRender extends
         if ( cfgPrinterTrackerCount != cfgPrinterTracker.getTrackingCount() )
         {
             SortedMap cp = new TreeMap();
-
-            // add provided printers
-            addConfigurationPrinter( cp, new SystemPropertiesPrinter(), SystemPropertiesPrinter.LABEL,
null );
-            addConfigurationPrinter( cp, new ThreadPrinter(), ThreadPrinter.LABEL, null );
-
             ServiceReference[] refs = cfgPrinterTracker.getServiceReferences();
             if ( refs != null )
             {
@@ -409,125 +404,6 @@ public class ConfigurationRender extends
         return title;
     }
 
-    private static class SystemPropertiesPrinter implements ConfigurationPrinter
-    {
-
-        private static final String TITLE = "System Properties";
-
-        static final String LABEL = "_systemproperties";
-
-
-        public String getTitle()
-        {
-            return TITLE;
-        }
-
-
-        public void printConfiguration( PrintWriter printWriter )
-        {
-            Properties props = System.getProperties();
-            SortedSet keys = new TreeSet( props.keySet() );
-            for ( Iterator ki = keys.iterator(); ki.hasNext(); )
-            {
-                Object key = ki.next();
-                infoLine( printWriter, null, ( String ) key, props.get( key ) );
-            }
-
-        }
-
-    }
-
-    private static class ThreadPrinter implements ConfigurationPrinter
-    {
-
-        private static final String TITLE = "Threads";
-
-        static final String LABEL = "_threads";
-
-
-        public String getTitle()
-        {
-            return TITLE;
-        }
-
-
-        public void printConfiguration( PrintWriter pw )
-        {
-            // first get the root thread group
-            ThreadGroup rootGroup = Thread.currentThread().getThreadGroup();
-            while ( rootGroup.getParent() != null )
-            {
-                rootGroup = rootGroup.getParent();
-            }
-
-            printThreadGroup( pw, rootGroup );
-
-            int numGroups = rootGroup.activeGroupCount();
-            ThreadGroup[] groups = new ThreadGroup[2 * numGroups];
-            rootGroup.enumerate( groups );
-            for ( int i = 0; i < groups.length; i++ )
-            {
-                printThreadGroup( pw, groups[i] );
-            }
-        }
-
-        private static final void printThreadGroup( PrintWriter pw, ThreadGroup group )
-        {
-            if ( group != null )
-            {
-                StringBuffer info = new StringBuffer();
-                info.append( "ThreadGroup " ).append( group.getName() );
-                info.append( " [" );
-                info.append( "maxprio=" ).append( group.getMaxPriority() );
-
-                info.append( ", parent=" );
-                if ( group.getParent() != null )
-                {
-                    info.append( group.getParent().getName() );
-                }
-                else
-                {
-                    info.append( '-' );
-                }
-
-                info.append( ", isDaemon=" ).append( group.isDaemon() );
-                info.append( ", isDestroyed=" ).append( group.isDestroyed() );
-                info.append( ']' );
-
-                infoLine( pw, null, null, info.toString() );
-
-                int numThreads = group.activeCount();
-                Thread[] threads = new Thread[numThreads * 2];
-                group.enumerate( threads, false );
-                for ( int i = 0; i < threads.length; i++ )
-                {
-                    printThread( pw, threads[i] );
-                }
-
-                pw.println();
-            }
-        }
-
-
-        private static final void printThread( PrintWriter pw, Thread thread )
-        {
-            if ( thread != null )
-            {
-                StringBuffer info = new StringBuffer();
-                info.append( "Thread " ).append( thread.getName() );
-                info.append( " [" );
-                info.append( "priority=" ).append( thread.getPriority() );
-                info.append( ", alive=" ).append( thread.isAlive() );
-                info.append( ", daemon=" ).append( thread.isDaemon() );
-                info.append( ", interrupted=" ).append( thread.isInterrupted() );
-                info.append( ", loader=" ).append( thread.getContextClassLoader() );
-                info.append( ']' );
-
-                infoLine( pw, "  ", null, info.toString() );
-            }
-        }
-    }
-
     private abstract static class ConfigurationWriter extends PrintWriter
     {
 
@@ -542,10 +418,11 @@ public class ConfigurationRender extends
 
         abstract void end();
 
-        public void handleAttachments(final String title, final URL[] urls)
-        throws IOException
+
+        public void handleAttachments( final String title, final URL[] urls ) throws IOException
         {
-            throw new UnsupportedOperationException("handleAttachments not supported by this
configuration writer: " + this);
+            throw new UnsupportedOperationException( "handleAttachments not supported by
this configuration writer: "
+                + this );
         }
 
     }

Added: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/SystemPropertiesPrinter.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/SystemPropertiesPrinter.java?rev=922604&view=auto
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/SystemPropertiesPrinter.java
(added)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/SystemPropertiesPrinter.java
Sat Mar 13 16:50:42 2010
@@ -0,0 +1,57 @@
+/*
+ * 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
+ *
+ * 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.felix.webconsole.internal.misc;
+
+
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.apache.felix.webconsole.internal.AbstractConfigurationPrinter;
+
+
+public class SystemPropertiesPrinter extends AbstractConfigurationPrinter
+{
+
+    private static final String TITLE = "System Properties";
+
+    private static final String LABEL = "_systemproperties";
+
+
+    public String getTitle()
+    {
+        return TITLE;
+    }
+
+
+    public void printConfiguration( PrintWriter printWriter )
+    {
+        Properties props = System.getProperties();
+        SortedSet keys = new TreeSet( props.keySet() );
+        for ( Iterator ki = keys.iterator(); ki.hasNext(); )
+        {
+            Object key = ki.next();
+            ConfigurationRender.infoLine( printWriter, null, ( String ) key, props.get( key
) );
+        }
+
+    }
+
+}
\ No newline at end of file

Propchange: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/SystemPropertiesPrinter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/SystemPropertiesPrinter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadPrinter.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadPrinter.java?rev=922604&view=auto
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadPrinter.java
(added)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadPrinter.java
Sat Mar 13 16:50:42 2010
@@ -0,0 +1,117 @@
+/*
+ * 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
+ *
+ * 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.felix.webconsole.internal.misc;
+
+
+import java.io.PrintWriter;
+
+import org.apache.felix.webconsole.internal.AbstractConfigurationPrinter;
+
+
+public class ThreadPrinter extends AbstractConfigurationPrinter
+{
+
+    private static final String TITLE = "Threads";
+
+    private static final String LABEL = "_threads";
+
+
+    public String getTitle()
+    {
+        return TITLE;
+    }
+
+
+    public void printConfiguration( PrintWriter pw )
+    {
+        // first get the root thread group
+        ThreadGroup rootGroup = Thread.currentThread().getThreadGroup();
+        while ( rootGroup.getParent() != null )
+        {
+            rootGroup = rootGroup.getParent();
+        }
+
+        printThreadGroup( pw, rootGroup );
+
+        int numGroups = rootGroup.activeGroupCount();
+        ThreadGroup[] groups = new ThreadGroup[2 * numGroups];
+        rootGroup.enumerate( groups );
+        for ( int i = 0; i < groups.length; i++ )
+        {
+            printThreadGroup( pw, groups[i] );
+        }
+    }
+
+
+    private static final void printThreadGroup( PrintWriter pw, ThreadGroup group )
+    {
+        if ( group != null )
+        {
+            StringBuffer info = new StringBuffer();
+            info.append( "ThreadGroup " ).append( group.getName() );
+            info.append( " [" );
+            info.append( "maxprio=" ).append( group.getMaxPriority() );
+
+            info.append( ", parent=" );
+            if ( group.getParent() != null )
+            {
+                info.append( group.getParent().getName() );
+            }
+            else
+            {
+                info.append( '-' );
+            }
+
+            info.append( ", isDaemon=" ).append( group.isDaemon() );
+            info.append( ", isDestroyed=" ).append( group.isDestroyed() );
+            info.append( ']' );
+
+            ConfigurationRender.infoLine( pw, null, null, info.toString() );
+
+            int numThreads = group.activeCount();
+            Thread[] threads = new Thread[numThreads * 2];
+            group.enumerate( threads, false );
+            for ( int i = 0; i < threads.length; i++ )
+            {
+                printThread( pw, threads[i] );
+            }
+
+            pw.println();
+        }
+    }
+
+
+    private static final void printThread( PrintWriter pw, Thread thread )
+    {
+        if ( thread != null )
+        {
+            StringBuffer info = new StringBuffer();
+            info.append( "Thread " ).append( thread.getName() );
+            info.append( " [" );
+            info.append( "priority=" ).append( thread.getPriority() );
+            info.append( ", alive=" ).append( thread.isAlive() );
+            info.append( ", daemon=" ).append( thread.isDaemon() );
+            info.append( ", interrupted=" ).append( thread.isInterrupted() );
+            info.append( ", loader=" ).append( thread.getContextClassLoader() );
+            info.append( ']' );
+
+            ConfigurationRender.infoLine( pw, "  ", null, info.toString() );
+        }
+    }
+}
\ No newline at end of file

Propchange: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadPrinter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadPrinter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url



Mime
View raw message