jenes.statistics
Class StatisticsLogger

java.lang.Object
  extended by jenes.statistics.StatisticsLogger

public class StatisticsLogger
extends java.lang.Object

This class provides an utility wrapper for logging the statistics. In order to log statistics, the class has to extend LoggableStatistics in order to automatically retrieve figures. Figures are provided by methods returning double value figures and annotated as @Loggable. For example:

 class MyStatistics extends LoggableStatistics {
    ...
    @Loggable("SomeFigure")
    double getSomeValue() { ... }
    ...
    @Loggable("SomeCount")
    double getSomeCount() { ... }
    ...
 }
 
 
Statistics are passed to the logger as specified at instantiation time.

Author:
Luigi Troiano
See Also:
StatisticsLogger.LoggableStatistics

Nested Class Summary
static interface StatisticsLogger.Loggable
          Annotation for methods providing some figure in a LoggableStatistics object.
static class StatisticsLogger.LoggableStatistics
          This class provides the support for making a statistics loggable.
 
Constructor Summary
StatisticsLogger(AbstractLogger logger, java.lang.String... figures)
          Creastes a StatisticsLogger.
 
Method Summary
 void close()
          Closes the undelying logger.
protected  void finalize()
           
 AbstractLogger getLogger()
          Returns the logger used for storing the statistics.
 void record(StatisticsLogger.LoggableStatistics statistics)
          Store a new statistic record in the logger.
 void save()
          Saves the undelying logger.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatisticsLogger

public StatisticsLogger(AbstractLogger logger,
                        java.lang.String... figures)
Creastes a StatisticsLogger. If figures is empty, no filter is applied and all statistics are able to be saved.

Parameters:
logger - - the logger used to save the statistics
figures - - the figures that we are interested to save
Method Detail

record

public void record(StatisticsLogger.LoggableStatistics statistics)
Store a new statistic record in the logger.

Parameters:
statistics - - the statistics being logged.

getLogger

public AbstractLogger getLogger()
Returns the logger used for storing the statistics.

Returns:
the logger

save

public void save()
Saves the undelying logger.


close

public void close()
Closes the undelying logger.


finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object