1 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 19 public class JVMRuntimeInfoImpl implements JVMRuntimeInfo, Startable { 20 21 public JVMRuntimeInfoImpl(ConfigurationManager manager ) throws Exception { 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 ) entry.getKey(), (String ) entry.getValue()) ; 31 } 32 } 33 } 34 35 public String getName() { return "N/A" ; } 36 public String getSpecName() { return "N/A" ; } 37 public String getSpecVendor() { return "N/A" ; } 38 public String getSpecVersion() { return "N/A" ; } 39 public String getManagementSpecVersion() { return "N/A" ;} 40 41 public String getVmName() { return "N/A"; } 42 public String getVmVendor() { return "N/A" ; } 43 public String 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 getBootClassPath() { return "N/A"; } 50 public String getClassPath() { return "N/A" ; } 51 public String 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 getSystemPropertiesAsText() { 59 StringBuffer b = new StringBuffer () ; 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 toString() { 72 StringBuffer b = new StringBuffer () ; 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 |