1 4 package org.jfox.ioc.common; 5 6 import java.text.NumberFormat ; 7 8 import org.jfox.ioc.ComponentContext; 9 import org.jfox.ioc.annotation.Managable; 10 import org.jfox.ioc.ext.ActiveComponent; 11 import org.jfox.ioc.ext.ManagableComponent; 12 import org.jfox.ioc.ext.SingletonComponent; 13 14 17 18 public class SysMonitor implements ManagableComponent, ActiveComponent, SingletonComponent{ 19 private static NumberFormat format = NumberFormat.getInstance();; 20 21 @Managable 22 public String getTotalMemory() { 23 long m = (long) (Runtime.getRuntime().totalMemory() / 1024); 24 return format.format(m) + " K"; 25 } 26 27 @Managable 28 public String getFreeMemory() { 29 long m = (long) (Runtime.getRuntime().freeMemory() / 1024); 30 return format.format(m) + " K"; 31 } 32 33 @Managable 34 public String getMaxMemory() { 35 long m = (long) (Runtime.getRuntime().maxMemory() / 1024); 36 return format.format(m) + " K"; 37 } 38 39 @Managable 40 public int getThreadCount() { 41 return Thread.activeCount(); 42 } 43 44 @Managable 45 public void gc() { 46 System.gc(); 47 } 48 49 public void setComponentContext(ComponentContext ctx) { 50 } 51 52 public static void main(String [] args) { 53 54 } 55 } 56 57 | Popular Tags |