001 package org.shiftone.jrat.core.jmx.info; 002 003 004 import org.shiftone.jrat.util.VersionUtil; 005 import org.shiftone.jrat.util.log.Logger; 006 007 import java.lang.reflect.Method; 008 009 010 /** 011 * @author jeff@shiftone.org (Jeff Drost) 012 */ 013 public class JRatInfo implements JRatInfoMBean { 014 015 private static final Logger LOG = Logger.getLogger(JRatInfo.class); 016 017 public String getBuiltBy() { 018 return VersionUtil.getBuiltBy(); 019 } 020 021 022 public String getBuiltOn() { 023 return VersionUtil.getBuiltOn(); 024 } 025 026 027 public String getVersion() { 028 return VersionUtil.getVersion(); 029 } 030 031 032 public long getTotalMemory() { 033 return Runtime.getRuntime().totalMemory(); 034 } 035 036 037 public long getMaxMemory() { 038 039 try { 040 Method maxMemory = Runtime.class.getMethod("maxMemory", new Class[]{}); 041 Long result = (Long) maxMemory.invoke(Runtime.getRuntime(), new Object[]{}); 042 043 return result.longValue(); 044 } 045 catch (Exception e) { 046 } 047 048 return 0; 049 } 050 051 052 public long getFreeMemory() { 053 return Runtime.getRuntime().freeMemory(); 054 } 055 056 057 public int getActiveThreadCount() { 058 return Thread.activeCount(); 059 } 060 061 062 public void gc() { 063 Runtime.getRuntime().gc(); 064 } 065 }