If it isn't already, this should be part of the Configuration API (or of a helper class in its package).
[EMAIL PROTECTED] writes: > jtaylor 02/04/11 19:09:19 > > Modified: src/java/org/apache/stratum/component ComponentLoader.java > src/java/org/apache/stratum/configuration > ConfigurationConverter.java > Log: > Adding a Configuration -> Properties conversion method > > Revision Changes Path > 1.8 +13 -7 >jakarta-turbine-stratum/src/java/org/apache/stratum/component/ComponentLoader.java > > Index: ComponentLoader.java > =================================================================== > RCS file: >/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/component/ComponentLoader.java,v > retrieving revision 1.7 > retrieving revision 1.8 > diff -u -r1.7 -r1.8 > --- ComponentLoader.java 5 Apr 2002 06:50:19 -0000 1.7 > +++ ComponentLoader.java 12 Apr 2002 02:09:19 -0000 1.8 > @@ -70,7 +70,7 @@ > * > * @author <a href="mailto:eric NOSPAM dobbse.net">Eric Dobbs</a> > * @author <a href="mailto:[EMAIL PROTECTED]">Martin Poeschl</a> > - * @version $Id: ComponentLoader.java,v 1.7 2002/04/05 06:50:19 dobbs Exp $ > + * @version $Id: ComponentLoader.java,v 1.8 2002/04/12 02:09:19 jtaylor Exp $ > */ > public class ComponentLoader > { > @@ -167,15 +167,18 @@ > > for (int i = 0; i < components.size(); i++) > { > - componentName = (String) components.get(i); > + componentName = (String) components.get(i); > componentClassName = getComponentClassname(componentName); > - componentConfig = getComponentConfigFile(componentName); > - componentAdditionalConfig = >this.getComponentAdditionalConfig(componentName); > + componentConfig = getComponentConfigFile(componentName); > + componentAdditionalConfig = > + getComponentAdditionalConfig(componentName); > > log.info("loading component: name=" + componentName + " class=" > + componentClassName + " config=" + componentConfig); > > - loadedComponents[i] = loadComponent(componentClassName, >componentConfig, componentAdditionalConfig); > + loadedComponents[i] = loadComponent(componentClassName, > + componentConfig, > + componentAdditionalConfig); > } > return loadedComponents; > } > @@ -192,7 +195,9 @@ > * @param configFile the String path name of the component's config file > * @return the loaded component or null if it failed to load > */ > - public Object loadComponent(String className, String configFile, >Configuration additionalConfig) > + public Object loadComponent(String className, > + String configFile, > + Configuration additionalConfig) > { > Object component = null; > > @@ -208,7 +213,8 @@ > > // configure component using the given config file > ((Configurable) component) > - .configure(new >PropertiesConfiguration(configFile,additionalConfig)); > + .configure(new PropertiesConfiguration(configFile, > + additionalConfig)); > > // initialize component > ((Initializable) component).initialize(); > > > > 1.3 +23 -1 >jakarta-turbine-stratum/src/java/org/apache/stratum/configuration/ConfigurationConverter.java > > Index: ConfigurationConverter.java > =================================================================== > RCS file: >/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/configuration/ConfigurationConverter.java,v > retrieving revision 1.2 > retrieving revision 1.3 > diff -u -r1.2 -r1.3 > --- ConfigurationConverter.java 13 Mar 2002 19:04:23 -0000 1.2 > +++ ConfigurationConverter.java 12 Apr 2002 02:09:19 -0000 1.3 > @@ -66,7 +66,7 @@ > * standard Properties. > * > * @author <a href="mailto:[EMAIL PROTECTED]">Martin Poeschl</a> > - * @version $Id: ConfigurationConverter.java,v 1.2 2002/03/13 19:04:23 mpoeschl >Exp $ > + * @version $Id: ConfigurationConverter.java,v 1.3 2002/04/12 02:09:19 jtaylor >Exp $ > */ > public class ConfigurationConverter > { > @@ -118,6 +118,28 @@ > String key = (String) i.next(); > props.setProperty(key, c.getProperty(key)); > } > + return props; > + } > + > + /** > + * Convert a Configuration class into a Properties class. Multvalue keys > + * will be collapsed by {@link Configuration#getString}. > + * > + * @param c Configuration object to convert > + * @return Properties created from the Configuration > + */ > + public static Properties getProperties( Configuration c ) > + { > + Properties props = new Properties(); > + > + Iterator iter = c.getKeys(); > + > + while ( iter.hasNext() ) > + { > + String key = (String) iter.next(); > + props.setProperty( key, c.getString( key ) ); > + } > + > return props; > } > } > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
