1 22 package org.jboss.management.j2ee.statistics; 23 24 import javax.management.j2ee.statistics.Statistic ; 25 import java.io.Serializable ; 26 27 34 public abstract class StatisticImpl 35 implements Statistic , Serializable 36 { 37 39 40 private static final long serialVersionUID = -3427364348020739916L; 41 42 protected String name; 44 protected String units; 45 protected String description; 46 protected long startTime; 47 protected long lastSampleTime; 48 49 51 53 60 public StatisticImpl(String name, String units, String description) 61 { 62 this.name = name; 63 this.units = units; 64 this.description = description; 65 this.startTime = System.currentTimeMillis(); 66 } 67 68 70 72 public String getName() 73 { 74 return name; 75 } 76 77 public String getUnit() 78 { 79 return units; 80 } 81 82 public String getDescription() 83 { 84 return description; 85 } 86 87 public long getStartTime() 88 { 89 return startTime; 90 } 91 92 public long getLastSampleTime() 93 { 94 return lastSampleTime; 95 } 96 97 100 public void reset() 101 { 102 startTime = System.currentTimeMillis(); 103 lastSampleTime = startTime; 104 } 105 106 109 public void set() 110 { 111 lastSampleTime = System.currentTimeMillis(); 112 } 113 114 public String toString() 115 { 116 StringBuffer tmp = new StringBuffer (name); 117 tmp.append('('); 118 tmp.append("description: "); 119 tmp.append(description); 120 tmp.append(", units: "); 121 tmp.append(units); 122 tmp.append(", startTime: "); 123 tmp.append(startTime); 124 tmp.append(", lastSampleTime: "); 125 tmp.append(lastSampleTime); 126 tmp.append(')'); 127 return tmp.toString(); 128 } 129 } 130 | Popular Tags |