FELIX-802 Fix display of JVM information - only extract from system properties
and Runtime when the VM Statistics is to be displayed insted of on each
request
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@711275 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/AbstractWebConsolePlugin.java b/webconsole/src/main/java/org/apache/felix/webconsole/AbstractWebConsolePlugin.java
index d586120..0049c94 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/AbstractWebConsolePlugin.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/AbstractWebConsolePlugin.java
@@ -20,10 +20,18 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.text.MessageFormat;
-import java.util.*;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
import javax.servlet.ServletException;
-import javax.servlet.http.*;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
@@ -49,41 +57,37 @@
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\">"
+ "<head>"
+ "<meta http-equiv=\"Content-Type\" content=\"text/html; utf-8\">"
- + "<link rel=\"icon\" href=\"{15}/res/imgs/favicon.ico\">"
- + "<title>{0} - {12}</title>"
- + "<script src=\"{15}/res/ui/admin.js\" language=\"JavaScript\"></script>"
- + "<script src=\"{15}/res/ui/ui.js\" language=\"JavaScript\"></script>"
+ + "<link rel=\"icon\" href=\"{6}/res/imgs/favicon.ico\">"
+ + "<title>{0} - {2}</title>"
+ + "<script src=\"{5}/res/ui/admin.js\" language=\"JavaScript\"></script>"
+ + "<script src=\"{5}/res/ui/ui.js\" language=\"JavaScript\"></script>"
+ "<script language=\"JavaScript\">"
- + "ABOUT_VERSION=''{1}'';"
- + "ABOUT_JVERSION=''{2}'';"
- + "ABOUT_JRT=''{3} (build {2})'';"
- + "ABOUT_JVM=''{4} (build {5}, {6})'';"
- + "ABOUT_MEM=\"{7} KB\";"
- + "ABOUT_USED=\"{8} KB\";"
- + "ABOUT_FREE=\"{9} KB\";"
- + "appRoot = \"{15}\";"
- + "pluginRoot = appRoot + \"/{16}\";"
+ + "appRoot = \"{5}\";"
+ + "pluginRoot = appRoot + \"/{6}\";"
+ "</script>"
- + "<link href=\"{15}/res/ui/admin.css\" rel=\"stylesheet\" type=\"text/css\">"
+ + "<link href=\"{5}/res/ui/admin.css\" rel=\"stylesheet\" type=\"text/css\">"
+ "</head>"
+ "<body>"
+ "<div id=\"main\">"
+ "<div id=\"lead\">"
+ "<h1>"
- + "{0}<br>{12}"
+ + "{0}<br>{2}"
+ "</h1>"
+ "<p>"
- + "<a target=\"_blank\" href=\"{13}\" title=\"{11}\"><img src=\"{15}/res/imgs/logo.png\" width=\"165\" height=\"63\" border=\"0\"></a>"
+ + "<a target=\"_blank\" href=\"{3}\" title=\"{1}\"><img src=\"{5}/res/imgs/logo.png\" width=\"165\" height=\"63\" border=\"0\"></a>"
+ "</p>" + "</div>";
+ /**
+ String header = MessageFormat.format( HEADER, new Object[]
+ { adminTitle, productName, getTitle(), productWeb, vendorName,
+ ( String ) request.getAttribute( OsgiManager.ATTR_APP_ROOT ), getLabel() } );
+ */
private BundleContext bundleContext;
private String adminTitle;
- private String adminVersion;
private String productName;
private String productWeb;
private String vendorName;
- private String vendorWeb;
//---------- HttpServlet Overwrites ----------------------------------------
@@ -126,11 +130,9 @@
Dictionary headers = bundleContext.getBundle().getHeaders();
adminTitle = ( String ) headers.get( Constants.BUNDLE_NAME ); // "OSGi Management Console";
- adminVersion = ( String ) headers.get( Constants.BUNDLE_VERSION ); // "1.0.0-SNAPSHOT";
productName = "Apache Felix";
productWeb = ( String ) headers.get( Constants.BUNDLE_DOCURL );
vendorName = ( String ) headers.get( Constants.BUNDLE_VENDOR );
- vendorWeb = "http://www.apache.org";
}
@@ -163,15 +165,8 @@
PrintWriter pw = response.getWriter();
- long freeMem = Runtime.getRuntime().freeMemory() / 1024;
- long totalMem = Runtime.getRuntime().totalMemory() / 1024;
- long usedMem = totalMem - freeMem;
-
String header = MessageFormat.format( HEADER, new Object[]
- { adminTitle, adminVersion, System.getProperty( "java.runtime.version" ),
- System.getProperty( "java.runtime.name" ), System.getProperty( "java.vm.name" ),
- System.getProperty( "java.vm.version" ), System.getProperty( "java.vm.info" ), new Long( totalMem ),
- new Long( usedMem ), new Long( freeMem ), vendorWeb, productName, getTitle(), productWeb, vendorName,
+ { adminTitle, productName, getTitle(), productWeb, vendorName,
( String ) request.getAttribute( OsgiManager.ATTR_APP_ROOT ), getLabel() } );
pw.println( header );
@@ -229,8 +224,8 @@
for ( Iterator li = map.values().iterator(); li.hasNext(); )
{
- pw.print ( "<nobr>" );
- pw.print ( li.next() );
+ pw.print( "<nobr>" );
+ pw.print( li.next() );
pw.println( "</nobr>" );
}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatRender.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatRender.java
index 9bf359b..ca18cbc 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatRender.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatRender.java
@@ -150,11 +150,17 @@
pw.println( "<th colspan='2' class='content container'>Java Information:</th>" );
pw.println( "</tr>" );
- this.infoLine( pw, "Java Runtime", "ABOUT_JRT" );
- this.infoLine( pw, "Java Virtual Machine", "ABOUT_JVM" );
- this.infoLine( pw, "Total Memory", "ABOUT_MEM" );
- this.infoLine( pw, "Used Memory", "ABOUT_USED" );
- this.infoLine( pw, "Free Memory", "ABOUT_FREE" );
+ long freeMem = Runtime.getRuntime().freeMemory() / 1024;
+ long totalMem = Runtime.getRuntime().totalMemory() / 1024;
+ long usedMem = totalMem - freeMem;
+
+ this.infoLine( pw, "Java Runtime", System.getProperty( "java.runtime.name" ) + "(build "
+ + System.getProperty( "java.runtime.version" ) + ")" );
+ this.infoLine( pw, "Java Virtual Machine", System.getProperty( "java.vm.name" ) + "(build "
+ + System.getProperty( "java.vm.version" ) + ", " + System.getProperty( "java.vm.info" ) + ")" );
+ this.infoLine( pw, "Total Memory", totalMem + " KB" );
+ this.infoLine( pw, "Used Memory", usedMem + " KB" );
+ this.infoLine( pw, "Free Memory", freeMem + " KB" );
pw.println( "<tr class='content'>" );
pw.println( "<form method='post'>" );
@@ -168,12 +174,12 @@
}
- private void infoLine( PrintWriter pw, String label, String jsName )
+ private void infoLine( PrintWriter pw, String label, String value )
{
pw.println( "<tr class='content'>" );
pw.println( "<td class='content'>" + label + "</td>" );
pw.println( "<td class='content'>" );
- pw.println( "<script> document.write(" + jsName + "); </script>" );
+ pw.println( value );
pw.println( "</td></tr>" );
}
diff --git a/webconsole/src/main/resources/res/ui/admin.js b/webconsole/src/main/resources/res/ui/admin.js
index 0739c71..52d0c2c 100644
--- a/webconsole/src/main/resources/res/ui/admin.js
+++ b/webconsole/src/main/resources/res/ui/admin.js
@@ -70,17 +70,6 @@
document.write(date.toLocaleString());
}
-/* shows the about screen */
-function showAbout() {
-// Temporarily disabled, as thee is no about.html page (fmeschbe, 20070330)
-// var arguments = ABOUT_VERSION+";"+ABOUT_JVERSION+";"+ABOUT_MEM+";"+ABOUT_USED+";"+ABOUT_FREE;
-// if (window.showModalDialog) {
-// window.showModalDialog("about.html", arguments, "help: no; status: no; resizable: no; center: yes; scroll: no");
-// } else {
-// aboutWin = window.open("about.html?a="+arguments, "about", "width=500,height=420,modal,status=no,toolbar=no,menubar=no,personalbar=no");
-// }
-}
-
//-----------------------------------------------------------------------------
// Ajax Support