1 package org.apache.velocity.runtime.resource.loader; 2 3 18 19 import org.apache.velocity.runtime.RuntimeServices; 20 import org.apache.velocity.util.StringUtils; 21 22 28 public class ResourceLoaderFactory 29 { 30 34 public static ResourceLoader getLoader(RuntimeServices rs, String loaderClassName) 35 throws Exception 36 { 37 ResourceLoader loader = null; 38 39 try 40 { 41 loader = ((ResourceLoader)Class.forName(loaderClassName) 42 .newInstance()); 43 44 rs.info("Resource Loader Instantiated: " + 45 loader.getClass().getName()); 46 47 return loader; 48 } 49 catch( Exception e) 50 { 51 rs.error("Problem instantiating the template loader.\n" + 52 "Look at your properties file and make sure the\n" + 53 "name of the template loader is correct. Here is the\n" + 54 "error: " + StringUtils.stackTrace(e)); 55 56 throw new Exception ("Problem initializing template loader: " + loaderClassName + 57 "\nError is: " + StringUtils.stackTrace(e)); 58 } 59 } 60 } 61 | Popular Tags |