001    /** 
002     * 
003     * Copyright 2004 Protique Ltd
004     * 
005     * Licensed under the Apache License, Version 2.0 (the "License"); 
006     * you may not use this file except in compliance with the License. 
007     * 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     * 
017     **/
018    package org.activemq.management;
019    
020    import javax.jms.Destination;
021    
022    import org.activemq.util.IndentPrinter;
023    
024    /**
025     * Statistics for a JMS consumer
026     * 
027     * @version $Revision: 1.1.1.1 $
028     */
029    public class JMSConsumerStatsImpl extends JMSEndpointStatsImpl {
030        private String origin;
031    
032        public JMSConsumerStatsImpl(JMSSessionStatsImpl sessionStats, Destination destination) {
033            super(sessionStats);
034            if (destination != null) {
035                this.origin = destination.toString();
036            }
037        }
038    
039        public JMSConsumerStatsImpl(CountStatisticImpl messageCount, CountStatisticImpl pendingMessageCount, CountStatisticImpl expiredMessageCount, TimeStatisticImpl messageWaitTime, 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    }