KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > martiansoftware > nailgun > builtins > NGServerStats


1 /*
2
3   Copyright 2004, Martian Software, Inc.
4
5   Licensed under the Apache License, Version 2.0 (the "License");
6   you may not use this file except in compliance with the License.
7   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 implied.
14   See the License for the specific language governing permissions and
15   limitations under the License.
16
17 */

18
19 package com.martiansoftware.nailgun.builtins;
20
21 import java.util.Iterator JavaDoc;
22 import java.util.Map JavaDoc;
23
24 import com.martiansoftware.nailgun.NGServer;
25 import com.martiansoftware.nailgun.NGContext;
26
27 /**
28  * <p>Displays all <a HREF="NailStats.html">NailStats</a> tracked by the server.</p>
29  *
30  * <p>This can be run standalone with no arguments. It will also run automatically
31  * upon <code>NGServer</code> shutdown, sending its output to the server's <code>System.out</code>.</p>
32  *
33  * <p>This is aliased by default to the command "<code>ng-stats</code>".</p>
34  * @author <a HREF="http://www.martiansoftware.com/contact.html">Marty Lamb</a>
35  */

36
37 public class NGServerStats {
38
39     public static void nailShutdown(NGServer server) {
40         dumpStats(server, server.out);
41     }
42     
43     public static void nailMain(NGContext context) {
44         dumpStats(context.getNGServer(), context.out);
45     }
46
47     private static void dumpStats(NGServer server, java.io.PrintStream JavaDoc out) {
48         Map JavaDoc stats = server.getNailStats();
49         for (Iterator JavaDoc i = stats.values().iterator(); i.hasNext();) {
50             out.println(i.next());
51         }
52     }
53
54 }
55
Popular Tags