1 package org.jbpm.instantiation; 2 3 import java.lang.reflect.*; 4 import org.apache.commons.logging.*; 5 6 public class ConfigurationPropertyInstantiator 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 newInstance = clazz.newInstance(); 15 16 Method setter = clazz.getDeclaredMethod( "setConfiguration", parameterTypes ); 18 setter.setAccessible(true); 19 setter.invoke( newInstance, new Object []{ configuration } ); 20 21 } catch (Exception e) { 22 log.error( "couldn't instantiate '" + clazz.getName() + "'", e ); 23 throw new RuntimeException ( e ); 24 } 25 return newInstance; 26 } 27 28 private static final Log log = LogFactory.getLog(ConfigurationPropertyInstantiator.class); 29 } 30 | Popular Tags |