1 23 24 package com.sun.ejb.base.stats; 25 26 import javax.management.j2ee.statistics.Stats ; 27 import javax.management.j2ee.statistics.Statistic ; 28 import javax.management.j2ee.statistics.CountStatistic ; 29 import javax.management.j2ee.statistics.BoundedRangeStatistic ; 30 31 import com.sun.enterprise.admin.monitor.registry.MonitoringRegistry; 32 import com.sun.enterprise.admin.monitor.registry.MonitoringLevelListener; 33 import com.sun.enterprise.admin.monitor.registry.MonitoringLevel; 34 import com.sun.enterprise.admin.monitor.registry.MonitoringRegistrationException; 35 36 import com.sun.enterprise.server.ApplicationServer; 37 38 import com.sun.enterprise.admin.monitor.stats.GenericStatsImpl; 39 40 import java.util.logging.*; 41 import com.sun.enterprise.log.Log; 42 import com.sun.logging.*; 43 44 50 51 52 public abstract class StatsImpl 53 implements Stats 54 { 55 protected static Logger _logger = 56 LogDomains.getLogger(LogDomains.EJB_LOGGER); 57 58 private GenericStatsImpl genericStatsDelegate; 59 protected boolean monitorOn = false; 60 protected boolean registered = true; 61 private MonitoringLevel currentMonitoringLevel; 62 63 protected StatsImpl() { 64 } 65 66 protected void initialize(String statInterfaceName) { 67 try { 68 genericStatsDelegate = new GenericStatsImpl(statInterfaceName, this); 69 } catch(ClassNotFoundException cnfEx) { 70 throw new RuntimeException (statInterfaceName + " not found", cnfEx); 71 } 72 } 73 74 public Statistic getStatistic(String statName) { 75 return genericStatsDelegate.getStatistic(statName); 76 } 77 78 public String [] getStatisticNames() { 79 return genericStatsDelegate.getStatisticNames(); 80 } 81 82 public Statistic [] getStatistics() { 83 return genericStatsDelegate.getStatistics(); 84 } 85 86 public String statToString() { 87 StringBuffer sbuf = new StringBuffer (); 88 Statistic [] stats = getStatistics(); 89 int sz = stats.length; 90 for (int i=0; i<sz; i++) { 91 if (stats[i] instanceof CountStatistic ) { 92 CountStatistic stat = (CountStatistic ) stats[i]; 93 sbuf.append(stat.getName()).append("=") 94 .append(stat.getCount()).append("; "); 95 } else if (stats[i] instanceof BoundedRangeStatistic ) { 96 BoundedRangeStatistic stat = (BoundedRangeStatistic ) stats[i]; 97 sbuf.append(stat.getName()).append("=") 98 .append(stat.getCurrent()).append("; "); 99 } else { 100 sbuf.append(stats[i].getName()).append("=?"); 101 } 102 } 103 104 return sbuf.toString(); 105 } 106 107 } 108 | Popular Tags |