1 18 package org.apache.activemq.management; 19 20 import org.apache.activemq.ActiveMQSession; 21 import org.apache.activemq.util.IndentPrinter; 22 23 import java.util.List ; 24 29 public class JMSConnectionStatsImpl extends StatsImpl { 30 private List sessions; 31 private boolean transactional; 32 33 public JMSConnectionStatsImpl(List sessions, boolean transactional) { 34 this.sessions = sessions; 35 this.transactional = transactional; 36 } 37 38 public JMSSessionStatsImpl[] getSessions() { 39 Object [] sessionArray = sessions.toArray(); 41 int size = sessionArray.length; 42 JMSSessionStatsImpl[] answer = new JMSSessionStatsImpl[size]; 43 for (int i = 0; i < size; i++) { 44 ActiveMQSession session = (ActiveMQSession) sessionArray[i]; 45 answer[i] = session.getSessionStats(); 46 } 47 return answer; 48 } 49 50 public void reset() { 51 super.reset(); 52 JMSSessionStatsImpl[] stats = getSessions(); 53 for (int i = 0, size = stats.length; i < size; i++) { 54 stats[i].reset(); 55 } 56 } 57 58 61 public void setEnabled(boolean enabled){ 62 super.setEnabled(enabled); 63 JMSSessionStatsImpl[] stats = getSessions(); 64 for (int i = 0, size = stats.length; i < size; i++) { 65 stats[i].setEnabled(enabled); 66 } 67 68 } 69 70 71 public boolean isTransactional() { 72 return transactional; 73 } 74 75 public String toString() { 76 StringBuffer buffer = new StringBuffer ("connection{ "); 77 JMSSessionStatsImpl[] array = getSessions(); 78 for (int i = 0; i < array.length; i++) { 79 if (i > 0) { 80 buffer.append(", "); 81 } 82 buffer.append(Integer.toString(i)); 83 buffer.append(" = "); 84 buffer.append(array[i]); 85 } 86 buffer.append(" }"); 87 return buffer.toString(); 88 } 89 90 public void dump(IndentPrinter out) { 91 out.printIndent(); 92 out.println("connection {"); 93 out.incrementIndent(); 94 JMSSessionStatsImpl[] array = getSessions(); 95 for (int i = 0; i < array.length; i++) { 96 JMSSessionStatsImpl sessionStat = (JMSSessionStatsImpl) array[i]; 97 out.printIndent(); 98 out.println("session {"); 99 out.incrementIndent(); 100 sessionStat.dump(out); 101 out.decrementIndent(); 102 out.printIndent(); 103 out.println("}"); 104 } 105 out.decrementIndent(); 106 out.printIndent(); 107 out.println("}"); 108 out.flush(); 109 } 110 } 111 | Popular Tags |