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/29 17:33:06 UTC
[1/5] celix git commit: CELIX-424: Fixes resources cmake
configuration for pubsub
Repository: celix
Updated Branches:
refs/heads/feature/CELIX-426-cxx-api e633316f8 -> be6612f0f
CELIX-424: Fixes resources cmake configuration for pubsub
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/afcfea11
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/afcfea11
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/afcfea11
Branch: refs/heads/feature/CELIX-426-cxx-api
Commit: afcfea11c3559a4312b8405452fde87b52662fae
Parents: 3bce889
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Mon May 28 10:36:51 2018 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Mon May 28 10:36:51 2018 +0200
----------------------------------------------------------------------
.../pubsub/examples/mp_pubsub/publisher/CMakeLists.txt | 10 +++++-----
.../pubsub/examples/mp_pubsub/subscriber/CMakeLists.txt | 10 +++++-----
bundles/pubsub/examples/pubsub/publisher/CMakeLists.txt | 12 ++++++------
.../pubsub/examples/pubsub/publisher2/CMakeLists.txt | 12 ++++++------
.../pubsub/examples/pubsub/subscriber/CMakeLists.txt | 12 ++++++------
5 files changed, 28 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/afcfea11/bundles/pubsub/examples/mp_pubsub/publisher/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/pubsub/examples/mp_pubsub/publisher/CMakeLists.txt b/bundles/pubsub/examples/mp_pubsub/publisher/CMakeLists.txt
index 653387e..76c9bce 100644
--- a/bundles/pubsub/examples/mp_pubsub/publisher/CMakeLists.txt
+++ b/bundles/pubsub/examples/mp_pubsub/publisher/CMakeLists.txt
@@ -26,18 +26,18 @@ target_link_libraries(org.apache.celix.pubsub_publisher.MpPublisher PRIVATE Celi
target_include_directories(org.apache.celix.pubsub_publisher.MpPublisher PRIVATE private/include)
celix_bundle_files(org.apache.celix.pubsub_publisher.MpPublisher
- ${PROJECT_SOURCE_DIR}/pubsub/examples/mp_pubsub/msg_descriptors/msg_ew.descriptor
- ${PROJECT_SOURCE_DIR}/pubsub/examples/mp_pubsub/msg_descriptors/msg_ide.descriptor
- ${PROJECT_SOURCE_DIR}/pubsub/examples/mp_pubsub/msg_descriptors/msg_kinematics.descriptor
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/mp_pubsub/msg_descriptors/msg_ew.descriptor
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/mp_pubsub/msg_descriptors/msg_ide.descriptor
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/mp_pubsub/msg_descriptors/msg_kinematics.descriptor
DESTINATION "META-INF/descriptors"
)
celix_bundle_files(org.apache.celix.pubsub_publisher.MpPublisher
- ${PROJECT_SOURCE_DIR}/pubsub/examples/keys/publisher
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/keys/publisher
DESTINATION "META-INF/keys"
)
celix_bundle_files(org.apache.celix.pubsub_publisher.MpPublisher
- ${PROJECT_SOURCE_DIR}/pubsub/examples/keys/subscriber/public
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/keys/subscriber/public
DESTINATION "META-INF/keys/subscriber"
)
http://git-wip-us.apache.org/repos/asf/celix/blob/afcfea11/bundles/pubsub/examples/mp_pubsub/subscriber/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/pubsub/examples/mp_pubsub/subscriber/CMakeLists.txt b/bundles/pubsub/examples/mp_pubsub/subscriber/CMakeLists.txt
index 1185ec5..444764e 100644
--- a/bundles/pubsub/examples/mp_pubsub/subscriber/CMakeLists.txt
+++ b/bundles/pubsub/examples/mp_pubsub/subscriber/CMakeLists.txt
@@ -26,18 +26,18 @@ target_link_libraries(org.apache.celix.pubsub_subscriber.MpSubscriber PRIVATE Ce
target_include_directories(org.apache.celix.pubsub_subscriber.MpSubscriber PRIVATE private/include)
celix_bundle_files( org.apache.celix.pubsub_subscriber.MpSubscriber
- ${PROJECT_SOURCE_DIR}/pubsub/examples/mp_pubsub/msg_descriptors/msg_ew.descriptor
- ${PROJECT_SOURCE_DIR}/pubsub/examples/mp_pubsub/msg_descriptors/msg_ide.descriptor
- ${PROJECT_SOURCE_DIR}/pubsub/examples/mp_pubsub/msg_descriptors/msg_kinematics.descriptor
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/mp_pubsub/msg_descriptors/msg_ew.descriptor
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/mp_pubsub/msg_descriptors/msg_ide.descriptor
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/mp_pubsub/msg_descriptors/msg_kinematics.descriptor
DESTINATION "META-INF/descriptors"
)
celix_bundle_files(org.apache.celix.pubsub_subscriber.MpSubscriber
- ${PROJECT_SOURCE_DIR}/pubsub/examples/keys/subscriber
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/keys/subscriber
DESTINATION "META-INF/keys"
)
celix_bundle_files(org.apache.celix.pubsub_subscriber.MpSubscriber
- ${PROJECT_SOURCE_DIR}/pubsub/examples/keys/publisher/public
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/keys/publisher/public
DESTINATION "META-INF/keys/publisher"
)
http://git-wip-us.apache.org/repos/asf/celix/blob/afcfea11/bundles/pubsub/examples/pubsub/publisher/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/pubsub/examples/pubsub/publisher/CMakeLists.txt b/bundles/pubsub/examples/pubsub/publisher/CMakeLists.txt
index 176a57e..00b528c 100644
--- a/bundles/pubsub/examples/pubsub/publisher/CMakeLists.txt
+++ b/bundles/pubsub/examples/pubsub/publisher/CMakeLists.txt
@@ -27,23 +27,23 @@ target_link_libraries(celix_pubsub_poi_publisher PRIVATE Celix::framework Celix:
target_include_directories(celix_pubsub_poi_publisher PRIVATE private/include)
celix_bundle_files(celix_pubsub_poi_publisher
- ${PROJECT_SOURCE_DIR}/pubsub/examples/pubsub/msg_descriptors/msg_poi1.descriptor
- ${PROJECT_SOURCE_DIR}/pubsub/examples/pubsub/msg_descriptors/msg_poi2.descriptor
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/msg_poi1.descriptor
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/msg_poi2.descriptor
DESTINATION "META-INF/descriptors"
)
celix_bundle_files(celix_pubsub_poi_publisher
- ${PROJECT_SOURCE_DIR}/pubsub/examples/pubsub/msg_descriptors/poi1.properties
- ${PROJECT_SOURCE_DIR}/pubsub/examples/pubsub/msg_descriptors/poi2.properties
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/poi1.properties
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/poi2.properties
DESTINATION "META-INF/topics/pub"
)
celix_bundle_files(celix_pubsub_poi_publisher
- ${PROJECT_SOURCE_DIR}/pubsub/examples/keys/publisher
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/keys/publisher
DESTINATION "META-INF/keys"
)
celix_bundle_files(celix_pubsub_poi_publisher
- ${PROJECT_SOURCE_DIR}/pubsub/examples/keys/subscriber/public
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/keys/subscriber/public
DESTINATION "META-INF/keys/subscriber"
)
http://git-wip-us.apache.org/repos/asf/celix/blob/afcfea11/bundles/pubsub/examples/pubsub/publisher2/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/pubsub/examples/pubsub/publisher2/CMakeLists.txt b/bundles/pubsub/examples/pubsub/publisher2/CMakeLists.txt
index 30d86ee..e59d793 100644
--- a/bundles/pubsub/examples/pubsub/publisher2/CMakeLists.txt
+++ b/bundles/pubsub/examples/pubsub/publisher2/CMakeLists.txt
@@ -27,24 +27,24 @@ target_include_directories(celix_pubsub_poi_publisher2 PRIVATE ../publisher/priv
celix_bundle_files(celix_pubsub_poi_publisher2
- ${PROJECT_SOURCE_DIR}/pubsub/examples/pubsub/msg_descriptors/msg_poi1.descriptor
- ${PROJECT_SOURCE_DIR}/pubsub/examples/pubsub/msg_descriptors/msg_poi2.descriptor
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/msg_poi1.descriptor
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/msg_poi2.descriptor
DESTINATION "META-INF/descriptors"
)
celix_bundle_files(celix_pubsub_poi_publisher2
- ${PROJECT_SOURCE_DIR}/pubsub/examples/pubsub/msg_descriptors/poi1.properties
- ${PROJECT_SOURCE_DIR}/pubsub/examples/pubsub/msg_descriptors/poi2.properties
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/poi1.properties
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/poi2.properties
DESTINATION "META-INF/topics/pub"
)
celix_bundle_files(celix_pubsub_poi_publisher2
- ${PROJECT_SOURCE_DIR}/pubsub/examples/keys/publisher
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/keys/publisher
DESTINATION "META-INF/keys"
)
celix_bundle_files(celix_pubsub_poi_publisher2
- ${PROJECT_SOURCE_DIR}/pubsub/examples/keys/subscriber/public
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/keys/subscriber/public
DESTINATION "META-INF/keys/subscriber"
)
http://git-wip-us.apache.org/repos/asf/celix/blob/afcfea11/bundles/pubsub/examples/pubsub/subscriber/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/pubsub/examples/pubsub/subscriber/CMakeLists.txt b/bundles/pubsub/examples/pubsub/subscriber/CMakeLists.txt
index 0eb13ff..05afa04 100644
--- a/bundles/pubsub/examples/pubsub/subscriber/CMakeLists.txt
+++ b/bundles/pubsub/examples/pubsub/subscriber/CMakeLists.txt
@@ -28,23 +28,23 @@ target_include_directories(celix_pubsub_poi_subscriber PRIVATE private/include)
celix_bundle_files(celix_pubsub_poi_subscriber
- ${PROJECT_SOURCE_DIR}/pubsub/examples/pubsub/msg_descriptors/msg_poi1.descriptor
- ${PROJECT_SOURCE_DIR}/pubsub/examples/pubsub/msg_descriptors/msg_poi2.descriptor
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/msg_poi1.descriptor
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/msg_poi2.descriptor
DESTINATION "META-INF/descriptors"
)
celix_bundle_files(celix_pubsub_poi_subscriber
- ${PROJECT_SOURCE_DIR}/pubsub/examples/pubsub/msg_descriptors/poi1.properties
- ${PROJECT_SOURCE_DIR}/pubsub/examples/pubsub/msg_descriptors/poi2.properties
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/poi1.properties
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/pubsub/msg_descriptors/poi2.properties
DESTINATION "META-INF/topics/sub"
)
celix_bundle_files(celix_pubsub_poi_subscriber
- ${PROJECT_SOURCE_DIR}/pubsub/examples/keys/subscriber
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/keys/subscriber
DESTINATION "META-INF/keys"
)
celix_bundle_files(celix_pubsub_poi_subscriber
- ${PROJECT_SOURCE_DIR}/pubsub/examples/keys/publisher/public
+ ${PROJECT_SOURCE_DIR}/bundles/pubsub/examples/keys/publisher/public
DESTINATION "META-INF/keys/publisher"
)
[2/5] celix git commit: CELIX-446: Refactor the bundle activators of
the service_example_c and best_practice_example_c to use the activator
generation macro
Posted by pn...@apache.org.
CELIX-446: Refactor the bundle activators of the service_example_c and best_practice_example_c to use the activator generation macro
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/3e5a6a79
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/3e5a6a79
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/3e5a6a79
Branch: refs/heads/feature/CELIX-426-cxx-api
Commit: 3e5a6a797c190e5073b7260393a41fc70cf7ffb1
Parents: afcfea1
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Mon May 28 11:45:09 2018 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Mon May 28 11:45:09 2018 +0200
----------------------------------------------------------------------
.../best_practice_example_c/bar/CMakeLists.txt | 13 +--
.../bar/private/src/bar_activator.c | 53 +++++--------
.../best_practice_example_c/foo1/CMakeLists.txt | 13 +--
.../foo1/private/src/foo1_activator.c | 83 +++++++++-----------
.../best_practice_example_c/foo2/CMakeLists.txt | 13 +--
.../foo2/private/src/foo2_activator.c | 83 +++++++++-----------
.../src/dynamic_consumer_example.c | 41 +++-------
.../src/dynamic_provider_example.c | 51 ++++--------
.../src/simple_consumer_example.c | 29 ++-----
.../src/simple_provider_example.c | 39 +++------
libs/framework/include/bundle_activator.h | 39 +++++++++
11 files changed, 177 insertions(+), 280 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/3e5a6a79/examples/celix-examples/best_practice_example_c/bar/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/best_practice_example_c/bar/CMakeLists.txt b/examples/celix-examples/best_practice_example_c/bar/CMakeLists.txt
index 7df3051..38083ae 100644
--- a/examples/celix-examples/best_practice_example_c/bar/CMakeLists.txt
+++ b/examples/celix-examples/best_practice_example_c/bar/CMakeLists.txt
@@ -25,15 +25,4 @@ add_celix_bundle(bar
SOURCES
private/src/bar_activator
private/src/bar.c
-)
-
-IF(APPLE)
- target_link_libraries(bar PRIVATE Celix::framework -Wl,-all_load dependency_manager_static)
-else()
- if(ENABLE_ADDRESS_SANITIZER)
- #With asan there can be undefined symbols
- target_link_libraries(bar PRIVATE -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive Celix::framework )
- else()
- target_link_libraries(bar PRIVATE -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive Celix::framework )
- endif()
-endif()
+)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/3e5a6a79/examples/celix-examples/best_practice_example_c/bar/private/src/bar_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/best_practice_example_c/bar/private/src/bar_activator.c b/examples/celix-examples/best_practice_example_c/bar/private/src/bar_activator.c
index 0fa7889..39d0164 100644
--- a/examples/celix-examples/best_practice_example_c/bar/private/src/bar_activator.c
+++ b/examples/celix-examples/best_practice_example_c/bar/private/src/bar_activator.c
@@ -22,49 +22,32 @@
#include <stdlib.h>
-struct activator {
+typedef struct activator {
bar_t *bar;
example_t exampleService;
-};
+} activator_t;
-celix_status_t dm_create(bundle_context_pt context, void **userData) {
+static celix_status_t activator_start(activator_t *act, celix_bundle_context_t *ctx) {
celix_status_t status = CELIX_SUCCESS;
- struct activator *act = calloc(1, sizeof(*act));
- if (act != NULL) {
-
- act->bar = bar_create();
- act->exampleService.handle = act->bar;
- act->exampleService.method = (void*) bar_method;
-
- if (act->bar != NULL) {
- *userData = act;
- } else {
- free(act);
- }
- } else {
+ act->bar = bar_create();
+ act->exampleService.handle = act->bar;
+ act->exampleService.method = (void*) bar_method;
+ if (act->bar == NULL) {
status = CELIX_ENOMEM;
+ } else {
+ dm_component_pt cmp = NULL;
+ component_create(ctx, "BAR", &cmp);
+ component_setImplementation(cmp, act->bar);
+ component_addInterface(cmp, EXAMPLE_NAME, EXAMPLE_VERSION, &act->exampleService, NULL);
+ dependencyManager_add(celix_bundleContext_getDependencyManager(ctx), cmp);
}
return status;
}
-celix_status_t dm_init(void *userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator *activator = userData;
-
- dm_component_pt cmp = NULL;
- component_create(context, "BAR", &cmp);
- component_setImplementation(cmp, activator->bar);
- component_addInterface(cmp, EXAMPLE_NAME, EXAMPLE_VERSION, &activator->exampleService, NULL);
-
- dependencyManager_add(manager, cmp);
- return status;
+static celix_status_t activator_stop(activator_t *act, celix_bundle_context_t *ctx) {
+ dependencyManager_removeAllComponents(celix_bundleContext_getDependencyManager(ctx));
+ bar_destroy(act->bar);
+ return CELIX_SUCCESS;
}
-celix_status_t dm_destroy(void *userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator *activator = userData;
- bar_destroy(activator->bar);
- free(activator);
- return status;
-};
-
+CELIX_GEN_BUNDLE_ACTIVATOR(activator_t, activator_start, activator_stop)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/3e5a6a79/examples/celix-examples/best_practice_example_c/foo1/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/best_practice_example_c/foo1/CMakeLists.txt b/examples/celix-examples/best_practice_example_c/foo1/CMakeLists.txt
index d732c76..b3cdb53 100644
--- a/examples/celix-examples/best_practice_example_c/foo1/CMakeLists.txt
+++ b/examples/celix-examples/best_practice_example_c/foo1/CMakeLists.txt
@@ -25,15 +25,4 @@ add_celix_bundle(foo1
SOURCES
private/src/foo1_activator
private/src/foo1.c
-)
-
-IF(APPLE)
- target_link_libraries(foo1 PRIVATE -Wl,-all_load dependency_manager_static)
-else()
- if(ENABLE_ADDRESS_SANITIZER)
- #With asan there can be undefined symbols
- target_link_libraries(foo1 PRIVATE -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
- else()
- target_link_libraries(foo1 PRIVATE -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
- endif()
-endif()
+)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/3e5a6a79/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c b/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
index f94888b..6b2f578 100644
--- a/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
+++ b/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
@@ -26,63 +26,50 @@ struct activator {
foo1_t *foo;
};
-celix_status_t dm_create(bundle_context_pt context, void **userData) {
+static celix_status_t activator_start(activator_t *act, celix_bundle_context_t *ctx) {
celix_status_t status = CELIX_SUCCESS;
- struct activator *act = calloc(1, sizeof(*act));
- if (act != NULL) {
- act->foo = foo1_create();
- if (act->foo != NULL) {
- *userData = act;
- } else {
- free(act);
- }
- } else {
+ act->foo = foo1_create();
+ if (act->foo == NULL) {
status = CELIX_ENOMEM;
- }
- return status;
-}
-
-celix_status_t dm_init(void *userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator *activator = userData;
+ } else {
+ dm_component_pt cmp = NULL;
+ component_create(ctx, "FOO1", &cmp);
+ component_setImplementation(cmp, act->foo);
- dm_component_pt cmp = NULL;
- component_create(context, "FOO1", &cmp);
- component_setImplementation(cmp, activator->foo);
+ /*
+ With the component_setCallbacksSafe we register callbacks when a component is started / stopped using a component
+ with type foo1_t*
+ */
+ component_setCallbacksSafe(cmp, foo1_t*, NULL, foo1_start, foo1_stop, NULL);
- /*
- With the component_setCallbacksSafe we register callbacks when a component is started / stopped using a component
- with type foo1_t*
- */
- component_setCallbacksSafe(cmp, foo1_t*, NULL, foo1_start, foo1_stop, NULL);
+ dm_service_dependency_pt dep = NULL;
+ serviceDependency_create(&dep);
+ serviceDependency_setRequired(dep, true);
+ serviceDependency_setService(dep, EXAMPLE_NAME, EXAMPLE_CONSUMER_RANGE, NULL);
+ serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING);
- dm_service_dependency_pt dep = NULL;
- serviceDependency_create(&dep);
- serviceDependency_setRequired(dep, true);
- serviceDependency_setService(dep, EXAMPLE_NAME, EXAMPLE_CONSUMER_RANGE, NULL);
- serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING);
+ /*
+ With the serviceDependency_setCallbacksSafe we register callbacks when a service
+ is added and about to be removed for the component type foo1_t* and service type example_t*.
- /*
- With the serviceDependency_setCallbacksSafe we register callbacks when a service
- is added and about to be removed for the component type foo1_t* and service type example_t*.
+ We should protect the usage of the
+ service because after removal of the service the memory location of that service
+ could be freed
+ */
+ serviceDependency_setCallbacksSafe(dep, foo1_t*, const example_t*, foo1_setExample, NULL, NULL, NULL, NULL);
+ component_addServiceDependency(cmp, dep);
- We should protect the usage of the
- service because after removal of the service the memory location of that service
- could be freed
- */
- serviceDependency_setCallbacksSafe(dep, foo1_t*, const example_t*, foo1_setExample, NULL, NULL, NULL, NULL);
- component_addServiceDependency(cmp, dep);
+ dependencyManager_add(celix_bundleContext_getDependencyManager(ctx), cmp);
- dependencyManager_add(manager, cmp);
+ }
+ return status;
+}
- return status;
+static celix_status_t activator_stop(activator_t *act, celix_bundle_context_t *ctx) {
+ dependencyManager_removeAllComponents(celix_bundleContext_getDependencyManager(ctx));
+ foo1_destroy(act->foo);
+ return CELIX_SUCCESS;
}
-celix_status_t dm_destroy(void *userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator *activator = userData;
- foo1_destroy(activator->foo);
- free(activator);
- return status;
-};
+CELIX_GEN_BUNDLE_ACTIVATOR(activator_t, activator_start, activator_stop)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/3e5a6a79/examples/celix-examples/best_practice_example_c/foo2/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/best_practice_example_c/foo2/CMakeLists.txt b/examples/celix-examples/best_practice_example_c/foo2/CMakeLists.txt
index adb8f64..f3dd0f3 100644
--- a/examples/celix-examples/best_practice_example_c/foo2/CMakeLists.txt
+++ b/examples/celix-examples/best_practice_example_c/foo2/CMakeLists.txt
@@ -25,15 +25,4 @@ add_celix_bundle(foo2
SOURCES
private/src/foo2_activator
private/src/foo2.c
-)
-
-IF(APPLE)
- target_link_libraries(foo2 PRIVATE -Wl,-all_load dependency_manager_static)
-else()
- if(ENABLE_ADDRESS_SANITIZER)
- #With asan there can be undefined symbols
- target_link_libraries(foo2 PRIVATE -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
- else()
- target_link_libraries(foo2 PRIVATE -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
- endif()
-endif()
+)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/3e5a6a79/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2_activator.c b/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2_activator.c
index 5c047da..309b8c1 100644
--- a/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2_activator.c
+++ b/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2_activator.c
@@ -26,63 +26,52 @@ struct activator {
foo2_t *foo;
};
-celix_status_t dm_create(bundle_context_pt context, void **userData) {
+static celix_status_t activator_start(struct activator *act, celix_bundle_context_t *ctx) {
celix_status_t status = CELIX_SUCCESS;
- struct activator *act = calloc(1, sizeof(*act));
- if (act != NULL) {
- act->foo = foo2_create();
- if (act->foo != NULL) {
- *userData = act;
- } else {
- free(act);
- }
- } else {
+ act->foo = foo2_create();
+ if (act->foo == NULL) {
status = CELIX_ENOMEM;
- }
- return status;
-}
+ } else {
-celix_status_t dm_init(void *userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator *activator = userData;
+ dm_component_pt cmp = NULL;
+ component_create(ctx, "FOO2", &cmp);
+ component_setImplementation(cmp, act->foo);
- dm_component_pt cmp = NULL;
- component_create(context, "FOO2", &cmp);
- component_setImplementation(cmp, activator->foo);
+ /*
+ With the component_setCallbacksSafe we register callbacks when a component is started / stopped using a component
+ with type foo1_t*
+ */
+ component_setCallbacksSafe(cmp, foo2_t*, NULL, foo2_start, foo2_stop, NULL);
- /*
- With the component_setCallbacksSafe we register callbacks when a component is started / stopped using a component
- with type foo1_t*
- */
- component_setCallbacksSafe(cmp, foo2_t*, NULL, foo2_start, foo2_stop, NULL);
+ dm_service_dependency_pt dep = NULL;
+ serviceDependency_create(&dep);
+ serviceDependency_setRequired(dep, false);
+ serviceDependency_setService(dep, EXAMPLE_NAME, EXAMPLE_CONSUMER_RANGE, NULL);
+ serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND);
- dm_service_dependency_pt dep = NULL;
- serviceDependency_create(&dep);
- serviceDependency_setRequired(dep, false);
- serviceDependency_setService(dep, EXAMPLE_NAME, EXAMPLE_CONSUMER_RANGE, NULL);
- serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND);
+ /*
+ With the serviceDependency_setCallbacksSafe we register callbacks when a service
+ is added and about to be removed for the component type foo1_t* and service type example_t*.
- /*
- With the serviceDependency_setCallbacksSafe we register callbacks when a service
- is added and about to be removed for the component type foo1_t* and service type example_t*.
+ We should protect the usage of the
+ service because after removal of the service the memory location of that service
+ could be freed
+ */
+ serviceDependency_setCallbacksSafe(dep, foo2_t*, const example_t*, NULL, foo2_addExample, NULL,
+ foo2_removeExample, NULL);
+ component_addServiceDependency(cmp, dep);
- We should protect the usage of the
- service because after removal of the service the memory location of that service
- could be freed
- */
- serviceDependency_setCallbacksSafe(dep, foo2_t*, const example_t*, NULL, foo2_addExample, NULL, foo2_removeExample, NULL);
- component_addServiceDependency(cmp, dep);
+ dependencyManager_add(celix_bundleContext_getDependencyManager(ctx), cmp);
+ }
- dependencyManager_add(manager, cmp);
+ return status;
+}
- return status;
+static celix_status_t activator_stop(struct activator *act, celix_bundle_context_t *ctx) {
+ dependencyManager_removeAllComponents(celix_bundleContext_getDependencyManager(ctx));
+ foo2_destroy(act->foo);
+ return CELIX_SUCCESS;
}
-celix_status_t dm_destroy(void *userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator *activator = userData;
- foo2_destroy(activator->foo);
- free(activator);
- return status;
-};
+CELIX_GEN_BUNDLE_ACTIVATOR(struct activator, activator_start, activator_stop)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/3e5a6a79/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 b935271..cef384c 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
@@ -149,39 +149,24 @@ void * run(void *handle) {
return NULL;
}
-celix_status_t bundleActivator_create(celix_bundle_context_t *ctx, void **out) {
- celix_status_t status = CELIX_SUCCESS;
- activator_data_t *data = calloc(1, sizeof(*data));
+static celix_status_t activator_start(activator_data_t *data, celix_bundle_context_t *ctx) {
if (data != NULL) {
- data->ctx = ctx;
- data->trackCount = 0;
- data->running = true;
- pthread_mutex_init(&data->mutex, NULL);
- *out = data;
- } else {
- status = CELIX_ENOMEM;
- }
- return status;
-}
-
-celix_status_t bundleActivator_start(void * handle, celix_bundle_context_t *ctx) {
- activator_data_t *data = handle;
- pthread_create(&data->thread, NULL, run, data);
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_stop(void * handle, celix_bundle_context_t *ctx) {
- activator_data_t *data = handle;
- setRunning(data, false);
- pthread_join(data->thread, NULL);
+ data->ctx = ctx;
+ data->trackCount = 0;
+ data->running = true;
+ pthread_mutex_init(&data->mutex, NULL);
+ pthread_create(&data->thread, NULL, run, data);
+ }
return CELIX_SUCCESS;
}
-celix_status_t bundleActivator_destroy(void * handle, celix_bundle_context_t *ctx) {
- activator_data_t *data = handle;
+static celix_status_t activator_stop(activator_data_t *data, celix_bundle_context_t *ctx __attribute__((unused))) {
if (data != NULL) {
+ setRunning(data, false);
+ pthread_join(data->thread, NULL);
pthread_mutex_destroy(&data->mutex);
- free(data);
}
- return CELIX_SUCCESS;
+ 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/3e5a6a79/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 7a7d9d9..4756718 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
@@ -41,7 +41,7 @@ static int calc(void *handle __attribute__((unused)), int input) {
}
static bool isRunning(activator_data_t *data) {
- bool result = false;
+ bool result;
pthread_mutex_lock(&data->mutex);
result = data->running;
pthread_mutex_unlock(&data->mutex);
@@ -68,7 +68,7 @@ void * run(void *handle) {
data->svcIds[i++] = celix_bundleContext_registerService(data->ctx, &data->svc, EXAMPLE_CALC_NAME, props);
} else { //down
celix_bundleContext_unregisterService(data->ctx, data->svcIds[i]);
- data->svcIds[--i] = -1L;
+ data->svcIds[i--] = -1L;
}
if (i == 99) {
up = false;
@@ -89,45 +89,26 @@ void * run(void *handle) {
return NULL;
}
-celix_status_t bundleActivator_create(celix_bundle_context_t *ctx, void **out) {
- celix_status_t status = CELIX_SUCCESS;
- activator_data_t *data = calloc(1, sizeof(*data));
- if (data != NULL) {
- data->svc.handle = data;
- data->svc.calc = calc;
- data->ctx = ctx;
- data->running = true;
- pthread_mutex_init(&data->mutex, NULL);
-
- for (int i = 0; i < 100; ++i) {
- data->svcIds[i] = -1L;
- }
-
- *out = data;
- } else {
- status = CELIX_ENOMEM;
- }
- return status;
-}
+static celix_status_t activator_start(activator_data_t *data, celix_bundle_context_t *ctx) {
+ data->svc.handle = data;
+ data->svc.calc = calc;
+ data->ctx = ctx;
+ data->running = true;
+ pthread_mutex_init(&data->mutex, NULL);
+
+ for (int i = 0; i < 100; ++i) {
+ data->svcIds[i] = -1L;
+ }
-celix_status_t bundleActivator_start(void * handle, celix_bundle_context_t *ctx) {
- activator_data_t *data = handle;
pthread_create(&data->thread, NULL, run ,data);
return CELIX_SUCCESS;
}
-celix_status_t bundleActivator_stop(void * handle, celix_bundle_context_t *ctx) {
- activator_data_t *data = handle;
+static celix_status_t activator_stop(activator_data_t *data, celix_bundle_context_t *ctx __attribute__((unused))) {
setRunning(data, false);
pthread_join(data->thread, NULL);
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * handle, celix_bundle_context_t *ctx) {
- activator_data_t *data = handle;
- if (data != NULL) {
- pthread_mutex_destroy(&data->mutex);
- free(data);
- }
+ pthread_mutex_destroy(&data->mutex);
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/3e5a6a79/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 edf88c6..1204036 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
@@ -47,21 +47,9 @@ static void useCalc(activator_data_t *data __attribute__((unused)), example_calc
printf("Called highest ranking service. Result is %i\n", result);
}
-celix_status_t bundleActivator_create(celix_bundle_context_t *ctx, void **out) {
- celix_status_t status = CELIX_SUCCESS;
- activator_data_t *data = calloc(1, sizeof(*data));
- if (data != NULL) {
- data->ctx = ctx;
- data->trkId = -1L;
- *out = data;
- } else {
- status = CELIX_ENOMEM;
- }
- return status;
-}
-
-celix_status_t bundleActivator_start(void * handle, celix_bundle_context_t *ctx) {
- activator_data_t *data = handle;
+static celix_status_t activator_start(activator_data_t *data, celix_bundle_context_t *ctx) {
+ data->ctx = ctx;
+ data->trkId = -1L;
printf("Starting service tracker\n");
data->trkId = celix_bundleContext_trackServices(data->ctx, EXAMPLE_CALC_NAME, data, (void*)addSvc, (void*)removeSvc);
@@ -69,17 +57,12 @@ celix_status_t bundleActivator_start(void * handle, celix_bundle_context_t *ctx)
printf("Trying to use calc service\n");
celix_bundleContext_useService(data->ctx, EXAMPLE_CALC_NAME, data, (void*)useCalc);
- return CELIX_SUCCESS;
+ return CELIX_SUCCESS;
}
-celix_status_t bundleActivator_stop(void * handle, celix_bundle_context_t *ctx) {
- activator_data_t *data = handle;
+static celix_status_t activator_stop(activator_data_t *data, celix_bundle_context_t *ctx) {
celix_bundleContext_stopTracker(data->ctx, data->trkId);
return CELIX_SUCCESS;
}
-celix_status_t bundleActivator_destroy(void * handle, celix_bundle_context_t *ctx) {
- activator_data_t *data = handle;
- free(data);
- 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/3e5a6a79/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 3358903..486225a 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
@@ -25,7 +25,6 @@
#include "constants.h"
typedef struct activator_data {
- celix_bundle_context_t *ctx;
example_calc_t svc;
int seed;
long svcId;
@@ -36,38 +35,22 @@ static int calc(activator_data_t *data, int input) {
return data->seed * input;
}
-celix_status_t bundleActivator_create(celix_bundle_context_t *ctx, void **out) {
- celix_status_t status = CELIX_SUCCESS;
- activator_data_t *data = calloc(1, sizeof(*data));
- if (data != NULL) {
- data->svc.handle = data;
- data->svc.calc = (void*)calc;
- data->ctx = ctx;
- data->seed = 42;
- data->svcId = -1L;
- *out = data;
- } else {
- status = CELIX_ENOMEM;
- }
- return status;
-}
+static celix_status_t activator_start(activator_data_t *data, celix_bundle_context_t *ctx) {
+ data->svc.handle = data;
+ data->svc.calc = (void*)calc;
+ data->seed = 42;
+ data->svcId = -1L;
-celix_status_t bundleActivator_start(void * handle, celix_bundle_context_t *ctx) {
- activator_data_t *data = handle;
- data->svcId = celix_bundleContext_registerService(data->ctx, &data->svc, EXAMPLE_CALC_NAME, NULL);
+ data->svcId = celix_bundleContext_registerService(ctx, &data->svc, EXAMPLE_CALC_NAME, NULL);
printf("Registered calc service with service id %li\n", data->svcId);
- return CELIX_SUCCESS;
+
+ return CELIX_SUCCESS;
}
-celix_status_t bundleActivator_stop(void * handle, celix_bundle_context_t *ctx) {
- activator_data_t *data = handle;
- celix_bundleContext_unregisterService(data->ctx, data->svcId);
+static celix_status_t activator_stop(activator_data_t *data, celix_bundle_context_t *ctx) {
+ celix_bundleContext_unregisterService(ctx, data->svcId);
printf("Unregistered calc service with service id %li\n", data->svcId);
return CELIX_SUCCESS;
}
-celix_status_t bundleActivator_destroy(void * handle, celix_bundle_context_t *ctx) {
- activator_data_t *data = handle;
- free(data);
- 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/3e5a6a79/libs/framework/include/bundle_activator.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/bundle_activator.h b/libs/framework/include/bundle_activator.h
index 8c91957..3265f65 100644
--- a/libs/framework/include/bundle_activator.h
+++ b/libs/framework/include/bundle_activator.h
@@ -116,6 +116,45 @@ 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
[4/5] celix git commit: CELIX-446: Removes building osx with gcc from
travis config.
Posted by pn...@apache.org.
CELIX-446: Removes building osx with gcc from travis config.
This configuration is difficult to reproduce and gcc is covered under linux.
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/dfa9d1c7
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/dfa9d1c7
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/dfa9d1c7
Branch: refs/heads/feature/CELIX-426-cxx-api
Commit: dfa9d1c7ccdb6a55743a26607e5b90cf1288f4e4
Parents: 218d265
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Mon May 28 23:32:55 2018 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Mon May 28 23:32:55 2018 +0200
----------------------------------------------------------------------
.travis.yml | 4 ----
libs/utils/CMakeLists.txt | 3 +--
2 files changed, 1 insertion(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/dfa9d1c7/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index f8de607..3347221 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -26,10 +26,6 @@ matrix:
compiler: clang
- os: osx
osx_image: xcode7.3
- compiler: gcc
- env: MACOSX_DEPLOYMENT_TARGET=10.11
- - os: osx
- osx_image: xcode7.3
compiler: clang
env: MACOSX_DEPLOYMENT_TARGET=10.11
- os: linux
http://git-wip-us.apache.org/repos/asf/celix/blob/dfa9d1c7/libs/utils/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/libs/utils/CMakeLists.txt b/libs/utils/CMakeLists.txt
index 595eabd..7433446 100644
--- a/libs/utils/CMakeLists.txt
+++ b/libs/utils/CMakeLists.txt
@@ -69,8 +69,7 @@ celix_subproject(UTILS-TESTS "Option to build the utilities library tests" "OFF"
if (ENABLE_TESTING AND UTILS-TESTS)
find_package(CppUTest REQUIRED)
- include_directories(${CUNIT_INCLUDE_DIRS})
- include_directories(${CPPUTEST_INCLUDE_DIR})
+ include_directories(SYSTEM ${CPPUTEST_INCLUDE_DIR})
include_directories(include)
include_directories(src)
[3/5] celix git commit: CELIX-446: Refactor bundle activator struct
name to ensure it is unique
Posted by pn...@apache.org.
CELIX-446: Refactor bundle activator struct name to ensure it is unique
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/218d265c
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/218d265c
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/218d265c
Branch: refs/heads/feature/CELIX-426-cxx-api
Commit: 218d265c5082c1dafcdcb92863fed89da50f00ed
Parents: 3e5a6a7
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Mon May 28 16:08:29 2018 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Mon May 28 16:08:29 2018 +0200
----------------------------------------------------------------------
.../foo1/private/src/foo1_activator.c | 4 ++--
libs/framework/include/bundle.h | 7 +++++--
libs/framework/include/framework.h | 3 ---
libs/framework/private/mock/bundle_mock.c | 4 ++--
libs/framework/private/test/bundle_test.cpp | 6 +++---
libs/framework/src/bundle.c | 4 ++--
libs/framework/src/bundle_private.h | 4 +++-
libs/framework/src/framework.c | 11 +++++------
8 files changed, 22 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c b/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
index 6b2f578..61783ef 100644
--- a/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
+++ b/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
@@ -22,9 +22,9 @@
#include <stdlib.h>
-struct activator {
+typedef struct activator {
foo1_t *foo;
-};
+} activator_t;
static celix_status_t activator_start(activator_t *act, celix_bundle_context_t *ctx) {
celix_status_t status = CELIX_SUCCESS;
http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/libs/framework/include/bundle.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/bundle.h b/libs/framework/include/bundle.h
index b105615..1cd100a 100644
--- a/libs/framework/include/bundle.h
+++ b/libs/framework/include/bundle.h
@@ -44,6 +44,9 @@
extern "C" {
#endif
+struct celix_bundle_activator;
+typedef struct celix_bundle_activator celix_bundle_activator_t;
+
FRAMEWORK_EXPORT celix_status_t bundle_create(bundle_pt *bundle);
FRAMEWORK_EXPORT celix_status_t
@@ -63,9 +66,9 @@ FRAMEWORK_EXPORT void *bundle_getHandle(bundle_pt bundle);
FRAMEWORK_EXPORT void bundle_setHandle(bundle_pt bundle, void *handle);
-FRAMEWORK_EXPORT activator_pt bundle_getActivator(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_bundle_activator_t *bundle_getActivator(bundle_pt bundle);
-FRAMEWORK_EXPORT celix_status_t bundle_setActivator(bundle_pt bundle, activator_pt activator);
+FRAMEWORK_EXPORT celix_status_t bundle_setActivator(bundle_pt bundle, celix_bundle_activator_t *activator);
FRAMEWORK_EXPORT celix_status_t bundle_getContext(bundle_pt bundle, bundle_context_pt *context);
http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/libs/framework/include/framework.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/framework.h b/libs/framework/include/framework.h
index 5143f47..f02b784 100644
--- a/libs/framework/include/framework.h
+++ b/libs/framework/include/framework.h
@@ -27,9 +27,6 @@
#ifndef FRAMEWORK_H_
#define FRAMEWORK_H_
-typedef struct activator *activator_pt;
-typedef struct activator activator_t;
-
typedef struct framework *framework_pt;
typedef struct framework framework_t;
http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/libs/framework/private/mock/bundle_mock.c
----------------------------------------------------------------------
diff --git a/libs/framework/private/mock/bundle_mock.c b/libs/framework/private/mock/bundle_mock.c
index 8ab5068..c64a97b 100644
--- a/libs/framework/private/mock/bundle_mock.c
+++ b/libs/framework/private/mock/bundle_mock.c
@@ -81,12 +81,12 @@ void bundle_setHandle(bundle_pt bundle, void * handle) {
mock_c()->actualCall("bundle_setHandle");
}
-activator_pt bundle_getActivator(bundle_pt bundle) {
+celix_bundle_activator_t *bundle_getActivator(bundle_pt bundle) {
mock_c()->actualCall("bundle_getActivator");
return mock_c()->returnValue().value.pointerValue;
}
-celix_status_t bundle_setActivator(bundle_pt bundle, activator_pt activator) {
+celix_status_t bundle_setActivator(bundle_pt bundle, celix_bundle_activator_t *activator) {
mock_c()->actualCall("bundle_setActivator");
return mock_c()->returnValue().value.intValue;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/libs/framework/private/test/bundle_test.cpp
----------------------------------------------------------------------
diff --git a/libs/framework/private/test/bundle_test.cpp b/libs/framework/private/test/bundle_test.cpp
index 57ac1e2..f11b34d 100644
--- a/libs/framework/private/test/bundle_test.cpp
+++ b/libs/framework/private/test/bundle_test.cpp
@@ -258,10 +258,10 @@ TEST(bundle, setHandle) {
TEST(bundle, getActivator) {
bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
- activator_pt expected = (activator_pt) 0x10;
+ celix_bundle_activator_t *expected = (celix_bundle_activator_t*) 0x10;
bundle->activator = expected;
- activator_pt actual = bundle_getActivator(bundle);
+ celix_bundle_activator_t *actual = bundle_getActivator(bundle);
POINTERS_EQUAL(expected, actual);
free(bundle);
@@ -269,7 +269,7 @@ TEST(bundle, getActivator) {
TEST(bundle, setActivator) {
bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
- activator_pt expected = (activator_pt) 0x10;
+ celix_bundle_activator_t *expected = (celix_bundle_activator_t*) 0x10;
celix_status_t status = bundle_setActivator(bundle, expected);
LONGS_EQUAL(CELIX_SUCCESS, status);
http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/libs/framework/src/bundle.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/bundle.c b/libs/framework/src/bundle.c
index 6493c9f..bc6af4a 100644
--- a/libs/framework/src/bundle.c
+++ b/libs/framework/src/bundle.c
@@ -157,11 +157,11 @@ void bundle_setHandle(bundle_pt bundle, void * handle) {
bundle->handle = handle;
}
-activator_pt bundle_getActivator(bundle_pt bundle) {
+celix_bundle_activator_t* bundle_getActivator(bundle_pt bundle) {
return bundle->activator;
}
-celix_status_t bundle_setActivator(bundle_pt bundle, activator_pt activator) {
+celix_status_t bundle_setActivator(bundle_pt bundle, celix_bundle_activator_t *activator) {
bundle->activator = activator;
return CELIX_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/libs/framework/src/bundle_private.h
----------------------------------------------------------------------
diff --git a/libs/framework/src/bundle_private.h b/libs/framework/src/bundle_private.h
index ea0a06e..1c295c3 100644
--- a/libs/framework/src/bundle_private.h
+++ b/libs/framework/src/bundle_private.h
@@ -24,9 +24,11 @@
#include "bundle.h"
#include "celix_bundle.h"
+
+
struct bundle {
bundle_context_pt context;
- activator_pt activator;
+ struct celix_bundle_activator *activator;
bundle_state_e state;
void * handle;
bundle_archive_pt archive;
http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/libs/framework/src/framework.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c
index 8cbe183..c28153a 100644
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@ -49,7 +49,7 @@ typedef celix_status_t (*start_function_fp)(void *userData, bundle_context_t *co
typedef celix_status_t (*stop_function_fp)(void *userData, bundle_context_t *context);
typedef celix_status_t (*destroy_function_fp)(void *userData, bundle_context_t *context);
-struct activator {
+struct celix_bundle_activator {
void * userData;
create_function_fp create;
@@ -454,8 +454,7 @@ celix_status_t fw_init(framework_pt framework) {
status = CELIX_DO_IF(status, bundleContext_create(framework, framework->logger, framework->bundle, &context));
status = CELIX_DO_IF(status, bundle_setContext(framework->bundle, context));
if (status == CELIX_SUCCESS) {
- activator_pt activator = NULL;
- activator = (activator_pt) calloc(1,(sizeof(*activator)));
+ celix_bundle_activator_t *activator = calloc(1,(sizeof(*activator)));
if (activator != NULL) {
bundle_context_t *context = NULL;
void * userData = NULL;
@@ -727,7 +726,7 @@ celix_status_t fw_startBundle(framework_pt framework, bundle_pt bundle, int opti
bundle_context_t *context = NULL;
bundle_state_e state;
module_pt module = NULL;
- activator_pt activator = NULL;
+ celix_bundle_activator_t *activator = NULL;
char *error = NULL;
const char *name = NULL;
@@ -776,7 +775,7 @@ celix_status_t fw_startBundle(framework_pt framework, bundle_pt bundle, int opti
status = CELIX_DO_IF(status, bundle_setContext(bundle, context));
if (status == CELIX_SUCCESS) {
- activator = (activator_pt) calloc(1,(sizeof(*activator)));
+ activator = calloc(1,(sizeof(*activator)));
if (activator == NULL) {
status = CELIX_ENOMEM;
} else {
@@ -921,7 +920,7 @@ celix_status_t framework_updateBundle(framework_pt framework, bundle_pt bundle,
celix_status_t fw_stopBundle(framework_pt framework, bundle_pt bundle, bool record) {
celix_status_t status = CELIX_SUCCESS;
bundle_state_e state;
- activator_pt activator = NULL;
+ celix_bundle_activator_t *activator = NULL;
bundle_context_t *context = NULL;
bool wasActive = false;
long id = 0;
[5/5] 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/be6612f0
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/be6612f0
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/be6612f0
Branch: refs/heads/feature/CELIX-426-cxx-api
Commit: be6612f0f259cf080fe5ca1f6fbbfa9bb61a502c
Parents: e633316 dfa9d1c
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Tue May 29 19:32:57 2018 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Tue May 29 19:32:57 2018 +0200
----------------------------------------------------------------------
.travis.yml | 4 -
.../examples/mp_pubsub/publisher/CMakeLists.txt | 10 +-
.../mp_pubsub/subscriber/CMakeLists.txt | 10 +-
.../examples/pubsub/publisher/CMakeLists.txt | 12 +-
.../examples/pubsub/publisher2/CMakeLists.txt | 12 +-
.../examples/pubsub/subscriber/CMakeLists.txt | 12 +-
.../best_practice_example_c/bar/CMakeLists.txt | 13 +-
.../bar/private/src/bar_activator.c | 53 +-
.../best_practice_example_c/foo1/CMakeLists.txt | 13 +-
.../foo1/private/src/foo1_activator.c | 87 +-
.../best_practice_example_c/foo2/CMakeLists.txt | 13 +-
.../foo2/private/src/foo2_activator.c | 83 +-
.../src/dynamic_consumer_example.c | 41 +-
.../src/dynamic_provider_example.c | 51 +-
.../src/simple_consumer_example.c | 29 +-
.../src/simple_provider_example.c | 39 +-
libs/framework/include/bundle.h | 7 +-
libs/framework/include/bundle_activator.h | 39 +
libs/framework/include/framework.h | 5 +-
libs/framework/private/mock/bundle_mock.c | 4 +-
libs/framework/private/test/bundle_test.cpp | 6 +-
libs/framework/src/bundle.c | 4 +-
libs/framework/src/bundle.c.orig | 779 -----
libs/framework/src/bundle_context.c.orig | 963 ------
libs/framework/src/bundle_private.h | 4 +-
libs/framework/src/framework.c | 43 +-
libs/framework/src/framework.c.orig | 2829 ------------------
libs/utils/CMakeLists.txt | 1 -
libs/utils/CMakeLists.txt.orig | 129 -
utils/include/celix_exports.h | 25 -
30 files changed, 244 insertions(+), 5076 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/be6612f0/libs/framework/include/bundle.h
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/be6612f0/libs/framework/include/framework.h
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/be6612f0/libs/framework/private/mock/bundle_mock.c
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/be6612f0/libs/framework/src/bundle.c
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/be6612f0/libs/framework/src/framework.c
----------------------------------------------------------------------
diff --cc libs/framework/src/framework.c
index a98be36,c28153a..b0a0a67
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@@ -49,9 -49,9 +49,9 @@@ typedef celix_status_t (*start_function
typedef celix_status_t (*stop_function_fp)(void *userData, bundle_context_t *context);
typedef celix_status_t (*destroy_function_fp)(void *userData, bundle_context_t *context);
- struct activator {
+ struct celix_bundle_activator {
void * userData;
-
+
create_function_fp create;
start_function_fp start;
stop_function_fp stop;
@@@ -774,9 -773,9 +773,9 @@@ celix_status_t fw_startBundle(framework
module_getSymbolicName(module, &name);
status = CELIX_DO_IF(status, bundleContext_create(framework, framework->logger, bundle, &context));
status = CELIX_DO_IF(status, bundle_setContext(bundle, context));
-
+
if (status == CELIX_SUCCESS) {
- activator = (activator_pt) calloc(1,(sizeof(*activator)));
+ activator = calloc(1,(sizeof(*activator)));
if (activator == NULL) {
status = CELIX_ENOMEM;
} else {