1 33 package net.myvietnam.mvncore.web; 34 35 import net.myvietnam.mvncore.MVNCoreConfig; 36 import net.myvietnam.mvncore.web.impl.URLResolverServletImpl; 37 import org.apache.commons.logging.Log; 38 import org.apache.commons.logging.LogFactory; 39 40 public class URLResolverFactory { 41 42 private static Log log = LogFactory.getLog(URLResolverFactory.class); 43 44 private static URLResolver urlResolver = null; 45 46 49 private URLResolverFactory() { 50 } 51 52 public static URLResolver getURLResolver() { 53 54 if (urlResolver == null) { 55 String urlResolverClassName = MVNCoreConfig.getURLResolverClassName(); 56 try { 57 if (urlResolverClassName.length() > 0) { 58 Class urlResolverClass = Class.forName(urlResolverClassName); 59 urlResolver = (URLResolver) urlResolverClass.newInstance(); 60 } 61 } catch (Throwable ex) { 62 log.error("Cannot load URLResolver implementation (" + urlResolverClassName + ")", ex); 63 } 64 65 if (urlResolver == null) { 67 urlResolver = new URLResolverServletImpl(); 68 } 69 70 log.info("Using URLResolver = " + urlResolver); 71 } 72 73 return urlResolver; 74 } 75 } 76 | Popular Tags |