KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > container > monitor > jvm > v14 > JVMRuntimeInfoImpl


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.container.monitor.jvm.v14;
6
7 import java.util.* ;
8
9 import org.exoplatform.Constants;
10 import org.exoplatform.commons.utils.ExoProperties;
11 import org.exoplatform.container.configuration.* ;
12 import org.picocontainer.Startable;
13 import org.exoplatform.container.monitor.jvm.JVMRuntimeInfo;
14 /**
15  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
16  * @since Nov 8, 2004
17  * @version $Id$
18  */

19 public class JVMRuntimeInfoImpl implements JVMRuntimeInfo, Startable {
20   
21   public JVMRuntimeInfoImpl(ConfigurationManager manager ) throws Exception JavaDoc {
22     ServiceConfiguration sconf =
23       manager.getServiceConfiguration(JVMRuntimeInfo.class) ;
24     PropertiesParam param = sconf.getPropertiesParam("add.system.properties") ;
25     if(param != null) {
26       ExoProperties props = param.getProperties() ;
27       Iterator i = props.entrySet().iterator() ;
28       while(i.hasNext()) {
29         Map.Entry entry = (Map.Entry)i.next() ;
30         System.setProperty((String JavaDoc) entry.getKey(), (String JavaDoc) entry.getValue()) ;
31       }
32     }
33   }
34   
35   public String JavaDoc getName() { return "N/A" ; }
36   public String JavaDoc getSpecName() { return "N/A" ; }
37   public String JavaDoc getSpecVendor() { return "N/A" ; }
38   public String JavaDoc getSpecVersion() { return "N/A" ; }
39   public String JavaDoc getManagementSpecVersion() { return "N/A" ;}
40   
41   public String JavaDoc getVmName() { return "N/A"; }
42   public String JavaDoc getVmVendor() { return "N/A" ; }
43   public String JavaDoc getVmVersion() { return "N/A" ; }
44   
45   public List getInputArguments() { return Constants.EMPTY_LIST ; }
46   public Map getSystemProperties() { return Constants.EMPTY_MAP ; }
47   
48   public boolean getBootClassPathSupported() { return false ;}
49   public String JavaDoc getBootClassPath() { return "N/A"; }
50   public String JavaDoc getClassPath() { return "N/A" ; }
51   public String JavaDoc getLibraryPath() { return "N/A" ; }
52   
53   public long getStartTime() { return -1 ; }
54   public long getUptime() { return -1 ; }
55   
56   public boolean isManagementSupported() { return false ; }
57   
58   public String JavaDoc getSystemPropertiesAsText() {
59     StringBuffer JavaDoc b = new StringBuffer JavaDoc() ;
60     Iterator i = System.getProperties().entrySet().iterator() ;
61     while(i.hasNext()) {
62       Map.Entry entry = (Map.Entry)i.next() ;
63       b.append(entry.getKey()).append("=").append(entry.getValue()).append("\n") ;
64     }
65     return b.toString() ;
66   }
67   
68   public void start() {}
69   public void stop() {}
70  
71   public String JavaDoc toString() {
72     StringBuffer JavaDoc b = new StringBuffer JavaDoc() ;
73     b.append("Name: ").append(getName()).append("\n") ;
74     b.append("Specification Name: ").append(getSpecName()).append("\n") ;
75     b.append("Specification Vendor: ").append(getSpecVendor()).append("\n") ;
76     b.append("Specification Version: ").append(getSpecVersion()).append("\n") ;
77     b.append("Management Spec Version: ").append(getManagementSpecVersion()).append("\n\n") ;
78     
79     b.append("Virtual Machine Name: ").append(getVmName()).append("\n") ;
80     b.append("Virtual Machine Vendor: ").append(getVmVendor()).append("\n") ;
81     b.append("Virtual Machine Version: ").append(getVmVersion()).append("\n\n") ;
82     
83     b.append("Input Arguments: ").append(getInputArguments()).append("\n") ;
84     b.append("System Properties: ").append(getSystemProperties()).append("\n\n") ;
85     
86     b.append("Boot Class Path Support: ").append(getBootClassPathSupported()).append("\n") ;
87     b.append("Boot Class Path: ").append(getBootClassPath()).append("\n") ;
88     b.append("Class Path: ").append(getClassPath()).append("\n") ;
89     b.append("Library Path: ").append(getLibraryPath()).append("\n\n") ;
90     
91     b.append("Start Time: ").append(new Date(getStartTime())).append("\n") ;
92     b.append("Up Time: ").append(getUptime()/(1000 * 60)).append("min\n") ;
93     return b.toString() ;
94   }
95 }
Popular Tags