1 16 package org.directwebremoting.create; 17 18 import org.directwebremoting.extend.Creator; 19 import org.directwebremoting.util.LocalUtil; 20 import org.directwebremoting.util.Logger; 21 import org.directwebremoting.util.Messages; 22 23 27 public class NewCreator extends AbstractCreator implements Creator 28 { 29 33 public void setClass(String classname) 34 { 35 try 36 { 37 clazz = LocalUtil.classForName(classname); 38 } 39 catch (ExceptionInInitializerError ex) 40 { 41 log.warn("Class load error", ex); 42 throw new IllegalArgumentException (Messages.getString("Creator.ClassLoadError", classname)); 43 } 44 catch (ClassNotFoundException ex) 45 { 46 throw new IllegalArgumentException (Messages.getString("Creator.ClassNotFound", classname)); 47 } 48 } 49 50 53 public Class getType() 54 { 55 return clazz; 56 } 57 58 61 public Object getInstance() throws InstantiationException  62 { 63 try 64 { 65 return clazz.newInstance(); 66 } 67 catch (IllegalAccessException ex) 68 { 69 throw new InstantiationException (Messages.getString("Creator.IllegalAccess")); 71 } 72 } 73 74 78 public void setClassName(String className) 79 { 80 setClass(className); 81 } 82 83 87 public String getClassName() 88 { 89 return getType().getName(); 90 } 91 92 95 private static final Logger log = Logger.getLogger(NewCreator.class); 96 97 100 private Class clazz; 101 } 102 | Popular Tags |