1 23 24 28 29 34 35 package com.sun.enterprise.admin.monitor.stats; 36 37 import javax.management.j2ee.statistics.CountStatistic ; 38 import com.sun.enterprise.admin.monitor.stats.CountStatisticImpl; 39 import javax.management.j2ee.statistics.Statistic ; 40 41 48 49 public class MutableCountStatisticImpl implements CountStatistic , MutableCountStatistic { 50 51 private final CountStatistic initial; 52 private long count; 53 private long lastSampleTime; 54 private long startTime; 55 56 62 public MutableCountStatisticImpl(CountStatistic initial) { 63 this.initial = initial; 64 this.count = initial.getCount(); 65 this.lastSampleTime = initial.getLastSampleTime(); 66 this.startTime = lastSampleTime; 67 } 68 69 78 public void reset() { 79 this.count = initial.getCount(); 80 this.lastSampleTime = System.currentTimeMillis(); 81 this.startTime = this.lastSampleTime; 82 } 83 84 94 public void setCount(long count) { 95 this.count = count; 96 this.lastSampleTime = System.currentTimeMillis(); 97 } 98 99 109 public Statistic unmodifiableView() { 110 return ( new CountStatisticImpl( 111 this.count, initial.getName(), initial.getUnit(), initial.getDescription(), this.lastSampleTime, this.startTime )); 118 } 119 120 public long getLastSampleTime() { 121 return ( this.lastSampleTime ); 122 } 123 124 public long getStartTime() { 125 return ( this.startTime ); 126 } 127 128 public String getName() { 129 return ( initial.getName() ); 130 } 131 132 public String getDescription() { 133 return ( initial.getDescription() ); 134 } 135 136 public String getUnit() { 137 return ( initial.getUnit()); 138 } 139 140 public Statistic modifiableView() { 141 return ( this ); 142 } 143 144 public long getCount() { 145 return ( this.count ); 146 } 147 148 149 public void setDescription (final String s) { 150 try { 151 ((StatisticImpl)this.initial).setDescription(s); 152 } 153 catch(final Exception e) { 154 } 155 } 156 } 157 | Popular Tags |