1 23 24 package com.sun.enterprise.admin.monitor.stats.spi; 25 import java.lang.management.ManagementFactory ; 26 import java.lang.management.ClassLoadingMXBean ; 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.JVMClassLoadingStats; 33 import com.sun.enterprise.admin.monitor.stats.MutableCountStatistic; 34 import com.sun.enterprise.admin.monitor.stats.MutableCountStatisticImpl; 35 import com.sun.enterprise.admin.monitor.stats.GenericStatsImpl; 36 import com.sun.enterprise.admin.monitor.stats.CountStatisticImpl; 37 import com.sun.enterprise.admin.monitor.stats.StatisticImpl; 38 import com.sun.enterprise.util.i18n.StringManager; 39 40 41 public class JVMClassLoadingStatsImpl implements JVMClassLoadingStats { 42 43 private GenericStatsImpl baseStatsImpl; 44 private static final String STATS_INTERFACE_NAME = 45 "com.sun.enterprise.admin.monitor.stats.JVMClassLoadingStats"; 46 private MutableCountStatistic loadedClassCount; 48 private MutableCountStatistic unloadedClassCount; 49 private MutableCountStatistic totalLoadedClassCount; 50 private ClassLoadingMXBean bean; 51 private static final StringManager localStrMgr = 52 StringManager.getManager(JVMClassLoadingStatsImpl.class); 53 54 55 56 57 public JVMClassLoadingStatsImpl() { 58 59 try { 60 baseStatsImpl = new GenericStatsImpl(STATS_INTERFACE_NAME, this); 61 } catch(Exception e) { 62 63 } 64 bean = ManagementFactory.getClassLoadingMXBean(); 67 68 initializeStatistics(); 70 71 } 72 73 public CountStatistic getTotalLoadedClassCount() { 74 long classCount = bean.getTotalLoadedClassCount(); 75 totalLoadedClassCount.setCount (classCount); 76 return (CountStatistic )totalLoadedClassCount.unmodifiableView (); 77 } 78 79 public CountStatistic getLoadedClassCount() { 80 long classCount = bean.getLoadedClassCount(); 81 loadedClassCount.setCount (classCount); 82 return (CountStatistic )loadedClassCount.unmodifiableView (); 83 } 84 85 public CountStatistic getUnloadedClassCount() { 86 long classCount = bean.getUnloadedClassCount(); 87 unloadedClassCount.setCount (classCount); 88 return (CountStatistic )unloadedClassCount.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_classes_load"), 122 StatisticImpl.DEFAULT_UNIT, 123 localStrMgr.getString("monitor.stats.total_classes_load_desc")); 124 totalLoadedClassCount = new MutableCountStatisticImpl(c); 125 126 c = new CountStatisticImpl( 128 localStrMgr.getString("monitor.stats.classes_loaded"), 129 StatisticImpl.DEFAULT_UNIT, 130 localStrMgr.getString("monitor.stats.classes_loaded_desc")); 131 loadedClassCount = new MutableCountStatisticImpl(c); 132 133 c = new CountStatisticImpl( 135 localStrMgr.getString("monitor.stats.classes_unloaded"), 136 StatisticImpl.DEFAULT_UNIT, 137 localStrMgr.getString("monitor.stats.classes_unloaded_desc")); 138 unloadedClassCount = new MutableCountStatisticImpl(c); 139 } 140 141 } 142 | Popular Tags |