1 19 20 package org.apache.excalibur.instrument.manager.http; 21 22 import java.io.FileNotFoundException ; 23 import java.io.IOException ; 24 import java.io.PrintWriter ; 25 import java.util.Map ; 26 27 import org.apache.excalibur.instrument.manager.DefaultInstrumentManager; 28 import org.apache.excalibur.instrument.manager.InstrumentSampleDescriptor; 29 import org.apache.excalibur.instrument.manager.NoSuchInstrumentSampleException; 30 31 37 public class XMLSnapshotsHandler 38 extends AbstractXMLHandler 39 { 40 43 49 public XMLSnapshotsHandler( DefaultInstrumentManager manager, 50 InstrumentManagerHTTPConnector connector ) 51 { 52 super( "/snapshots.xml", manager, connector ); 53 } 54 55 58 65 public void doGet( String path, Map parameters, PrintWriter out ) 66 throws IOException 67 { 68 String [] names = getParameters( parameters, "name" ); 69 long[] baseTimes = getLongParameters( parameters, "base-time", 0 ); 70 boolean packed = getBooleanParameter( parameters, "packed", false ); 71 boolean compact = getBooleanParameter( parameters, "compact", false ); 72 73 if ( ( baseTimes.length == 0 ) && ( names.length > 0 ) ) 74 { 75 baseTimes = new long[names.length]; 76 } 77 else if ( names.length != baseTimes.length ) 78 { 79 throw new FileNotFoundException ( 80 "The number of base-time values not equal to the number of names." ); 81 } 82 83 out.println( InstrumentManagerHTTPConnector.XML_BANNER ); 84 if ( names.length > 0 ) 85 { 86 outputLine( out, "", packed, "<samples>" ); 87 88 for ( int i = 0; i < names.length; i++ ) 89 { 90 InstrumentSampleDescriptor desc; 91 try 92 { 93 desc = 94 getInstrumentManager().locateInstrumentSampleDescriptor( names[i] ); 95 96 outputSampleHistory( out, desc, "", baseTimes[i], packed, compact ); 97 } 98 catch ( NoSuchInstrumentSampleException e ) 99 { 100 outputLine( out, " ", packed, 101 "<sample name=\"" + names[i] + "\" expired=\"true\"/>" ); 102 } 103 } 104 105 outputLine( out, "", packed, "</samples>" ); 106 } 107 else 108 { 109 outputLine( out, "", packed, "<samples/>" ); 110 } 111 } 112 113 116 } 117 118 | Popular Tags |