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/05/31 15:09:04 UTC

[1/4] celix git commit: CELIX-446: Adds altenertive celix_bundleActivator_* api for the bundle activators

Repository: celix
Updated Branches:
  refs/heads/feature/CELIX-426-cxx-api be6612f0f -> 34914e827


CELIX-446: Adds altenertive celix_bundleActivator_* api for the bundle activators


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

Branch: refs/heads/feature/CELIX-426-cxx-api
Commit: 3e27acf533a195132934a3a5d6935c95f47c7ea9
Parents: dfa9d1c
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Tue May 29 20:42:36 2018 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Tue May 29 20:44:54 2018 +0200

----------------------------------------------------------------------
 examples/celix-examples/CMakeLists.txt          |   2 +
 .../bundle_example_c/CMakeLists.txt             |  28 ++++
 .../bundle_example_c/src/bundle_activator.c     |  40 +++++
 .../celix-examples/services_example_c/README.md |  16 +-
 .../src/dynamic_consumer_example.c              |   2 +-
 .../src/dynamic_provider_example.c              |   2 +-
 .../src/simple_consumer_example.c               |   2 +-
 .../src/simple_provider_example.c               |   2 +-
 libs/framework/include/bundle_activator.h       |  64 +-------
 libs/framework/include/celix_bundle_activator.h | 148 +++++++++++++++++++
 libs/framework/include/celix_bundle_context.h   |  15 ++
 libs/framework/include/constants.h              |  15 +-
 libs/framework/include/dm_activator.h           |   2 +-
 libs/framework/src/bundle_context.c             |  48 +++---
 libs/framework/src/framework.c                  |  12 ++
 15 files changed, 305 insertions(+), 93 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/3e27acf5/examples/celix-examples/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/CMakeLists.txt b/examples/celix-examples/CMakeLists.txt
index 2ade793..f11979f 100644
--- a/examples/celix-examples/CMakeLists.txt
+++ b/examples/celix-examples/CMakeLists.txt
@@ -21,6 +21,8 @@ else ()
     set(EXAMPLES true) #celix_subproject is only available in the celix project -> using examples dir in other project is also supported
 endif ()
 if (EXAMPLES)
+    add_subdirectory(bundle_example_c)
+
     add_subdirectory(hello_world)
     add_subdirectory(hello_world_test)
 

http://git-wip-us.apache.org/repos/asf/celix/blob/3e27acf5/examples/celix-examples/bundle_example_c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/bundle_example_c/CMakeLists.txt b/examples/celix-examples/bundle_example_c/CMakeLists.txt
new file mode 100644
index 0000000..aabf370
--- /dev/null
+++ b/examples/celix-examples/bundle_example_c/CMakeLists.txt
@@ -0,0 +1,28 @@
+# 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(bundle_example_c
+    VERSION 1.0.0
+    SOURCES src/bundle_activator.c
+)
+
+add_celix_container(bundle_example_c_container
+    BUNDLES
+        Celix::shell
+        Celix::shell_tui
+        bundle_example_c
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/3e27acf5/examples/celix-examples/bundle_example_c/src/bundle_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/bundle_example_c/src/bundle_activator.c b/examples/celix-examples/bundle_example_c/src/bundle_activator.c
new file mode 100644
index 0000000..7b9d0d0
--- /dev/null
+++ b/examples/celix-examples/bundle_example_c/src/bundle_activator.c
@@ -0,0 +1,40 @@
+/**
+ *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.
+ */
+
+
+#include "celix_bundle_activator.h"
+#include "celix_bundle.h"
+
+typedef struct activator_data {
+    /*intentional empty*/
+} activator_data_t;
+
+
+
+static celix_status_t activator_start(activator_data_t *data, celix_bundle_context_t *ctx) {
+    printf("Hello world from C bundle with id %li\n", celix_bundle_getId(celix_bundleContext_getBundle(ctx)));
+    return CELIX_SUCCESS;
+}
+
+static celix_status_t activator_stop(activator_data_t *data, celix_bundle_context_t *ctx) {
+    printf("Goodbye world from C bundle with id %li\n", celix_bundle_getId(celix_bundleContext_getBundle(ctx)));
+    return CELIX_SUCCESS;
+}
+
+CELIX_GEN_BUNDLE_ACTIVATOR(activator_data_t, activator_start, activator_stop)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/3e27acf5/examples/celix-examples/services_example_c/README.md
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/README.md b/examples/celix-examples/services_example_c/README.md
index a4f50ba..14c21b0 100644
--- a/examples/celix-examples/services_example_c/README.md
+++ b/examples/celix-examples/services_example_c/README.md
@@ -21,12 +21,20 @@ This example show how services can be provided and consumer by bundles.
 
 The example uses the `celix_bundleContext_registerService` to provide
 services and uses a combination of `celix_bundleContext_useService`,
- `celix_bundleContext_useServices` and `celix_bundleContext_trackServices`
- to consume services.
+`celix_bundleContext_useServices` and `celix_bundleContext_trackServices`
+to consume services.
 
- TODO intro bundle context
+The bundle context is the proxy to the Celix framework for a bundle
+and can be used to:
 
- See the `bundle_context.h` for documentation about these - and other -functions
+- Register services
+- Register service factories
+- Use services
+- Track services
+- Track bundles
+- Track service trackers
+
+See the `bundle_context.h` for documentation about these - and other -functions
 
 # Simple Service Provider & Consumer Example
 

http://git-wip-us.apache.org/repos/asf/celix/blob/3e27acf5/examples/celix-examples/services_example_c/src/dynamic_consumer_example.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/src/dynamic_consumer_example.c b/examples/celix-examples/services_example_c/src/dynamic_consumer_example.c
index cef384c..673a84a 100644
--- a/examples/celix-examples/services_example_c/src/dynamic_consumer_example.c
+++ b/examples/celix-examples/services_example_c/src/dynamic_consumer_example.c
@@ -24,7 +24,7 @@
 #include <constants.h>
 
 #include "example_calc.h"
-#include "bundle_activator.h"
+#include "celix_bundle_activator.h"
 
 typedef struct activator_data {
     celix_bundle_context_t *ctx;

http://git-wip-us.apache.org/repos/asf/celix/blob/3e27acf5/examples/celix-examples/services_example_c/src/dynamic_provider_example.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/src/dynamic_provider_example.c b/examples/celix-examples/services_example_c/src/dynamic_provider_example.c
index 4756718..1b09ab9 100644
--- a/examples/celix-examples/services_example_c/src/dynamic_provider_example.c
+++ b/examples/celix-examples/services_example_c/src/dynamic_provider_example.c
@@ -22,7 +22,7 @@
 #include <stdlib.h>
 
 #include "example_calc.h"
-#include "bundle_activator.h"
+#include "celix_bundle_activator.h"
 #include "constants.h"
 
 typedef struct activator_data {

http://git-wip-us.apache.org/repos/asf/celix/blob/3e27acf5/examples/celix-examples/services_example_c/src/simple_consumer_example.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/src/simple_consumer_example.c b/examples/celix-examples/services_example_c/src/simple_consumer_example.c
index 1204036..e3b1789 100644
--- a/examples/celix-examples/services_example_c/src/simple_consumer_example.c
+++ b/examples/celix-examples/services_example_c/src/simple_consumer_example.c
@@ -24,7 +24,7 @@
 #include <constants.h>
 
 #include "example_calc.h"
-#include "bundle_activator.h"
+#include "celix_bundle_activator.h"
 
 typedef struct activator_data {
     celix_bundle_context_t *ctx;

http://git-wip-us.apache.org/repos/asf/celix/blob/3e27acf5/examples/celix-examples/services_example_c/src/simple_provider_example.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/src/simple_provider_example.c b/examples/celix-examples/services_example_c/src/simple_provider_example.c
index 486225a..d0ebc1d 100644
--- a/examples/celix-examples/services_example_c/src/simple_provider_example.c
+++ b/examples/celix-examples/services_example_c/src/simple_provider_example.c
@@ -21,7 +21,7 @@
 #include <stdlib.h>
 
 #include "example_calc.h"
-#include "bundle_activator.h"
+#include "celix_bundle_activator.h"
 #include "constants.h"
 
 typedef struct activator_data {

http://git-wip-us.apache.org/repos/asf/celix/blob/3e27acf5/libs/framework/include/bundle_activator.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/bundle_activator.h b/libs/framework/include/bundle_activator.h
index 3265f65..99ef6bc 100644
--- a/libs/framework/include/bundle_activator.h
+++ b/libs/framework/include/bundle_activator.h
@@ -16,31 +16,16 @@
  *specific language governing permissions and limitations
  *under the License.
  */
-/**
- *
- * @defgroup BundleActivator BundleActivator
- * @ingroup framework
- * @{
- *	\brief		Customizes the starting and stopping of a bundle.
- *	\details	\ref BundleActivator is a header that must be implemented by every
- * 				bundle. The Framework creates/starts/stops/destroys activator instances using the
- * 				functions described in this header. If the bundleActivator_start()
- * 				function executes successfully, it is guaranteed that the same instance's
- * 				bundleActivator_stop() function will be called when the bundle is
- * 				to be stopped. The same applies to the bundleActivator_create() and
- * 				bundleActivator_destroy() functions.
- * 				The Framework must not concurrently call the activator functions.
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \date      	March 18, 2010
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef BUNDLE_ACTIVATOR_H_
-#define BUNDLE_ACTIVATOR_H_
+
+#include <stdlib.h>
 
 #include "bundle_context.h"
 #include "celix_bundle_context.h"
 #include "framework_exports.h"
 
+#ifndef BUNDLE_ACTIVATOR_H_
+#define BUNDLE_ACTIVATOR_H_
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -116,45 +101,6 @@ ACTIVATOR_EXPORT celix_status_t bundleActivator_stop(void *userData, bundle_cont
 ACTIVATOR_EXPORT celix_status_t
 bundleActivator_destroy(void *userData, bundle_context_t* context);
 
-
-/**
- * This macro generated the required bundle activator functions. These can be used to more type safe bundle activator
- * entries.
- *
- * The macro will create the following bundlea activator functions:
- * - bundleActivator_create which allocates a pointer to the provided type.
- * - bundleActivator_start/stop which will call the respectively provided typed start/stop functions.
- * - bundleActivator_destroy will free the allocated for the provided type.
- *
- * @param type The activator type (e.g. 'struct shell_activator').
- * @param start the activator actStart function with the following signature: celix_status_t (*)(<actType>*, celix_bundle_context_t*).
- * @param stop the activator actStop function with the following signature: celix_status_t (*)(<actType>*, celix_bundle_context_t*).
- */
-#define CELIX_GEN_BUNDLE_ACTIVATOR(actType, actStart, actStop)                                                         \
-celix_status_t bundleActivator_create(celix_bundle_context_t *ctx __attribute__((unused)), void **userData) {          \
-    celix_status_t status = CELIX_SUCCESS;                                                                             \
-    actType *data = calloc(1, sizeof(*data));                                                                          \
-    if (data != NULL) {                                                                                                \
-        *userData = data;                                                                                              \
-    } else {                                                                                                           \
-        status = CELIX_ENOMEM;                                                                                         \
-    }                                                                                                                  \
-    return status;                                                                                                     \
-}                                                                                                                      \
-                                                                                                                       \
-celix_status_t bundleActivator_start(void *userData, celix_bundle_context_t *ctx) {                                    \
-    return actStart((actType*)userData, ctx);                                                                          \
-}                                                                                                                      \
-                                                                                                                       \
-celix_status_t bundleActivator_stop(void *userData, celix_bundle_context_t *ctx) {                                     \
-    return actStop((actType*)userData, ctx);                                                                           \
-}                                                                                                                      \
-                                                                                                                       \
-celix_status_t bundleActivator_destroy(void *userData, celix_bundle_context_t *ctx __attribute__((unused))) {          \
-    free(userData);                                                                                                    \
-    return CELIX_SUCCESS;                                                                                              \
-}
-
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/celix/blob/3e27acf5/libs/framework/include/celix_bundle_activator.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix_bundle_activator.h b/libs/framework/include/celix_bundle_activator.h
new file mode 100644
index 0000000..eb7d514
--- /dev/null
+++ b/libs/framework/include/celix_bundle_activator.h
@@ -0,0 +1,148 @@
+/*
+ *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.
+ */
+
+#include <stdlib.h>
+
+#include "celix_bundle_context.h"
+
+#ifndef CELIX_BUNDLE_ACTIVATOR_H_
+#define CELIX_BUNDLE_ACTIVATOR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Called when this bundle is started so the bundle can create an instance for its activator.
+ * The framework does not assume any type for the activator instance, this is implementation specific.
+ * The activator instance is handle as a void pointer by the framework, the implementation must cast it to the
+ * implementation specific type.
+ *
+ * @param ctx The execution context of the bundle being started.
+ * @param[out] userData A pointer to the specific activator instance used by this bundle.
+ *
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- Any other status code will mark the bundle as stopped and the framework will remove this
+ * 		  bundle's listeners, unregister all services, and release all services used by this bundle.
+ */
+celix_status_t celix_bundleActivator_create(celix_bundle_context_t *ctx, void **userData);
+
+/**
+ * Called when this bundle is started so the Framework can perform the bundle-specific activities necessary
+ * to start this bundle. This method can be used to register services or to allocate any resources that this
+ * bundle needs.
+ *
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ *
+ * @param userData The activator instance to be used.
+ * @param ctx The execution context of the bundle being started.
+ *
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- Any other status code will mark the bundle as stopped and the framework will remove this
+ * 		  bundle's listeners, unregister all services, and release all services used by this bundle.
+ */
+celix_status_t celix_bundleActivator_start(void *userData, celix_bundle_context_t *ctx);
+
+/**
+ * Called when this bundle is stopped so the Framework can perform the bundle-specific activities necessary
+ * to stop the bundle. In general, this method should undo the work that the <code>bundleActivator_start()</code>
+ * function started. There should be no active threads that were started by this bundle when this bundle returns.
+ * A stopped bundle must not call any Framework objects.
+ *
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ *
+ * @param userData The activator instance to be used.
+ * @param ctx The execution context of the bundle being stopped.
+ *
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- Any other status code will mark the bundle as stopped and the framework will remove this
+ * 		  bundle's listeners, unregister all services, and release all services used by this bundle.
+ */
+celix_status_t celix_bundleActivator_stop(void *userData, celix_bundle_context_t *ctx);
+
+/**
+ * Called when this bundle is stopped so the bundle can destroy the instance of its activator. In general, this
+ * method should undo the work that the <code>bundleActivator_create()</code> function initialized.
+ *
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ *
+ * @param userData The activator instance to be used.
+ * @param ctx The execution context of the bundle being stopped.
+ *
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- Any other status code will mark the bundle as stopped and the framework will remove this
+ * 		  bundle's listeners, unregister all services, and release all services used by this bundle.
+ */
+celix_status_t celix_bundleActivator_destroy(void *userData, celix_bundle_context_t* ctx);
+
+
+/**
+ * This macro generated the required bundle activator functions. These can be used to more type safe bundle activator
+ * entries.
+ *
+ * The macro will create the following bundlea activator functions:
+ * - bundleActivator_create which allocates a pointer to the provided type.
+ * - bundleActivator_start/stop which will call the respectively provided typed start/stop functions.
+ * - bundleActivator_destroy will free the allocated for the provided type.
+ *
+ * @param type The activator type (e.g. 'struct shell_activator').
+ * @param start the activator actStart function with the following signature: celix_status_t (*)(<actType>*, celix_bundle_context_t*).
+ * @param stop the activator actStop function with the following signature: celix_status_t (*)(<actType>*, celix_bundle_context_t*).
+ */
+#define CELIX_GEN_BUNDLE_ACTIVATOR(actType, actStart, actStop)                                                         \
+celix_status_t celix_bundleActivator_create(celix_bundle_context_t *ctx __attribute__((unused)), void **userData) {    \
+    celix_status_t status = CELIX_SUCCESS;                                                                             \
+    actType *data = calloc(1, sizeof(*data));                                                                          \
+    if (data != NULL) {                                                                                                \
+        *userData = data;                                                                                              \
+    } else {                                                                                                           \
+        status = CELIX_ENOMEM;                                                                                         \
+    }                                                                                                                  \
+    return status;                                                                                                     \
+}                                                                                                                      \
+                                                                                                                       \
+celix_status_t celix_bundleActivator_start(void *userData, celix_bundle_context_t *ctx) {                              \
+    return actStart((actType*)userData, ctx);                                                                          \
+}                                                                                                                      \
+                                                                                                                       \
+celix_status_t celix_bundleActivator_stop(void *userData, celix_bundle_context_t *ctx) {                               \
+    return actStop((actType*)userData, ctx);                                                                           \
+}                                                                                                                      \
+                                                                                                                       \
+celix_status_t celix_bundleActivator_destroy(void *userData, celix_bundle_context_t *ctx __attribute__((unused))) {    \
+    free(userData);                                                                                                    \
+    return CELIX_SUCCESS;                                                                                              \
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CELIX_BUNDLE_ACTIVATOR_H_ */
+
+/**
+ * @}
+ */

http://git-wip-us.apache.org/repos/asf/celix/blob/3e27acf5/libs/framework/include/celix_bundle_context.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix_bundle_context.h b/libs/framework/include/celix_bundle_context.h
index bc67b1d..58dca4e 100644
--- a/libs/framework/include/celix_bundle_context.h
+++ b/libs/framework/include/celix_bundle_context.h
@@ -728,6 +728,21 @@ long celix_bundleContext_trackServiceTrackers(
  */
 dm_dependency_manager_t* celix_bundleContext_getDependencyManager(celix_bundle_context_t *ctx);
 
+
+/**
+ * Returns the bundle for this bundle context.
+ */
+celix_bundle_t* celix_bundleContext_getBundle(celix_bundle_context_t *ctx);
+
+
+/**
+ * Gets the config property - or environment variable if the config property does not exist - for the provided name.
+ * @param key The key of the property to receive
+ * @param defaultVal The default value to use if the property is not found (can be NULL)
+ * @return The property value for the provided key or the provided defaultValue is the key is not found.
+ */
+const char* celix_bundleContext_getProperty(celix_bundle_context_t *ctx, const char *key, const char *defaultVal);
+
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/celix/blob/3e27acf5/libs/framework/include/constants.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/constants.h b/libs/framework/include/constants.h
index 06d89be..b9be0bd 100644
--- a/libs/framework/include/constants.h
+++ b/libs/framework/include/constants.h
@@ -43,10 +43,17 @@ static const char *const CELIX_FRAMEWORK_SERVICE_CXX_LANGUAGE = "C++";
 static const char *const CELIX_FRAMEWORK_SERVICE_SHARED_LANGUAGE = "shared"; //e.g. marker services
 
 static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR = "Bundle-Activator";
-static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_CREATE = "bundleActivator_create";
-static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_START = "bundleActivator_start";
-static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP = "bundleActivator_stop";
-static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY = "bundleActivator_destroy";
+
+static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_CREATE = "celix_bundleActivator_create";
+static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_START = "celix_bundleActivator_start";
+static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP = "celix_bundleActivator_stop";
+static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY = "celix_bundleActivator_destroy";
+
+static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_CREATE = "bundleActivator_create";
+static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_START = "bundleActivator_start";
+static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_STOP = "bundleActivator_stop";
+static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_DESTROY = "bundleActivator_destroy";
+
 
 static const char *const OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_CREATE = "dm_create";
 static const char *const OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_INIT = "dm_init";

http://git-wip-us.apache.org/repos/asf/celix/blob/3e27acf5/libs/framework/include/dm_activator.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/dm_activator.h b/libs/framework/include/dm_activator.h
index 86f33db..1e06331 100644
--- a/libs/framework/include/dm_activator.h
+++ b/libs/framework/include/dm_activator.h
@@ -35,7 +35,7 @@
 #include "dm_dependency_manager.h"
 #include "dm_component.h"
 #include "dm_service_dependency.h"
-#include "bundle_activator.h"
+#include "celix_bundle_activator.h"
 
 #ifdef __cplusplus
 extern "C" {

http://git-wip-us.apache.org/repos/asf/celix/blob/3e27acf5/libs/framework/src/bundle_context.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/bundle_context.c b/libs/framework/src/bundle_context.c
index 4fac5e7..d3a2c1e 100644
--- a/libs/framework/src/bundle_context.c
+++ b/libs/framework/src/bundle_context.c
@@ -105,17 +105,12 @@ celix_status_t bundleContext_destroy(bundle_context_pt context) {
 	return status;
 }
 
-celix_status_t bundleContext_getBundle(bundle_context_pt context, bundle_pt *bundle) {
+celix_status_t bundleContext_getBundle(bundle_context_pt context, bundle_pt *out) {
 	celix_status_t status = CELIX_SUCCESS;
-
-	if (context == NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		*bundle = context->bundle;
-	}
-
-	framework_logIfError(logger, status, NULL, "Failed to get bundle");
-
+    celix_bundle_t *bnd = celix_bundleContext_getBundle(context);
+    if (out != NULL) {
+        *out = bnd;
+    }
 	return status;
 }
 
@@ -404,18 +399,12 @@ celix_status_t bundleContext_getProperty(bundle_context_pt context, const char *
 	return bundleContext_getPropertyWithDefault(context, name, NULL, value);
 }
 
-celix_status_t bundleContext_getPropertyWithDefault(bundle_context_pt context, const char* name, const char* defaultValue, const char** value) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (context == NULL || name == NULL) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    } else {
-        fw_getProperty(context->framework, name, defaultValue, value);
+celix_status_t bundleContext_getPropertyWithDefault(bundle_context_pt context, const char* name, const char* defaultValue, const char** out) {
+    const char *val = celix_bundleContext_getProperty(context, name, defaultValue);
+    if (out != NULL) {
+        *out = val;
     }
-
-    framework_logIfError(logger, status, NULL, "Failed to get property [name=%s]", name);
-
-    return status;
+    return CELIX_SUCCESS;
 }
 
 
@@ -955,4 +944,21 @@ long celix_bundleContext_trackServiceTrackers(
         free(entry);
     }
     return trackerId;
+}
+
+celix_bundle_t* celix_bundleContext_getBundle(celix_bundle_context_t *ctx) {
+    celix_bundle_t *bnd = NULL;
+    if (ctx != NULL) {
+        bnd = ctx->bundle;
+    }
+    return bnd;
+}
+
+
+const char* celix_bundleContext_getProperty(celix_bundle_context_t *ctx, const char *key, const char *defaultVal) {
+    const char *val = NULL;
+    if (ctx != NULL) {
+        fw_getProperty(ctx->framework, key, defaultVal, &val);
+    }
+    return val;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/3e27acf5/libs/framework/src/framework.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c
index c28153a..fbae5db 100644
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@ -782,9 +782,21 @@ celix_status_t fw_startBundle(framework_pt framework, bundle_pt bundle, int opti
                         void * userData = NULL;
                         bundle_context_t *context;
                         create_function_fp create = (create_function_fp) fw_getSymbol((handle_t) bundle_getHandle(bundle), OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_CREATE);
+                        if (create == NULL) {
+                            create = fw_getSymbol(bundle_getHandle(bundle), OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_CREATE);
+                        }
                         start_function_fp start = (start_function_fp) fw_getSymbol((handle_t) bundle_getHandle(bundle), OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_START);
+                        if (start == NULL) {
+                            start = (start_function_fp) fw_getSymbol((handle_t) bundle_getHandle(bundle), OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_START);
+                        }
                         stop_function_fp stop = (stop_function_fp) fw_getSymbol((handle_t) bundle_getHandle(bundle), OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP);
+                        if (stop == NULL) {
+                            stop = (stop_function_fp) fw_getSymbol((handle_t) bundle_getHandle(bundle), OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_STOP);
+                        }
                         destroy_function_fp destroy = (destroy_function_fp) fw_getSymbol((handle_t) bundle_getHandle(bundle), OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY);
+                        if (destroy == NULL) {
+                            destroy = (destroy_function_fp) fw_getSymbol((handle_t) bundle_getHandle(bundle), OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_DESTROY);
+                        }
 
                         activator->create = create;
                         activator->start = start;


[4/4] celix git commit: Merge branch 'develop' into feature/CELIX-426-cxx-api

Posted by pn...@apache.org.
Merge branch 'develop' into feature/CELIX-426-cxx-api


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

Branch: refs/heads/feature/CELIX-426-cxx-api
Commit: 34914e827e7f1937165fbdfe0c21e3c97aa59773
Parents: be6612f 3182ca7
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Thu May 31 17:08:07 2018 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Thu May 31 17:08:07 2018 +0200

----------------------------------------------------------------------
 examples/celix-examples/CMakeLists.txt          |   8 +-
 .../bundle_example_c/CMakeLists.txt             |  28 ++++
 .../bundle_example_c/src/bundle_activator.c     |  40 +++++
 .../phase3/src/Phase3BaseActivator.h            |   6 +
 .../celix-examples/services_example_c/README.md |  16 +-
 .../src/dynamic_consumer_example.c              |   2 +-
 .../src/dynamic_provider_example.c              |   2 +-
 .../src/simple_consumer_example.c               |   2 +-
 .../src/simple_provider_example.c               |   2 +-
 libs/dependency_manager/CMakeLists.txt          |   4 +-
 libs/framework/include/bundle_activator.h       |  64 +-------
 libs/framework/include/celix/Constants.h        |   2 +-
 libs/framework/include/celix_bundle_activator.h | 148 +++++++++++++++++++
 libs/framework/include/celix_bundle_context.h   |   8 +-
 libs/framework/include/celix_constants.h        |  27 ++--
 libs/framework/include/constants.h              |   2 +-
 libs/framework/include/dm_activator.h           |   2 +-
 .../private/test/bundle_context_test.cpp        |   6 +-
 libs/framework/src/bundle_context.c             |  56 ++++---
 libs/framework/src/framework.c                  |  12 ++
 20 files changed, 311 insertions(+), 126 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/34914e82/examples/celix-examples/CMakeLists.txt
----------------------------------------------------------------------
diff --cc examples/celix-examples/CMakeLists.txt
index 426e854,f11979f..c313e8e
--- a/examples/celix-examples/CMakeLists.txt
+++ b/examples/celix-examples/CMakeLists.txt
@@@ -21,18 -21,16 +21,12 @@@ else (
      set(EXAMPLES true) #celix_subproject is only available in the celix project -> using examples dir in other project is also supported
  endif ()
  if (EXAMPLES)
+     add_subdirectory(bundle_example_c)
 -
 -    add_subdirectory(hello_world)
 -    add_subdirectory(hello_world_test)
 +    add_subdirectory(bundle_example_cxx)
  
      add_subdirectory(services_example_c)
 -
 -    add_subdirectory(best_practice_example_c)
      add_subdirectory(services_example_cxx)
  
- 
-     add_subdirectory(best_practice_example_c)
-     add_subdirectory(best_practice_example_cxx)
- 
-     add_subdirectory(hello_world)
-     add_subdirectory(hello_world_test)
- 
      add_subdirectory(dm_example)
      add_subdirectory(dm_example_cxx)
  

http://git-wip-us.apache.org/repos/asf/celix/blob/34914e82/examples/celix-examples/dm_example_cxx/phase3/src/Phase3BaseActivator.h
----------------------------------------------------------------------
diff --cc examples/celix-examples/dm_example_cxx/phase3/src/Phase3BaseActivator.h
index 951b18a,0f3d813..d42ad41
--- a/examples/celix-examples/dm_example_cxx/phase3/src/Phase3BaseActivator.h
+++ b/examples/celix-examples/dm_example_cxx/phase3/src/Phase3BaseActivator.h
@@@ -20,17 -20,16 +20,23 @@@
  #ifndef CELIX_PHASE3BASEACTIVATOR_H
  #define CELIX_PHASE3BASEACTIVATOR_H
  
 -#include "celix/dm/DmActivator.h"
 +#include "celix/IBundleActivator.h"
 +#include "Phase3Cmp.h"
  
 -using namespace celix::dm;
 -
 -class Phase3BaseActivator : public DmActivator {
 +class Phase3BaseActivator : public celix::IBundleActivator {
  public:
 -    Phase3BaseActivator(DependencyManager& mng) : DmActivator(mng), cmp(mng.createComponent<Phase3Cmp>()) {}
 -    void init();
 +    Phase3BaseActivator(){}
 +    virtual ~Phase3BaseActivator(){}
++
++    Phase3BaseActivator(const Phase3BaseActivator&) = delete;
++    Phase3BaseActivator(Phase3BaseActivator&&) = delete;
++    Phase3BaseActivator& operator=(const Phase3BaseActivator&) = delete;
++    Phase3BaseActivator& operator=(Phase3BaseActivator&&) = delete;
++
 +    celix_status_t start(celix::BundleContext& ctx) override;
 +    celix_status_t stop(celix::BundleContext& ctx) override;
  protected:
 -    celix::dm::Component<Phase3Cmp>& cmp;
 +    celix::dm::Component<Phase3Cmp> *cmp{nullptr};
  };
  
  #endif //CELIX_PHASE3BASEACTIVATOR_H

http://git-wip-us.apache.org/repos/asf/celix/blob/34914e82/libs/framework/include/celix/Constants.h
----------------------------------------------------------------------
diff --cc libs/framework/include/celix/Constants.h
index 8317069,0000000..b957f61
mode 100644,000000..100644
--- a/libs/framework/include/celix/Constants.h
+++ b/libs/framework/include/celix/Constants.h
@@@ -1,47 -1,0 +1,47 @@@
 +/**
 + *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.
 + */
 +
 +
 +#ifndef CXX_CELIX_CONSTANTS_H
 +#define CXX_CELIX_CONSTANTS_H
 +
 +#include "celix_constants.h"
 +
 +namespace celix {
 +    class Constants {
 +    public:
-         static constexpr const char *const SERVICE_NAME  = OSGI_FRAMEWORK_OBJECTCLASS;
++        static constexpr const char *const SERVICE_NAME = OSGI_FRAMEWORK_OBJECTCLASS;
 +        static constexpr const char *const SERVICE_ID = OSGI_FRAMEWORK_SERVICE_ID;
 +        static constexpr const char *const SERVICE_PID = OSGI_FRAMEWORK_SERVICE_PID;
 +        static constexpr const char *const SERVICE_RANKING = OSGI_FRAMEWORK_SERVICE_RANKING;
 +
 +        static constexpr const char *const SERVICE_VERSION = CELIX_FRAMEWORK_SERVICE_VERSION;
 +        static constexpr const char *const SERVICE_LANGUAGE = CELIX_FRAMEWORK_SERVICE_LANGUAGE;
 +        static constexpr const char *const SERVICE_C_LANG = CELIX_FRAMEWORK_SERVICE_C_LANGUAGE;
 +        static constexpr const char *const SERVICE_CXX_LANG = CELIX_FRAMEWORK_SERVICE_CXX_LANGUAGE;
 +        static constexpr const char *const SERVICE_SHARED_LANG = CELIX_FRAMEWORK_SERVICE_SHARED_LANGUAGE; //e.g. marker services
 +
 +        static constexpr const char *const FRAMEWORK_STORAGE = OSGI_FRAMEWORK_FRAMEWORK_STORAGE;
 +        static constexpr const char *const FRAMEWORK_CLEAN = OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN;
 +        static constexpr const char *const FRAMEWORK_CLEAN_ON_FIRST_INIT = OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT;
 +        static constexpr const char *const FRAMEWORK_UUID = OSGI_FRAMEWORK_FRAMEWORK_UUID;
 +    };
 +}
 +
 +#endif //CXX_CELIX_CONSTANTS_H

http://git-wip-us.apache.org/repos/asf/celix/blob/34914e82/libs/framework/include/celix_bundle_context.h
----------------------------------------------------------------------
diff --cc libs/framework/include/celix_bundle_context.h
index 6b0b628,58dca4e..634145e
--- a/libs/framework/include/celix_bundle_context.h
+++ b/libs/framework/include/celix_bundle_context.h
@@@ -728,13 -728,21 +728,11 @@@ long celix_bundleContext_trackServiceTr
   */
  dm_dependency_manager_t* celix_bundleContext_getDependencyManager(celix_bundle_context_t *ctx);
  
 -
--/**
-  * Gets the bundle for this bundle context
-  *
-  * @return the bundle or NULL if unsuccessful.
 - * Returns the bundle for this bundle context.
-- */
  celix_bundle_t* celix_bundleContext_getBundle(celix_bundle_context_t *ctx);
  
 -
 -/**
 - * Gets the config property - or environment variable if the config property does not exist - for the provided name.
 - * @param key The key of the property to receive
 - * @param defaultVal The default value to use if the property is not found (can be NULL)
 - * @return The property value for the provided key or the provided defaultValue is the key is not found.
 - */
+ const char* celix_bundleContext_getProperty(celix_bundle_context_t *ctx, const char *key, const char *defaultVal);
+ 
++
  #ifdef __cplusplus
  }
  #endif

http://git-wip-us.apache.org/repos/asf/celix/blob/34914e82/libs/framework/include/celix_constants.h
----------------------------------------------------------------------
diff --cc libs/framework/include/celix_constants.h
index d46c8fb,0000000..10996a4
mode 100644,000000..100644
--- a/libs/framework/include/celix_constants.h
+++ b/libs/framework/include/celix_constants.h
@@@ -1,79 -1,0 +1,80 @@@
 +/**
 + *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.
 + */
- /*
-  * constants.h
-  *
-  *  \date       Apr 29, 2010
-  *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
-  *  \copyright	Apache License, Version 2.0
-  */
 +
 +#ifndef CELIX_CONSTANTS_H_
 +#define CELIX_CONSTANTS_H_
 +
 +#ifdef __cplusplus
 +extern "C" {
 +#endif
 +
 +#define OSGI_FRAMEWORK_OBJECTCLASS "objectClass"
- #define OSGI_FRAMEWORK_SERVICE_NAME "objectClass" //TODO rename in future?
 +#define OSGI_FRAMEWORK_SERVICE_ID "service.id"
 +#define OSGI_FRAMEWORK_SERVICE_PID "service.pid"
 +#define OSGI_FRAMEWORK_SERVICE_RANKING "service.ranking"
 +
 +#define CELIX_FRAMEWORK_SERVICE_VERSION "service.version"
 +#define CELIX_FRAMEWORK_SERVICE_LANGUAGE "service.lang"
 +#define CELIX_FRAMEWORK_SERVICE_C_LANGUAGE "C"
 +#define CELIX_FRAMEWORK_SERVICE_CXX_LANGUAGE "C++"
 +#define CELIX_FRAMEWORK_SERVICE_SHARED_LANGUAGE "shared" //e.g. marker services
 +
 +#define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR "Bundle-Activator"
- #define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_CREATE "bundleActivator_create"
- #define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_START "bundleActivator_start"
- #define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP "bundleActivator_stop"
- #define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY "bundleActivator_destroy"
++
++#define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_CREATE "celix_bundleActivator_create"
++#define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_START "celix_bundleActivator_start"
++#define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP "celix_bundleActivator_stop"
++#define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY "celix_bundleActivator_destroy"
++
++#define OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_CREATE "bundleActivator_create"
++#define OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_START "bundleActivator_start"
++#define OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_STOP "bundleActivator_stop"
++#define OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_DESTROY "bundleActivator_destroy"
++
 +
 +#define OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_CREATE "dm_create"
 +#define OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_INIT "dm_init"
 +#define OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_DESTROY "dm_destroy"
 +
++
 +#define OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME "Bundle-SymbolicName"
 +#define OSGI_FRAMEWORK_BUNDLE_VERSION "Bundle-Version"
 +#define OSGI_FRAMEWORK_PRIVATE_LIBRARY "Private-Library"
 +#define OSGI_FRAMEWORK_EXPORT_LIBRARY "Export-Library"
 +#define OSGI_FRAMEWORK_IMPORT_LIBRARY "Import-Library"
-     
++
 +#define OSGI_FRAMEWORK_FRAMEWORK_STORAGE "org.osgi.framework.storage"
 +#define OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN "org.osgi.framework.storage.clean"
 +#define OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT "onFirstInit"
 +#define OSGI_FRAMEWORK_FRAMEWORK_UUID "org.osgi.framework.uuid"
 +
 +#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"
 +#define CELIX_AUTO_START_3 "CELIX_AUTO_START_3"
 +#define CELIX_AUTO_START_4 "CELIX_AUTO_START_4"
 +#define CELIX_AUTO_START_5 "CELIX_AUTO_START_5"
 +
 +
++
 +#ifdef __cplusplus
 +}
 +#endif
 +
 +#endif /* CONSTANTS_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/34914e82/libs/framework/include/constants.h
----------------------------------------------------------------------
diff --cc libs/framework/include/constants.h
index ac00241,b9be0bd..d9680b3
--- a/libs/framework/include/constants.h
+++ b/libs/framework/include/constants.h
@@@ -16,5 -16,71 +16,5 @@@
   *specific language governing permissions and limitations
   *under the License.
   */
 -/*
 - * constants.h
 - *
 - *  \date       Apr 29, 2010
 - *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
 - *  \copyright	Apache License, Version 2.0
 - */
 -
 -#ifndef CONSTANTS_H_
 -#define CONSTANTS_H_
 -
 -#ifdef __cplusplus
 -extern "C" {
 -#endif
 -
 -static const char *const OSGI_FRAMEWORK_OBJECTCLASS = "objectClass";
 -static const char *const OSGI_FRAMEWORK_SERVICE_ID = "service.id";
 -static const char *const OSGI_FRAMEWORK_SERVICE_PID = "service.pid";
 -static const char *const OSGI_FRAMEWORK_SERVICE_RANKING = "service.ranking";
 -
 -static const char *const CELIX_FRAMEWORK_SERVICE_VERSION = "service.version";
 -static const char *const CELIX_FRAMEWORK_SERVICE_LANGUAGE = "service.lang";
 -static const char *const CELIX_FRAMEWORK_SERVICE_C_LANGUAGE = "C";
 -static const char *const CELIX_FRAMEWORK_SERVICE_CXX_LANGUAGE = "C++";
 -static const char *const CELIX_FRAMEWORK_SERVICE_SHARED_LANGUAGE = "shared"; //e.g. marker services
 -
 -static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR = "Bundle-Activator";
 -
 -static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_CREATE = "celix_bundleActivator_create";
 -static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_START = "celix_bundleActivator_start";
 -static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP = "celix_bundleActivator_stop";
 -static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY = "celix_bundleActivator_destroy";
 -
 -static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_CREATE = "bundleActivator_create";
 -static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_START = "bundleActivator_start";
 -static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_STOP = "bundleActivator_stop";
 -static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_DESTROY = "bundleActivator_destroy";
 -
 -
 -static const char *const OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_CREATE = "dm_create";
 -static const char *const OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_INIT = "dm_init";
 -static const char *const OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_DESTROY = "dm_destroy";
 -
 -
 -static const char *const OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName";
 -static const char *const OSGI_FRAMEWORK_BUNDLE_VERSION = "Bundle-Version";
 -static const char *const OSGI_FRAMEWORK_PRIVATE_LIBRARY = "Private-Library";
 -static const char *const OSGI_FRAMEWORK_EXPORT_LIBRARY = "Export-Library";
 -static const char *const OSGI_FRAMEWORK_IMPORT_LIBRARY = "Import-Library";
 -
 -static const char *const OSGI_FRAMEWORK_FRAMEWORK_STORAGE = "org.osgi.framework.storage";
 -static const char *const OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN = "org.osgi.framework.storage.clean";
 -static const char *const OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT = "onFirstInit";
 -static const char *const OSGI_FRAMEWORK_FRAMEWORK_UUID = "org.osgi.framework.uuid";
 -
 -#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"
 -#define CELIX_AUTO_START_3 "CELIX_AUTO_START_3"
 -#define CELIX_AUTO_START_4 "CELIX_AUTO_START_4"
 -#define CELIX_AUTO_START_5 "CELIX_AUTO_START_5"
 -
 -
 -#ifdef __cplusplus
 -}
 -#endif
  
- #include "celix_constants.h"
 -#endif /* CONSTANTS_H_ */
++#include "celix_constants.h"

http://git-wip-us.apache.org/repos/asf/celix/blob/34914e82/libs/framework/src/bundle_context.c
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/celix/blob/34914e82/libs/framework/src/framework.c
----------------------------------------------------------------------


[2/4] celix git commit: CELIX-446: Fixes bundle context test for bundleContext_getProperty

Posted by pn...@apache.org.
CELIX-446: Fixes bundle context test for bundleContext_getProperty


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

Branch: refs/heads/feature/CELIX-426-cxx-api
Commit: b1a91a4cc19f041bd404c837f228e6713cbfc566
Parents: 3e27acf
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Tue May 29 22:07:56 2018 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Tue May 29 22:07:56 2018 +0200

----------------------------------------------------------------------
 libs/framework/private/test/bundle_context_test.cpp | 6 +-----
 libs/framework/src/bundle_context.c                 | 8 +++++++-
 2 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/b1a91a4c/libs/framework/private/test/bundle_context_test.cpp
----------------------------------------------------------------------
diff --git a/libs/framework/private/test/bundle_context_test.cpp b/libs/framework/private/test/bundle_context_test.cpp
index 21abb80..9ae57e0 100644
--- a/libs/framework/private/test/bundle_context_test.cpp
+++ b/libs/framework/private/test/bundle_context_test.cpp
@@ -590,7 +590,7 @@ TEST(bundle_context, removeFrameworkListener){
 }
 
 TEST(bundle_context, getProperty) {
-	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+//	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
 
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
@@ -612,9 +612,5 @@ TEST(bundle_context, getProperty) {
 	LONGS_EQUAL(CELIX_SUCCESS, status);
 	STRCMP_EQUAL(value, actualValue);
 
-	actualValue = NULL;
-	status = bundleContext_getProperty(context, NULL, &actualValue);
-
-	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
 	free(context);
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/b1a91a4c/libs/framework/src/bundle_context.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/bundle_context.c b/libs/framework/src/bundle_context.c
index d3a2c1e..84d6346 100644
--- a/libs/framework/src/bundle_context.c
+++ b/libs/framework/src/bundle_context.c
@@ -108,9 +108,15 @@ celix_status_t bundleContext_destroy(bundle_context_pt context) {
 celix_status_t bundleContext_getBundle(bundle_context_pt context, bundle_pt *out) {
 	celix_status_t status = CELIX_SUCCESS;
     celix_bundle_t *bnd = celix_bundleContext_getBundle(context);
+    if (context == NULL) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
     if (out != NULL) {
         *out = bnd;
     }
+
+    framework_logIfError(logger, status, NULL, "Failed to get bundle");
+
 	return status;
 }
 
@@ -961,4 +967,4 @@ const char* celix_bundleContext_getProperty(celix_bundle_context_t *ctx, const c
         fw_getProperty(ctx->framework, key, defaultVal, &val);
     }
     return val;
-}
\ No newline at end of file
+}


[3/4] celix git commit: CELIX-446: Fixes wrong include setup for the dependnecy manager lib

Posted by pn...@apache.org.
CELIX-446: Fixes wrong include setup for the dependnecy manager lib


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

Branch: refs/heads/feature/CELIX-426-cxx-api
Commit: 3182ca7aa4c72da19869558123e3af1f949fb8a1
Parents: b1a91a4
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Wed May 30 21:52:09 2018 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Wed May 30 21:53:08 2018 +0200

----------------------------------------------------------------------
 libs/dependency_manager/CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/3182ca7a/libs/dependency_manager/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/libs/dependency_manager/CMakeLists.txt b/libs/dependency_manager/CMakeLists.txt
index 52051ab..758cc49 100644
--- a/libs/dependency_manager/CMakeLists.txt
+++ b/libs/dependency_manager/CMakeLists.txt
@@ -19,7 +19,7 @@
 add_library(dependency_manager_static STATIC src/dm_activator.c)
 target_include_directories(dependency_manager_static PUBLIC
         $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/api>
-        $<INSTALL_INTERFACE:include/celix/dependency_manager>
+        $<INSTALL_INTERFACE:include/celix>
 )
 if (APPLE)
     target_link_libraries(dependency_manager_static Celix::framework "-undefined dynamic_lookup")
@@ -30,7 +30,7 @@ endif()
 add_library(dependency_manager_so SHARED src/dm_activator.c)
 target_include_directories(dependency_manager_so PUBLIC
         $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/api>
-        $<INSTALL_INTERFACE:include/celix/dependency_manager>
+        $<INSTALL_INTERFACE:include/celix>
 )
 if (APPLE)
     target_link_libraries(dependency_manager_so Celix::framework "-undefined dynamic_lookup")