1 18 package org.apache.activemq.management; 19 20 import java.util.List ; 21 22 import org.apache.activemq.ActiveMQConnection; 23 import org.apache.activemq.util.IndentPrinter; 24 25 import java.util.concurrent.CopyOnWriteArrayList ; 26 27 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 72 75 public void setEnabled(boolean enabled){ 76 super.setEnabled(enabled); 77 JMSConnectionStatsImpl[] stats = getConnections(); 78 for (int i = 0, size = stats.length; i < size; i++) { 79 stats[i].setEnabled(enabled); 80 } 81 82 } 83 } 84 | Popular Tags |