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