1 45 package org.openejb.webadmin.main; 46 47 import java.io.File ; 48 import java.io.IOException ; 49 import java.io.PrintWriter ; 50 import java.util.Arrays ; 51 import java.util.Enumeration ; 52 import java.util.Properties ; 53 import java.util.StringTokenizer ; 54 55 import org.openejb.webadmin.HttpRequest; 56 import org.openejb.webadmin.HttpResponse; 57 import org.openejb.webadmin.WebAdminBean; 58 59 62 public class PropertiesBean extends WebAdminBean { 63 64 67 public void ejbCreate() { 68 section = "Properties"; 71 } 72 73 78 public void postProcess(HttpRequest request, HttpResponse response) throws IOException { 79 } 80 81 86 public void preProcess(HttpRequest request, HttpResponse response) throws IOException { 87 } 88 89 95 public void writeBody(PrintWriter body) throws IOException { 96 Properties p = System.getProperties(); 97 Enumeration e = p.keys(); 98 String [] propertyList = new String [p.size()]; 99 100 body.println("<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\">"); 101 String currentProperty = null; 102 body.println("<tr><th align=\"left\">Property Name</th><th align=\"left\">Property Value</th></tr>"); 103 int j = 0; 104 while ( e.hasMoreElements() ) { 105 propertyList[j++] = (String ) e.nextElement(); 106 } 107 Arrays.sort(propertyList); 108 109 String [] color = new String []{"c9c5fe", "FFFFFF"}; 110 for ( int i=0; i<propertyList.length; i++ ) { 111 String name = propertyList[i]; 112 String value = System.getProperty(propertyList[i]); 113 114 body.println("<tr bgcolor=\"#"+ color[i%2] +"\" >"); 115 body.println("<td valign=\"top\">" + name + "</td>"); 116 body.println("<td>"); 117 if (propertyList[i].endsWith(".path")) { 118 StringTokenizer path = new StringTokenizer (value,File.pathSeparator); 119 while (path.hasMoreTokens()) { 120 body.print(path.nextToken()); 121 body.println("<br>"); 122 } 123 } else { 124 body.println(value); 125 } 126 body.println(" </td>"); 127 body.println("</tr>"); 128 } 129 body.println("</table>"); 130 } 131 132 140 public void writeHtmlTitle(PrintWriter body) throws IOException { 141 body.print(HTML_TITLE); 142 } 143 144 150 public void writePageTitle(PrintWriter body) throws IOException { 151 body.print("System Properties"); 152 } 153 154 174 public void writeSubMenuItems(PrintWriter body) throws IOException { 175 } 176 } 177 | Popular Tags |