View Javadoc

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.JMSProducerStats;
24  
25  /***
26   * Statistics for a JMS producer
27   * 
28   * @version $Revision: 1.7 $
29   */
30  public class JMSProducerStatsImpl extends JMSEndpointStatsImpl implements JMSProducerStats {
31      private String destination;
32  
33      public JMSProducerStatsImpl(JMSSessionStatsImpl sessionStats, Destination destination) {
34          super(sessionStats);
35          if (destination != null) {
36              this.destination = destination.toString();
37          }
38      }
39  
40      public JMSProducerStatsImpl(CountStatisticImpl messageCount, CountStatisticImpl pendingMessageCount, CountStatisticImpl expiredMessageCount, TimeStatisticImpl messageWaitTime, TimeStatisticImpl messageRateTime, String destination) {
41          super(messageCount, pendingMessageCount, expiredMessageCount, messageWaitTime, messageRateTime);
42          this.destination = destination;
43      }
44  
45      public String getDestination() {
46          return destination;
47      }
48  
49      public String toString() {
50          StringBuffer buffer = new StringBuffer();
51          buffer.append("producer ");
52          buffer.append(destination);
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("producer ");
62          out.print(destination);
63          out.println(" {");
64          out.incrementIndent();
65  
66          super.dump(out);
67  
68          out.decrementIndent();
69          out.printIndent();
70          out.println("}");
71      }
72  }