1 16 package org.apache.jetspeed.services; 17 18 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService; 19 import org.apache.jetspeed.services.logging.JetspeedLogger; 20 import org.apache.turbine.services.InitializationException; 21 import org.apache.turbine.services.Service; 22 23 29 public class ServiceHelper 30 { 31 private static final JetspeedLogger log = JetspeedLogFactoryService.getLogger(ServiceHelper.class.getName()); 32 33 40 static public Class loadModelClass(Service service, String configurationName) 41 throws InitializationException 42 { 43 String className = service.getConfiguration().getString(configurationName, null); 44 if (null == className) 45 { 46 throw new InitializationException(configurationName + " implementation configuration not found."); 47 } 48 try 49 { 50 return Class.forName(className); 51 52 } 53 catch (ClassNotFoundException e) 54 { 55 throw new InitializationException("Could not preload " + className + " implementation class.", e); 56 } 57 } 58 59 68 public static Object createObject(Class classe) 69 { 70 Object object = null; 71 try 72 { 73 object = classe.newInstance(); 74 } 75 catch (Exception e) 76 { 77 log.error("Factory failed to create object: " + classe.getName(), e); 78 } 79 80 return object; 81 } 82 83 } 84 | Popular Tags |