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     */
017    package org.apache.activemq.management;
018    
019    import javax.jms.Destination;
020    
021    import org.apache.activemq.util.IndentPrinter;
022    
023    /**
024     * Statistics for a JMS producer
025     * 
026     * 
027     */
028    public class JMSProducerStatsImpl extends JMSEndpointStatsImpl {
029        private String destination;
030    
031        public JMSProducerStatsImpl(JMSSessionStatsImpl sessionStats, Destination destination) {
032            super(sessionStats);
033            if (destination != null) {
034                this.destination = destination.toString();
035            }
036        }
037    
038        public JMSProducerStatsImpl(CountStatisticImpl messageCount, CountStatisticImpl pendingMessageCount, CountStatisticImpl expiredMessageCount, TimeStatisticImpl messageWaitTime,
039                                    TimeStatisticImpl messageRateTime, String destination) {
040            super(messageCount, pendingMessageCount, expiredMessageCount, messageWaitTime, messageRateTime);
041            this.destination = destination;
042        }
043    
044        public String getDestination() {
045            return destination;
046        }
047    
048        public String toString() {
049            StringBuffer buffer = new StringBuffer();
050            buffer.append("producer ");
051            buffer.append(destination);
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("producer ");
061            out.print(destination);
062            out.println(" {");
063            out.incrementIndent();
064    
065            super.dump(out);
066    
067            out.decrementIndent();
068            out.printIndent();
069            out.println("}");
070        }
071    }