Coverage Report - org.mule.module.management.mbean.StatisticsService
 
Classes in this File Line Coverage Branch Coverage Complexity
StatisticsService
0%
0/30
0%
0/2
0
 
 1  
 /*
 2  
  * $Id: StatisticsService.java 20288 2010-11-22 01:19:54Z mike.schilling $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.module.management.mbean;
 12  
 
 13  
 import org.mule.api.MuleContext;
 14  
 import org.mule.management.stats.AllStatistics;
 15  
 import org.mule.management.stats.FlowConstructStatistics;
 16  
 import org.mule.management.stats.printers.CSVPrinter;
 17  
 import org.mule.management.stats.printers.HtmlTablePrinter;
 18  
 import org.mule.management.stats.printers.XMLPrinter;
 19  
 
 20  
 import java.io.StringWriter;
 21  
 import java.util.Collection;
 22  
 
 23  
 import org.apache.commons.logging.Log;
 24  
 import org.apache.commons.logging.LogFactory;
 25  
 
 26  
 /**
 27  
  * <code>StatisicsService</code> exposes Mule processing statistics
 28  
  */
 29  0
 public class StatisticsService implements StatisticsServiceMBean
 30  
 {
 31  
     /**
 32  
      * Serial version
 33  
      */
 34  
     private static final long serialVersionUID = -4949499389883146363L;
 35  
 
 36  
     /**
 37  
      * logger used by this class
 38  
      */
 39  0
     protected static final Log logger = LogFactory.getLog(StatisticsService.class);
 40  
 
 41  0
     private AllStatistics stats = new AllStatistics();
 42  
     private MuleContext muleContext;
 43  
 
 44  
     public void setMuleContext(MuleContext context)
 45  
     {
 46  0
         this.muleContext = context;
 47  0
         if (muleContext == null)
 48  
         {
 49  0
             stats = new AllStatistics();
 50  
         }
 51  
         else
 52  
         {
 53  0
             stats = this.muleContext.getStatistics();
 54  
         }
 55  
 
 56  0
     }
 57  
 
 58  
     /**
 59  
      * @see org.mule.api.management.stats.Statistics#clear()
 60  
      */
 61  
     public void clear()
 62  
     {
 63  0
         stats.clear();
 64  0
     }
 65  
 
 66  
     /**
 67  
      * @see org.mule.api.management.stats.Statistics#isEnabled()
 68  
      */
 69  
     public boolean isEnabled()
 70  
     {
 71  0
         return stats.isEnabled();
 72  
     }
 73  
 
 74  
     /**
 75  
      * @see org.mule.api.management.stats.Statistics#setEnabled(boolean)
 76  
      */
 77  
     public void setEnabled(boolean b)
 78  
     {
 79  0
         stats.setEnabled(b);
 80  
 
 81  0
     }
 82  
 
 83  
     /**
 84  
      * @deprecated use #getServiceStatistics
 85  
      */
 86  
     @Deprecated
 87  
     public Collection getComponentStatistics()
 88  
     {
 89  0
         return stats.getServiceStatistics();
 90  
     }
 91  
 
 92  
     public Collection<FlowConstructStatistics> getServiceStatistics()
 93  
     {
 94  0
         return stats.getServiceStatistics();
 95  
     }
 96  
 
 97  
     public void logSummary()
 98  
     {
 99  0
         stats.logSummary();
 100  0
     }
 101  
 
 102  
     public String printCSVSummary ()
 103  
     {
 104  0
         StringWriter w = new StringWriter(2048);
 105  0
         CSVPrinter printer = new CSVPrinter(w);
 106  0
         printer.setPrintHeaders(true);
 107  0
         stats.logSummary(printer);
 108  0
         return w.toString();
 109  
     }
 110  
 
 111  
     public String printHtmlSummary ()
 112  
     {
 113  0
         StringWriter w = new StringWriter(8192);
 114  0
         HtmlTablePrinter printer = new HtmlTablePrinter(w);
 115  0
         stats.logSummary(printer);
 116  0
         return w.toString();
 117  
     }
 118  
 
 119  
     public String printXmlSummary()
 120  
     {
 121  0
         StringWriter w = new StringWriter(8192);
 122  0
         XMLPrinter printer = new XMLPrinter(w);
 123  0
         stats.logSummary(printer);
 124  0
         return w.toString();
 125  
     }
 126  
 
 127  
 }