1 23 24 package com.sun.enterprise.admin.monitor.stats.spi; 25 import java.lang.management.ManagementFactory ; 26 import java.lang.management.CompilationMXBean ; 27 import javax.management.ObjectName ; 28 import javax.management.MBeanServerFactory ; 29 import javax.management.MBeanServer ; 30 import javax.management.j2ee.statistics.Statistic ; 31 import javax.management.j2ee.statistics.CountStatistic ; 32 import com.sun.enterprise.admin.monitor.stats.StringStatistic; 33 import com.sun.enterprise.admin.monitor.stats.JVMCompilationStats; 34 import com.sun.enterprise.admin.monitor.stats.MutableCountStatistic; 35 import com.sun.enterprise.admin.monitor.stats.MutableCountStatisticImpl; 36 import com.sun.enterprise.admin.monitor.stats.GenericStatsImpl; 37 import com.sun.enterprise.admin.monitor.stats.CountStatisticImpl; 38 import com.sun.enterprise.admin.monitor.stats.StringStatisticImpl; 39 import com.sun.enterprise.util.i18n.StringManager; 40 41 public class JVMCompilationStatsImpl implements JVMCompilationStats { 42 43 private GenericStatsImpl baseStatsImpl; 44 private static final String STATS_INTERFACE_NAME = 45 "com.sun.enterprise.admin.monitor.stats.JVMCompilationStats"; 46 private MBeanServer server; 47 private MutableCountStatistic compileTime; 48 private StringStatistic name; 49 private CompilationMXBean bean; 50 final long initTime; 51 private static final StringManager localStrMgr = 52 StringManager.getManager(JVMCompilationStatsImpl.class); 53 54 55 56 public JVMCompilationStatsImpl() { 57 58 initTime = System.currentTimeMillis (); 59 try { 60 baseStatsImpl = new GenericStatsImpl(STATS_INTERFACE_NAME, this); 61 } catch(Exception e) { 62 63 } 64 bean = ManagementFactory.getCompilationMXBean(); 67 68 initializeStatistics(); 70 71 } 72 73 public StringStatistic getName() { 74 75 String name = bean.getName(); 76 77 return new StringStatisticImpl(name, 78 localStrMgr.getString("monitor.stats.name_string"), 79 localStrMgr.getString("monitor.stats.string_units"), 80 localStrMgr.getString("monitor.stats.name_of_jit_compiler"), 81 initTime, 82 System.currentTimeMillis()); 83 } 84 85 public CountStatistic getTotalCompilationTime() { 86 long cTime = bean.getTotalCompilationTime(); 87 compileTime.setCount (cTime); 88 return (CountStatistic )compileTime.unmodifiableView (); 89 } 90 91 96 public Statistic [] getStatistics() { 97 return baseStatsImpl.getStatistics(); 98 } 99 100 104 public Statistic getStatistic(String str) { 105 return baseStatsImpl.getStatistic(str); 106 } 107 108 113 public String [] getStatisticNames() { 114 return baseStatsImpl.getStatisticNames(); 115 } 116 117 private void initializeStatistics() { 118 119 CountStatistic c = new CountStatisticImpl( 121 localStrMgr.getString("monitor.stats.total_compilation_time"), 122 localStrMgr.getString("monitor.stats.milli_sec_units"), 123 localStrMgr.getString("monitor.stats.total_compilation_time_desc")); 124 compileTime = new MutableCountStatisticImpl(c); 125 } 126 127 } 128 | Popular Tags |