Permalink
Browse files

Use a Map instead of a Properties for config map. (FELIX-3455)

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1350990 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
Richard S. Hall
Richard S. Hall committed Jun 16, 2012
1 parent 7b0d8d4 commit 6cf675983205871ad31b97dca799260c72ab122a
Showing with 13 additions and 11 deletions.
  1. +13 −11 main/src/main/java/org/apache/felix/main/Main.java
@@ -230,13 +230,13 @@ else if (expectBundleDir)
Main.loadSystemProperties();
// Read configuration properties.
- Properties configProps = Main.loadConfigProperties();
+ Map<String, String> configProps = Main.loadConfigProperties();
// If no configuration properties were found, then create
// an empty properties object.
if (configProps == null)
{
System.err.println("No " + CONFIG_PROPERTIES_FILE_VALUE + " found.");
- configProps = new Properties();
+ configProps = new HashMap<String, String>();
}
// Copy framework properties from the system properties.
@@ -246,19 +246,19 @@ else if (expectBundleDir)
// that overwrites anything in the config file.
if (bundleDir != null)
{
- configProps.setProperty(AutoProcessor.AUTO_DEPLOY_DIR_PROPERY, bundleDir);
+ configProps.put(AutoProcessor.AUTO_DEPLOY_DIR_PROPERY, bundleDir);
}
// If there is a passed in bundle cache directory, then
// that overwrites anything in the config file.
if (cacheDir != null)
{
- configProps.setProperty(Constants.FRAMEWORK_STORAGE, cacheDir);
+ configProps.put(Constants.FRAMEWORK_STORAGE, cacheDir);
}
// If enabled, register a shutdown hook to make sure the framework is
// cleanly shutdown when the VM exits.
- String enableHook = configProps.getProperty(SHUTDOWN_HOOK_PROP);
+ String enableHook = configProps.get(SHUTDOWN_HOOK_PROP);
if ((enableHook == null) || !enableHook.equalsIgnoreCase("false"))
{
Runtime.getRuntime().addShutdownHook(new Thread("Felix Shutdown Hook") {
@@ -470,7 +470,7 @@ public static void loadSystemProperties()
* </p>
* @return A <tt>Properties</tt> instance or <tt>null</tt> if there was an error.
**/
- public static Properties loadConfigProperties()
+ public static Map<String, String> loadConfigProperties()
{
// The config properties file is either specified by a system
// property or it is in the conf/ directory of the Felix
@@ -552,26 +552,28 @@ public static Properties loadConfigProperties()
return null;
}
- // Perform variable substitution for system properties.
+ // Perform variable substitution for system properties and
+ // convert to dictionary.
+ Map<String, String> map = new HashMap<String, String>();
for (Enumeration e = props.propertyNames(); e.hasMoreElements(); )
{
String name = (String) e.nextElement();
- props.setProperty(name,
+ map.put(name,
Util.substVars(props.getProperty(name), name, null, props));
}
- return props;
+ return map;
}
- public static void copySystemProperties(Properties configProps)
+ public static void copySystemProperties(Map configProps)
{
for (Enumeration e = System.getProperties().propertyNames();
e.hasMoreElements(); )
{
String key = (String) e.nextElement();
if (key.startsWith("felix.") || key.startsWith("org.osgi.framework."))
{
- configProps.setProperty(key, System.getProperty(key));
+ configProps.put(key, System.getProperty(key));
}
}
}

0 comments on commit 6cf6759

Please sign in to comment.