1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.portal.portlets.admin;
18
19
20 import org.apache.ecs.html.Table;
21 import org.apache.ecs.html.TD;
22 import org.apache.ecs.html.TR;
23 import org.apache.ecs.ConcreteElement;
24
25
26 import org.apache.jetspeed.portal.portlets.AbstractPortlet;
27 import org.apache.jetspeed.portal.PortletException;
28 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
29 import org.apache.jetspeed.services.logging.JetspeedLogger;
30
31
32 import org.apache.turbine.util.RunData;
33
34
35 import java.util.Enumeration;
36 import java.util.Properties;
37
38 /***
39 Handles enumerating Portlets that are also applications
40
41 @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
42 @version $Id: JavaRuntimePortlet.java,v 1.18 2004/02/23 03:26:19 jford Exp $
43 */
44 public class JavaRuntimePortlet extends AbstractPortlet
45 {
46
47 /***
48 * Static initialization of the logger for this class
49 */
50 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(JavaRuntimePortlet.class.getName());
51
52 public ConcreteElement getContent( RunData rundata ) {
53
54 Table table = new Table().setWidth("100%");
55
56 try {
57
58 Runtime jvm = Runtime.getRuntime();
59
60 table.addElement( new TR()
61 .addElement( new TD("Free Memory (in bytes)") )
62 .addElement( new TD( Long.toString( jvm.freeMemory() ) ) ) );
63
64 table.addElement( new TR()
65 .addElement( new TD("Total Memory (in bytes)") )
66 .addElement( new TD( Long.toString( jvm.totalMemory() ) ) ) );
67
68
69 Properties props = System.getProperties();
70
71 Enumeration enum = props.propertyNames();
72 while( enum.hasMoreElements() ) {
73 Object key = enum.nextElement();
74 if ( ! ( key instanceof String ) ) {
75 continue;
76 }
77
78 Object value = props.getProperty( key.toString() );
79 table.addElement( new TR()
80 .addElement( new TD( key.toString() ) )
81 .addElement( new TD( value.toString() ) ) );
82
83 }
84 } catch (Throwable t) {
85 logger.error("Throwable", t);
86 table.addElement( new TR()
87 .addElement( new TD( "Error" ) )
88 .addElement( new TD( "Could not read system properties" ) ) );
89 }
90
91 return table;
92 }
93
94 /***
95 @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
96 @version $Id: JavaRuntimePortlet.java,v 1.18 2004/02/23 03:26:19 jford Exp $
97 */
98 public void init() throws PortletException {
99
100 this.setTitle("Java Runtime");
101 this.setDescription("Information about your Java Runtime");
102
103 }
104
105 public boolean getAllowEdit(RunData rundata) {
106 return false;
107 }
108
109 public boolean getAllowMaximize(RunData rundata) {
110 return false;
111 }
112
113
114 }