KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > excalibur > instrument > manager > http > HTMLInstrumentManagerHandler


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14  * implied.
15  *
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19
20 package org.apache.excalibur.instrument.manager.http;
21
22 import java.io.IOException JavaDoc;
23 import java.io.PrintWriter JavaDoc;
24 import java.util.Map JavaDoc;
25
26 import org.apache.excalibur.instrument.manager.DefaultInstrumentManager;
27 import org.apache.excalibur.instrument.manager.InstrumentableDescriptor;
28
29 /**
30  *
31  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
32  * @version CVS $Revision: 1.6 $ $Date: 2004/03/06 14:01:28 $
33  * @since 4.1
34  */

35 public class HTMLInstrumentManagerHandler
36     extends AbstractHTMLHandler
37 {
38     /*---------------------------------------------------------------
39      * Constructors
40      *-------------------------------------------------------------*/

41     /**
42      * Creates a new HTMLInstrumentManagerHandler.
43      *
44      * @param manager Reference to the DefaultInstrumentManager.
45      * @param connector The InstrumentManagerHTTPConnector.
46      */

47     public HTMLInstrumentManagerHandler( DefaultInstrumentManager manager,
48                                          InstrumentManagerHTTPConnector connector )
49     {
50         super( "/instrument-manager.html", manager, connector );
51     }
52     
53     /*---------------------------------------------------------------
54      * AbstractHTTPURLHandler Methods
55      *-------------------------------------------------------------*/

56     /**
57      * Handles the specified request.
58      *
59      * @param The full path being handled.
60      * @param parameters A Map of the parameters in the request.
61      * @param os The PrintWriter to write the result to.
62      */

63     public void doGet( String JavaDoc path, Map JavaDoc parameters, PrintWriter JavaDoc out )
64         throws IOException JavaDoc
65     {
66         long oldMemory = getLongParameter( parameters, "oldMemory", 0 );
67         long newMemory = getLongParameter( parameters, "newMemory", 0 );
68         
69         String JavaDoc gcLabel = "<a HREF='gc.html'>Perform Garbage Collection</a>";
70         if ( ( oldMemory != 0 ) && ( newMemory != 0 ) )
71         {
72             gcLabel = gcLabel + " (Freed: " + ( oldMemory - newMemory ) + "bytes. "
73                 + "Now " + newMemory + " bytes.";
74         }
75         
76         // This is the root
77
out.println( "<html>" );
78         out.println( "<head><title>" + getInstrumentManager().getDescription()
79             + "</title></head>" );
80         out.println( "<body>" );
81         
82         breadCrumbs( out, false );
83
84         
85         out.println( "<h2>Instrument Manager</h2>" );
86         startTable( out );
87         tableRow( out, 0, "Name", getInstrumentManager().getName() );
88         tableRow( out, 0, "Description", getInstrumentManager().getDescription() );
89         
90         if ( !getConnector().isReadOnly() )
91         {
92             tableRow( out, 0, "GC", gcLabel );
93         }
94         
95         endTable( out );
96         
97         InstrumentableDescriptor[] instrumentables =
98             getInstrumentManager().getInstrumentableDescriptors();
99         if ( instrumentables.length > 0 )
100         {
101             out.println( "<h2>Instrumentables</h2>" );
102             outputInstrumentables( out, instrumentables );
103         }
104         
105         footer( out );
106         
107         out.println( "</body>" );
108         out.println( "</html>" );
109     }
110             
111     /*---------------------------------------------------------------
112      * Methods
113      *-------------------------------------------------------------*/

114 }
115
116
Popular Tags