[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework/repository Repository.java,1.2,1.
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-03-22 14:21:12
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/repository In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24394/repository Modified Files: Repository.java Log Message: no message Index: Repository.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/repository/Repository.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Repository.java 17 Mar 2006 05:13:48 -0000 1.2 --- Repository.java 22 Mar 2006 14:20:45 -0000 1.3 *************** *** 8,11 **** --- 8,12 ---- import org.jmonks.batchserver.framework.controller.JobController; import org.jmonks.batchserver.framework.*; + import org.jmonks.batchserver.framework.repository.db4o.Db4oRepository; *************** *** 17,21 **** * This povides utility methods to logs the job statistics and persist job controllers, * transfer some information between the jobs and transfer some management and monitor ! * information between framework and server. * </p> * <p> --- 18,24 ---- * This povides utility methods to logs the job statistics and persist job controllers, * transfer some information between the jobs and transfer some management and monitor ! * information between framework and server. Repository make sure only one instance ! * of the implementation class will be created (implements the singleton pattern) ! * and will be used through out the system/job. * </p> * <p> *************** *** 23,27 **** * This declares an abstract method init with the protected access for the repository * implementors to inititalize the repository implementation. Implementors should implement ! * this method and make sure default constructor exist to enable the initialization of * this implementation from the factory method. * </p> --- 26,30 ---- * This declares an abstract method init with the protected access for the repository * implementors to inititalize the repository implementation. Implementors should implement ! * this method and make sure constructor is exist and accessible to enable the initialization of * this implementation from the factory method. * </p> *************** *** 32,38 **** public abstract class Repository { - private static Logger logger=Logger.getLogger(Repository.class); ! /** --- 35,45 ---- public abstract class Repository { private static Logger logger=Logger.getLogger(Repository.class); ! ! /** ! * Variable to hold the singleton instance of repository implementation ! * defined in framework configuration. ! */ ! private static Repository repository=null; /** *************** *** 52,104 **** * repository configuration in framework configuration file. * - * @param repositoryConfig Repository configuration object. - * * @throws ConfigurationException If repositoryClassName is missing or invalid * or it cannot be instantiated because of the lack of mandatory properties required * by the specific repository implementations. - * @throws IllegalArgumentException If input repositoryConfig is null. */ ! public static Repository getRepository(FrameworkConfig.RepositoryConfig repositoryConfig) { logger.trace("Entering getRepository"); ! ! if(repositoryConfig==null) ! throw new IllegalArgumentException("repository configuration object cannot be null."); ! ! String repositoryClassName=repositoryConfig.getRepositoryClassName(); ! if(repositoryClassName==null || "".equals(repositoryClassName)) ! throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, "repository class name is not defined in repository configuration"); ! logger.debug("repository class name = " + repositoryClassName); ! ! Repository repository=null; ! ! try ! { ! repository=(Repository)Class.forName(repositoryClassName).newInstance(); ! repository.init(repositoryConfig.getRepositoryConfigProperties()); ! logger.debug("created the repository implemenation class"); ! ! } ! catch(ClassNotFoundException exception) ! { ! exception.printStackTrace(); ! logger.error(exception.getMessage(),exception); ! throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, exception.getMessage()); ! } ! catch(InstantiationException exception) { ! exception.printStackTrace(); ! logger.error(exception.getMessage(),exception); ! throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, exception.getMessage()); } ! catch(IllegalAccessException exception) { ! exception.printStackTrace(); ! logger.error(exception.getMessage(),exception); ! throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, exception.getMessage()); } ! ! logger.trace("Exiting getRepository"); ! return repository; } --- 59,114 ---- * repository configuration in framework configuration file. * * @throws ConfigurationException If repositoryClassName is missing or invalid * or it cannot be instantiated because of the lack of mandatory properties required * by the specific repository implementations. */ ! public static synchronized Repository getRepository() { logger.trace("Entering getRepository"); ! if(repository==null) { ! FrameworkConfig.RepositoryConfig repositoryConfig=FrameworkConfig.getInstance().getRepositoryConfig(); ! ! if(repositoryConfig==null) ! throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, "repository configuration is not defined in framework configuration"); ! ! String repositoryClassName=repositoryConfig.getRepositoryClassName(); ! if(repositoryClassName==null || "".equals(repositoryClassName)) ! throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, "repository class name is not defined in repository configuration"); ! logger.debug("repository class name = " + repositoryClassName); ! ! try ! { ! repository=(Repository)Class.forName(repositoryClassName).newInstance(); ! repository.init(repositoryConfig.getRepositoryConfigProperties()); ! logger.debug("created the repository implemenation class"); ! } ! catch(ClassNotFoundException exception) ! { ! exception.printStackTrace(); ! logger.error(exception.getMessage(),exception); ! throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, exception.getMessage()); ! } ! catch(InstantiationException exception) ! { ! exception.printStackTrace(); ! logger.error(exception.getMessage(),exception); ! throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, exception.getMessage()); ! } ! catch(IllegalAccessException exception) ! { ! exception.printStackTrace(); ! logger.error(exception.getMessage(),exception); ! throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, exception.getMessage()); ! } } ! else { ! /** ! * Reposiotry instance has been initialized already. ! */ } ! logger.trace("Exiting getRepository " + (repository!=null)); ! return repository; } |