rendered paste bodypackage org.jsffc;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
public class Factory {
public Map<String, Constructor> createConstructorMap(String propertiesPath, Class ... classes) throws IOException {
Map<String, Constructor> constructorTable = new HashMap<String, Constructor>();
InputStream propertiesStream = getClass().getResourceAsStream(propertiesPath);
Properties factoryProperties = new Properties();
if (propertiesStream == null) {
return new HashMap<String, Constructor>();
}
factoryProperties.load(propertiesStream);
propertiesStream.close();
for(Enumeration names = factoryProperties.propertyNames(); names.hasMoreElements();) {
String name = (String) names.nextElement();
try {
constructorTable.put(name, Class.forName(factoryProperties.getProperty(name)).getConstructor(classes));
} catch(Exception e) {
e.printStackTrace();
}
}
return constructorTable;
}
}