In an effort to clean up the Felix API in preparation for the 1.0.0 release,
modified the Felix constructor to accept a Map for its configuration
properties, rather than a PropertyResolver. This allowed us to delete
four unneeded PropertyResolver-related classes. Modified the various
code that was impacted by these changes, including the launcher. (FELIX-324)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@555374 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java b/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
index 31a47fd..aa67456 100644
--- a/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
+++ b/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
@@ -35,7 +35,6 @@
import java.util.Set;
import org.apache.felix.framework.util.FelixConstants;
-import org.apache.felix.framework.util.PropertyResolver;
import org.apache.felix.framework.util.Util;
import org.apache.felix.framework.util.manifestparser.Capability;
import org.apache.felix.framework.util.manifestparser.ManifestParser;
@@ -133,7 +132,7 @@
* @param config the configuration to read properties from.
* @param systemBundleInfo the info to change if we need to add exports.
*/
- ExtensionManager(Logger logger, PropertyResolver config, BundleInfo systemBundleInfo)
+ ExtensionManager(Logger logger, Map configMap, BundleInfo systemBundleInfo)
{
m_logger = logger;
m_systemBundleInfo = systemBundleInfo;
@@ -143,7 +142,7 @@
Map map = ((SystemBundleArchive) m_systemBundleInfo.getArchive()).getManifestHeader(0);
// Initialize header map as a case insensitive map.
map.put(FelixConstants.BUNDLE_VERSION,
- config.get(FelixConstants.FELIX_VERSION_PROPERTY));
+ configMap.get(FelixConstants.FELIX_VERSION_PROPERTY));
map.put(FelixConstants.BUNDLE_SYMBOLICNAME,
FelixConstants.SYSTEM_BUNDLE_SYMBOLICNAME);
map.put(FelixConstants.BUNDLE_NAME, "System Bundle");
@@ -162,7 +161,7 @@
try
{
setCapabilities(ManifestParser.parseExportHeader(
- config.get(Constants.FRAMEWORK_SYSTEMPACKAGES)));
+ (String) configMap.get(Constants.FRAMEWORK_SYSTEMPACKAGES)));
}
catch (Exception ex)
{
@@ -170,7 +169,7 @@
m_logger.log(
Logger.LOG_ERROR,
"Error parsing system bundle export statement: "
- + config.get(Constants.FRAMEWORK_SYSTEMPACKAGES), ex);
+ + configMap.get(Constants.FRAMEWORK_SYSTEMPACKAGES), ex);
}
}
@@ -567,4 +566,4 @@
m_extensions.add(extension);
}
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index 4573d02..8ca1113 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -43,10 +43,10 @@
// Logging related member variables.
private Logger m_logger = null; // TODO: KARL - Why package private?
- // Config properties.
- private PropertyResolver m_config = null;
- // Configuration properties passed into constructor.
- private MutablePropertyResolver m_configMutable = null;
+ // Immutable config properties.
+ private Map m_configMap = null;
+ // Mutable configuration properties passed into constructor.
+ private Map m_configMutableMap = null;
// MODULE FACTORY.
private IModuleFactory m_factory = null;
@@ -115,21 +115,24 @@
* <p>
* This method starts the framework instance; instances of the framework
* are dormant until this method is called. The caller may also provide
- * <tt>MutablePropertyResolver</tt> implementations that the instance will
- * use to obtain configuration or framework properties. Configuration
- * properties are used internally by the framework and its extensions to alter
- * its default behavior. Framework properties are used by bundles
- * and are accessible from <tt>BundleContext.getProperty()</tt>.
+ * <tt>Map</tt> instance that will be used to obtain configuration or
+ * framework properties. Configuration properties are used internally by
+ * the framework and its extensions to alter its default behavior.
+ * Framework properties are used by bundles and are accessible from
+ * <tt>BundleContext.getProperty()</tt>. This map instance is used
+ * directly (i.e., it is not copied), which means that it is possible to
+ * change the property values externally at run time, but this is strongly
+ * discouraged for the framework's configuration properties.
* </p>
* <p>
* Configuration properties are the sole means to configure the framework's
* default behavior; the framework does not refer to any system properties for
- * configuration information. If a <tt>MutablePropertyResolver</tt> is
- * supplied to this method for configuration properties, then the framework will
- * consult the <tt>MutablePropertyResolver</tt> instance for any and all
- * configuration properties. It is possible to specify a <tt>null</tt>
- * configuration property resolver, in which case the framework will use its
- * default behavior in all cases. However, if the
+ * configuration information. If a <tt>Map</tt> is supplied to this method
+ * for configuration properties, then the framework will consult the
+ * <tt>Map</tt> instance for any and all configuration properties. It is
+ * possible to specify a <tt>null</tt> for the configuration property map,
+ * in which case the framework will use its default behavior in all cases.
+ * However, if the
* <a href="cache/DefaultBundleCache.html"><tt>DefaulBundleCache</tt></a>
* is used, then at a minimum a profile name or profile directory must
* be specified.
@@ -207,17 +210,16 @@
* class documentation for more information.
* </p>
*
- * @param configMutable An object for obtaining configuration properties,
+ * @param configMutableMap An map for obtaining configuration properties,
* may be <tt>null</tt>.
* @param activatorList A list of System Bundle activators.
**/
- public Felix(MutablePropertyResolver configMutable, List activatorList)
+ public Felix(Map configMutableMap, List activatorList)
{
// Initialize member variables.
- m_factory = null;
- m_configMutable = (configMutable == null)
- ? new MutablePropertyResolverImpl(new StringMap(false)) : configMutable;
- m_config = new PropertyResolverImpl(m_configMutable);
+ m_configMutableMap = (configMutableMap == null)
+ ? new StringMap(false) : configMutableMap;
+ m_configMap = Collections.unmodifiableMap(m_configMutableMap);
m_activatorList = activatorList;
// Create logger with appropriate log level. Even though the
@@ -225,7 +227,7 @@
// services, it is created now because it is needed before
// the system bundle is created. The system bundle's context
// will be set below after the system bundle is created.
- m_logger = new Logger(m_configMutable.get(FelixConstants.LOG_LEVEL_PROP));
+ m_logger = new Logger((String) m_configMutableMap.get(FelixConstants.LOG_LEVEL_PROP));
// Initialize other member variables.
m_activeStartLevel = FelixConstants.FRAMEWORK_INACTIVE_STARTLEVEL;
@@ -247,7 +249,7 @@
m_systemBundleInfo = new BundleInfo(
m_logger, new SystemBundleArchive(), null);
m_extensionManager =
- new ExtensionManager(m_logger, m_config, m_systemBundleInfo);
+ new ExtensionManager(m_logger, m_configMap, m_systemBundleInfo);
m_systemBundleInfo.addModule(
m_factory.createModule("0", m_extensionManager));
}
@@ -577,7 +579,7 @@
try
{
- m_cache = new BundleCache(m_logger, m_config);
+ m_cache = new BundleCache(m_logger, m_configMap);
}
catch (Exception ex)
{
@@ -585,7 +587,7 @@
ex.printStackTrace();
// Only shutdown the JVM if the framework is running stand-alone.
- String embedded = m_config.get(
+ String embedded = (String) m_configMap.get(
FelixConstants.EMBEDDED_EXECUTION_PROP);
boolean isEmbedded = (embedded == null)
? false : embedded.equals("true");
@@ -600,7 +602,7 @@
}
// Create search policy for module loader.
- m_policyCore = new R4SearchPolicyCore(m_logger, m_config);
+ m_policyCore = new R4SearchPolicyCore(m_logger, m_configMap);
// Add a resolver listener to the search policy
// so that we will be notified when modules are resolved
@@ -783,7 +785,7 @@
// Get the framework's default start level.
int startLevel = FelixConstants.FRAMEWORK_DEFAULT_STARTLEVEL;
- String s = m_config.get(FelixConstants.FRAMEWORK_STARTLEVEL_PROP);
+ String s = (String) m_configMap.get(FelixConstants.FRAMEWORK_STARTLEVEL_PROP);
if (s != null)
{
try
@@ -1107,7 +1109,7 @@
**/
protected int getInitialBundleStartLevel()
{
- String s = m_config.get(FelixConstants.BUNDLE_STARTLEVEL_PROP);
+ String s = (String) m_configMap.get(FelixConstants.BUNDLE_STARTLEVEL_PROP);
if (s != null)
{
@@ -1143,7 +1145,7 @@
"Initial start level must be greater than zero.");
}
- m_configMutable.put(
+ m_configMutableMap.put(
FelixConstants.BUNDLE_STARTLEVEL_PROP, Integer.toString(startLevel));
}
@@ -1910,7 +1912,7 @@
// Try to save the activator in the cache.
// NOTE: This is non-standard OSGi behavior and only
// occurs if strictness is disabled.
- String strict = m_config.get(FelixConstants.STRICT_OSGI_PROP);
+ String strict = (String) m_configMap.get(FelixConstants.STRICT_OSGI_PROP);
boolean isStrict = (strict == null) ? true : strict.equals("true");
if (!isStrict)
{
@@ -2124,7 +2126,7 @@
protected String getProperty(String key)
{
// First, check the config properties.
- String val = (String) m_config.get(key);
+ String val = (String) m_configMap.get(key);
// If not found, then try the system properties.
return (val == null) ? System.getProperty(key) : val;
}
@@ -3297,7 +3299,7 @@
Object securityContext, boolean isExtensionBundle)
throws Exception
{
- ManifestParser mp = new ManifestParser(m_logger, m_config, headerMap);
+ ManifestParser mp = new ManifestParser(m_logger, m_configMap, headerMap);
// Verify that the bundle symbolic name and version is unique.
if (mp.getManifestVersion().equals("2"))
@@ -3374,7 +3376,7 @@
BundleActivator activator = null;
- String strict = m_config.get(FelixConstants.STRICT_OSGI_PROP);
+ String strict = (String) m_configMap.get(FelixConstants.STRICT_OSGI_PROP);
boolean isStrict = (strict == null) ? true : strict.equals("true");
if (!isStrict)
{
@@ -3515,25 +3517,25 @@
private void initializeFrameworkProperties()
{
// Standard OSGi properties.
- m_configMutable.put(
+ m_configMutableMap.put(
FelixConstants.FRAMEWORK_VERSION,
FelixConstants.FRAMEWORK_VERSION_VALUE);
- m_configMutable.put(
+ m_configMutableMap.put(
FelixConstants.FRAMEWORK_VENDOR,
FelixConstants.FRAMEWORK_VENDOR_VALUE);
- m_configMutable.put(
+ m_configMutableMap.put(
FelixConstants.FRAMEWORK_LANGUAGE,
System.getProperty("user.language"));
- m_configMutable.put(
+ m_configMutableMap.put(
FelixConstants.FRAMEWORK_OS_VERSION,
System.getProperty("os.version"));
String s = null;
s = R4LibraryClause.normalizeOSName(System.getProperty("os.name"));
- m_configMutable.put(FelixConstants.FRAMEWORK_OS_NAME, s);
+ m_configMutableMap.put(FelixConstants.FRAMEWORK_OS_NAME, s);
s = R4LibraryClause.normalizeProcessor(System.getProperty("os.arch"));
- m_configMutable.put(FelixConstants.FRAMEWORK_PROCESSOR, s);
- m_configMutable.put(
+ m_configMutableMap.put(FelixConstants.FRAMEWORK_PROCESSOR, s);
+ m_configMutableMap.put(
FelixConstants.FELIX_VERSION_PROPERTY, getFrameworkVersion());
}
@@ -3575,21 +3577,21 @@
// the start level to which the bundles are assigned is specified by
// appending a ".n" to the auto-install property name, where "n" is
// the desired start level for the list of bundles.
- String[] keys = m_config.getKeys();
- for (int i = 0; (keys != null) && (i < keys.length); i++)
+ for (Iterator i = m_configMap.keySet().iterator(); i.hasNext(); )
{
- if (keys[i].startsWith(FelixConstants.AUTO_INSTALL_PROP))
+ String key = (String) i.next();
+ if (key.startsWith(FelixConstants.AUTO_INSTALL_PROP))
{
int startLevel = 1;
try
{
- startLevel = Integer.parseInt(keys[i].substring(keys[i].lastIndexOf('.') + 1));
+ startLevel = Integer.parseInt(key.substring(key.lastIndexOf('.') + 1));
}
catch (NumberFormatException ex)
{
- m_logger.log(Logger.LOG_ERROR, "Invalid property: " + keys[i]);
+ m_logger.log(Logger.LOG_ERROR, "Invalid property: " + key);
}
- StringTokenizer st = new StringTokenizer(m_config.get(keys[i]), "\" ",true);
+ StringTokenizer st = new StringTokenizer((String) m_configMap.get(key), "\" ",true);
if (st.countTokens() > 0)
{
String location = null;
@@ -3622,20 +3624,21 @@
// where "n" is the desired start level for the list of bundles.
// The following code starts bundles in two passes, first it installs
// them, then it starts them.
- for (int i = 0; (keys != null) && (i < keys.length); i++)
+ for (Iterator i = m_configMap.keySet().iterator(); i.hasNext(); )
{
- if (keys[i].startsWith(FelixConstants.AUTO_START_PROP))
+ String key = (String) i.next();
+ if (key.startsWith(FelixConstants.AUTO_START_PROP))
{
int startLevel = 1;
try
{
- startLevel = Integer.parseInt(keys[i].substring(keys[i].lastIndexOf('.') + 1));
+ startLevel = Integer.parseInt(key.substring(key.lastIndexOf('.') + 1));
}
catch (NumberFormatException ex)
{
- m_logger.log(Logger.LOG_ERROR, "Invalid property: " + keys[i]);
+ m_logger.log(Logger.LOG_ERROR, "Invalid property: " + key);
}
- StringTokenizer st = new StringTokenizer(m_config.get(keys[i]), "\" ",true);
+ StringTokenizer st = new StringTokenizer((String) m_configMap.get(key), "\" ",true);
if (st.countTokens() > 0)
{
String location = null;
@@ -3661,11 +3664,12 @@
}
// Now loop through and start the installed bundles.
- for (int i = 0; (keys != null) && (i < keys.length); i++)
+ for (Iterator i = m_configMap.keySet().iterator(); i.hasNext(); )
{
- if (keys[i].startsWith(FelixConstants.AUTO_START_PROP))
+ String key = (String) i.next();
+ if (key.startsWith(FelixConstants.AUTO_START_PROP))
{
- StringTokenizer st = new StringTokenizer(m_config.get(keys[i]), "\" ",true);
+ StringTokenizer st = new StringTokenizer((String) m_configMap.get(key), "\" ",true);
if (st.countTokens() > 0)
{
String location = null;
@@ -3786,7 +3790,7 @@
// Add the bundle activator for the start level service.
m_activatorList.add(new StartLevelActivator(m_logger, Felix.this));
// Add the bundle activator for the url handler service.
- m_activatorList.add(new URLHandlersActivator(m_config, Felix.this));
+ m_activatorList.add(new URLHandlersActivator(m_configMap, Felix.this));
// Start all activators.
for (int i = 0; i < m_activatorList.size(); i++)
@@ -3949,7 +3953,7 @@
}
// Finally shutdown the JVM if the framework is running stand-alone.
- String embedded = m_config.get(FelixConstants.EMBEDDED_EXECUTION_PROP);
+ String embedded = (String) m_configMap.get(FelixConstants.EMBEDDED_EXECUTION_PROP);
boolean isEmbedded = (embedded == null) ? false : embedded.equals("true");
if (!isEmbedded)
{
diff --git a/framework/src/main/java/org/apache/felix/framework/URLHandlersActivator.java b/framework/src/main/java/org/apache/felix/framework/URLHandlersActivator.java
index f801134..8608185 100644
--- a/framework/src/main/java/org/apache/felix/framework/URLHandlersActivator.java
+++ b/framework/src/main/java/org/apache/felix/framework/URLHandlersActivator.java
@@ -18,8 +18,8 @@
*/
package org.apache.felix.framework;
+import java.util.Map;
import org.apache.felix.framework.util.FelixConstants;
-import org.apache.felix.framework.util.PropertyResolver;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
@@ -34,13 +34,13 @@
**/
class URLHandlersActivator implements BundleActivator
{
- private PropertyResolver m_config = null;
+ private Map m_configMap = null;
private Felix m_framework = null;
private BundleContext m_context = null;
- public URLHandlersActivator(PropertyResolver config, Felix framework)
+ public URLHandlersActivator(Map configMap, Felix framework)
{
- m_config = config;
+ m_configMap = configMap;
m_framework = framework;
}
@@ -53,10 +53,10 @@
m_context = context;
// Only register the framework with the URL Handlers service
// if the service is enabled.
- boolean enable = (m_config.get(
+ boolean enable = (m_configMap.get(
FelixConstants.SERVICE_URLHANDLERS_PROP) == null)
? true
- : !m_config.get(FelixConstants.SERVICE_URLHANDLERS_PROP).equals("false");
+ : !m_configMap.get(FelixConstants.SERVICE_URLHANDLERS_PROP).equals("false");
URLHandlers.registerInstance(m_framework, m_context, enable);
}
@@ -64,4 +64,4 @@
{
URLHandlers.unregisterInstance(m_framework);
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/main/java/org/apache/felix/framework/cache/BundleCache.java b/framework/src/main/java/org/apache/felix/framework/cache/BundleCache.java
index 2b70548..908fe20 100644
--- a/framework/src/main/java/org/apache/felix/framework/cache/BundleCache.java
+++ b/framework/src/main/java/org/apache/felix/framework/cache/BundleCache.java
@@ -22,7 +22,6 @@
import java.util.*;
import org.apache.felix.framework.Logger;
-import org.apache.felix.framework.util.PropertyResolver;
import org.apache.felix.framework.util.SecureAction;
/**
@@ -81,17 +80,17 @@
protected static transient final String CACHE_DIR_NAME = ".felix";
protected static transient final String BUNDLE_DIR_PREFIX = "bundle";
- private PropertyResolver m_cfg = null;
+ private Map m_configMap = null;
private Logger m_logger = null;
private File m_profileDir = null;
private BundleArchive[] m_archives = null;
private static SecureAction m_secureAction = new SecureAction();
- public BundleCache(Logger logger, PropertyResolver cfg)
+ public BundleCache(Logger logger, Map configMap)
throws Exception
{
- m_cfg = cfg;
+ m_configMap = configMap;
m_logger = logger;
initialize();
}
@@ -252,7 +251,7 @@
// Get buffer size value.
try
{
- String sBufSize = m_cfg.get(CACHE_BUFSIZE_PROP);
+ String sBufSize = (String) m_configMap.get(CACHE_BUFSIZE_PROP);
if (sBufSize != null)
{
BUFSIZE = Integer.parseInt(sBufSize);
@@ -264,7 +263,7 @@
}
// See if the profile directory is specified.
- String profileDirStr = m_cfg.get(CACHE_PROFILE_DIR_PROP);
+ String profileDirStr = (String) m_configMap.get(CACHE_PROFILE_DIR_PROP);
if (profileDirStr != null)
{
m_profileDir = new File(profileDirStr);
@@ -277,7 +276,7 @@
// First, determine the location of the cache directory; it
// can either be specified or in the default location.
- String cacheDirStr = m_cfg.get(CACHE_DIR_PROP);
+ String cacheDirStr = (String) m_configMap.get(CACHE_DIR_PROP);
if (cacheDirStr == null)
{
// Since no cache directory was specified, put it
@@ -289,7 +288,7 @@
}
// Now, get the profile name.
- String profileName = m_cfg.get(CACHE_PROFILE_PROP);
+ String profileName = (String) m_configMap.get(CACHE_PROFILE_PROP);
if (profileName == null)
{
throw new IllegalArgumentException(
diff --git a/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java b/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
index 93b9886..ebaab48 100755
--- a/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
+++ b/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
@@ -33,7 +33,7 @@
public class R4SearchPolicyCore implements ModuleListener
{
private Logger m_logger = null;
- private PropertyResolver m_config = null;
+ private Map m_configMap = null;
private IModuleFactory m_factory = null;
// Maps a package name to an array of modules.
private Map m_availPkgIndexMap = new HashMap();
@@ -59,13 +59,13 @@
// Re-usable security manager for accessing class context.
private static SecurityManagerEx m_sm = new SecurityManagerEx();
- public R4SearchPolicyCore(Logger logger, PropertyResolver config)
+ public R4SearchPolicyCore(Logger logger, Map configMap)
{
m_logger = logger;
- m_config = config;
+ m_configMap = configMap;
// Read the boot delegation property and parse it.
- String s = m_config.get(Constants.FRAMEWORK_BOOTDELEGATION);
+ String s = (String) m_configMap.get(Constants.FRAMEWORK_BOOTDELEGATION);
s = (s == null) ? "java.*" : s + ",java.*";
StringTokenizer st = new StringTokenizer(s, " ,");
m_bootPkgs = new String[st.countTokens()];
diff --git a/framework/src/main/java/org/apache/felix/framework/util/MutablePropertyResolver.java b/framework/src/main/java/org/apache/felix/framework/util/MutablePropertyResolver.java
deleted file mode 100644
index ec37556..0000000
--- a/framework/src/main/java/org/apache/felix/framework/util/MutablePropertyResolver.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.framework.util;
-
-public interface MutablePropertyResolver extends PropertyResolver
-{
- public String put(String key, String value);
-}
\ No newline at end of file
diff --git a/framework/src/main/java/org/apache/felix/framework/util/MutablePropertyResolverImpl.java b/framework/src/main/java/org/apache/felix/framework/util/MutablePropertyResolverImpl.java
deleted file mode 100644
index 16f6ff1..0000000
--- a/framework/src/main/java/org/apache/felix/framework/util/MutablePropertyResolverImpl.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.framework.util;
-
-import java.util.Map;
-
-public class MutablePropertyResolverImpl implements MutablePropertyResolver
-{
- private Map m_props = null;
-
- public MutablePropertyResolverImpl(Map props)
- {
- m_props = props;
- }
-
- public synchronized String put(String key, String value)
- {
- return (String) m_props.put(key, value);
- }
-
- public synchronized String get(String key)
- {
- return (String) m_props.get(key);
- }
-
- public synchronized String[] getKeys()
- {
- return (String[]) m_props.keySet().toArray(new String[0]);
- }
-}
\ No newline at end of file
diff --git a/framework/src/main/java/org/apache/felix/framework/util/PropertyResolver.java b/framework/src/main/java/org/apache/felix/framework/util/PropertyResolver.java
deleted file mode 100644
index 1816bd8..0000000
--- a/framework/src/main/java/org/apache/felix/framework/util/PropertyResolver.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.framework.util;
-
-public interface PropertyResolver
-{
- public String get(String key);
- public String[] getKeys();
-}
\ No newline at end of file
diff --git a/framework/src/main/java/org/apache/felix/framework/util/PropertyResolverImpl.java b/framework/src/main/java/org/apache/felix/framework/util/PropertyResolverImpl.java
deleted file mode 100644
index 416e7cc..0000000
--- a/framework/src/main/java/org/apache/felix/framework/util/PropertyResolverImpl.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.framework.util;
-
-public class PropertyResolverImpl implements PropertyResolver
-{
- private MutablePropertyResolver m_resolver = null;
-
- public PropertyResolverImpl(MutablePropertyResolver resolver)
- {
- m_resolver = resolver;
- }
-
- public String get(String key)
- {
- return (m_resolver == null) ? null : m_resolver.get(key);
- }
-
- public String[] getKeys()
- {
- return (m_resolver == null) ? null : m_resolver.getKeys();
- }
-}
\ No newline at end of file
diff --git a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
index b478a8d..cdad237 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
@@ -30,7 +30,7 @@
public class ManifestParser
{
private Logger m_logger = null;
- private PropertyResolver m_config = null;
+ private Map m_configMap = null;
private Map m_headerMap = null;
private String m_bundleSymbolicName = null;
private Version m_bundleVersion = null;
@@ -40,11 +40,11 @@
private R4LibraryClause[] m_libraryHeaders = null;
private boolean m_libraryHeadersOptional = false;
- public ManifestParser(Logger logger, PropertyResolver config, Map headerMap)
+ public ManifestParser(Logger logger, Map configMap, Map headerMap)
throws BundleException
{
m_logger = logger;
- m_config = config;
+ m_configMap = configMap;
m_headerMap = headerMap;
// Verify that only manifest version 2 is specified.
@@ -329,7 +329,7 @@
// Search for matching native clauses.
for (int i = 0; i < m_libraryHeaders.length; i++)
{
- if (m_libraryHeaders[i].match(m_config))
+ if (m_libraryHeaders[i].match(m_configMap))
{
clauseList.add(m_libraryHeaders[i]);
}
diff --git a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4LibraryClause.java b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4LibraryClause.java
index 9d2a16f..ee33c85 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4LibraryClause.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4LibraryClause.java
@@ -86,12 +86,12 @@
return m_selectionFilter;
}
- public boolean match(PropertyResolver config) throws BundleException
+ public boolean match(Map configMap) throws BundleException
{
- String normal_osname = normalizeOSName(config.get(Constants.FRAMEWORK_OS_NAME));
- String normal_processor = normalizeProcessor(config.get(Constants.FRAMEWORK_PROCESSOR));
- String normal_osversion = normalizeOSVersion(config.get(Constants.FRAMEWORK_OS_VERSION));
- String normal_language = config.get(Constants.FRAMEWORK_LANGUAGE);
+ String normal_osname = normalizeOSName((String) configMap.get(Constants.FRAMEWORK_OS_NAME));
+ String normal_processor = normalizeProcessor((String) configMap.get(Constants.FRAMEWORK_PROCESSOR));
+ String normal_osversion = normalizeOSVersion((String) configMap.get(Constants.FRAMEWORK_OS_VERSION));
+ String normal_language = (String) configMap.get(Constants.FRAMEWORK_LANGUAGE);
// Check library's osname.
if (!checkOSNames(normal_osname, getOSNames()))
@@ -124,7 +124,7 @@
// Check library's selection-filter if specified.
if ((getSelectionFilter() != null) &&
(getSelectionFilter().length() >= 0) &&
- !checkSelectionFilter(config, getSelectionFilter()))
+ !checkSelectionFilter(configMap, getSelectionFilter()))
{
return false;
}
@@ -190,15 +190,15 @@
return false;
}
- private boolean checkSelectionFilter(PropertyResolver config, String expr)
+ private boolean checkSelectionFilter(Map configMap, String expr)
throws BundleException
{
// Get all framework properties
Dictionary dict = new Hashtable();
- String[] keys = config.getKeys();
- for (int i = 0; i < keys.length; i++)
+ for (Iterator i = configMap.keySet().iterator(); i.hasNext(); )
{
- dict.put(keys[i], config.get(keys[i]));
+ Object key = i.next();
+ dict.put(key, configMap.get(key));
}
// Compute expression
try
diff --git a/main/src/main/java/org/apache/felix/main/Main.java b/main/src/main/java/org/apache/felix/main/Main.java
index d70eacd..c69f74a 100644
--- a/main/src/main/java/org/apache/felix/main/Main.java
+++ b/main/src/main/java/org/apache/felix/main/Main.java
@@ -25,7 +25,6 @@
import org.apache.felix.framework.Felix;
import org.apache.felix.framework.cache.BundleCache;
-import org.apache.felix.framework.util.MutablePropertyResolverImpl;
import org.apache.felix.framework.util.StringMap;
/**
@@ -97,8 +96,8 @@
* the desired URL using the <tt>felix.config.properties</tt>
* system property; this should be set using the <tt>-D</tt> syntax
* when executing the JVM. Refer to the
- * <a href="Felix.html#start(org.apache.felix.framework.util.MutablePropertyResolver, org.apache.felix.framework.util.MutablePropertyResolver, java.util.List)">
- * <tt>Felix.start()</tt></a> method documentation for more
+ * <a href="Felix.html#Felix(java.util.Map, java.util.List)">
+ * <tt>Felix</tt></a> constructor documentation for more
* information on the framework configuration options.
* </li>
* <li><i><b>Perform system property variable substitution on configuration
@@ -116,10 +115,11 @@
* <a href="cache/DefaultBundleCache.html"><tt>DefaultBundleCache</tt></a>
* documentation for more details its configuration options.
* </li>
- * <li><i><b>Creates and starts a framework instance.</b></i> A simple
- * <a href="util/MutablePropertyResolver.html"><tt>MutablePropertyResolver</tt></a>
+ * <li><i><b>Creates and starts a framework instance.</b></i> A
+ * case insensitive
+ * <a href="util/StringMap.html"><tt>StringMap</tt></a>
* is created for the configuration property file and is passed
- * into the framework when it is started.
+ * into the framework.
* </li>
* </ol>
* <p>
@@ -131,8 +131,8 @@
* the configuration property file cannot be found, the framework will appear to
* be hung or deadlocked. This is not the case, it is executing correctly,
* there is just no way to interact with it. Refer to the
- * <a href="Felix.html#start(org.apache.felix.framework.util.MutablePropertyResolver, org.apache.felix.framework.util.MutablePropertyResolver, java.util.List)">
- * <tt>Felix.start()</tt></a> method documentation for more information on
+ * <a href="Felix.html#Felix(java.util.Map, java.util.List)">
+ * <tt>Felix</tt></a> constructor documentation for more information on
* framework configuration options.
* </p>
* @param argv An array of arguments, all of which are ignored.
@@ -191,10 +191,7 @@
try
{
// Now create an instance of the framework.
- m_felix = new Felix(
- new MutablePropertyResolverImpl(
- new StringMap(configProps, false)),
- null);
+ m_felix = new Felix(new StringMap(configProps, false), null);
m_felix.start();
}
catch (Exception ex)