KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > region > ConnectionStatistics


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

18
19 package org.apache.activemq.broker.region;
20
21
22 import org.apache.activemq.management.CountStatisticImpl;
23 import org.apache.activemq.management.StatsImpl;
24
25 /**
26  * The J2EE Statistics for the Connection.
27  *
28  * @version $Revision: 514694 $
29  */

30 public class ConnectionStatistics extends StatsImpl {
31
32     private CountStatisticImpl enqueues;
33     private CountStatisticImpl dequeues;
34
35     public ConnectionStatistics() {
36
37         enqueues = new CountStatisticImpl("enqueues", "The number of messages that have been sent to the connection");
38         dequeues = new CountStatisticImpl("dequeues", "The number of messages that have been dispatched from the connection");
39
40         addStatistic("enqueues", enqueues);
41         addStatistic("dequeues", dequeues);
42     }
43
44     public CountStatisticImpl getEnqueues() {
45         return enqueues;
46     }
47
48     public CountStatisticImpl getDequeues() {
49         return dequeues;
50     }
51
52     public void reset() {
53         super.reset();
54         enqueues.reset();
55         dequeues.reset();
56     }
57     
58     public void setEnabled(boolean enabled) {
59         super.setEnabled(enabled);
60         enqueues.setEnabled(enabled);
61         dequeues.setEnabled(enabled);
62     }
63
64     public void setParent(ConnectorStatistics parent) {
65         if (parent != null) {
66             enqueues.setParent(parent.getEnqueues());
67             dequeues.setParent(parent.getDequeues());
68         }
69         else {
70             enqueues.setParent(null);
71             dequeues.setParent(null);
72         }
73     }
74
75
76 }
77
Popular Tags