1 49 package org.mr.core.cmc; 50 51 import org.apache.commons.logging.Log; 52 import org.apache.commons.logging.LogFactory; 53 54 import javax.management.*; 55 56 61 public class GetMemStatJMX extends StandardMBean implements GetMemStatJMXMBean { 62 public Log log; 63 64 public GetMemStatJMX()throws NotCompliantMBeanException{ 65 super(GetMemStatJMXMBean.class); 66 log=LogFactory.getLog("GetMemStatJMX"); 67 } 68 69 72 public String [] getStatus(){ 73 long free = Runtime.getRuntime().freeMemory()/1000; 74 long memoryInVM = Runtime.getRuntime().totalMemory()/1000; 75 long maxMem = Runtime.getRuntime().maxMemory()/1000; 76 long used = memoryInVM - free; 77 78 String [] value ={"Used memory = "+ used +"K bytes", 79 "Free memory in system "+free+"K bytes", 80 "Total of memory in VM "+memoryInVM+"K bytes", 81 "Max memory available for the VM "+maxMem+"K bytes"}; 82 return value; 83 } 84 85 protected String getDescription(MBeanInfo i_mBeanInfo) { 86 return "returns the memory status of the system "; 87 } 88 89 protected String getDescription(MBeanAttributeInfo i_mBeanAttributeInfo) { 90 return "returns the memory status of the system "; 91 } 92 93 } 94 | Popular Tags |