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