You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by bp...@apache.org on 2015/12/18 08:33:18 UTC

celix git commit: CELIX-208: refactor celix_launcher to enable embedded launch without stream

Repository: celix
Updated Branches:
  refs/heads/develop cf00b5a9b -> 268f4e494


CELIX-208: refactor celix_launcher to enable embedded launch without stream


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

Branch: refs/heads/develop
Commit: 268f4e49451f500bbb9bb51c81d20f167f5bf093
Parents: cf00b5a
Author: Bjoern Petri <bp...@apache.org>
Authored: Fri Dec 18 08:31:46 2015 +0100
Committer: Bjoern Petri <bp...@apache.org>
Committed: Fri Dec 18 08:31:46 2015 +0100

----------------------------------------------------------------------
 framework/private/src/celix_launcher.c    | 116 +++++++++++++------------
 framework/public/include/celix_launcher.h |   1 +
 2 files changed, 62 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/268f4e49/framework/private/src/celix_launcher.c
----------------------------------------------------------------------
diff --git a/framework/private/src/celix_launcher.c b/framework/private/src/celix_launcher.c
index c3dbb82..144c8dc 100644
--- a/framework/private/src/celix_launcher.c
+++ b/framework/private/src/celix_launcher.c
@@ -63,78 +63,84 @@ int celixLauncher_launchWithStream(FILE *stream, framework_pt *framework) {
         perror(NULL);
         status = 1;
     }
+    else {
+        status = celixLauncher_launchWithProperties(config, framework);
+    }
+
+    return status;
+}
 
 
+int celixLauncher_launchWithProperties(properties_pt config, framework_pt *framework) {
+    celix_status_t status;
 #ifndef CELIX_NO_CURLINIT
     // Before doing anything else, let's setup Curl
     curl_global_init(CURL_GLOBAL_NOTHING);
 #endif
 
+    char *autoStart = properties_get(config, "cosgi.auto.start.1");
 
-    if (status == 0) {
-        char *autoStart = properties_get(config, "cosgi.auto.start.1");
-        celix_status_t status;
-        status = framework_create(framework, config);
-        bundle_pt fwBundle = NULL;
+    status = framework_create(framework, config);
+    bundle_pt fwBundle = NULL;
+    if (status == CELIX_SUCCESS) {
+        status = fw_init(*framework);
         if (status == CELIX_SUCCESS) {
-            status = fw_init(*framework);
-            if (status == CELIX_SUCCESS) {
-                // Start the system bundle
-                framework_getFrameworkBundle(*framework, &fwBundle);
-                bundle_start(fwBundle);
-
-                char delims[] = " ";
-                char *result = NULL;
-                char *save_ptr = NULL;
-                linked_list_pt bundles;
-                array_list_pt installed = NULL;
-                bundle_context_pt context = NULL;
-                linked_list_iterator_pt iter = NULL;
-                unsigned int i;
-
-                linkedList_create(&bundles);
-                result = strtok_r(autoStart, delims, &save_ptr);
-                while (result != NULL) {
-                    char *location = strdup(result);
-                    linkedList_addElement(bundles, location);
-                    result = strtok_r(NULL, delims, &save_ptr);
-                }
-                // First install all bundles
-                // Afterwards start them
-                arrayList_create(&installed);
-                bundle_getContext(fwBundle, &context);
-                iter = linkedListIterator_create(bundles, 0);
-                while (linkedListIterator_hasNext(iter)) {
-                    bundle_pt current = NULL;
-                    char *location = (char *) linkedListIterator_next(iter);
-                    if (bundleContext_installBundle(context, location, &current) == CELIX_SUCCESS) {
-                        // Only add bundle if it is installed correctly
-                        arrayList_add(installed, current);
-                    } else {
-                        printf("Could not install bundle from %s\n", location);
-                    }
-                    linkedListIterator_remove(iter);
-                    free(location);
-                }
-                linkedListIterator_destroy(iter);
-                linkedList_destroy(bundles);
-
-                for (i = 0; i < arrayList_size(installed); i++) {
-                    bundle_pt installedBundle = (bundle_pt) arrayList_get(installed, i);
-                    bundle_startWithOptions(installedBundle, 0);
+            // Start the system bundle
+            framework_getFrameworkBundle(*framework, &fwBundle);
+            bundle_start(fwBundle);
+
+            char delims[] = " ";
+            char *result = NULL;
+            char *save_ptr = NULL;
+            linked_list_pt bundles;
+            array_list_pt installed = NULL;
+            bundle_context_pt context = NULL;
+            linked_list_iterator_pt iter = NULL;
+            unsigned int i;
+
+            linkedList_create(&bundles);
+            result = strtok_r(autoStart, delims, &save_ptr);
+            while (result != NULL) {
+                char *location = strdup(result);
+                linkedList_addElement(bundles, location);
+                result = strtok_r(NULL, delims, &save_ptr);
+            }
+            // First install all bundles
+            // Afterwards start them
+            arrayList_create(&installed);
+            bundle_getContext(fwBundle, &context);
+            iter = linkedListIterator_create(bundles, 0);
+            while (linkedListIterator_hasNext(iter)) {
+                bundle_pt current = NULL;
+                char *location = (char *) linkedListIterator_next(iter);
+                if (bundleContext_installBundle(context, location, &current) == CELIX_SUCCESS) {
+                    // Only add bundle if it is installed correctly
+                    arrayList_add(installed, current);
+                } else {
+                    printf("Could not install bundle from %s\n", location);
                 }
+                linkedListIterator_remove(iter);
+                free(location);
+            }
+            linkedListIterator_destroy(iter);
+            linkedList_destroy(bundles);
 
-                arrayList_destroy(installed);
+            for (i = 0; i < arrayList_size(installed); i++) {
+                bundle_pt installedBundle = (bundle_pt) arrayList_get(installed, i);
+                bundle_startWithOptions(installedBundle, 0);
             }
-        }
 
-        if (status != CELIX_SUCCESS) {
-            printf("Problem creating framework\n");
+            arrayList_destroy(installed);
         }
+    }
 
-        printf("Launcher: Framework Started\n");
+    if (status != CELIX_SUCCESS) {
+        printf("Problem creating framework\n");
     }
 
+    printf("Launcher: Framework Started\n");
+
+
     return status;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/268f4e49/framework/public/include/celix_launcher.h
----------------------------------------------------------------------
diff --git a/framework/public/include/celix_launcher.h b/framework/public/include/celix_launcher.h
index a5d375f..701e548 100644
--- a/framework/public/include/celix_launcher.h
+++ b/framework/public/include/celix_launcher.h
@@ -32,6 +32,7 @@
 
 int celixLauncher_launch(const char *configFile, framework_pt *framework);
 int celixLauncher_launchWithStream(FILE *config, framework_pt *framework);
+int celixLauncher_launchWithProperties(properties_pt config, framework_pt *framework);
 
 void celixLauncher_stop(framework_pt framework);
 void celixLauncher_destroy(framework_pt framework);