Coverage Report - pt.digitalis.dif.utils.logging.DIFInitAspect
 
Classes in this File Line Coverage Branch Coverage Complexity
DIFInitAspect
0%
0/14
0%
0/6
0
 
 1  0
 /**
 2  
  * - Digitalis Internal Framework v2.0 -
 3  
  *
 4  
  * (C) 2007, Digitalis Informatica. 
 5  
  * 
 6  
  * Distribuicao e Gestao de Informatica, Lda.
 7  
  * Estrada de Paco de Arcos num.9 - Piso -1
 8  
  * 2780-666 Paco de Arcos
 9  
  * Telefone: (351) 21 4408990
 10  
  * Fax: (351) 21 4408999
 11  
  * http://www.digitalis.pt 
 12  
  */
 13  
 package pt.digitalis.dif.utils.logging;
 14  
 
 15  
 import pt.digitalis.log.LogLevel;
 16  
 import pt.digitalis.dif.startup.DIFInitializer;
 17  
 
 18  
 /**
 19  
  * Contains the logging logic to be applied on the DIF Initialization process.
 20  
  * 
 21  
  * @author Pedro Viegas <a href="mailto:pviegas@digitalis.pt">pviegas@digitalis.pt</a>
 22  
  * @created Oct 9, 2007
 23  
  * 
 24  
  */
 25  0
 public final aspect DIFInitAspect extends DIFLogAspect {
 26  
 
 27  
     /** Keeps the class enhancing start timestamp */
 28  
     private long difInitStartTime;
 29  
 
 30  
     /** Captures the DEM Entity classes identifying process. */
 31  0
     private pointcut DIFInitialization() : execution (* pt.digitalis.dif.startup.DIFInitializer.initialize()) && excludeLoggingAppliances();
 32  
 
 33  
     /**
 34  
      * Since the DIFInitializer.initialize() sets it's own initialization internal flag, if the aspect relies on the
 35  
      * DIFInitializer.isInitialized() method to execute the after():DIFInitialization advice, the advice body will never be picked up.
 36  
      * As such, the aspect must rely on another method to log the initialization time.
 37  
      */
 38  0
     private boolean initializationInProgress = false;
 39  
 
 40  
     /**
 41  
      * Logs the DIF Initialization start
 42  
      */
 43  
     before() : DIFInitialization()
 44  
     {
 45  0
         if (!DIFInitializer.isInitialized()) {
 46  0
             difInitStartTime = System.currentTimeMillis();
 47  
 
 48  0
             getLogger().log(LogLevel.INFO, "DIF Initialization started...");
 49  
 
 50  0
             initializationInProgress = true;
 51  
         }
 52  0
     }
 53  
 
 54  
     /**
 55  
      * Logs the DIF Initialization end
 56  
      */
 57  
     after() : DIFInitialization()
 58  
     {
 59  0
         if (initializationInProgress) {
 60  0
             getLogger().log(LogLevel.INFO,
 61  0
                     "DIF Initialized in " + (System.currentTimeMillis() - difInitStartTime) + " ms.");
 62  
 
 63  0
             initializationInProgress = false;
 64  
         }
 65  0
     }
 66  
 }