1 10 11 package org.mule.management.mbeans; 12 13 import java.io.StringWriter ; 14 import java.util.Collection ; 15 16 import org.apache.commons.logging.Log; 17 import org.apache.commons.logging.LogFactory; 18 import org.mule.MuleManager; 19 import org.mule.management.stats.AllStatistics; 20 import org.mule.management.stats.printers.CSVPrinter; 21 import org.mule.management.stats.printers.HtmlTablePrinter; 22 import org.mule.umo.manager.UMOManager; 23 24 30 public class StatisticsService implements StatisticsServiceMBean 31 { 32 35 private static final long serialVersionUID = -4949499389883146363L; 36 37 40 protected static Log logger = LogFactory.getLog(StatisticsService.class); 41 42 private AllStatistics stats = new AllStatistics(); 43 private MuleManager manager = null; 44 45 public void setManager(UMOManager manager) 46 { 47 this.manager = (MuleManager)manager; 48 if (manager == null) 49 { 50 stats = new AllStatistics(); 51 } 52 else 53 { 54 stats = this.manager.getStatistics(); 55 } 56 57 } 58 59 62 public void clear() 63 { 64 stats.clear(); 65 } 66 67 70 public boolean isEnabled() 71 { 72 return stats.isEnabled(); 73 } 74 75 78 public void setEnabled(boolean b) 79 { 80 stats.setEnabled(b); 81 82 } 83 84 public Collection getComponentStatistics() 85 { 86 return stats.getComponentStatistics(); 87 } 88 89 public void logSummary() 90 { 91 stats.logSummary(); 92 } 93 94 public void logCSVSummary() 95 { 96 CSVPrinter printer = new CSVPrinter(System.out); 97 printer.setPrintHeaders(true); 98 stats.logSummary(printer); 99 } 100 101 105 public String printHtmlSummary() 106 { 107 StringWriter w = new StringWriter (); 108 HtmlTablePrinter printer = new HtmlTablePrinter(w); 109 stats.logSummary(printer); 110 return w.toString(); 111 } 112 113 public String getHtmlSummary() 114 { 115 return printHtmlSummary(); 116 } 117 } 118 | Popular Tags |