You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2018/10/29 20:03:11 UTC

[1/2] celix git commit: CELIX-433: Started on making installable celix containers, beginning with making it possible to configure bundles paths and making improves the handling of embedded properties.

Repository: celix
Updated Branches:
  refs/heads/develop 1ffdd947b -> 33a93db0a


CELIX-433: Started on making installable celix containers, beginning with making it possible to configure bundles paths and making improves the handling of embedded properties.


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/83456580
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/83456580
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/83456580

Branch: refs/heads/develop
Commit: 83456580172b441c09b70f5346bed4f3cafd9953
Parents: 1ffdd94
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Mon Oct 29 19:23:46 2018 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Mon Oct 29 19:23:46 2018 +0100

----------------------------------------------------------------------
 libs/framework/include/constants.h              |   3 +
 libs/framework/src/bundle_context.c             |   2 +-
 libs/framework/src/celix_launcher.c             | 167 +++++++++++--------
 libs/framework/src/framework.c                  |  44 ++++-
 libs/framework/tst/CMakeLists.txt               |   3 +-
 .../tst/bundle_context_bundles_tests.cpp        |  16 ++
 libs/framework/tst/subdir/CMakeLists.txt        |  20 +++
 libs/utils/include/celix_properties.h           |  10 +-
 libs/utils/include/hash_map.h                   |   2 -
 libs/utils/private/test/properties_test.cpp     |  20 +++
 libs/utils/src/hash_map.c                       |   2 +-
 libs/utils/src/properties.c                     |  16 +-
 12 files changed, 227 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/83456580/libs/framework/include/constants.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/constants.h b/libs/framework/include/constants.h
index a15d8ad..97d9b47 100644
--- a/libs/framework/include/constants.h
+++ b/libs/framework/include/constants.h
@@ -74,6 +74,9 @@ static const char *const OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_NAME = "org.osgi
 static const bool        OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_DEFAULT = true;
 static const char *const OSGI_FRAMEWORK_FRAMEWORK_UUID = "org.osgi.framework.uuid";
 
+static const char *const CELIX_BUNDLES_PATH_NAME = "CELIX_BUNDLE_PATH";
+static const char *const CELIX_BUNDLES_PATH_DEFAULT = "bundles";
+
 #define CELIX_AUTO_START_0 "CELIX_AUTO_START_0"
 #define CELIX_AUTO_START_1 "CELIX_AUTO_START_1"
 #define CELIX_AUTO_START_2 "CELIX_AUTO_START_2"

http://git-wip-us.apache.org/repos/asf/celix/blob/83456580/libs/framework/src/bundle_context.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/bundle_context.c b/libs/framework/src/bundle_context.c
index 23fde80..83503a5 100644
--- a/libs/framework/src/bundle_context.c
+++ b/libs/framework/src/bundle_context.c
@@ -139,7 +139,7 @@ celix_status_t bundleContext_installBundle(bundle_context_pt context, const char
 	return bundleContext_installBundle2(context, location, NULL, bundle);
 }
 
-celix_status_t bundleContext_installBundle2(bundle_context_pt context, const char * location, const char *inputFile, bundle_pt *bundle) {
+celix_status_t bundleContext_installBundle2(bundle_context_pt context, const char *location, const char *inputFile, bundle_pt *bundle) {
 	celix_status_t status = CELIX_SUCCESS;
 	bundle_pt b = NULL;
 

http://git-wip-us.apache.org/repos/asf/celix/blob/83456580/libs/framework/src/celix_launcher.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/celix_launcher.c b/libs/framework/src/celix_launcher.c
index 5df0c85..405d646 100644
--- a/libs/framework/src/celix_launcher.c
+++ b/libs/framework/src/celix_launcher.c
@@ -40,22 +40,28 @@
 #include <curl/curl.h>
 #include <signal.h>
 #include <libgen.h>
+#include "celix_array_list.h"
 #include "celix_launcher.h"
 #include "framework.h"
 #include "linked_list_iterator.h"
 
 static void show_usage(char* prog_name);
+static void show_properties(celix_properties_t *embeddedProps, const char *configFile);
 static void shutdown_framework(int signal);
 static void ignore(int signal);
 
 static int celixLauncher_launchWithConfigAndProps(const char *configFile, framework_pt *framework, properties_pt packedConfig);
-static int celixLauncher_launchWithStreamAndProps(FILE *stream, framework_pt *framework, properties_pt packedConfig);
+
+static void combine_properties(celix_properties_t *orignal, const celix_properties_t *append);
 
 #define DEFAULT_CONFIG_FILE "config.properties"
 
-static framework_pt framework = NULL;
+static framework_t *g_fw = NULL;
 
 int celixLauncher_launchAndWaitForShutdown(int argc, char *argv[], properties_pt packedConfig) {
+	framework_pt framework = NULL;
+
+
 	// Perform some minimal command-line option parsing...
 	char *opt = NULL;
 	if (argc > 1) {
@@ -63,19 +69,34 @@ int celixLauncher_launchAndWaitForShutdown(int argc, char *argv[], properties_pt
 	}
 
 	char *config_file = NULL;
-
-	if (opt) {
+	bool showProps = false;
+	for (int i = 1; i < argc; ++i) {
+		opt = argv[i];
 		// Check whether the user wants some help...
-		if (strcmp("-h", opt) == 0 || strcmp("-help", opt) == 0) {
+		if (strncmp("-h", opt, strlen("-h")) == 0 || strncmp("--help", opt, strlen("--help")) == 0) {
 			show_usage(argv[0]);
 			return 0;
+		} else if (strncmp("-p", opt, strlen("-p")) == 0 || strncmp("--props", opt, strlen("--props")) == 0) {
+			showProps = true;
 		} else {
 			config_file = opt;
 		}
-	} else {
+	}
+
+	if (config_file == NULL) {
 		config_file = DEFAULT_CONFIG_FILE;
 	}
 
+	if (packedConfig == NULL) {
+		packedConfig = properties_create();
+	}
+
+	if (showProps) {
+		show_properties(packedConfig, config_file);
+		celix_properties_destroy(packedConfig);
+		return 0;
+	}
+
 	struct sigaction sigact;
 	memset(&sigact, 0, sizeof(sigact));
 	sigact.sa_handler = shutdown_framework;
@@ -87,8 +108,10 @@ int celixLauncher_launchAndWaitForShutdown(int argc, char *argv[], properties_pt
 	sigaction(SIGUSR1,  &sigact, NULL);
 	sigaction(SIGUSR2,  &sigact, NULL);
 
+
 	int rc = celixLauncher_launchWithConfigAndProps(config_file, &framework, packedConfig);
 	if (rc == 0) {
+		g_fw = framework;
 		celixLauncher_waitForShutdown(framework);
 		celixLauncher_destroy(framework);
 	}
@@ -96,12 +119,16 @@ int celixLauncher_launchAndWaitForShutdown(int argc, char *argv[], properties_pt
 }
 
 static void show_usage(char* prog_name) {
-	printf("Usage:\n  %s [path/to/config.properties]\n\n", basename(prog_name));
+	printf("Usage:\n  %s [-h|-p] [path/to/runtime/config.properties]\n", basename(prog_name));
+	printf("Options:\n");
+	printf("\t-h | --help: Show this message\n");
+	printf("\t-p | --props: Show the embedded and runtime properties for this celix container\n");
+	printf("\n");
 }
 
 static void shutdown_framework(int signal) {
-	if (framework != NULL) {
-		celixLauncher_stop(framework); //NOTE main thread will destroy
+	if (g_fw != NULL) {
+		celixLauncher_stop(g_fw); //NOTE main thread will destroy
 	}
 }
 
@@ -113,75 +140,22 @@ int celixLauncher_launch(const char *configFile, framework_pt *framework) {
 	return celixLauncher_launchWithConfigAndProps(configFile, framework, NULL);
 }
 
-static int celixLauncher_launchWithConfigAndProps(const char *configFile, framework_pt *framework, properties_pt packedConfig){
-	int status = 0;
-	FILE *config = fopen(configFile, "r");
+static int celixLauncher_launchWithConfigAndProps(const char *configFile, framework_pt *framework, properties_pt packedConfig) {
 	if (packedConfig == NULL) {
 		packedConfig = properties_create();
 	}
 
+	FILE *config = fopen(configFile, "r");
 	if (config != NULL) {
-		status = celixLauncher_launchWithStreamAndProps(config, framework, packedConfig);
-	} else {
-		status = celixLauncher_launchWithProperties(packedConfig, framework);
+		celix_properties_t *configProps = celix_properties_loadWithStream(config);
+		fclose(config);
+		combine_properties(packedConfig, configProps);
+		celix_properties_destroy(configProps);
 	}
 
-	return status;
+	return celixLauncher_launchWithProperties(packedConfig, framework);
 }
 
-static int celixLauncher_launchWithStreamAndProps(FILE *stream, framework_pt *framework, properties_pt packedConfig){
-	int status = 0;
-
-	properties_pt runtimeConfig = properties_loadWithStream(stream);
-	fclose(stream);
-
-	// Make sure we've read it and that nothing went wrong with the file access...
-	// If there is no runtimeConfig, the packedConfig can be stored as global config
-	if (runtimeConfig == NULL){
-		runtimeConfig = packedConfig;
-	}
-
-	if (runtimeConfig == NULL) {
-		fprintf(stderr, "Error: invalid configuration file");
-		perror(NULL);
-		status = 1;
-	} else {
-		// Check if there's a pre-compiled config available
-		if (packedConfig != NULL){
-			// runtimeConfig and packedConfig must be merged
-			// when a duplicate of a key is available, the runtimeConfig must be prioritized
-
-			hash_map_iterator_t iter = hashMapIterator_construct(packedConfig);
-
-			hash_map_entry_pt entry = hashMapIterator_nextEntry(&iter);
-
-			while (entry != NULL) {
-				const char * key = (const char *) hashMapEntry_getKey(entry);
-				const char * value = (const char *) hashMapEntry_getValue(entry);
-
-				// Check existence of key in runtimeConfig
-				if (!hashMap_containsKey(runtimeConfig, key)) {
-					properties_set(runtimeConfig, key, value);
-				}
-
-				entry = hashMapIterator_nextEntry(&iter);
-				if (entry != NULL) {
-					key = (const char *) hashMapEntry_getKey(entry);
-					value = (const char *) hashMapEntry_getValue(entry);
-				}
-			}
-
-			// normally, the framework_destroy will clean up the properties_pt
-			// since there are 2 properties_pt available (runtimeConfig and packedConfig)
-			// the packedConfig must be destroyed
-			properties_destroy(packedConfig);
-		}
-
-		status = celixLauncher_launchWithProperties(runtimeConfig, framework);
-	}
-
-	return status;
-}
 
 int celixLauncher_launchWithProperties(properties_pt config, framework_pt *framework) {
 	celix_status_t status;
@@ -217,3 +191,58 @@ void celixLauncher_stop(framework_pt framework) {
 		bundle_stop(fwBundle);
 	}
 }
+
+static void show_properties(celix_properties_t *embeddedProps, const char *configFile) {
+	const char *key = NULL;
+	printf("Embedded properties:\n");
+	if (embeddedProps == NULL || celix_properties_size(embeddedProps) == 0) {
+		printf("|- Empty!\n");
+	} else {
+		CELIX_PROPERTIES_FOR_EACH(embeddedProps, key) {
+			const char *val = celix_properties_get(embeddedProps, key, "!Error!");
+			printf("|- %s=%s\n", key, val);
+		}
+	}
+	printf("\n");
+
+	celix_properties_t *configProps = NULL;
+	if (configFile != NULL) {
+		configProps = celix_properties_load(configFile);
+	}
+	printf("Runtime properties (input %s):\n", configFile);
+	if (configProps == NULL || celix_properties_size(configProps) == 0) {
+		printf("|- Empty!\n");
+	} else {
+		CELIX_PROPERTIES_FOR_EACH(configProps, key) {
+			const char *val = celix_properties_get(configProps, key, "!Error!");
+			printf("|- %s=%s\n", key, val);
+		}
+	}
+    printf("\n");
+
+	//combined result
+	combine_properties(embeddedProps, configProps);
+	printf("Resolved (embedded + runtime) properties:\n");
+	if (embeddedProps == NULL || celix_properties_size(embeddedProps) == 0) {
+		printf("|- Empty!\n");
+	} else {
+		CELIX_PROPERTIES_FOR_EACH(embeddedProps, key) {
+			const char *val = celix_properties_get(embeddedProps, key, "!Error!");
+			printf("|- %s=%s\n", key, val);
+		}
+	}
+    printf("\n");
+
+	if (configProps != NULL) {
+		celix_properties_destroy(configProps);
+	}
+}
+
+static void combine_properties(celix_properties_t *orignal, const celix_properties_t *append) {
+	if (orignal != NULL && append != NULL) {
+		const char *key = NULL;
+		CELIX_PROPERTIES_FOR_EACH(append, key) {
+			celix_properties_set(orignal, key, celix_properties_get(append, key, NULL));
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/83456580/libs/framework/src/framework.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c
index 75c61e8..f10b259 100644
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@ -778,10 +778,49 @@ celix_status_t fw_installBundle(framework_pt framework, bundle_pt * bundle, cons
 	return fw_installBundle2(framework, bundle, -1, location, inputFile, NULL);
 }
 
-celix_status_t fw_installBundle2(framework_pt framework, bundle_pt * bundle, long id, const char * location, const char *inputFile, bundle_archive_pt archive) {
+static char* resolveBundleLocation(celix_framework_t *fw, const char *bndLoc, const char *p) {
+    char *result = NULL;
+    if (strnlen(bndLoc, 1) > 0) {
+        if (bndLoc[0] == '/') {
+            //absolute path, just use that
+            asprintf(&result, "%s", bndLoc);
+        } else if (access(bndLoc, F_OK) != -1) {
+            //current relative path points to an existing file, so use that.
+            result = strndup(bndLoc, 1024*1024);
+        } else {
+            //relative path -> resolve using BUNDLES_PATH
+            char *paths = strndup(p, 1024 * 1024);
+            const char *sep = ";";
+            char *savePtr = NULL;
+
+            for (char *path = strtok_r(paths, sep, &savePtr); path != NULL; path = strtok_r(NULL, sep, &savePtr)){
+                char *absPath = NULL;
+                asprintf(&absPath, "%s/%s", path, bndLoc);
+                if (access(absPath, F_OK) != -1 ) {
+                    result = absPath;
+                    break;
+                } else {
+                    free(absPath);
+                }
+            }
+            free(paths);
+        }
+    }
+    return result;
+}
+
+celix_status_t fw_installBundle2(framework_pt framework, bundle_pt * bundle, long id, const char *bndLoc, const char *inputFile, bundle_archive_pt archive) {
     celix_status_t status = CELIX_SUCCESS;
     bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
 
+    const char *paths = celix_bundleContext_getProperty(framework->bundle->context, CELIX_BUNDLES_PATH_NAME, CELIX_BUNDLES_PATH_DEFAULT);
+    char *location = resolveBundleLocation(framework, bndLoc, paths);
+    if (location == NULL) {
+        fw_log(framework->logger, OSGI_FRAMEWORK_LOG_WARNING, "Cannot find bundle %s. Using %s=%s", bndLoc, CELIX_BUNDLES_PATH_NAME, paths);
+        free(location);
+        return CELIX_FILE_IO_EXCEPTION;
+    }
+
     //increase use count of framework bundle to prevent a stop. TODO is concurrent installing of bundles supported? -> else need another lock
     fw_bundleEntry_increaseUseCount(framework, framework->bundleId);
 
@@ -797,6 +836,7 @@ celix_status_t fw_installBundle2(framework_pt framework, bundle_pt * bundle, lon
         *bundle = framework_getBundle(framework, location);
         if (*bundle != NULL) {
             fw_bundleEntry_decreaseUseCount(framework, framework->bundleId);
+            free(location);
             return CELIX_SUCCESS;
         }
 
@@ -839,6 +879,8 @@ celix_status_t fw_installBundle2(framework_pt framework, bundle_pt * bundle, lon
         status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_INSTALLED, *bundle));
     }
 
+    free(location);
+
   	return status;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/83456580/libs/framework/tst/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/libs/framework/tst/CMakeLists.txt b/libs/framework/tst/CMakeLists.txt
index 38d0ed8..48f0d05 100644
--- a/libs/framework/tst/CMakeLists.txt
+++ b/libs/framework/tst/CMakeLists.txt
@@ -19,6 +19,7 @@
 add_celix_bundle(simple_test_bundle1 NO_ACTIVATOR VERSION 1.0.0)
 add_celix_bundle(simple_test_bundle2 NO_ACTIVATOR VERSION 1.0.0)
 add_celix_bundle(simple_test_bundle3 NO_ACTIVATOR VERSION 1.0.0)
+add_subdirectory(subdir) #simple_test_bundle4 and simeple_test_bundle5
 
 add_executable(test_framework
     run_tests.cpp
@@ -28,7 +29,7 @@ add_executable(test_framework
     bundle_context_services_test.cpp
 )
 target_link_libraries(test_framework Celix::framework ${CURL_LIBRARIES} ${CPPUTEST_LIBRARY})
-add_dependencies(test_framework simple_test_bundle1_bundle simple_test_bundle2_bundle simple_test_bundle3_bundle)
+add_dependencies(test_framework simple_test_bundle1_bundle simple_test_bundle2_bundle simple_test_bundle3_bundle simple_test_bundle4_bundle simple_test_bundle5_bundle)
 target_include_directories(test_framework PRIVATE ../src)
 
 configure_file(config.properties.in config.properties @ONLY)

http://git-wip-us.apache.org/repos/asf/celix/blob/83456580/libs/framework/tst/bundle_context_bundles_tests.cpp
----------------------------------------------------------------------
diff --git a/libs/framework/tst/bundle_context_bundles_tests.cpp b/libs/framework/tst/bundle_context_bundles_tests.cpp
index d3629c5..179bb6f 100644
--- a/libs/framework/tst/bundle_context_bundles_tests.cpp
+++ b/libs/framework/tst/bundle_context_bundles_tests.cpp
@@ -37,6 +37,8 @@ TEST_GROUP(CelixBundleContextBundlesTests) {
     const char * const TEST_BND1_LOC = "simple_test_bundle1.zip";
     const char * const TEST_BND2_LOC = "simple_test_bundle2.zip";
     const char * const TEST_BND3_LOC = "simple_test_bundle3.zip";
+    const char * const TEST_BND4_LOC = "simple_test_bundle4.zip";
+    const char * const TEST_BND5_LOC = "simple_test_bundle5.zip";
 
     void setup() {
         properties = properties_create();
@@ -55,6 +57,20 @@ TEST_GROUP(CelixBundleContextBundlesTests) {
     }
 };
 
+TEST(CelixBundleContextBundlesTests, installBundlesTest) {
+    long bndId = celix_bundleContext_installBundle(ctx, "non-existing.zip", true);
+    CHECK(bndId < 0);
+
+    bndId = celix_bundleContext_installBundle(ctx, TEST_BND1_LOC, true);
+    CHECK(bndId >= 0);
+
+    bndId = celix_bundleContext_installBundle(ctx, TEST_BND4_LOC, true); //not loaded in subdir
+    CHECK(bndId < 0);
+
+    setenv(CELIX_BUNDLES_PATH_NAME, "subdir", true);
+    bndId = celix_bundleContext_installBundle(ctx, TEST_BND4_LOC, true); //subdir now part of CELIX_BUNDLES_PATH
+    CHECK(bndId >= 0);
+}
 
 TEST(CelixBundleContextBundlesTests, useBundlesTest) {
     int count = 0;

http://git-wip-us.apache.org/repos/asf/celix/blob/83456580/libs/framework/tst/subdir/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/libs/framework/tst/subdir/CMakeLists.txt b/libs/framework/tst/subdir/CMakeLists.txt
new file mode 100644
index 0000000..033a061
--- /dev/null
+++ b/libs/framework/tst/subdir/CMakeLists.txt
@@ -0,0 +1,20 @@
+# 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.
+
+
+add_celix_bundle(simple_test_bundle4 NO_ACTIVATOR VERSION 1.0.0)
+add_celix_bundle(simple_test_bundle5 NO_ACTIVATOR VERSION 1.0.0)

http://git-wip-us.apache.org/repos/asf/celix/blob/83456580/libs/utils/include/celix_properties.h
----------------------------------------------------------------------
diff --git a/libs/utils/include/celix_properties.h b/libs/utils/include/celix_properties.h
index f6e871b..fbc59ab 100644
--- a/libs/utils/include/celix_properties.h
+++ b/libs/utils/include/celix_properties.h
@@ -31,6 +31,7 @@ extern "C" {
 #endif
 
 typedef hash_map_t celix_properties_t;
+typedef hash_map_iterator_t celix_properties_iterator_t;
 
 
 /**********************************************************************************************************************
@@ -69,10 +70,15 @@ void celix_properties_setBool(celix_properties_t *props, const char *key, bool v
 void celix_properties_setDouble(celix_properties_t *props, const char *key, double val);
 double celix_properties_getAsDouble(const celix_properties_t *props, const char *key, double defaultValue);
 
+int celix_properties_size(const celix_properties_t *properties);
+
+celix_properties_iterator_t celix_propertiesIterator_construct(const celix_properties_t *properties);
+bool celix_propertiesIterator_hasNext(celix_properties_iterator_t *iter);
+const char* celix_propertiesIterator_nextKey(celix_properties_iterator_t *iter);
 
 #define CELIX_PROPERTIES_FOR_EACH(props, key) \
-    for(hash_map_iterator_t iter = hashMapIterator_construct(props); \
-        hashMapIterator_hasNext(&iter), (key) = (const char*)hashMapIterator_nextKey(&iter);)
+    for(hash_map_iterator_t iter = celix_propertiesIterator_construct(props); \
+        celix_propertiesIterator_hasNext(&iter), (key) = celix_propertiesIterator_nextKey(&iter);)
 
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/83456580/libs/utils/include/hash_map.h
----------------------------------------------------------------------
diff --git a/libs/utils/include/hash_map.h b/libs/utils/include/hash_map.h
index 3768b7e..d9d1b66 100644
--- a/libs/utils/include/hash_map.h
+++ b/libs/utils/include/hash_map.h
@@ -89,8 +89,6 @@ UTILS_EXPORT void hashMapIterator_dealloc(hash_map_iterator_pt iterator);
 
 UTILS_EXPORT void hashMapIterator_init(hash_map_pt map, hash_map_iterator_pt iterator);
 
-UTILS_EXPORT void hashMapIterator_deinit(hash_map_iterator_pt iterator);
-
 UTILS_EXPORT hash_map_iterator_t hashMapIterator_construct(hash_map_pt map);
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/83456580/libs/utils/private/test/properties_test.cpp
----------------------------------------------------------------------
diff --git a/libs/utils/private/test/properties_test.cpp b/libs/utils/private/test/properties_test.cpp
index 8ea6933..e2f2134 100644
--- a/libs/utils/private/test/properties_test.cpp
+++ b/libs/utils/private/test/properties_test.cpp
@@ -219,3 +219,23 @@ TEST(properties, boolTest) {
 
 	celix_properties_destroy(properties);
 }
+
+TEST(properties, sizeAndIteratorTest) {
+	celix_properties_t *props = celix_properties_create();
+	CHECK_EQUAL(0, celix_properties_size(props));
+	celix_properties_set(props, "a", "1");
+	celix_properties_set(props, "b", "2");
+	CHECK_EQUAL(2, celix_properties_size(props));
+	celix_properties_set(props, "c", "  3  ");
+	celix_properties_set(props, "d", "4");
+	CHECK_EQUAL(4, celix_properties_size(props));
+
+	int count = 0;
+	const char *_key = NULL;
+	CELIX_PROPERTIES_FOR_EACH(props, _key) {
+		count++;
+	}
+	CHECK_EQUAL(4, count);
+
+	celix_properties_destroy(props);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/83456580/libs/utils/src/hash_map.c
----------------------------------------------------------------------
diff --git a/libs/utils/src/hash_map.c b/libs/utils/src/hash_map.c
index bc514a7..d1f29c6 100644
--- a/libs/utils/src/hash_map.c
+++ b/libs/utils/src/hash_map.c
@@ -102,7 +102,7 @@ void hashMap_destroy(hash_map_pt map, bool freeKeys, bool freeValues) {
 	free(map);
 }
 
-int hashMap_size(hash_map_pt map) {
+int hashMap_size(hash_map_t *map) {
 	return map->size;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/83456580/libs/utils/src/properties.c
----------------------------------------------------------------------
diff --git a/libs/utils/src/properties.c b/libs/utils/src/properties.c
index 191dfd8..33068e6 100644
--- a/libs/utils/src/properties.c
+++ b/libs/utils/src/properties.c
@@ -445,4 +445,18 @@ bool celix_properties_getAsBool(celix_properties_t *props, const char *key, bool
 
 void celix_properties_setBool(celix_properties_t *props, const char *key, bool val) {
     celix_properties_set(props, key, val ? "true" : "false");
-}
\ No newline at end of file
+}
+
+int celix_properties_size(const celix_properties_t *properties) {
+	return hashMap_size((hash_map_t*)properties);
+}
+
+celix_properties_iterator_t celix_propertiesIterator_construct(const celix_properties_t *properties) {
+	return hashMapIterator_construct((hash_map_t*)properties);
+}
+bool celix_propertiesIterator_hasNext(celix_properties_iterator_t *iter) {
+	return hashMapIterator_hasNext(iter);
+}
+const char* celix_propertiesIterator_nextKey(celix_properties_iterator_t *iter) {
+	return (const char*)hashMapIterator_nextKey(iter);
+}


[2/2] celix git commit: CELIX-433: Moves the generation of config.properties to the main.c/main.cc program for a celix container.

Posted by pn...@apache.org.
CELIX-433: Moves the generation of config.properties to the main.c/main.cc program for a celix container.

Also:
- config.properties must now be configured using RUNTIME_PROPERTIES. If no runtime properties are present the config.properties will not be generated.
- Remove the generation of run.sh, release.sh and eclipse launch file. Preferred way of running is just to run the executable.
- Running a celix container with -p/--props argument will now print the config properties info (embedded, runtime and env).


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/33a93db0
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/33a93db0
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/33a93db0

Branch: refs/heads/develop
Commit: 33a93db0a71b945aaf2869e250e61b059a3c45c1
Parents: 8345658
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Mon Oct 29 20:59:12 2018 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Mon Oct 29 20:59:12 2018 +0100

----------------------------------------------------------------------
 cmake/cmake_celix/ContainerPackaging.cmake      | 104 ++++++++-----------
 .../celix-examples/dm_example/CMakeLists.txt    |   4 +-
 libs/framework/include/constants.h              |   2 +-
 libs/framework/src/celix_launcher.c             |  37 ++++---
 libs/framework/src/framework.c                  |   5 +-
 libs/utils/src/properties.c                     |  11 +-
 6 files changed, 79 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/33a93db0/cmake/cmake_celix/ContainerPackaging.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/ContainerPackaging.cmake b/cmake/cmake_celix/ContainerPackaging.cmake
index 0408e8f..4c4e967 100644
--- a/cmake/cmake_celix/ContainerPackaging.cmake
+++ b/cmake/cmake_celix/ContainerPackaging.cmake
@@ -39,7 +39,7 @@ function(add_celix_container)
 
     set(OPTIONS COPY CXX)
     set(ONE_VAL_ARGS GROUP NAME LAUNCHER LAUNCHER_SRC DIR)
-    set(MULTI_VAL_ARGS BUNDLES PROPERTIES EMBEDDED_PROPERTIES)
+    set(MULTI_VAL_ARGS BUNDLES PROPERTIES EMBEDDED_PROPERTIES RUNTIME_PROPERTIES)
     cmake_parse_arguments(CONTAINER "${OPTIONS}" "${ONE_VAL_ARGS}" "${MULTI_VAL_ARGS}" ${ARGN})
 
     ##### Check arguments #####
@@ -66,10 +66,6 @@ function(add_celix_container)
     list(APPEND CONTAINERDEPS ${CONTAINER_TARGET})
     set_target_properties(celix-containers PROPERTIES "CONTAINER_DEPLOYMENTS" "${CONTAINERDEPS}")
 
-    #FILE TARGETS FOR CONTAINER
-    set(CONTAINER_PROPS "${CONTAINER_LOC}/config.properties")
-    set(CONTAINER_ECLIPSE_LAUNCHER "${CONTAINER_LOC}/${CONTAINER_NAME}.launch")
-
     set(LAUNCHER_DEP )
     if (CONTAINER_LAUNCHER)
         if (IS_ABSOLUTE "${CONTAINER_LAUNCHER}")
@@ -92,20 +88,32 @@ function(add_celix_container)
         else()
             set(LAUNCHER_SRC "${PROJECT_BINARY_DIR}/celix/gen/containers/${CONTAINER_TARGET}/main.c")
         endif()
+        set(STAGE1_LAUNCHER_SRC "${PROJECT_BINARY_DIR}/celix/gen/containers/${CONTAINER_TARGET}/main.stage1.c")
 
         file(GENERATE
-                OUTPUT "${LAUNCHER_SRC}"
+                OUTPUT "${STAGE1_LAUNCHER_SRC}"
                 CONTENT "#include <celix_launcher.h>
 int main(int argc, char *argv[]) {
     const char * config = \"\\
+CELIX_CONTAINER_NAME=$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_NAME>\\n\\
+CELIX_BUNDLES_PATH=bundles\\n\\
+$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_0>>:CELIX_AUTO_START_0=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_0>, >\\n>\\
+$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_1>>:CELIX_AUTO_START_1=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_1>, >\\n>\\
+$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_2>>:CELIX_AUTO_START_2=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_2>, >\\n>\\
+$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_3>>:CELIX_AUTO_START_3=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_3>, >\\n>\\
+$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_4>>:CELIX_AUTO_START_4=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_4>, >\\n>\\
+$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_5>>:CELIX_AUTO_START_5=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_5>, >\\n>\\
+$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_6>>:CELIX_AUTO_START_5=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_6>, >\\n>\\
 $<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_EMBEDDED_PROPERTIES>,\\n\\
 >\";
 
-    properties_pt packedConfig = properties_loadFromString(config);
-    return celixLauncher_launchAndWaitForShutdown(argc, argv, packedConfig);
+    celix_properties_t *embeddedProps = celix_properties_loadFromString(config);
+    return celixLauncher_launchAndWaitForShutdown(argc, argv, embeddedProps);
 }
 "
         )
+
+        file(GENERATE OUTPUT "${LAUNCHER_SRC}" INPUT "${STAGE1_LAUNCHER_SRC}")
     endif ()
 
     if (LAUNCHER_SRC) #compilation needed
@@ -121,24 +129,20 @@ $<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_EMBEDDED_PROPERTIES>,\\n\
         )
     endif ()
 
-    #generate config.properties
+    #generate config.properties. C
+    set(CONTAINER_PROPS "${CONTAINER_LOC}/config.properties")
     set(STAGE1_PROPERTIES "${PROJECT_BINARY_DIR}/celix/gen/containers/${CONTAINER_TARGET}/container-config-stage1.properties")
     file(GENERATE 
         OUTPUT "${STAGE1_PROPERTIES}"
-        CONTENT "CELIX_AUTO_START_0=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_0>, >
-CELIX_AUTO_START_1=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_1>, >
-CELIX_AUTO_START_2=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_2>, >
-CELIX_AUTO_START_3=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_3>, >
-CELIX_AUTO_START_4=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_4>, >
-CELIX_AUTO_START_5=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_5>, >
-CELIX_CONTAINER_NAME=$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_NAME>
-$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_PROPERTIES>,
+        CONTENT "$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_RUNTIME_PROPERTIES>,
 >
 "
     )
+    #Condition is there so that config.properties file will only be generated if there are runtime properties
     file(GENERATE
         OUTPUT "${CONTAINER_PROPS}"
         INPUT "${STAGE1_PROPERTIES}"
+        CONDITION $<NOT:$<STREQUAL:,$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_RUNTIME_PROPERTIES>>>
     )
 
     #needed in the release.sh & run.sh files
@@ -158,63 +162,37 @@ $<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_PROPERTIES>,
         set(LIB_PATH_NAME "LD_LIBRARY_PATH")
     endif()
 
-    set(RELEASE_SH ${CONTAINER_LOC}/release.sh)
-    set(RELEASE_CONTENT "#!/bin/sh\nexport ${LIB_PATH_NAME}=${CELIX_LIB_DIRS}:\${${LIB_PATH_NAME}}\nexport PATH=${CELIX_BIN_DIR}:\${PATH}")
-    file(GENERATE
-        OUTPUT ${RELEASE_SH}
-        CONTENT ${RELEASE_CONTENT}
-    )
-
-    set(RUN_SH ${CONTAINER_LOC}/run.sh)
-    set(RUN_CONTENT "${RELEASE_CONTENT}\n${LAUNCHER} \$@\n")
-    file(GENERATE
-        OUTPUT ${RUN_SH}
-        CONTENT ${RUN_CONTENT}
-    )
-
-    #generate eclipse project launch file
-    set(PROGRAM_NAME "${LAUNCHER}")
-    set(PROJECT_ATTR "${CMAKE_PROJECT_NAME}-build")
-    set(WORKING_DIRECTORY ${CONTAINER_LOC})
-    include("${CELIX_CMAKE_DIRECTORY}/RunConfig.in.cmake") #set VAR RUN_CONFIG_IN
-    file(GENERATE
-        OUTPUT "${CONTAINER_ECLIPSE_LAUNCHER}"
-        CONTENT "${RUN_CONFIG_IN}"
-    )
 
     #add a custom target which can depend on generation expressions
     add_custom_target(${CONTAINER_TARGET}-deps
         DEPENDS
-            ${RUN_SH}
-            ${CONTAINER_ECLIPSE_LAUNCHER}
-            ${RELEASE_SH}
-            ${CONTAINER_PROPS}
             $<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_TARGET_DEPS>
     )
     add_dependencies(${CONTAINER_TARGET} ${CONTAINER_TARGET}-deps)
 
-
     ##### Container Target Properties #####
     #internal use
     set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_TARGET_DEPS" "") #target deps for the container.
-    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_BUNDLES_LEVEL_0" "") #bundles to deploy for the container for run level 0
-    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_BUNDLES_LEVEL_1" "") #bundles to deploy for the container for run level 0
-    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_BUNDLES_LEVEL_2" "") #bundles to deploy for the container for run level 0
-    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_BUNDLES_LEVEL_3" "") #bundles to deploy for the container for run level 0
-    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_BUNDLES_LEVEL_4" "") #bundles to deploy for the container for run level 0
-    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_BUNDLES_LEVEL_5" "") #bundles to deploy for the container for run level 0
+    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_BUNDLES_LEVEL_0" "") #bundles to deploy for the container for startup level 0
+    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_BUNDLES_LEVEL_1" "") #bundles to deploy for the container for startup level 1
+    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_BUNDLES_LEVEL_2" "") #bundles to deploy for the container for startup level 2
+    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_BUNDLES_LEVEL_3" "") #bundles to deploy for the container for startup level 3, the default used startup level
+    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_BUNDLES_LEVEL_4" "") #bundles to deploy for the container for startup level 4
+    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_BUNDLES_LEVEL_5" "") #bundles to deploy for the container for startup level 5
+    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_BUNDLES_LEVEL_6" "") #bundles to deploy for the container for startup level 6
     set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_COPY_BUNDLES" ${CONTAINER_COPY}) #copy bundles in bundle dir or link using abs paths. NOTE this cannot be changed after a add_deploy command
 
     #deploy specific
     set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_NAME" "${CONTAINER_NAME}")
     set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_GROUP" "${CONTAINER_GROUP}")
     set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_LOC" "${CONTAINER_LOC}")
-    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_PROPERTIES" "")
+    set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_RUNTIME_PROPERTIES" "")
     set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_EMBEDDED_PROPERTIES" "")
     #####
 
-    celix_container_bundles(${CONTAINER_TARGET} LEVEL 1 ${CONTAINER_BUNDLES})
-    celix_container_properties(${CONTAINER_TARGET} ${CONTAINER_PROPERTIES})
+    celix_container_bundles(${CONTAINER_TARGET} LEVEL 3 ${CONTAINER_BUNDLES})
+    celix_container_embedded_properties(${CONTAINER_TARGET} ${CONTAINER_PROPERTIES})
+    celix_container_runtime_properties(${CONTAINER_TARGET} ${CONTAINER_RUNTIME_PROPERTIES})
     celix_container_embedded_properties(${CONTAINER_TARGET} ${CONTAINER_EMBEDDED_PROPERTIES})
 
 
@@ -327,7 +305,7 @@ function(celix_container_bundles)
         set(HANDLED FALSE)
         if (IS_ABSOLUTE ${BUNDLE} AND EXISTS ${BUNDLE})
                get_filename_component(BUNDLE_FILENAME ${BUNDLE} NAME)
-               set(COPY_LOC "bundles/${BUNDLE_FILENAME}")
+               set(COPY_LOC "${BUNDLE_FILENAME}")
                set(ABS_LOC "${BUNDLE}")
                set(HANDLED TRUE)
            elseif (TARGET ${BUNDLE})
@@ -338,7 +316,7 @@ function(celix_container_bundles)
                else()
                    get_target_property(IMP ${BUNDLE} BUNDLE_IMPORTED)
                    if (IMP) #An imported bundle target -> handle target without DEPENDS
-                       set(COPY_LOC "bundles/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>")
+                       set(COPY_LOC "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>")
                        set(ABS_LOC "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>")
                        set(HANDLED TRUE)
                    endif ()
@@ -346,7 +324,7 @@ function(celix_container_bundles)
            endif ()
 
            if (NOT HANDLED) #not a imported bundle target, so assuming a (future) bundle target
-               set(COPY_LOC "bundles/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>")
+               set(COPY_LOC "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>")
                set(ABS_LOC "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>")
 
                if (NOT COPY) #in case of COPY dep will be added in celix_container_bundles_dir
@@ -375,21 +353,21 @@ function(celix_container_bundles)
 endfunction()
 
 function(deploy_properties)
-    celix_container_properties(${ARGN})
+    celix_container_runtime_properties(${ARGN})
 endfunction()
-function(celix_container_properties)
+function(celix_container_runtime_properties)
     #0 is container TARGET
     #1..n is bundles
     list(GET ARGN 0 CONTAINER_TARGET)
     list(REMOVE_AT ARGN 0)
 
-    get_target_property(PROPS ${CONTAINER_TARGET} "CONTAINER_PROPERTIES")
+    get_target_property(PROPS ${CONTAINER_TARGET} "CONTAINER_RUNTIME_PROPERTIES")
 
     foreach(PROP IN ITEMS ${ARGN})
         list(APPEND PROPS ${PROP})
     endforeach()
 
-   set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_PROPERTIES" "${PROPS}")
+   set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_RUNTIME_PROPERTIES" "${PROPS}")
 endfunction()
 
 function(deploy_embedded_properties)
@@ -410,3 +388,7 @@ function(celix_container_embedded_properties)
 
     set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_EMBEDDED_PROPERTIES" "${PROPS}")
 endfunction()
+
+function(celix_container_properties)
+    celix_container_embedded_properties(${ARGN})
+endfunction()

http://git-wip-us.apache.org/repos/asf/celix/blob/33a93db0/examples/celix-examples/dm_example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/dm_example/CMakeLists.txt b/examples/celix-examples/dm_example/CMakeLists.txt
index 64b9479..581a17c 100644
--- a/examples/celix-examples/dm_example/CMakeLists.txt
+++ b/examples/celix-examples/dm_example/CMakeLists.txt
@@ -34,8 +34,10 @@ add_celix_container(dm_example
         dm_example_phase2a
         dm_example_phase2b
         dm_example_phase3
-    PROPERTIES
+    RUNTIME_PROPERTIES
         LOGHELPER_ENABLE_STDOUT_FALLBACK=true
+        PROP2=val2
+        PROP3=val3
 )
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/33a93db0/libs/framework/include/constants.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/constants.h b/libs/framework/include/constants.h
index 97d9b47..c099312 100644
--- a/libs/framework/include/constants.h
+++ b/libs/framework/include/constants.h
@@ -74,7 +74,7 @@ static const char *const OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_NAME = "org.osgi
 static const bool        OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_DEFAULT = true;
 static const char *const OSGI_FRAMEWORK_FRAMEWORK_UUID = "org.osgi.framework.uuid";
 
-static const char *const CELIX_BUNDLES_PATH_NAME = "CELIX_BUNDLE_PATH";
+static const char *const CELIX_BUNDLES_PATH_NAME = "CELIX_BUNDLES_PATH";
 static const char *const CELIX_BUNDLES_PATH_DEFAULT = "bundles";
 
 #define CELIX_AUTO_START_0 "CELIX_AUTO_START_0"

http://git-wip-us.apache.org/repos/asf/celix/blob/33a93db0/libs/framework/src/celix_launcher.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/celix_launcher.c b/libs/framework/src/celix_launcher.c
index 405d646..9fa5c48 100644
--- a/libs/framework/src/celix_launcher.c
+++ b/libs/framework/src/celix_launcher.c
@@ -194,6 +194,8 @@ void celixLauncher_stop(framework_pt framework) {
 
 static void show_properties(celix_properties_t *embeddedProps, const char *configFile) {
 	const char *key = NULL;
+	celix_properties_t *keys = celix_properties_create(); //only to store the keys
+
 	printf("Embedded properties:\n");
 	if (embeddedProps == NULL || celix_properties_size(embeddedProps) == 0) {
 		printf("|- Empty!\n");
@@ -201,41 +203,48 @@ static void show_properties(celix_properties_t *embeddedProps, const char *confi
 		CELIX_PROPERTIES_FOR_EACH(embeddedProps, key) {
 			const char *val = celix_properties_get(embeddedProps, key, "!Error!");
 			printf("|- %s=%s\n", key, val);
-		}
+            celix_properties_set(keys, key, NULL);
+        }
 	}
 	printf("\n");
 
-	celix_properties_t *configProps = NULL;
+	celix_properties_t *runtimeProps = NULL;
 	if (configFile != NULL) {
-		configProps = celix_properties_load(configFile);
+        runtimeProps = celix_properties_load(configFile);
 	}
 	printf("Runtime properties (input %s):\n", configFile);
-	if (configProps == NULL || celix_properties_size(configProps) == 0) {
+	if (runtimeProps == NULL || celix_properties_size(runtimeProps) == 0) {
 		printf("|- Empty!\n");
 	} else {
-		CELIX_PROPERTIES_FOR_EACH(configProps, key) {
-			const char *val = celix_properties_get(configProps, key, "!Error!");
+		CELIX_PROPERTIES_FOR_EACH(runtimeProps, key) {
+			const char *val = celix_properties_get(runtimeProps, key, "!Error!");
 			printf("|- %s=%s\n", key, val);
+            celix_properties_set(keys, key, NULL);
 		}
 	}
     printf("\n");
 
 	//combined result
-	combine_properties(embeddedProps, configProps);
-	printf("Resolved (embedded + runtime) properties:\n");
-	if (embeddedProps == NULL || celix_properties_size(embeddedProps) == 0) {
+	combine_properties(embeddedProps, runtimeProps);
+	printf("Resolved (env, runtime and embedded) properties:\n");
+	if (celix_properties_size(keys) == 0) {
 		printf("|- Empty!\n");
 	} else {
-		CELIX_PROPERTIES_FOR_EACH(embeddedProps, key) {
-			const char *val = celix_properties_get(embeddedProps, key, "!Error!");
-			printf("|- %s=%s\n", key, val);
+		CELIX_PROPERTIES_FOR_EACH(keys, key) {
+			const char *valEm = celix_properties_get(embeddedProps, key, NULL);
+            const char *valRt = celix_properties_get(runtimeProps, key, NULL);
+            const char *envVal = getenv(key);
+            const char *val = envVal != NULL ? envVal : valRt != NULL ? valRt : valEm;
+            const char *source = envVal != NULL ? "environment" : valRt != NULL ? "runtime" : "embedded";
+			printf("|- %s=%s (source %s)\n", key, val, source);
 		}
 	}
     printf("\n");
 
-	if (configProps != NULL) {
-		celix_properties_destroy(configProps);
+	if (runtimeProps != NULL) {
+		celix_properties_destroy(runtimeProps);
 	}
+	celix_properties_destroy(keys);
 }
 
 static void combine_properties(celix_properties_t *orignal, const celix_properties_t *append) {

http://git-wip-us.apache.org/repos/asf/celix/blob/33a93db0/libs/framework/src/framework.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c
index f10b259..2de670c 100644
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@ -723,7 +723,7 @@ static void framework_autoStartConfiguredBundlesForList(bundle_context_t *fwCtx,
             if (rc == CELIX_SUCCESS) {
                 arrayList_add(installed, bnd);
             } else {
-                printf("Could not install bundle from %s\n", location); //TODO use logger
+                printf("Could not install bundle '%s'\n", location);
             }
             location = strtok_r(NULL, delims, &save_ptr);
         }
@@ -813,7 +813,8 @@ celix_status_t fw_installBundle2(framework_pt framework, bundle_pt * bundle, lon
     celix_status_t status = CELIX_SUCCESS;
     bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
 
-    const char *paths = celix_bundleContext_getProperty(framework->bundle->context, CELIX_BUNDLES_PATH_NAME, CELIX_BUNDLES_PATH_DEFAULT);
+    const char *paths = NULL;
+    fw_getProperty(framework, CELIX_BUNDLES_PATH_NAME, CELIX_BUNDLES_PATH_DEFAULT, &paths);
     char *location = resolveBundleLocation(framework, bndLoc, paths);
     if (location == NULL) {
         fw_log(framework->logger, OSGI_FRAMEWORK_LOG_WARNING, "Cannot find bundle %s. Using %s=%s", bndLoc, CELIX_BUNDLES_PATH_NAME, paths);

http://git-wip-us.apache.org/repos/asf/celix/blob/33a93db0/libs/utils/src/properties.c
----------------------------------------------------------------------
diff --git a/libs/utils/src/properties.c b/libs/utils/src/properties.c
index 33068e6..1519ecc 100644
--- a/libs/utils/src/properties.c
+++ b/libs/utils/src/properties.c
@@ -363,15 +363,16 @@ const char* celix_properties_get(const celix_properties_t *properties, const cha
 
 void celix_properties_set(celix_properties_t *properties, const char *key, const char *value) {
 	hash_map_entry_pt entry = hashMap_getEntry(properties, key);
-	char* oldValue = NULL;
+	char* oldVal = NULL;
+	char *newVal = value == NULL ? NULL : strndup(value, 1024*1024);
 	if (entry != NULL) {
 		char* oldKey = hashMapEntry_getKey(entry);
-		oldValue = hashMapEntry_getValue(entry);
-		hashMap_put(properties, oldKey, strndup(value, 1024*10));
+        oldVal = hashMapEntry_getValue(entry);
+		hashMap_put(properties, oldKey, newVal);
 	} else {
-		hashMap_put(properties, strndup(key, 1024*10), strndup(value, 1024*10));
+		hashMap_put(properties, strndup(key, 1024*1024), newVal);
 	}
-	free(oldValue);
+	free(oldVal);
 }
 
 void celix_properties_unset(celix_properties_t *properties, const char *key) {