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