Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/activemq/management/JMSStatsImpl.java


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.activemq.management;
19  
20  import java.util.List;
21  
22  import org.activemq.ActiveMQConnection;
23  import org.activemq.util.IndentPrinter;
24  
25  import EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArrayList;
26  
27  /**
28   * Statistics for a number of JMS connections
29   *
30   * @version $Revision: 1.1.1.1 $
31   */
32  public class JMSStatsImpl extends StatsImpl {
33      private List connections = new CopyOnWriteArrayList();
34  
35      public JMSStatsImpl() {
36      }
37  
38      public JMSConnectionStatsImpl[] getConnections() {
39          Object[] connectionArray = connections.toArray();
40          int size = connectionArray.length;
41          JMSConnectionStatsImpl[] answer = new JMSConnectionStatsImpl[size];
42          for (int i = 0; i < size; i++) {
43              ActiveMQConnection connection = (ActiveMQConnection) connectionArray[i];
44              answer[i] = connection.getConnectionStats();
45          }
46          return answer;
47      }
48  
49      public void addConnection(ActiveMQConnection connection) {
50          connections.add(connection);
51      }
52  
53      public void removeConnection(ActiveMQConnection connection) {
54          connections.remove(connection);
55      }
56  
57      public void dump(IndentPrinter out) {
58          out.printIndent();
59          out.println("factory {");
60          out.incrementIndent();
61          JMSConnectionStatsImpl[] array = getConnections();
62          for (int i = 0; i < array.length; i++) {
63              JMSConnectionStatsImpl connectionStat = (JMSConnectionStatsImpl) array[i];
64              connectionStat.dump(out);
65          }
66          out.decrementIndent();
67          out.printIndent();
68          out.println("}");
69          out.flush();
70      }
71  }