1 50 package org.apache.excalibur.instrument.manager; 51 52 import org.apache.avalon.framework.configuration.Configuration; 53 import org.apache.avalon.framework.configuration.ConfigurationException; 54 import org.apache.avalon.framework.configuration.DefaultConfiguration; 55 import org.apache.excalibur.instrument.manager.interfaces.InstrumentManagerClient; 56 57 65 abstract class AbstractValueInstrumentSample 66 extends AbstractInstrumentSample 67 implements ValueInstrumentListener 68 { 69 70 protected int m_value; 71 72 73 protected int m_valueCount; 74 75 78 89 protected AbstractValueInstrumentSample( InstrumentProxy instrumentProxy, 90 String name, 91 long interval, 92 int size, 93 String description, 94 long lease ) 95 { 96 super( instrumentProxy, name, interval, size, description, lease ); 97 98 m_value = 0; 100 } 101 102 105 113 public final int getInstrumentType() 114 { 115 return InstrumentManagerClient.INSTRUMENT_TYPE_VALUE; 116 } 117 118 127 public int getValueInner() 128 { 129 return m_value; 130 } 131 132 135 140 protected void saveState( DefaultConfiguration state ) 141 { 142 super.saveState( state ); 143 144 state.setAttribute( "value-count", Integer.toString( m_valueCount ) ); 145 } 146 147 158 protected void loadState( int value, Configuration state ) 159 throws ConfigurationException 160 { 161 m_value = value; 162 m_valueCount = state.getAttributeAsInteger( "value-count" ); 163 } 164 165 169 protected void postSaveNeedsReset() 170 { 171 m_value = 0; 172 m_valueCount = 0; 173 } 174 175 178 187 public void setValue( String instrumentName, int value, long time ) 188 { 189 setValueInner( value, time ); 192 } 193 194 195 198 204 protected abstract void setValueInner( int value, long time ); 205 } 206 | Popular Tags |