Author: abroekhuis
Date: Mon Jun 24 13:01:49 2013
New Revision: 1496013

URL: http://svn.apache.org/r1496013
Log:
CELIX-60: Added initial support for embedding

Added:
    incubator/celix/trunk/examples/embedding/
    incubator/celix/trunk/examples/embedding/CMakeLists.txt
      - copied, changed from r1496012, 
incubator/celix/trunk/launcher/CMakeLists.txt
    incubator/celix/trunk/examples/embedding/private/
    incubator/celix/trunk/examples/embedding/private/src/
    incubator/celix/trunk/examples/embedding/private/src/main.c
    incubator/celix/trunk/framework/private/include/framework_private.h
Modified:
    incubator/celix/trunk/examples/CMakeLists.txt
    incubator/celix/trunk/framework/private/src/bundle.c
    incubator/celix/trunk/framework/private/src/bundle_context.c
    incubator/celix/trunk/framework/private/src/framework.c
    incubator/celix/trunk/framework/private/src/service_registry.c
    incubator/celix/trunk/framework/public/include/bundle.h
    incubator/celix/trunk/framework/public/include/framework.h
    incubator/celix/trunk/launcher/CMakeLists.txt
    incubator/celix/trunk/launcher/private/src/launcher.c
    incubator/celix/trunk/shell/private/src/start_command.c
    incubator/celix/trunk/shell/private/src/stop_command.c

Modified: incubator/celix/trunk/examples/CMakeLists.txt
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/examples/CMakeLists.txt?rev=1496013&r1=1496012&r2=1496013&view=diff
==============================================================================
--- incubator/celix/trunk/examples/CMakeLists.txt (original)
+++ incubator/celix/trunk/examples/CMakeLists.txt Mon Jun 24 13:01:49 2013
@@ -26,4 +26,6 @@ if (EXAMPLES)
     add_subdirectory(osgi-in-action/chapter04-correct-listener)
     add_subdirectory(osgi-in-action/chapter01-greeting-example)
     add_subdirectory(osgi-in-action/chapter04-paint-example)
+    
+    add_subdirectory(embedding)
 endif(EXAMPLES)

Copied: incubator/celix/trunk/examples/embedding/CMakeLists.txt (from r1496012, 
incubator/celix/trunk/launcher/CMakeLists.txt)
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/examples/embedding/CMakeLists.txt?p2=incubator/celix/trunk/examples/embedding/CMakeLists.txt&p1=incubator/celix/trunk/launcher/CMakeLists.txt&r1=1496012&r2=1496013&rev=1496013&view=diff
==============================================================================
--- incubator/celix/trunk/launcher/CMakeLists.txt (original)
+++ incubator/celix/trunk/examples/embedding/CMakeLists.txt Mon Jun 24 13:01:49 
2013
@@ -14,13 +14,11 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-celix_subproject(LAUNCHER "Option to build the launcher" "ON" DEPS UTILS 
FRAMEWORK)
-if (LAUNCHER) 
-    add_executable(celix private/src/launcher)
-    
-    target_link_libraries(celix celix_framework)
-    include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-    include_directories("${PROJECT_SOURCE_DIR}/framework/private/include")
-    
-    install(TARGETS celix RUNTIME DESTINATION bin COMPONENT framework)
-endif (LAUNCHER) 
\ No newline at end of file
+
+#SET_HEADER(BUNDLE_SYMBOLICNAME "apache_celix_examples_embedding")
+#SET_HEADERS("Bundle-Name: Apache Celix Shell TUI") 
+       
+#bundle(hello_world SOURCES private/src/activator)
+add_executable(embedding private/src/main)
+include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+target_link_libraries(embedding celix_framework)
\ No newline at end of file

Added: incubator/celix/trunk/examples/embedding/private/src/main.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/examples/embedding/private/src/main.c?rev=1496013&view=auto
==============================================================================
--- incubator/celix/trunk/examples/embedding/private/src/main.c (added)
+++ incubator/celix/trunk/examples/embedding/private/src/main.c Mon Jun 24 
13:01:49 2013
@@ -0,0 +1,91 @@
+/**
+ *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.
+ */
+/*
+ * main.c
+ *
+ *  \date       May 22, 2013
+ *  \author     <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include <apr_general.h>
+
+#include "celix_errno.h"
+#include "framework.h"
+#include "bundle_context.h"
+
+struct foo {
+
+};
+
+struct fooSrv {
+       struct foo *handle;
+       celix_status_t (*foo)(struct foo *handle);
+};
+
+celix_status_t embedded_foo();
+
+int main(void) {
+       apr_status_t status = APR_SUCCESS;
+       apr_pool_t *memoryPool = NULL;
+
+       status = apr_initialize();
+       if (status != APR_SUCCESS) {
+               return CELIX_START_ERROR;
+       }
+
+       status = apr_pool_create(&memoryPool, NULL);
+       if (status != APR_SUCCESS) {
+               return CELIX_START_ERROR;
+       }
+
+       framework_t framework = NULL;
+       framework_create(&framework, memoryPool, NULL);
+       fw_init(framework);
+
+       bundle_t fwBundle = NULL;
+       framework_getFrameworkBundle(framework, &fwBundle);
+       bundle_start(fwBundle);
+
+       bundle_context_t context = NULL;
+       bundle_getContext(fwBundle, &context);
+
+       struct foo *f = apr_palloc(memoryPool, sizeof(*f));
+       struct fooSrv *fs = apr_palloc(memoryPool, sizeof(*fs));
+       fs->handle = f;
+       fs->foo = embedded_foo;
+
+       service_registration_t reg = NULL;
+       bundleContext_registerService(context, "foo", fs, NULL, &reg);
+
+       service_reference_t ref = NULL;
+       bundleContext_getServiceReference(context, "foo", &ref);
+
+       void *fs2 = NULL;
+       bundleContext_getService(context, ref, &fs2);
+
+       ((struct fooSrv*)fs2)->foo(((struct fooSrv*)fs2)->handle);
+}
+
+celix_status_t embedded_foo() {
+       printf("foo\n");
+       return CELIX_SUCCESS;
+}
+

Added: incubator/celix/trunk/framework/private/include/framework_private.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/framework_private.h?rev=1496013&view=auto
==============================================================================
--- incubator/celix/trunk/framework/private/include/framework_private.h (added)
+++ incubator/celix/trunk/framework/private/include/framework_private.h Mon Jun 
24 13:01:49 2013
@@ -0,0 +1,93 @@
+/**
+ *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.
+ */
+/*
+ * framework_private.h
+ *
+ *  \date       May 22, 2013
+ *  \author     <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef FRAMEWORK_PRIVATE_H_
+#define FRAMEWORK_PRIVATE_H_
+
+#include "framework.h"
+
+#include "manifest.h"
+#include "wire.h"
+#include "hash_map.h"
+#include "array_list.h"
+#include "celix_errno.h"
+#include "service_factory.h"
+#include "bundle_archive.h"
+#include "service_listener.h"
+#include "bundle_listener.h"
+#include "service_registration.h"
+#include "bundle_context.h"
+
+celix_status_t framework_start(framework_t framework);
+void framework_stop(framework_t framework);
+
+FRAMEWORK_EXPORT celix_status_t fw_getProperty(framework_t framework, const 
char *name, char **value);
+
+FRAMEWORK_EXPORT celix_status_t fw_installBundle(framework_t framework, 
bundle_t * bundle, char * location, char *inputFile);
+FRAMEWORK_EXPORT celix_status_t fw_uninstallBundle(framework_t framework, 
bundle_t bundle);
+
+FRAMEWORK_EXPORT celix_status_t framework_getBundleEntry(framework_t 
framework, bundle_t bundle, char *name, apr_pool_t *pool, char **entry);
+
+FRAMEWORK_EXPORT celix_status_t fw_startBundle(framework_t framework, bundle_t 
bundle, int options);
+FRAMEWORK_EXPORT celix_status_t framework_updateBundle(framework_t framework, 
bundle_t bundle, char *inputFile);
+FRAMEWORK_EXPORT celix_status_t fw_stopBundle(framework_t framework, bundle_t 
bundle, bool record);
+
+FRAMEWORK_EXPORT celix_status_t fw_registerService(framework_t framework, 
service_registration_t * registration, bundle_t bundle, char * serviceName, 
void * svcObj, properties_t properties);
+FRAMEWORK_EXPORT celix_status_t fw_registerServiceFactory(framework_t 
framework, service_registration_t * registration, bundle_t bundle, char * 
serviceName, service_factory_t factory, properties_t properties);
+FRAMEWORK_EXPORT void fw_unregisterService(service_registration_t 
registration);
+
+FRAMEWORK_EXPORT celix_status_t fw_getServiceReferences(framework_t framework, 
array_list_t *references, bundle_t bundle, const char * serviceName, char * 
filter);
+FRAMEWORK_EXPORT void * fw_getService(framework_t framework, bundle_t bundle, 
service_reference_t reference);
+FRAMEWORK_EXPORT bool framework_ungetService(framework_t framework, bundle_t 
bundle, service_reference_t reference);
+FRAMEWORK_EXPORT celix_status_t fw_getBundleRegisteredServices(framework_t 
framework, apr_pool_t *pool, bundle_t bundle, array_list_t *services);
+FRAMEWORK_EXPORT celix_status_t fw_getBundleServicesInUse(framework_t 
framework, bundle_t bundle, array_list_t *services);
+
+FRAMEWORK_EXPORT void fw_addServiceListener(framework_t framework, bundle_t 
bundle, service_listener_t listener, char * filter);
+FRAMEWORK_EXPORT void fw_removeServiceListener(framework_t framework, bundle_t 
bundle, service_listener_t listener);
+
+FRAMEWORK_EXPORT celix_status_t fw_addBundleListener(framework_t framework, 
bundle_t bundle, bundle_listener_t listener);
+FRAMEWORK_EXPORT celix_status_t fw_removeBundleListener(framework_t framework, 
bundle_t bundle, bundle_listener_t listener);
+
+FRAMEWORK_EXPORT void fw_serviceChanged(framework_t framework, 
service_event_type_e eventType, service_registration_t registration, 
properties_t oldprops);
+
+FRAMEWORK_EXPORT celix_status_t fw_isServiceAssignable(framework_t fw, 
bundle_t requester, service_reference_t reference, bool *assignable);
+
+//bundle_archive_t fw_createArchive(long id, char * location);
+//void revise(bundle_archive_t archive, char * location);
+FRAMEWORK_EXPORT celix_status_t getManifest(bundle_archive_t archive, 
apr_pool_t *pool, MANIFEST *manifest);
+
+FRAMEWORK_EXPORT bundle_t findBundle(bundle_context_t context);
+FRAMEWORK_EXPORT service_registration_t findRegistration(service_reference_t 
reference);
+
+FRAMEWORK_EXPORT service_reference_t listToArray(array_list_t list);
+FRAMEWORK_EXPORT celix_status_t framework_markResolvedModules(framework_t 
framework, hash_map_t wires);
+
+FRAMEWORK_EXPORT array_list_t framework_getBundles(framework_t framework);
+FRAMEWORK_EXPORT bundle_t framework_getBundle(framework_t framework, char * 
location);
+FRAMEWORK_EXPORT bundle_t framework_getBundleById(framework_t framework, long 
id);
+
+#endif /* FRAMEWORK_PRIVATE_H_ */

Modified: incubator/celix/trunk/framework/private/src/bundle.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle.c?rev=1496013&r1=1496012&r2=1496013&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle.c Mon Jun 24 13:01:49 
2013
@@ -30,7 +30,7 @@
 #include <apr_thread_proc.h>
 
 #include "bundle.h"
-#include "framework.h"
+#include "framework_private.h"
 #include "manifest.h"
 #include "module.h"
 #include "version.h"
@@ -293,24 +293,77 @@ celix_status_t bundle_createModule(bundl
        return status;
 }
 
-celix_status_t bundle_start(bundle_pt bundle, int options) {
+celix_status_t bundle_start(bundle_pt bundle) {
+       return bundle_startWithOptions(bundle, 0);
+}
+
+celix_status_t bundle_startWithOptions(bundle_pt bundle, int options) {
        celix_status_t status = CELIX_SUCCESS;
     if (bundle != NULL) {
-        status = fw_startBundle(bundle->framework, bundle, options);
+       bool systemBundle = false;
+       status = bundle_isSystemBundle(bundle, &systemBundle);
+       if (status == CELIX_SUCCESS) {
+               if (systemBundle) {
+                       framework_start(bundle->framework);
+               } else {
+                       status = fw_startBundle(bundle->framework, bundle, 
options);
+               }
+       }
     }
     return status;
 }
 
 celix_status_t bundle_update(bundle_pt bundle, char *inputFile) {
-       return framework_updateBundle(bundle->framework, bundle, inputFile);
+       celix_status_t status = CELIX_SUCCESS;
+       if (bundle != NULL) {
+               bool systemBundle = false;
+               status = bundle_isSystemBundle(bundle, &systemBundle);
+               if (status == CELIX_SUCCESS) {
+                       if (systemBundle) {
+                               // #TODO: Support framework update
+                               status = CELIX_BUNDLE_EXCEPTION;
+                       } else {
+                               status = 
framework_updateBundle(bundle->framework, bundle, inputFile);
+                       }
+               }
+       }
+       return status;
 }
 
-celix_status_t bundle_stop(bundle_pt bundle, int options) {
-       return fw_stopBundle(bundle->framework, bundle, ((options & 1) == 0));
+celix_status_t bundle_stop(bundle_pt bundle) {
+       return bundle_stopWithOptions(bundle, 0);
+}
+
+celix_status_t bundle_stopWithOptions(bundle_pt bundle, int options) {
+       celix_status_t status = CELIX_SUCCESS;
+       if (bundle != NULL) {
+               bool systemBundle = false;
+               status = bundle_isSystemBundle(bundle, &systemBundle);
+               if (status == CELIX_SUCCESS) {
+                       if (systemBundle) {
+                               framework_stop(bundle->framework);
+                       } else {
+                               status = fw_stopBundle(bundle->framework, 
bundle, options);
+                       }
+               }
+       }
+       return status;
 }
 
 celix_status_t bundle_uninstall(bundle_pt bundle) {
-    return fw_uninstallBundle(bundle->framework, bundle);
+       celix_status_t status = CELIX_SUCCESS;
+       if (bundle != NULL) {
+               bool systemBundle = false;
+               status = bundle_isSystemBundle(bundle, &systemBundle);
+               if (status == CELIX_SUCCESS) {
+                       if (systemBundle) {
+                               status = CELIX_BUNDLE_EXCEPTION;
+                       } else {
+                               status = fw_uninstallBundle(bundle->framework, 
bundle);
+                       }
+               }
+       }
+       return status;
 }
 
 celix_status_t bundle_setPersistentStateInactive(bundle_pt bundle) {

Modified: incubator/celix/trunk/framework/private/src/bundle_context.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_context.c?rev=1496013&r1=1496012&r2=1496013&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_context.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_context.c Mon Jun 24 
13:01:49 2013
@@ -28,7 +28,7 @@
 #include <string.h>
 
 #include "bundle_context.h"
-#include "framework.h"
+#include "framework_private.h"
 #include "bundle.h"
 
 struct bundleContext {

Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1496013&r1=1496012&r2=1496013&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Mon Jun 24 13:01:49 
2013
@@ -44,7 +44,7 @@
 #endif
 
 
-#include "framework.h"
+#include "framework_private.h"
 #include "filter.h"
 #include "constants.h"
 #include "archive.h"
@@ -189,11 +189,11 @@ celix_status_t framework_create(framewor
         } else {
             bundle_pt bundle = NULL;
             apr_pool_t *bundlePool;
-            apr_status_t apr_status = apr_pool_create(&bundlePool, 
(*framework)->mp);
-            if (apr_status != APR_SUCCESS) {
-                status = CELIX_FRAMEWORK_EXCEPTION;
-            } else {
-                apr_status_t apr_status = bundle_create(&bundle, bundlePool);
+//            apr_status_t apr_status = apr_pool_create(&bundlePool, 
(*framework)->mp);
+//            if (apr_status != APR_SUCCESS) {
+//                status = CELIX_FRAMEWORK_EXCEPTION;
+//            } else {
+                apr_status_t apr_status = bundle_create(&bundle, 
(*framework)->mp);
                 if (apr_status != CELIX_SUCCESS) {
                     status = CELIX_FRAMEWORK_EXCEPTION;
                 } else {
@@ -248,7 +248,7 @@ celix_status_t framework_create(framewor
                                                                        }
                                 }
                             }
-                        }
+//                        }
                     }
                 }
             }
@@ -1906,18 +1906,6 @@ static void *APR_THREAD_FUNC framework_s
        return NULL;
 }
 
-celix_status_t framework_getMemoryPool(framework_pt framework, apr_pool_t 
**pool) {
-       celix_status_t status = CELIX_SUCCESS;
-
-       if (framework != NULL && *pool == NULL) {
-               *pool = framework->mp;
-       } else {
-               status = CELIX_ILLEGAL_ARGUMENT;
-       }
-
-       return status;
-}
-
 celix_status_t framework_getFrameworkBundle(framework_pt framework, bundle_pt 
*bundle) {
        celix_status_t status = CELIX_SUCCESS;
 

Modified: incubator/celix/trunk/framework/private/src/service_registry.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_registry.c?rev=1496013&r1=1496012&r2=1496013&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registry.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registry.c Mon Jun 24 
13:01:49 2013
@@ -33,7 +33,7 @@
 #include "listener_hook_service.h"
 #include "constants.h"
 #include "service_reference.h"
-#include "framework.h"
+#include "framework_private.h"
 
 struct serviceRegistry {
     framework_pt framework;
@@ -114,11 +114,14 @@ void serviceRegistry_flushUsageCount(ser
        }
 }
 
-service_registry_pt serviceRegistry_create(framework_pt framework, void 
(*serviceChanged)(framework_pt, service_event_type_e, service_registration_pt, 
properties_pt)) {
+// #TODO: Add pool as argument
+service_registry_pt serviceRegistry_create(framework_pt framework, void 
(*serviceChanged)(framework_t, service_event_type_e, service_registration_t, 
properties_t)) {
        service_registry_pt registry;
+       bundle_pt fwBundle = NULL;
        apr_pool_t *pool = NULL;
 
-       framework_getMemoryPool(framework, &pool);
+       framework_getFrameworkBundle(framework, &fwBundle);
+       bundle_getMemoryPool(fwBundle, &pool);
        registry = (service_registry_pt) apr_palloc(pool, (sizeof(*registry)));
        if (registry == NULL) {
            // no memory
@@ -246,11 +249,15 @@ void serviceRegistry_unregisterService(s
        serviceRegistration_getServiceReferences(registration, &references);
        for (i = 0; i < arrayList_size(references); i++) {
                service_reference_pt reference = (service_reference_pt) 
arrayList_get(references, i);
+               bundle_pt fwBundle = NULL;
                apr_pool_t *pool = NULL;
                array_list_pt clients = NULL;
                unsigned int j;
 
-               framework_getMemoryPool(registry->framework, &pool);
+               framework_getFrameworkBundle(registry->framework, &fwBundle);
+               // #TODO: Replace with subpool, destroy pool after usage
+               bundle_getMemoryPool(fwBundle, &pool);
+
                clients = serviceRegistry_getUsingBundles(registry, pool, 
reference);
                for (j = 0; (clients != NULL) && (j < arrayList_size(clients)); 
j++) {
                        bundle_pt client = (bundle_pt) arrayList_get(clients, 
j);

Modified: incubator/celix/trunk/framework/public/include/bundle.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/bundle.h?rev=1496013&r1=1496012&r2=1496013&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/bundle.h (original)
+++ incubator/celix/trunk/framework/public/include/bundle.h Mon Jun 24 13:01:49 
2013
@@ -36,6 +36,8 @@ typedef struct bundle * bundle_pt;
 #include "bundle_state.h"
 #include "bundle_archive.h"
 #include "framework.h"
+#include "wire.h"
+#include "module.h"
 #include "service_reference.h"
 #include "bundle_context.h"
 
@@ -57,9 +59,11 @@ FRAMEWORK_EXPORT celix_status_t bundle_g
 FRAMEWORK_EXPORT celix_status_t bundle_setContext(bundle_pt bundle, 
bundle_context_pt context);
 FRAMEWORK_EXPORT celix_status_t bundle_getEntry(bundle_pt bundle, char * name, 
apr_pool_t *pool, char **entry);
 
-FRAMEWORK_EXPORT celix_status_t bundle_start(bundle_pt bundle, int options);
+FRAMEWORK_EXPORT celix_status_t bundle_start(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_status_t bundle_startWithOptions(bundle_pt bundle, int 
options);
 FRAMEWORK_EXPORT celix_status_t bundle_update(bundle_pt bundle, char 
*inputFile);
-FRAMEWORK_EXPORT celix_status_t bundle_stop(bundle_pt bundle, int options);
+FRAMEWORK_EXPORT celix_status_t bundle_stop(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_status_t bundle_stopWithOptions(bundle_pt bundle, int 
options);
 FRAMEWORK_EXPORT celix_status_t bundle_uninstall(bundle_pt bundle);
 
 FRAMEWORK_EXPORT celix_status_t bundle_setState(bundle_pt bundle, 
bundle_state_e state);

Modified: incubator/celix/trunk/framework/public/include/framework.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/framework.h?rev=1496013&r1=1496012&r2=1496013&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/framework.h (original)
+++ incubator/celix/trunk/framework/public/include/framework.h Mon Jun 24 
13:01:49 2013
@@ -30,74 +30,19 @@
 typedef struct activator * activator_pt;
 typedef struct framework * framework_pt;
 
-#include "manifest.h"
-#include "wire.h"
-#include "hash_map.h"
-#include "array_list.h"
 #include "celix_errno.h"
-#include "service_factory.h"
-#include "bundle_archive.h"
-#include "service_listener.h"
-#include "bundle_listener.h"
-#include "service_registration.h"
-#include "bundle_context.h"
 #include "framework_exports.h"
+#include "bundle.h"
+#include "properties.h"
 
+// #TODO: Move to FrameworkFactory according the OSGi Spec
 FRAMEWORK_EXPORT celix_status_t framework_create(framework_pt *framework, 
apr_pool_t *memoryPool, properties_pt config);
+// #TODO: Replace with a pool hook when this is possible
 FRAMEWORK_EXPORT celix_status_t framework_destroy(framework_pt framework);
 
 FRAMEWORK_EXPORT celix_status_t fw_init(framework_pt framework);
-FRAMEWORK_EXPORT celix_status_t framework_start(framework_pt framework);
-FRAMEWORK_EXPORT void framework_stop(framework_pt framework);
-
-FRAMEWORK_EXPORT celix_status_t fw_getProperty(framework_pt framework, const 
char *name, char **value);
-
-FRAMEWORK_EXPORT celix_status_t fw_installBundle(framework_pt framework, 
bundle_pt * bundle, char * location, char *inputFile);
-FRAMEWORK_EXPORT celix_status_t fw_uninstallBundle(framework_pt framework, 
bundle_pt bundle);
-
-FRAMEWORK_EXPORT celix_status_t framework_getBundleEntry(framework_pt 
framework, bundle_pt bundle, char *name, apr_pool_t *pool, char **entry);
-
-FRAMEWORK_EXPORT celix_status_t fw_startBundle(framework_pt framework, 
bundle_pt bundle, int options);
-FRAMEWORK_EXPORT celix_status_t framework_updateBundle(framework_pt framework, 
bundle_pt bundle, char *inputFile);
-FRAMEWORK_EXPORT celix_status_t fw_stopBundle(framework_pt framework, 
bundle_pt bundle, bool record);
-
-FRAMEWORK_EXPORT celix_status_t fw_registerService(framework_pt framework, 
service_registration_pt * registration, bundle_pt bundle, char * serviceName, 
void * svcObj, properties_pt properties);
-FRAMEWORK_EXPORT celix_status_t fw_registerServiceFactory(framework_pt 
framework, service_registration_pt * registration, bundle_pt bundle, char * 
serviceName, service_factory_pt factory, properties_pt properties);
-FRAMEWORK_EXPORT void fw_unregisterService(service_registration_pt 
registration);
-
-FRAMEWORK_EXPORT celix_status_t fw_getServiceReferences(framework_pt 
framework, array_list_pt *references, bundle_pt bundle, const char * 
serviceName, char * filter);
-FRAMEWORK_EXPORT void * fw_getService(framework_pt framework, bundle_pt 
bundle, service_reference_pt reference);
-FRAMEWORK_EXPORT bool framework_ungetService(framework_pt framework, bundle_pt 
bundle, service_reference_pt reference);
-FRAMEWORK_EXPORT celix_status_t fw_getBundleRegisteredServices(framework_pt 
framework, apr_pool_t *pool, bundle_pt bundle, array_list_pt *services);
-FRAMEWORK_EXPORT celix_status_t fw_getBundleServicesInUse(framework_pt 
framework, bundle_pt bundle, array_list_pt *services);
-
-FRAMEWORK_EXPORT void fw_addServiceListener(framework_pt framework, bundle_pt 
bundle, service_listener_pt listener, char * filter);
-FRAMEWORK_EXPORT void fw_removeServiceListener(framework_pt framework, 
bundle_pt bundle, service_listener_pt listener);
-
-FRAMEWORK_EXPORT celix_status_t fw_addBundleListener(framework_pt framework, 
bundle_pt bundle, bundle_listener_pt listener);
-FRAMEWORK_EXPORT celix_status_t fw_removeBundleListener(framework_pt 
framework, bundle_pt bundle, bundle_listener_pt listener);
-
-FRAMEWORK_EXPORT void fw_serviceChanged(framework_pt framework, 
service_event_type_e eventType, service_registration_pt registration, 
properties_pt oldprops);
-
-FRAMEWORK_EXPORT celix_status_t fw_isServiceAssignable(framework_pt fw, 
bundle_pt requester, service_reference_pt reference, bool *assignable);
-
-//bundle_archive_pt fw_createArchive(long id, char * location);
-//void revise(bundle_archive_pt archive, char * location);
-FRAMEWORK_EXPORT celix_status_t getManifest(bundle_archive_pt archive, 
apr_pool_t *pool, manifest_pt *manifest);
-
-FRAMEWORK_EXPORT bundle_pt findBundle(bundle_context_pt context);
-FRAMEWORK_EXPORT service_registration_pt findRegistration(service_reference_pt 
reference);
-
-FRAMEWORK_EXPORT service_reference_pt listToArray(array_list_pt list);
-FRAMEWORK_EXPORT celix_status_t framework_markResolvedModules(framework_pt 
framework, hash_map_pt wires);
-
 FRAMEWORK_EXPORT celix_status_t framework_waitForStop(framework_pt framework);
 
-FRAMEWORK_EXPORT array_list_pt framework_getBundles(framework_pt framework);
-FRAMEWORK_EXPORT bundle_pt framework_getBundle(framework_pt framework, char * 
location);
-FRAMEWORK_EXPORT bundle_pt framework_getBundleById(framework_pt framework, 
long id);
-
-FRAMEWORK_EXPORT celix_status_t framework_getMemoryPool(framework_pt 
framework, apr_pool_t **pool);
 FRAMEWORK_EXPORT celix_status_t framework_getFrameworkBundle(framework_pt 
framework, bundle_pt *bundle);
 
 #endif /* FRAMEWORK_H_ */

Modified: incubator/celix/trunk/launcher/CMakeLists.txt
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/launcher/CMakeLists.txt?rev=1496013&r1=1496012&r2=1496013&view=diff
==============================================================================
--- incubator/celix/trunk/launcher/CMakeLists.txt (original)
+++ incubator/celix/trunk/launcher/CMakeLists.txt Mon Jun 24 13:01:49 2013
@@ -20,7 +20,7 @@ if (LAUNCHER) 
     
     target_link_libraries(celix celix_framework)
     include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-    include_directories("${PROJECT_SOURCE_DIR}/framework/private/include")
+    include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
     
     install(TARGETS celix RUNTIME DESTINATION bin COMPONENT framework)
 endif (LAUNCHER) 
\ No newline at end of file

Modified: incubator/celix/trunk/launcher/private/src/launcher.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/launcher/private/src/launcher.c?rev=1496013&r1=1496012&r2=1496013&view=diff
==============================================================================
--- incubator/celix/trunk/launcher/private/src/launcher.c (original)
+++ incubator/celix/trunk/launcher/private/src/launcher.c Mon Jun 24 13:01:49 
2013
@@ -50,9 +50,8 @@ int main(void) {
        apr_status_t s = APR_SUCCESS;
        properties_pt config = NULL;
        char *autoStart = NULL;
-
-       
     apr_pool_t *pool = NULL;
+    bundle_pt fwBundle = NULL;
 
        (void) signal(SIGINT, launcher_shutdown);
 
@@ -73,7 +72,8 @@ int main(void) {
     fw_init(framework);
 
     // Start the system bundle
-    framework_start(framework);
+    framework_getFrameworkBundle(framework, &fwBundle);
+    bundle_start(fwBundle);
 
     if (apr_pool_create(&pool, memoryPool) == APR_SUCCESS) {
                char delims[] = " ";
@@ -115,7 +115,7 @@ int main(void) {
 
         for (i = 0; i < arrayList_size(installed); i++) {
             bundle_pt bundle = (bundle_pt) arrayList_get(installed, i);
-            bundle_start(bundle, 0);
+            bundle_startWithOptions(bundle, 0);
         }
 
         arrayList_destroy(installed);
@@ -134,7 +134,9 @@ int main(void) {
 }
 
 void launcher_shutdown(int signal) {
-       framework_stop(framework);
+       bundle_pt fwBundle = NULL;
+       framework_getFrameworkBundle(framework, &fwBundle);
+       bundle_stop(fwBundle);
 //     if (framework_waitForStop(framework) != CELIX_SUCCESS) {
 //             celix_log("Error waiting for stop.");
 //     }

Modified: incubator/celix/trunk/shell/private/src/start_command.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/shell/private/src/start_command.c?rev=1496013&r1=1496012&r2=1496013&view=diff
==============================================================================
--- incubator/celix/trunk/shell/private/src/start_command.c (original)
+++ incubator/celix/trunk/shell/private/src/start_command.c Mon Jun 24 13:01:49 
2013
@@ -58,7 +58,7 @@ void startCommand_execute(command_pt com
         bundle_pt bundle = NULL;
                bundleContext_getBundleById(command->bundleContext, id, 
&bundle);
                if (bundle != NULL) {
-                       bundle_start(bundle, 0);
+                       bundle_startWithOptions(bundle, 0);
                } else {
                        err("Bundle id is invalid.");
                }

Modified: incubator/celix/trunk/shell/private/src/stop_command.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/shell/private/src/stop_command.c?rev=1496013&r1=1496012&r2=1496013&view=diff
==============================================================================
--- incubator/celix/trunk/shell/private/src/stop_command.c (original)
+++ incubator/celix/trunk/shell/private/src/stop_command.c Mon Jun 24 13:01:49 
2013
@@ -61,7 +61,7 @@ void stopCommand_execute(command_pt comm
                        bundle_pt bundle = NULL;
                        bundleContext_getBundleById(command->bundleContext, id, 
&bundle);
                        if (bundle != NULL) {
-                               bundle_stop(bundle, 0);
+                               bundle_stopWithOptions(bundle, 0);
                        } else {
                                err("Bundle id is invalid.");
                        }


Reply via email to