Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

knapsack: default/*.properties files override settings defined in

felix.conf.  This is so that installers and bundles customize the
knapsack launcher without having to modify files at install time.
  • Loading branch information...
commit 51e714c8b53a83efdd3983de0387fa721fdaede8 1 parent 42c765e
@kgilmer authored
View
2  META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Knapsack for Apache Felix
Bundle-SymbolicName: org.knapsack
-Bundle-Version: 0.8.0
+Bundle-Version: 0.8.1
Bundle-Activator: org.knapsack.Activator
Main-Class: org.knapsack.Bootstrap
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
View
9 felix.conf
@@ -1,3 +1,7 @@
+# felix.conf - Properties for the Apache Felix OSGi framework and the knapsack launcher.
+# NOTE: Properties defined in *.properties files in /default directory will override
+# the properties defined here.
+#
# ----- Knapsack bootstrap properties
# LogService will be started with the framework if true
org.knapsack.builtin.logger = true
@@ -17,7 +21,10 @@ org.knapsack.configAdmin.overwrite = false
# If set to true, knapsack will accept socket connections from any host, not just 127.0.0.1
# org.knapsack.scripts.acceptAnyHost
# Override the default netcat implementation, which is Java-based. Using a native netcat client will significantly speed up the shell performance, but may require tuning for a specific environment
-# An example: org.knapsack.shell.command = nc
+# An example:
+# org.knapsack.shell.command = nc
+# An example for netcat versions that return with no data:
+# org.knapsack.shell.command = nc -q 1
org.knapsack.shell.command = java -cp $KNAPSACK_JAR org.knapsack.shell.Netcat
# ----- Felix properties
View
2  org/knapsack/Activator.java
@@ -56,7 +56,7 @@
/**
* This should be in sync with manifest version.
*/
- public static final String KNAPSACK_VERSION = "0.8.0";
+ public static final String KNAPSACK_VERSION = "0.8.1";
public static final String KNAPSACK_PID = "org.knapsack";
/**
View
12 org/knapsack/Config.java
@@ -105,12 +105,20 @@
* @throws InterruptedException
*/
protected Config(File baseDirectory) throws IOException {
+ Properties originalProperties = new Properties();
for (Object key : System.getProperties().keySet())
- this.put(key, System.getProperty(key.toString()));
-
+ originalProperties.put(key, System.getProperty(key.toString()));
+
+
this.baseDirectory = baseDirectory;
load(new FileInputStream(getConfigFile()));
+ // Overwrite any pre-existing properties that may have been reset by load().
+ // This makes the default/*.properties property files take precedence over felix.conf,
+ // allowing for simple overrides.
+ for (Object key : originalProperties.keySet())
+ this.put(key, originalProperties.get(key.toString()));
+
//Specify the root of the knapsack install if not explicitly defined.
if (!this.containsKey(CONFIG_KEY_ROOT_DIR))
this.put(CONFIG_KEY_ROOT_DIR, baseDirectory);
View
8 org/knapsack/LoadPropertiesFunction.java
@@ -48,8 +48,14 @@ private void loadPropertyFile(File f) throws IOException {
if (elems.length < 2)
throw new IOException("Invalid line in property file: " + line);
+
+ String key = elems[0].trim();
+ String value = line.substring(elems[0].length() + 1).trim();
+
+ if (System.getProperties().contains(key))
+ logger.log(LogService.LOG_WARNING, "Overriding property " + key + ". Existing value: " + System.getProperty(key) + " New value: " + value);
- System.getProperties().put(elems[0].trim(), line.substring(elems[0].length() + 1).trim());
+ System.getProperties().put(key, value);
}
}
View
2  scripts/.knapsack-command.sh
@@ -1,6 +1,8 @@
# This is the internal shell command used to pass 'native' commands to knapsack.
# It simply forwards the entire command line to knapsack, waits for a response,
# And prints the response back to the user.
+#
+# Do not edit this file, it is dynamically generated each time knapsack runs.
if [ -z $KNAPSACK_PORT ]; then
echo "KNAPSACK_PORT must be set."
Please sign in to comment.
Something went wrong with that request. Please try again.