Coverage Report - pt.digitalis.dif.ioc.DIFIoCRegistry
 
Classes in this File Line Coverage Branch Coverage Complexity
DIFIoCRegistry
0%
0/12
0%
0/6
3,5
 
 1  0
 /**
 2  
  * - Digitalis Internal Framework v2.0 - (C) 2007, Digitalis Informatica. Distribuicao e Gestao de Informatica, Lda.
 3  
  * Estrada de Paco de Arcos num.9 - Piso -1 2780-666 Paco de Arcos Telefone: (351) 21 4408990 Fax: (351) 21 4408999
 4  
  * http://www.digitalis.pt
 5  
  */
 6  
 package pt.digitalis.dif.ioc;
 7  
 
 8  
 import pt.digitalis.dif.startup.DIFStartupConfiguration;
 9  
 import pt.digitalis.utils.ioc.IIoCRegistry;
 10  
 import pt.digitalis.utils.ioc.IoCImplementations;
 11  
 import pt.digitalis.utils.ioc.exception.IoCException;
 12  
 import pt.digitalis.utils.ioc.guice.IoCRegistryGuiceImpl;
 13  
 
 14  
 /**
 15  
  * This class represents a wrapper class for the real registry implementation. Since we cant use IoC to abstract us from
 16  
  * the IoC implementation we wish to use, we will use this Facade class to get to the real implementation. The registry
 17  
  * is created with the proper implementation according to the default core dif configuration.
 18  
  * 
 19  
  * @author Pedro Viegas <a href="mailto:pviegas@digitalis.pt">pviegas@digitalis.pt</a>
 20  
  * @created Oct 2, 2007
 21  
  */
 22  
 final public class DIFIoCRegistry {
 23  
 
 24  
     /** IIoCRegistry instance */
 25  
     private static IIoCRegistry instance;
 26  
 
 27  
     /**
 28  
      * Getter for the Singleton instance of {@link IIoCRegistry}
 29  
      * 
 30  
      * @return the registry instance
 31  
      */
 32  
     static public IIoCRegistry getRegistry()
 33  
     {
 34  0
         if (instance == null)
 35  0
             if (IoCImplementations.GUICE.equals(DIFStartupConfiguration.getIoCImplementation()))
 36  
             {
 37  
                 try
 38  
                 {
 39  0
                     instance = IoCRegistryGuiceImpl.getRegistry(DIFStartupConfiguration.getModuleParser());
 40  
                 }
 41  0
                 catch (IoCException iocException)
 42  
                 {
 43  0
                     throw new RuntimeException("Could not find a valid IoC registry! Unable to proceed...",
 44  0
                             iocException);
 45  
                 }
 46  
             }
 47  
             else
 48  0
                 throw new RuntimeException("Unsupported IoC: \"" + DIFStartupConfiguration.getIoCImplementation()
 49  0
                         + "\"\n" + "Check DIF configuration.");
 50  
 
 51  0
         return instance;
 52  
     }
 53  
 
 54  
     /**
 55  
      * Enforce noninstantiability
 56  
      */
 57  0
     private DIFIoCRegistry()
 58  0
     {}
 59  
 }