1 19 20 package org.apache.excalibur.instrument.client.http; 21 22 import org.apache.excalibur.instrument.client.InstrumentSampleData; 23 import org.apache.excalibur.instrument.client.InstrumentSampleSnapshotData; 24 25 import org.apache.avalon.framework.configuration.Configuration; 26 import org.apache.avalon.framework.configuration.ConfigurationException; 27 28 class HTTPInstrumentSampleData 29 extends AbstractHTTPInstrumentSampleElementData 30 implements InstrumentSampleData 31 { 32 35 38 HTTPInstrumentSampleData( HTTPInstrumentData parent, 39 String name ) 40 { 41 super( (HTTPInstrumentManagerConnection)parent.getConnection(), parent, name ); 42 } 43 44 47 54 protected void update( Configuration configuration ) 55 throws ConfigurationException 56 { 57 super.update( configuration ); 58 59 if ( getLogger().isDebugEnabled() ) 60 { 61 getLogger().debug( 62 "Updated Instrument Sample '" + getName() + "' to version " + getStateVersion() ); 63 } 64 } 65 66 72 public boolean update() 73 { 74 HTTPInstrumentManagerConnection connection = 75 (HTTPInstrumentManagerConnection)getConnection(); 76 77 Configuration configuration = connection.getState( 78 "sample.xml?packed=true&name=" + urlEncode( getName() ) ); 79 if ( configuration != null ) 80 { 81 try 82 { 83 update( configuration ); 84 return true; 85 } 86 catch ( ConfigurationException e ) 87 { 88 getLogger().debug( "Unable to update.", e ); 89 } 90 } 91 92 return false; 93 } 94 95 98 101 public void updateLease() 102 { 103 HTTPInstrumentManagerConnection connection = 104 (HTTPInstrumentManagerConnection)getConnection(); 105 106 connection.getState( "sample-lease.xml?name=" + urlEncode( getName() ) ); 107 } 108 109 114 public InstrumentSampleSnapshotData getSnapshot() 115 { 116 HTTPInstrumentManagerConnection connection = 117 (HTTPInstrumentManagerConnection)getConnection(); 118 119 HTTPInstrumentSampleSnapshotData snapshot = 120 new HTTPInstrumentSampleSnapshotData( connection, getName() ); 121 snapshot.enableLogging( getLogger() ); 122 if ( snapshot.update() ) 123 { 124 return snapshot; 125 } 126 else 127 { 128 return null; 129 } 130 } 131 132 135 } | Popular Tags |