1 33 package net.myvietnam.mvncore.service; 34 35 import net.myvietnam.mvncore.MVNCoreConfig; 36 import net.myvietnam.mvncore.service.impl.MvnCoreServiceImpl; 37 38 import org.apache.commons.logging.Log; 39 import org.apache.commons.logging.LogFactory; 40 41 public class MvnCoreServiceFactory { 42 43 private static Log log = LogFactory.getLog(MvnCoreServiceFactory.class); 44 45 private MvnCoreServiceFactory() { 46 } 47 48 private static MvnCoreService mvnCoreService = null; 49 50 public static synchronized MvnCoreService getMvnCoreService() { 51 52 if (mvnCoreService == null) { 53 try { 54 Class c = Class.forName(MVNCoreConfig.getMvnCoreServiceClassName()); 55 mvnCoreService = (MvnCoreService) c.newInstance(); 56 log.info("mvnCoreService = " + mvnCoreService); 57 } catch (Exception e) { 58 log.error("Error loading the mvnCoreService.", e); 59 60 log.warn("Error loading the mvnCoreService. Using default MvnCoreService: " + MvnCoreServiceImpl.class.getName()); 61 mvnCoreService = new MvnCoreServiceImpl(); 62 } 63 } 64 return mvnCoreService; 65 } 66 67 } 68 | Popular Tags |