001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.activemq.management; 018 019import javax.jms.Destination; 020 021import org.apache.activemq.util.IndentPrinter; 022 023/** 024 * Statistics for a JMS consumer 025 * 026 * 027 */ 028public class JMSConsumerStatsImpl extends JMSEndpointStatsImpl { 029 private String origin; 030 031 public JMSConsumerStatsImpl(JMSSessionStatsImpl sessionStats, Destination destination) { 032 super(sessionStats); 033 if (destination != null) { 034 this.origin = destination.toString(); 035 } 036 } 037 038 public JMSConsumerStatsImpl(CountStatisticImpl messageCount, CountStatisticImpl pendingMessageCount, CountStatisticImpl expiredMessageCount, TimeStatisticImpl messageWaitTime, 039 TimeStatisticImpl messageRateTime, String origin) { 040 super(messageCount, pendingMessageCount, expiredMessageCount, messageWaitTime, messageRateTime); 041 this.origin = origin; 042 } 043 044 public String getOrigin() { 045 return origin; 046 } 047 048 public String toString() { 049 StringBuffer buffer = new StringBuffer(); 050 buffer.append("consumer "); 051 buffer.append(origin); 052 buffer.append(" { "); 053 buffer.append(super.toString()); 054 buffer.append(" }"); 055 return buffer.toString(); 056 } 057 058 public void dump(IndentPrinter out) { 059 out.printIndent(); 060 out.print("consumer "); 061 out.print(origin); 062 out.println(" {"); 063 out.incrementIndent(); 064 065 super.dump(out); 066 067 out.decrementIndent(); 068 out.printIndent(); 069 out.println("}"); 070 } 071}