KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > bus > management > counters > TransportServerCounters


1 package org.objectweb.celtix.bus.management.counters;
2
3
4 public class TransportServerCounters {
5     private static final String JavaDoc[] COUNTER_NAMES = {"RequestsTotal",
6                                                    "RequestsOneWay",
7                                                    "TotalError"};
8     private Counter[] counters;
9     
10     
11     private String JavaDoc owner;
12     
13     public TransportServerCounters(String JavaDoc o) {
14         owner = o;
15         counters = new Counter[COUNTER_NAMES.length];
16         initCounters();
17     }
18     public String JavaDoc getOwner() {
19         return owner;
20     }
21            
22     public Counter getRequestTotal() {
23         return counters[0];
24     }
25     
26     public Counter getRequestOneWay() {
27         return counters[1];
28     }
29     
30     public Counter getTotalError() {
31         return counters[2];
32     
33     }
34     
35     private void initCounters() {
36         for (int i = 0; i < COUNTER_NAMES.length; i++) {
37             Counter c = new Counter(COUNTER_NAMES[i]);
38             counters[i] = c;
39         }
40     }
41     
42     public void resetCounters() {
43         for (int i = 0; i < counters.length; i++) {
44             counters[i].reset();
45         }
46     }
47     
48     public void stopCounters() {
49         for (int i = 0; i < counters.length; i++) {
50             counters[i].stop();
51         }
52     }
53     
54     
55 }
56
Popular Tags