001    package com.khubla.pragmatach.framework.controller;
002    
003    import java.util.Set;
004    
005    import com.khubla.pragmatach.framework.api.PragmatachException;
006    
007    /**
008     * @author tome
009     */
010    public class Controllers {
011       /**
012        * instance
013        */
014       private static Controllers instance;
015    
016       /**
017        * singleton
018        */
019       public static Controllers getInstance() {
020          if (null == instance) {
021             instance = new Controllers();
022          }
023          return instance;
024       }
025    
026       /**
027        * get a PragmatachController instance
028        */
029       public static PragmatachController getInstance(Class<?> clazz) throws PragmatachException {
030          try {
031             return (PragmatachController) clazz.newInstance();
032          } catch (final Exception e) {
033             throw new PragmatachException("Exception in getInstance", e);
034          }
035       }
036    
037       private final Set<Class<?>> controllers;
038    
039       /**
040        * ctor
041        */
042       private Controllers() {
043          controllers = ControllerClasses.getControllers();
044       }
045    
046       public Set<Class<?>> getControllers() {
047          return controllers;
048       }
049    }