1 17 package org.apache.geronimo.management.stats; 18 19 import java.io.Serializable ; 20 import java.util.HashMap ; 21 import java.util.Map ; 22 import javax.management.j2ee.statistics.Statistic ; 23 import javax.management.j2ee.statistics.Stats ; 24 25 33 public class StatsImpl implements Stats , Serializable { 34 private final Map stats = new HashMap (); 35 36 public StatsImpl() { 37 } 38 39 protected void addStat(String name, Statistic value) { 40 stats.put(name, value); 41 } 42 43 49 protected void removeStat(String name) { 50 stats.remove(name); 51 } 52 53 public Statistic getStatistic(String statisticName) { 54 return (Statistic )stats.get(statisticName); 55 } 56 57 public String [] getStatisticNames() { 58 return (String []) stats.keySet().toArray(new String [stats.size()]); 59 } 60 61 public Statistic [] getStatistics() { 62 String [] names = getStatisticNames(); 63 Statistic [] result = new Statistic [names.length]; 64 for (int i = 0; i < names.length; i++) { 65 result[i] = (Statistic ) stats.get(names[i]); 66 } 67 return result; 68 } 69 } 70 | Popular Tags |