package 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 createConstructorMap(String propertiesPath, Class ... classes) throws IOException { Map constructorTable = new HashMap(); InputStream propertiesStream = getClass().getResourceAsStream(propertiesPath); Properties factoryProperties = new Properties(); if (propertiesStream == null) { return new HashMap(); } 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; } }