1 19 20 package org.apache.excalibur.instrument.client; 21 22 import org.apache.avalon.framework.configuration.Configuration; 23 import org.apache.avalon.framework.configuration.ConfigurationException; 24 import org.apache.avalon.framework.configuration.DefaultConfiguration; 25 26 32 class MaintainedSampleLease 33 { 34 private String m_instrumentName; 35 private String m_sampleName; 36 private int m_type; 37 private long m_interval; 38 private int m_size; 39 private long m_leaseDuration; 40 private String m_description; 41 42 45 MaintainedSampleLease( String instrumentName, 46 int type, 47 long interval, 48 int size, 49 long leaseDuration, 50 String description ) 51 { 52 m_instrumentName = instrumentName; 53 m_type = type; 54 m_interval = interval; 55 m_size = size; 56 m_leaseDuration = leaseDuration; 57 m_description = description; 58 59 m_sampleName = InstrumentSampleUtils.generateFullInstrumentSampleName( 60 m_instrumentName, m_type, m_interval, m_size ); 61 } 62 63 MaintainedSampleLease( Configuration stateConfig ) throws ConfigurationException 64 { 65 m_instrumentName = stateConfig.getAttribute ( "instrument-name" ); 66 m_type = stateConfig.getAttributeAsInteger( "type" ); 67 m_interval = stateConfig.getAttributeAsLong ( "interval" ); 68 m_size = stateConfig.getAttributeAsInteger( "size" ); 69 m_leaseDuration = stateConfig.getAttributeAsLong ( "lease-duration" ); 70 m_description = stateConfig.getAttribute ( "description" ); 71 72 m_sampleName = InstrumentSampleUtils.generateFullInstrumentSampleName( 73 m_instrumentName, m_type, m_interval, m_size ); 74 } 75 76 79 84 public final Configuration saveState() 85 { 86 DefaultConfiguration stateConfig = new DefaultConfiguration( "maintained-sample", "-" ); 87 88 stateConfig.setAttribute( "instrument-name", m_instrumentName ); 89 stateConfig.setAttribute( "type", 90 InstrumentSampleUtils.getInstrumentSampleTypeName( m_type ) ); 91 stateConfig.setAttribute( "interval", Long.toString( m_interval ) ); 92 stateConfig.setAttribute( "size", Integer.toString( m_size ) ); 93 stateConfig.setAttribute( "lease-duration", Long.toString( m_leaseDuration ) ); 94 stateConfig.setAttribute( "description", m_description ); 95 96 return stateConfig; 97 } 98 99 String getInstrumentName() 100 { 101 return m_instrumentName; 102 } 103 104 String getSampleName() 105 { 106 return m_sampleName; 107 } 108 109 int getType() 110 { 111 return m_type; 112 } 113 114 long getInterval() 115 { 116 return m_interval; 117 } 118 119 int getSize() 120 { 121 return m_size; 122 } 123 124 long getLeaseDuration() 125 { 126 return m_leaseDuration; 127 } 128 129 String getDescription() 130 { 131 return m_description; 132 } 133 } 134 135 | Popular Tags |