1 23 24 package com.sun.enterprise.admin.monitor.stats.spi; 25 import java.lang.management.GarbageCollectorMXBean ; 26 import javax.management.ObjectName ; 27 import javax.management.MBeanServerFactory ; 28 import javax.management.MBeanServer ; 29 import javax.management.j2ee.statistics.Statistic ; 30 import javax.management.j2ee.statistics.CountStatistic ; 31 import com.sun.enterprise.admin.monitor.stats.JVMGarbageCollectorStats; 32 import com.sun.enterprise.admin.monitor.stats.MutableCountStatistic; 33 import com.sun.enterprise.admin.monitor.stats.MutableCountStatisticImpl; 34 import com.sun.enterprise.admin.monitor.stats.GenericStatsImpl; 35 import com.sun.enterprise.admin.monitor.stats.CountStatisticImpl; 36 import com.sun.enterprise.admin.monitor.stats.StatisticImpl; 37 import com.sun.enterprise.util.i18n.StringManager; 38 39 public class JVMGarbageCollectorStatsImpl implements JVMGarbageCollectorStats { 40 41 private GenericStatsImpl baseStatsImpl; 42 private static final String STATS_INTERFACE_NAME = 43 "com.sun.enterprise.admin.monitor.stats.JVMGarbageCollectorStats"; 44 private MutableCountStatistic collectionCount; 46 private MutableCountStatistic collectionTime; 47 private GarbageCollectorMXBean bean; 48 private static final StringManager localStrMgr = 49 StringManager.getManager(JVMMemoryStatsImpl.class); 50 51 52 53 public JVMGarbageCollectorStatsImpl(GarbageCollectorMXBean gcMXBean) { 54 55 try { 56 baseStatsImpl = new GenericStatsImpl(STATS_INTERFACE_NAME, this); 57 } catch(Exception e) { 58 59 } 60 bean = gcMXBean; 63 64 initializeStatistics(); 66 } 67 68 public CountStatistic getCollectionTime() { 69 long collTime = bean.getCollectionTime(); 70 collectionTime.setCount (collTime); 71 return (CountStatistic )collectionTime.unmodifiableView (); 72 } 73 74 public CountStatistic getCollectionCount() { 75 long collCount = bean.getCollectionCount(); 76 collectionCount.setCount (collCount); 77 return (CountStatistic )collectionCount.unmodifiableView (); 78 } 79 80 85 public Statistic [] getStatistics() { 86 return baseStatsImpl.getStatistics(); 87 } 88 89 93 public Statistic getStatistic(String str) { 94 return baseStatsImpl.getStatistic(str); 95 } 96 97 102 public String [] getStatisticNames() { 103 return baseStatsImpl.getStatisticNames(); 104 } 105 106 private void initializeStatistics() { 107 108 CountStatistic c = new CountStatisticImpl( 110 localStrMgr.getString("monitor.stats.collection_cnt"), 111 StatisticImpl.DEFAULT_UNIT, 112 localStrMgr.getString("monitor.stats.collection_cnt_desc")); 113 collectionCount = new MutableCountStatisticImpl(c); 114 115 c = new CountStatisticImpl( 117 localStrMgr.getString("monitor.stats.collection_time"), 118 localStrMgr.getString("monitor.stats.milli_sec_units"), 119 localStrMgr.getString("monitor.stats.collection_time_desc")); 120 collectionTime = new MutableCountStatisticImpl(c); 121 } 122 } 123 | Popular Tags |