1 package org.jbpm.instantiation; 2 3 import java.lang.reflect.*; 4 import org.apache.commons.logging.*; 5 6 public class ConstructorInstantiator implements Instantiator { 7 8 private static final Class [] parameterTypes = new Class [] {String .class}; 9 10 public Object instantiate(Class clazz, String configuration) { 11 Object newInstance = null; 12 try { 13 Constructor constructor = clazz.getDeclaredConstructor( parameterTypes ); 14 constructor.setAccessible(true); 15 newInstance = constructor.newInstance( new Object [] { configuration } ); 16 } catch (Exception e) { 17 log.error( "couldn't instantiate '" + clazz.getName() + "'", e ); 18 throw new RuntimeException ( e ); 19 } 20 return newInstance; 21 } 22 23 private static final Log log = LogFactory.getLog(ConstructorInstantiator.class); 24 } 25 | Popular Tags |