1 /***
2 *
3 * Copyright 2004 Protique Ltd
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 package org.codehaus.activemq.management;
19
20 import org.codehaus.activemq.util.IndentPrinter;
21
22 import javax.jms.Destination;
23 import javax.management.j2ee.statistics.JMSConsumerStats;
24
25 /***
26 * Statistics for a JMS consumer
27 *
28 * @version $Revision: 1.7 $
29 */
30 public class JMSConsumerStatsImpl extends JMSEndpointStatsImpl implements JMSConsumerStats {
31 private String origin;
32
33 public JMSConsumerStatsImpl(JMSSessionStatsImpl sessionStats, Destination destination) {
34 super(sessionStats);
35 if (destination != null) {
36 this.origin = destination.toString();
37 }
38 }
39
40 public JMSConsumerStatsImpl(CountStatisticImpl messageCount, CountStatisticImpl pendingMessageCount, CountStatisticImpl expiredMessageCount, TimeStatisticImpl messageWaitTime, TimeStatisticImpl messageRateTime, String origin) {
41 super(messageCount, pendingMessageCount, expiredMessageCount, messageWaitTime, messageRateTime);
42 this.origin = origin;
43 }
44
45 public String getOrigin() {
46 return origin;
47 }
48
49 public String toString() {
50 StringBuffer buffer = new StringBuffer();
51 buffer.append("consumer ");
52 buffer.append(origin);
53 buffer.append(" { ");
54 buffer.append(super.toString());
55 buffer.append(" }");
56 return buffer.toString();
57 }
58
59 public void dump(IndentPrinter out) {
60 out.printIndent();
61 out.print("consumer ");
62 out.print(origin);
63 out.println(" {");
64 out.incrementIndent();
65
66 super.dump(out);
67
68 out.decrementIndent();
69 out.printIndent();
70 out.println("}");
71 }
72 }