1 18 19 package sync4j.syncclient.sps.common; 20 21 import java.util.Hashtable ; 22 23 import sync4j.syncclient.common.logging.Logger; 24 25 33 public class DataStoreManagerFactory { 34 35 37 public static final String DATASTORE_MANAGER_FILE_NAME_END = "StoreManager"; 38 39 41 private static Logger logger = new Logger(); 42 43 45 46 51 public static DataStoreManager getDataStoreManager(String storeManager, String storeManagerPackage) { 52 return getDataStoreManager( 53 storeManager, storeManagerPackage, DataStoreManager.class.getClassLoader() 54 ); 55 } 56 57 public static DataStoreManager getDataStoreManager(String storeManager , 58 String storeManagerPackage, 59 ClassLoader loader ) { 60 DataStoreManager dataStoreManager = null; 61 62 try { 63 String className = storeManagerPackage + '.' + storeManager + DATASTORE_MANAGER_FILE_NAME_END; 64 if (logger.isLoggable(Logger.DEBUG)) { 65 logger.debug("Creating a new instance of " + className); 66 } 67 dataStoreManager = (DataStoreManager) (loader.loadClass(className)).newInstance(); 68 } catch (Exception e) { 69 e.printStackTrace(); 70 if (logger.isLoggable(Logger.INFO)) { 71 logger.info("Error in loading class: " + e.getMessage()); 72 } 73 } 74 75 return dataStoreManager; 76 } 77 78 79 } | Popular Tags |