1 19 20 package org.apache.excalibur.instrument.manager.http; 21 22 import java.io.IOException ; 23 import java.io.PrintWriter ; 24 import java.util.Map ; 25 26 import org.apache.excalibur.instrument.manager.http.server.HTTPRedirect; 27 import org.apache.excalibur.instrument.manager.DefaultInstrumentManager; 28 import org.apache.excalibur.instrument.manager.InstrumentableDescriptor; 29 import org.apache.excalibur.instrument.manager.InstrumentDescriptor; 30 import org.apache.excalibur.instrument.manager.NoSuchInstrumentableException; 31 32 38 public class HTMLInstrumentableHandler 39 extends AbstractHTMLHandler 40 { 41 44 50 public HTMLInstrumentableHandler( DefaultInstrumentManager manager, 51 InstrumentManagerHTTPConnector connector ) 52 { 53 super( "/instrumentable.html", manager, connector ); 54 } 55 56 59 66 public void doGet( String path, Map parameters, PrintWriter out ) 67 throws IOException 68 { 69 String name = getParameter( parameters, "name" ); 70 InstrumentableDescriptor desc; 71 try 72 { 73 desc = getInstrumentManager().locateInstrumentableDescriptor( name ); 74 } 75 catch ( NoSuchInstrumentableException e ) 76 { 77 int pos = name.lastIndexOf( '.' ); 79 if ( pos >= 0 ) 80 { 81 throw new HTTPRedirect( 82 "instrumentable.html?name=" + urlEncode( name.substring( 0, pos ) ) ); 83 } 84 else 85 { 86 throw new HTTPRedirect( "instrument-manager.html" ); 87 } 88 } 89 90 out.println( "<html>" ); 91 out.println( "<head><title>" + desc.getDescription() + "</title></head>" ); 92 out.println( "<body>" ); 93 94 breadCrumbs( out, desc, false ); 95 96 out.println( "<h2>Instrumentable</h2>" ); 97 startTable( out ); 98 tableRow( out, 0, "Name", desc.getName() ); 99 tableRow( out, 0, "Description", desc.getDescription() ); 100 endTable( out ); 101 102 InstrumentableDescriptor[] instrumentables = desc.getChildInstrumentableDescriptors(); 103 if ( instrumentables.length > 0 ) 104 { 105 out.println( "<h2>Instrumentables</h2>" ); 106 outputInstrumentables( out, instrumentables ); 107 } 108 109 InstrumentDescriptor[] instruments = desc.getInstrumentDescriptors(); 110 if ( instruments.length > 0 ) 111 { 112 out.println( "<h2>Instruments</h2>" ); 113 outputInstruments( out, instruments ); 114 } 115 116 footer( out ); 117 118 out.println( "</body>" ); 119 out.println( "</html>" ); 120 } 121 122 125 } 126 127 | Popular Tags |