CELIX-438: Add a dependency manager API with the celix prefix. Also add a compile options to enable deprecated compiler warning for the 'old' api.
Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/2492416e Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/2492416e Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/2492416e Branch: refs/heads/develop Commit: 2492416e3d61d97d73e0673722ce6bc7ed39d0b7 Parents: 3526100 Author: Pepijn Noltes <[email protected]> Authored: Mon Nov 26 20:57:46 2018 +0100 Committer: Pepijn Noltes <[email protected]> Committed: Mon Nov 26 20:57:46 2018 +0100 ---------------------------------------------------------------------- .../log_service/loghelper_include/log_helper.h | 2 +- .../discovery_common/src/discovery_activator.c | 2 +- bundles/shell/shell/include/shell.h | 2 +- bundles/shell/shell/src/dm_shell_list_command.c | 115 +++--- cmake/cmake_celix/DockerPackaging.cmake | 2 +- examples/celix-examples/CMakeLists.txt | 2 + .../bar/private/src/bar_activator.c | 13 +- .../foo1/private/src/foo1_activator.c | 28 +- .../foo2/private/src/foo2.c | 2 +- .../foo2/private/src/foo2_activator.c | 30 +- .../civetweb/src/bundle_activator.c | 2 +- .../celix-examples/dm_example/CMakeLists.txt | 1 - .../dm_example/phase1/src/phase1_activator.c | 47 +-- .../dm_example/phase1/src/phase1_cmp.c | 6 +- .../dm_example/phase1/src/phase1_cmp.h | 2 +- .../dm_example/phase2a/src/phase2a_activator.c | 59 ++- .../dm_example/phase2b/src/phase2b_activator.c | 60 ++- .../dm_example/phase3/src/phase3_activator.c | 62 ++-- .../dm_example/phase3/src/phase3_cmp.c | 2 +- .../phase1/src/Phase1Activator.cc | 8 +- .../dm_example_cxx/phase1/src/Phase1Activator.h | 1 - .../celix-examples/embedding/private/src/main.c | 8 +- .../hello_world/private/src/activator.c | 8 +- .../hello_world_test/private/src/activator.c | 8 +- .../log_service_example/src/activator.c | 8 +- .../service_hook_example/src/activator.c | 12 +- .../src/dynamic_provider_example.c | 2 +- libs/dependency_manager_cxx/src/dm_activator.cc | 18 +- libs/framework/include/bundle.h | 76 ++-- libs/framework/include/bundle_activator.h | 16 +- libs/framework/include/bundle_context.h | 54 +-- libs/framework/include/bundle_revision.h | 4 +- libs/framework/include/celix/dm/Component.h | 20 +- .../framework/include/celix/dm/Component_Impl.h | 26 +- .../include/celix/dm/DependencyManager.h | 16 +- libs/framework/include/celix/dm/DmActivator.h | 14 +- .../include/celix/dm/ServiceDependency.h | 16 +- .../include/celix/dm/ServiceDependency_Impl.h | 83 ++--- libs/framework/include/celix_api.h | 3 +- libs/framework/include/celix_bundle_context.h | 2 +- .../include/celix_dependency_manager.h | 86 +++++ libs/framework/include/celix_dm_component.h | 154 ++++++++ libs/framework/include/celix_dm_info.h | 76 ++++ .../include/celix_dm_service_dependency.h | 169 +++++++++ libs/framework/include/celix_framework.h | 2 - .../framework/include/celix_framework_factory.h | 2 +- libs/framework/include/celix_launcher.h | 14 +- libs/framework/include/celix_types.h | 50 ++- libs/framework/include/dm_activator.h | 12 +- libs/framework/include/dm_component.h | 52 ++- libs/framework/include/dm_dependency_manager.h | 18 +- libs/framework/include/dm_info.h | 76 ---- libs/framework/include/dm_service_dependency.h | 36 +- libs/framework/include/framework.h | 17 +- libs/framework/include/listener_hook_service.h | 6 +- libs/framework/include/manifest.h | 4 +- libs/framework/include/module.h | 12 +- libs/framework/include/service_reference.h | 6 +- libs/framework/include/service_registration.h | 4 +- libs/framework/include/service_registry.h | 40 +- libs/framework/include/service_tracker.h | 12 +- .../private/mock/dm_dependency_manager_mock.c | 24 +- libs/framework/src/bundle_context.c | 13 +- libs/framework/src/bundle_context_private.h | 8 +- libs/framework/src/bundle_private.h | 4 +- libs/framework/src/dm_component_impl.c | 361 +++++++++++-------- libs/framework/src/dm_component_impl.h | 6 +- libs/framework/src/dm_dependency_manager_impl.c | 204 ++++++++--- libs/framework/src/dm_dependency_manager_impl.h | 21 +- libs/framework/src/dm_service_dependency.c | 299 +++++++++------ libs/framework/src/dm_service_dependency_impl.h | 63 ++-- libs/framework/src/framework.c | 5 +- libs/framework/src/framework_private.h | 4 +- libs/framework/src/module.c | 2 +- libs/utils/include/array_list.h | 67 ++-- libs/utils/include/celix_array_list.h | 17 +- libs/utils/include/filter.h | 2 +- libs/utils/include/properties.h | 35 +- libs/utils/private/test/filter_test.cpp | 2 +- libs/utils/src/array_list_private.h | 4 +- libs/utils/src/filter.c | 79 ++-- 81 files changed, 1744 insertions(+), 1166 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/bundles/log_service/loghelper_include/log_helper.h ---------------------------------------------------------------------- diff --git a/bundles/log_service/loghelper_include/log_helper.h b/bundles/log_service/loghelper_include/log_helper.h index 2ae9d83..5af5d77 100644 --- a/bundles/log_service/loghelper_include/log_helper.h +++ b/bundles/log_service/loghelper_include/log_helper.h @@ -27,7 +27,7 @@ typedef struct log_helper log_helper_t; typedef struct log_helper* log_helper_pt; -celix_status_t logHelper_create(bundle_context_pt context, log_helper_pt* log_helper); +celix_status_t logHelper_create(celix_bundle_context_t *context, log_helper_pt* log_helper); celix_status_t logHelper_start(log_helper_pt loghelper); celix_status_t logHelper_stop(log_helper_pt loghelper); celix_status_t logHelper_destroy(log_helper_pt* loghelper); http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/bundles/remote_services/discovery_common/src/discovery_activator.c ---------------------------------------------------------------------- diff --git a/bundles/remote_services/discovery_common/src/discovery_activator.c b/bundles/remote_services/discovery_common/src/discovery_activator.c index 3267d25..30a40b3 100644 --- a/bundles/remote_services/discovery_common/src/discovery_activator.c +++ b/bundles/remote_services/discovery_common/src/discovery_activator.c @@ -62,7 +62,7 @@ celix_status_t bundleActivator_createEPLTracker(struct activator *activator, ser return status; } -celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) { +celix_status_t bundleActivator_create(celix_bundle_context_t *context, void **userData) { celix_status_t status; struct activator* activator = calloc(1,sizeof(struct activator)); http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/bundles/shell/shell/include/shell.h ---------------------------------------------------------------------- diff --git a/bundles/shell/shell/include/shell.h b/bundles/shell/shell/include/shell.h index c8e7d60..42c2cdb 100644 --- a/bundles/shell/shell/include/shell.h +++ b/bundles/shell/shell/include/shell.h @@ -38,7 +38,7 @@ typedef shell_t* shell_pt; struct shellService { shell_pt shell; - celix_status_t (*getCommands)(shell_pt shell_ptr, array_list_pt *commands_ptr); + celix_status_t (*getCommands)(shell_pt shell_ptr, celix_array_list_t **commands_ptr); celix_status_t (*getCommandUsage)(shell_pt shell_ptr, char *command_name_str, char **usage_str); celix_status_t (*getCommandDescription)(shell_pt shell_ptr, char *command_name_str, char **command_description_str); celix_status_t (*getCommandReference)(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr); http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/bundles/shell/shell/src/dm_shell_list_command.c ---------------------------------------------------------------------- diff --git a/bundles/shell/shell/src/dm_shell_list_command.c b/bundles/shell/shell/src/dm_shell_list_command.c index aeb7afd..192f875 100644 --- a/bundles/shell/shell/src/dm_shell_list_command.c +++ b/bundles/shell/shell/src/dm_shell_list_command.c @@ -21,7 +21,7 @@ #include <string.h> #include <shell_constants.h> #include "celix_bundle_context.h" -#include "dm_dependency_manager.h" +#include "celix_dependency_manager.h" static const char * const OK_COLOR = "\033[92m"; @@ -29,21 +29,19 @@ static const char * const WARNING_COLOR = "\033[93m"; static const char * const NOK_COLOR = "\033[91m"; static const char * const END_COLOR = "\033[m"; -static void parseCommandLine(const char*line, array_list_pt *requestedBundleIds, bool *fullInfo, FILE *err) { +static void parseCommandLine(const char*line, celix_array_list_t **requestedBundleIds, bool *fullInfo, FILE *err) { *fullInfo = false; char *str = strdup(line); // skip first argument since this is the command strtok(str," "); char* tok = strtok(NULL," "); - *requestedBundleIds = NULL; - arrayList_create(requestedBundleIds); + *requestedBundleIds = celix_arrayList_create(); while (tok) { if (tok[0] == 'f') { // f or full argument => show full info *fullInfo = true; } else if ( (tok[0] >= '0') && (tok[0] <= '9')) { // bundle id - long *id = malloc(sizeof(*id)); - *id = strtol(tok, NULL, 10); - arrayList_add(*requestedBundleIds, id); + long id = strtol(tok, NULL, 10); + celix_arrayList_addLong(*requestedBundleIds, id); } else { fprintf (err, "DM: Skipping unknown argument: %s", tok ); } @@ -52,34 +50,6 @@ static void parseCommandLine(const char*line, array_list_pt *requestedBundleIds, free (str); } -static void destroyBundleIdList(array_list_pt ids) { - unsigned int size = arrayList_size(ids); - for (unsigned int i = 0; i < size; i++) { - free(arrayList_get(ids, i)); - } - arrayList_destroy(ids); -} - -/* - * Check if the ID is in the array list. If arrayist is empty also true is returned so that all - * bundles are shown - */ -static bool is_bundleId_in_list(array_list_pt ids, long id) { - unsigned int size = arrayList_size(ids); - bool result = false; - if (size == 0) { - result = true; - } - for(unsigned int i = 0; i < size; ++i) { - if (*((long*)arrayList_get(ids, i)) == id) { - result = true; - break; - } - } - return result; -} - - static void printFullInfo(FILE *out, bool colors, dm_component_info_pt compInfo) { const char *startColors = ""; const char *endColors = ""; @@ -136,58 +106,55 @@ static void printBasicInfo(FILE *out, bool colors, dm_component_info_pt compInfo } -celix_status_t dmListCommand_execute(void* handle, char * line, FILE *out, FILE *err) { - bundle_context_t *ctx = handle; +static void dm_printInfo(FILE *out, bool useColors, bool fullInfo, celix_dependency_manager_info_t *info) { + if (info != NULL) { + int size = celix_arrayList_size(info->components); + if (size > 0) { + fprintf(out, "[Bundle: %ld]\n", info->bndId); + for (unsigned int cmpCnt = 0; cmpCnt < size; cmpCnt++) { + dm_component_info_pt compInfo = celix_arrayList_get(info->components, cmpCnt); + if (fullInfo) { + printFullInfo(out, useColors, compInfo); + } else { + printBasicInfo(out, useColors, compInfo); + } + } + fprintf(out, "\n"); + } + } +} - array_list_t *bundles = NULL; - bundleContext_getBundles(ctx, &bundles); +celix_status_t dmListCommand_execute(void* handle, char * line, FILE *out, FILE *err) { + celix_bundle_context_t *ctx = handle; + celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx); const char *config = NULL; bundleContext_getPropertyWithDefault(ctx, SHELL_USE_ANSI_COLORS, SHELL_USE_ANSI_COLORS_DEFAULT_VALUE, &config); bool useColors = config != NULL && strncmp("true", config, 5) == 0; - array_list_pt bundleIds = NULL; + celix_array_list_t *bundleIds = NULL; bool fullInfo = false; parseCommandLine(line, &bundleIds, &fullInfo, err); - if (bundles != NULL) { - unsigned int size = arrayList_size(bundles); - for (unsigned int i = 0; i < size; ++i) { - long bndId = -1; - bundle_t *bnd = arrayList_get(bundles, i); - bundle_getBundleId(bnd, &bndId); - if (!is_bundleId_in_list(bundleIds, bndId)) { - continue; - } - bundle_context_t *bndCtx = NULL; - bundle_getContext(bnd, &bndCtx); - if (bndCtx != NULL) { - dm_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(bndCtx); - dm_dependency_manager_info_t *info = NULL; - dependencyManager_getInfo(mng, &info); - if (info != NULL) { - size_t size = celix_arrayList_size(info->components); - if (size > 0) { - fprintf(out, "[Bundle: %ld]\n", bndId); - for (unsigned int cmpCnt = 0; cmpCnt < size; cmpCnt++) { - dm_component_info_pt compInfo = celix_arrayList_get(info->components, cmpCnt); - if (fullInfo) { - printFullInfo(out, useColors, compInfo); - } else { - printBasicInfo(out, useColors, compInfo); - } - } - fprintf(out, "\n"); - } - dependencyManager_destroyInfo(mng, info); - } - + if (celix_arrayList_size(bundleIds) == 0) { + celix_array_list_t *infos = celix_dependencyManager_createInfos(mng); + for (int i = 0; i < celix_arrayList_size(infos); ++i) { + celix_dependency_manager_info_t *info = celix_arrayList_get(infos, i); + dm_printInfo(out, useColors, fullInfo, info); + } + celix_dependencyManager_destroyInfos(mng, infos); + } else { + for (int i = 0; i < celix_arrayList_size(bundleIds); ++i) { + long bndId = celix_arrayList_getLong(bundleIds, i); + celix_dependency_manager_info_t *info = celix_dependencyManager_createInfo(mng, bndId); + if (info != NULL) { + dm_printInfo(out, useColors, fullInfo, info); + celix_dependencyManager_destroyInfo(mng, info); } } - arrayList_destroy(bundles); } - destroyBundleIdList(bundleIds); + celix_arrayList_destroy(bundleIds); return CELIX_SUCCESS; } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/cmake/cmake_celix/DockerPackaging.cmake ---------------------------------------------------------------------- diff --git a/cmake/cmake_celix/DockerPackaging.cmake b/cmake/cmake_celix/DockerPackaging.cmake index cdc46c9..8556917 100644 --- a/cmake/cmake_celix/DockerPackaging.cmake +++ b/cmake/cmake_celix/DockerPackaging.cmake @@ -111,7 +111,7 @@ int main(int argc, char *argv[]) { $<JOIN:$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_EMBEDDED_PROPERTIES>,\\n\\ >\"; - properties_pt packedConfig = properties_loadFromString(config); + celix_properties_t *packedConfig = properties_loadFromString(config); return celixLauncher_launchAndWaitForShutdown(argc, argv, packedConfig); } " http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/celix-examples/CMakeLists.txt b/examples/celix-examples/CMakeLists.txt index 86ed757..e7ce308 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_compile_definitions(ADD_CELIX_DEPRECATED_WARNING) #ensure that no deprecated api is used in the examples + add_subdirectory(bundle_example_c) add_subdirectory(hello_world) http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/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 39d0164..25e82b0 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 @@ -17,7 +17,7 @@ *under the License. */ -#include "dm_activator.h" +#include "celix_api.h" #include "bar.h" #include <stdlib.h> @@ -35,17 +35,16 @@ static celix_status_t activator_start(activator_t *act, celix_bundle_context_t * 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); + celix_dm_component_t *cmp = celix_dmComponent_create(ctx, "BAR"); + celix_dmComponent_setImplementation(cmp, act->bar); + celix_dmComponent_addInterface(cmp, EXAMPLE_NAME, EXAMPLE_VERSION, &act->exampleService, NULL); + celix_dependencyManager_add(celix_bundleContext_getDependencyManager(ctx), cmp); } return status; } static celix_status_t activator_stop(activator_t *act, celix_bundle_context_t *ctx) { - dependencyManager_removeAllComponents(celix_bundleContext_getDependencyManager(ctx)); + celix_dependencyManager_removeAllComponents(celix_bundleContext_getDependencyManager(ctx)); bar_destroy(act->bar); return CELIX_SUCCESS; } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/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 61783ef..4098117 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 @@ -17,7 +17,7 @@ *under the License. */ -#include "dm_activator.h" +#include "celix_api.h" #include "foo1.h" #include <stdlib.h> @@ -32,21 +32,19 @@ static celix_status_t activator_start(activator_t *act, celix_bundle_context_t * if (act->foo == NULL) { status = CELIX_ENOMEM; } else { - dm_component_pt cmp = NULL; - component_create(ctx, "FOO1", &cmp); - component_setImplementation(cmp, act->foo); + celix_dm_component_t *cmp = celix_dmComponent_create(ctx, "FOO1"); + celix_dmComponent_setImplementation(cmp, act->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); + CELIX_DMCOMPONENT_SETCALLBACKS(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); + celix_dm_service_dependency_t *dep = celix_dmServiceDependency_create(); + celix_dmServiceDependency_setRequired(dep, true); + celix_dmServiceDependency_setService(dep, EXAMPLE_NAME, EXAMPLE_CONSUMER_RANGE, NULL); + celix_dmServiceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING); /* With the serviceDependency_setCallbacksSafe we register callbacks when a service @@ -56,17 +54,19 @@ static celix_status_t activator_start(activator_t *act, celix_bundle_context_t * 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); + celix_dm_service_dependency_callback_options_t opts = CELIX_EMPTY_DM_SERVICE_DEPENDENCY_CALLBACK_OPTIONS; + opts.set = (void*)foo1_setExample; + celix_dmServiceDependency_setCallbacksWithOptions(dep, &opts); + celix_dmComponent_addServiceDependency(cmp, dep); - dependencyManager_add(celix_bundleContext_getDependencyManager(ctx), cmp); + celix_dependencyManager_add(celix_bundleContext_getDependencyManager(ctx), cmp); } return status; } static celix_status_t activator_stop(activator_t *act, celix_bundle_context_t *ctx) { - dependencyManager_removeAllComponents(celix_bundleContext_getDependencyManager(ctx)); + celix_dependencyManager_removeAllComponents(celix_bundleContext_getDependencyManager(ctx)); foo1_destroy(act->foo); return CELIX_SUCCESS; } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2.c ---------------------------------------------------------------------- diff --git a/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2.c b/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2.c index b98e20b..4a1482c 100644 --- a/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2.c +++ b/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2.c @@ -37,7 +37,7 @@ static void* foo2_thread(void*); struct foo2_struct { - array_list_pt examples; + celix_array_list_t *examples; pthread_t thread; bool running; }; http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/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 309b8c1..9765e35 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 @@ -17,7 +17,7 @@ *under the License. */ -#include "dm_activator.h" +#include "celix_api.h" #include "foo2.h" #include <stdlib.h> @@ -33,21 +33,19 @@ static celix_status_t activator_start(struct activator *act, celix_bundle_contex status = CELIX_ENOMEM; } else { - dm_component_pt cmp = NULL; - component_create(ctx, "FOO2", &cmp); - component_setImplementation(cmp, act->foo); + celix_dm_component_t *cmp = celix_dmComponent_create(ctx, "FOO2"); + celix_dmComponent_setImplementation(cmp, act->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); + CELIX_DMCOMPONENT_SETCALLBACKS(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); + celix_dm_service_dependency_t *dep = celix_dmServiceDependency_create(); + celix_dmServiceDependency_setRequired(dep, false); + celix_dmServiceDependency_setService(dep, EXAMPLE_NAME, EXAMPLE_CONSUMER_RANGE, NULL); + celix_dmServiceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND); /* With the serviceDependency_setCallbacksSafe we register callbacks when a service @@ -57,18 +55,20 @@ static celix_status_t activator_start(struct activator *act, celix_bundle_contex 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); + celix_dm_service_dependency_callback_options_t opts = CELIX_EMPTY_DM_SERVICE_DEPENDENCY_CALLBACK_OPTIONS; + opts.add = (void*)foo2_addExample; + opts.remove = (void*)foo2_removeExample; + celix_dmServiceDependency_setCallbacksWithOptions(dep, &opts); + celix_dmComponent_addServiceDependency(cmp, dep); - dependencyManager_add(celix_bundleContext_getDependencyManager(ctx), cmp); + celix_dependencyManager_add(celix_bundleContext_getDependencyManager(ctx), cmp); } return status; } static celix_status_t activator_stop(struct activator *act, celix_bundle_context_t *ctx) { - dependencyManager_removeAllComponents(celix_bundleContext_getDependencyManager(ctx)); + celix_dependencyManager_removeAllComponents(celix_bundleContext_getDependencyManager(ctx)); foo2_destroy(act->foo); return CELIX_SUCCESS; } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/civetweb/src/bundle_activator.c ---------------------------------------------------------------------- diff --git a/examples/celix-examples/civetweb/src/bundle_activator.c b/examples/celix-examples/civetweb/src/bundle_activator.c index 17892fb..3dcd490 100644 --- a/examples/celix-examples/civetweb/src/bundle_activator.c +++ b/examples/celix-examples/civetweb/src/bundle_activator.c @@ -74,7 +74,7 @@ static int websocket_data_handler(struct mg_connection *conn, int bits, char *da static celix_status_t activator_start(activator_data_t *data, celix_bundle_context_t *ctx) { data->ctx = ctx; - bundle_t *bnd = celix_bundleContext_getBundle(ctx); + celix_bundle_t *bnd = celix_bundleContext_getBundle(ctx); data->root = celix_bundle_getEntry(bnd, "resources"); const char *options[] = { http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/celix-examples/dm_example/CMakeLists.txt b/examples/celix-examples/dm_example/CMakeLists.txt index 581a17c..a3986f8 100644 --- a/examples/celix-examples/dm_example/CMakeLists.txt +++ b/examples/celix-examples/dm_example/CMakeLists.txt @@ -22,7 +22,6 @@ add_subdirectory(phase2a) add_subdirectory(phase2b) add_subdirectory(phase3) - add_celix_container(dm_example COPY BUNDLES http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/phase1/src/phase1_activator.c ---------------------------------------------------------------------- diff --git a/examples/celix-examples/dm_example/phase1/src/phase1_activator.c b/examples/celix-examples/dm_example/phase1/src/phase1_activator.c index 31dcb16..985002a 100644 --- a/examples/celix-examples/dm_example/phase1/src/phase1_activator.c +++ b/examples/celix-examples/dm_example/phase1/src/phase1_activator.c @@ -26,8 +26,7 @@ #include <stdlib.h> #include <phase1_cmp.h> -#include "bundle_activator.h" -#include "dm_activator.h" +#include "celix_api.h" #include "phase1.h" @@ -36,51 +35,41 @@ struct phase1_activator_struct { phase1_t phase1Serv; }; -celix_status_t dm_create(bundle_context_pt context, void **userData) { - printf("PHASE1: dm_create\n"); - *userData = calloc(1, sizeof(struct phase1_activator_struct)); - return *userData != NULL ? CELIX_SUCCESS : CELIX_ENOMEM; -} - -celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("PHASE1: dm_init\n"); - celix_status_t status = CELIX_SUCCESS; - - - struct phase1_activator_struct *act = (struct phase1_activator_struct *)userData; - +static celix_status_t start(struct phase1_activator_struct *act, celix_bundle_context_t *ctx) { + celix_status_t status = CELIX_SUCCESS; + printf("PHASE1: start\n"); act->phase1Cmp = phase1_create(); if (act->phase1Cmp != NULL) { act->phase1Serv.handle = act->phase1Cmp; act->phase1Serv.getData = (void *)phase1_getData; - properties_pt props = properties_create(); + celix_properties_t *props = properties_create(); properties_set(props, "id", "phase1"); - dm_component_pt cmp; - component_create(context, "PHASE1_PROCESSING_COMPONENT", &cmp); - component_setImplementation(cmp, act->phase1Cmp); - component_setCallbacksSafe(cmp, phase1_cmp_t *, phase1_init, phase1_start, phase1_stop, phase1_deinit); + celix_dm_component_t *cmp= celix_dmComponent_create(ctx, "PHASE1_PROCESSING_COMPONENT"); + celix_dmComponent_setImplementation(cmp, act->phase1Cmp); + CELIX_DMCOMPONENT_SETCALLBACKS(cmp, phase1_cmp_t *, phase1_init, phase1_start, phase1_stop, phase1_deinit); phase1_setComp(act->phase1Cmp, cmp); - component_addInterface(cmp, PHASE1_NAME, PHASE1_VERSION, &act->phase1Serv, props); + celix_dmComponent_addInterface(cmp, PHASE1_NAME, PHASE1_VERSION, &act->phase1Serv, props); - dependencyManager_add(manager, cmp); + celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx); + celix_dependencyManager_add(mng, cmp); } else { status = CELIX_ENOMEM; } - - return status; + return status; } -celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("PHASE1: dm-destroy\n"); - - struct phase1_activator_struct *act = (struct phase1_activator_struct *)userData; +static celix_status_t stop(struct phase1_activator_struct *act, celix_bundle_context_t *ctx) { + printf("PHASE1: stop\n"); + celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx); + celix_dependencyManager_removeAllComponents(mng); if (act->phase1Cmp != NULL) { phase1_destroy(act->phase1Cmp); } - free(act); return CELIX_SUCCESS; } + +CELIX_GEN_BUNDLE_ACTIVATOR(struct phase1_activator_struct, start, stop); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/phase1/src/phase1_cmp.c ---------------------------------------------------------------------- diff --git a/examples/celix-examples/dm_example/phase1/src/phase1_cmp.c b/examples/celix-examples/dm_example/phase1/src/phase1_cmp.c index 40da821..e27dcb7 100644 --- a/examples/celix-examples/dm_example/phase1/src/phase1_cmp.c +++ b/examples/celix-examples/dm_example/phase1/src/phase1_cmp.c @@ -39,7 +39,7 @@ struct phase1_cmp_struct { celix_thread_t thread; bool running; unsigned int counter; - dm_component_pt component; + celix_dm_component_t *component; }; @@ -54,7 +54,7 @@ phase1_cmp_t *phase1_create(void) { return cmp; } -void phase1_setComp(phase1_cmp_t *cmp, dm_component_pt dmCmp) { +void phase1_setComp(phase1_cmp_t *cmp, celix_dm_component_t *dmCmp) { cmp->component = dmCmp; } @@ -95,7 +95,7 @@ static void *phase1_thread(void *data) { cmp->counter += 1; if (cmp->counter == 2) { static char *runtime_interface = "DUMMY INTERFACE: DO NOT USE\n"; - component_addInterface(cmp->component, "RUNTIME_ADDED_INTERFACE", "1.0.0", runtime_interface, NULL); + celix_dmComponent_addInterface(cmp->component, "RUNTIME_ADDED_INTERFACE", "1.0.0", runtime_interface, NULL); } usleep(SLEEPTIME); } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/phase1/src/phase1_cmp.h ---------------------------------------------------------------------- diff --git a/examples/celix-examples/dm_example/phase1/src/phase1_cmp.h b/examples/celix-examples/dm_example/phase1/src/phase1_cmp.h index 153eed1..002ece8 100644 --- a/examples/celix-examples/dm_example/phase1/src/phase1_cmp.h +++ b/examples/celix-examples/dm_example/phase1/src/phase1_cmp.h @@ -31,7 +31,7 @@ typedef struct phase1_cmp_struct phase1_cmp_t; phase1_cmp_t *phase1_create(void); -void phase1_setComp(phase1_cmp_t *cmp, dm_component_pt dmCmp); +void phase1_setComp(phase1_cmp_t *cmp, celix_dm_component_t *dmCmp); int phase1_init(phase1_cmp_t *cmp); int phase1_start(phase1_cmp_t *cmp); int phase1_stop(phase1_cmp_t *cmp); http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/phase2a/src/phase2a_activator.c ---------------------------------------------------------------------- diff --git a/examples/celix-examples/dm_example/phase2a/src/phase2a_activator.c b/examples/celix-examples/dm_example/phase2a/src/phase2a_activator.c index 6fa6919..04c0512 100644 --- a/examples/celix-examples/dm_example/phase2a/src/phase2a_activator.c +++ b/examples/celix-examples/dm_example/phase2a/src/phase2a_activator.c @@ -20,8 +20,7 @@ #include <stdlib.h> #include <phase2a_cmp.h> -#include "bundle_activator.h" -#include "dm_activator.h" +#include "celix_api.h" #include "phase1.h" #include "phase2.h" @@ -32,58 +31,48 @@ struct phase2a_activator_struct { phase2_t phase2Serv; }; -celix_status_t dm_create(bundle_context_pt context, void **userData) { - printf("phase2a: dm_create\n"); - *userData = calloc(1, sizeof(struct phase2a_activator_struct)); - return *userData != NULL ? CELIX_SUCCESS : CELIX_ENOMEM; -} - -celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("phase2a: dm_init\n"); - celix_status_t status = CELIX_SUCCESS; - - struct phase2a_activator_struct *act = (struct phase2a_activator_struct *)userData; - +static celix_status_t start(struct phase2a_activator_struct *act, celix_bundle_context_t *ctx) { + printf("phase2a: start\n"); + celix_status_t status = CELIX_SUCCESS; act->phase2aCmp = phase2a_create(); if (act->phase2aCmp != NULL) { act->phase2Serv.handle = act->phase2aCmp; act->phase2Serv.getData = (void *)phase2a_getData; - properties_pt props = properties_create(); + celix_properties_t *props = properties_create(); properties_set(props, "id", "phase2a"); - dm_component_pt cmp; - component_create(context, "PHASE2A_PROCESSING_COMPONENT", &cmp); - component_setImplementation(cmp, act->phase2aCmp); - component_setCallbacksSafe(cmp, phase2a_cmp_t *, phase2a_init, phase2a_start, phase2a_stop, phase2a_deinit); - component_addInterface(cmp, PHASE2_NAME, PHASE2_VERSION, &act->phase2Serv, props); + celix_dm_component_t *cmp = celix_dmComponent_create(ctx, "PHASE2A_PROCESSING_COMPONENT"); + celix_dmComponent_setImplementation(cmp, act->phase2aCmp); + CELIX_DMCOMPONENT_SETCALLBACKS(cmp, phase2a_cmp_t *, phase2a_init, phase2a_start, phase2a_stop, phase2a_deinit); + celix_dmComponent_addInterface(cmp, PHASE2_NAME, PHASE2_VERSION, &act->phase2Serv, props); - dm_service_dependency_pt dep; - serviceDependency_create(&dep); - serviceDependency_setService(dep, PHASE1_NAME, PHASE1_RANGE_ALL, NULL); - serviceDependency_setCallbacksSafe(dep, phase2a_cmp_t*, const phase1_t*, phase2a_setPhase1, NULL, NULL, NULL, NULL); - serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING); - serviceDependency_setRequired(dep, true); - component_addServiceDependency(cmp, dep); + celix_dm_service_dependency_t *dep = celix_dmServiceDependency_create(); + celix_dmServiceDependency_setService(dep, PHASE1_NAME, PHASE1_RANGE_ALL, NULL); + celix_dmServiceDependency_setCallback(dep, (void*)phase2a_setPhase1); + celix_dmServiceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING); + celix_dmServiceDependency_setRequired(dep, true); + celix_dmComponent_addServiceDependency(cmp, dep); - dependencyManager_add(manager, cmp); + celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx); + celix_dependencyManager_add(mng, cmp); } else { status = CELIX_ENOMEM; } - return status; + return status; } -celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("phase2a: dm-destroy\n"); - - struct phase2a_activator_struct *act = (struct phase2a_activator_struct *)userData; +static celix_status_t stop(struct phase2a_activator_struct *act, celix_bundle_context_t *ctx) { + printf("phase2a: stop\n"); + celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx); + celix_dependencyManager_removeAllComponents(mng); if (act->phase2aCmp != NULL) { phase2a_destroy(act->phase2aCmp); } - free(act); - return CELIX_SUCCESS; } + +CELIX_GEN_BUNDLE_ACTIVATOR(struct phase2a_activator_struct, start, stop) http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/phase2b/src/phase2b_activator.c ---------------------------------------------------------------------- diff --git a/examples/celix-examples/dm_example/phase2b/src/phase2b_activator.c b/examples/celix-examples/dm_example/phase2b/src/phase2b_activator.c index c7692d4..328b48a 100644 --- a/examples/celix-examples/dm_example/phase2b/src/phase2b_activator.c +++ b/examples/celix-examples/dm_example/phase2b/src/phase2b_activator.c @@ -26,8 +26,7 @@ #include <stdlib.h> #include <phase2b_cmp.h> -#include "bundle_activator.h" -#include "dm_activator.h" +#include "celix_api.h" #include "phase1.h" #include "phase2.h" @@ -38,58 +37,49 @@ struct phase2b_activator_struct { phase2_t phase2Serv; }; -celix_status_t dm_create(bundle_context_pt context, void **userData) { - printf("phase2b: dm_create\n"); - *userData = calloc(1, sizeof(struct phase2b_activator_struct)); - return *userData != NULL ? CELIX_SUCCESS : CELIX_ENOMEM; -} - -celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("phase2b: dm_init\n"); - celix_status_t status = CELIX_SUCCESS; - - struct phase2b_activator_struct *act = (struct phase2b_activator_struct *)userData; - +static celix_status_t start(struct phase2b_activator_struct *act, celix_bundle_context_t *ctx) { + printf("phase2b: start\n"); + celix_status_t status = CELIX_SUCCESS; act->phase2bCmp = phase2b_create(); if (act->phase2bCmp != NULL) { act->phase2Serv.handle = act->phase2bCmp; act->phase2Serv.getData = (void *)phase2b_getData; - properties_pt props = properties_create(); + celix_properties_t *props = properties_create(); properties_set(props, "id", "phase2b"); - dm_component_pt cmp; - component_create(context, "PHASE2B_PROCESSING_COMPONENT", &cmp); - component_setImplementation(cmp, act->phase2bCmp); - component_setCallbacksSafe(cmp, phase2b_cmp_t *, phase2b_init, phase2b_start, phase2b_stop, phase2b_deinit); - component_addInterface(cmp, PHASE2_NAME, PHASE2_VERSION, &act->phase2Serv, props); + celix_dm_component_t *cmp = celix_dmComponent_create(ctx, "PHASE2B_PROCESSING_COMPONENT"); + celix_dmComponent_setImplementation(cmp, act->phase2bCmp); + CELIX_DMCOMPONENT_SETCALLBACKS(cmp, phase2b_cmp_t *, phase2b_init, phase2b_start, phase2b_stop, phase2b_deinit); + celix_dmComponent_addInterface(cmp, PHASE2_NAME, PHASE2_VERSION, &act->phase2Serv, props); - dm_service_dependency_pt dep; - serviceDependency_create(&dep); - serviceDependency_setService(dep, PHASE1_NAME, PHASE1_RANGE_EXACT, NULL); - serviceDependency_setCallbacksSafe(dep, phase2b_cmp_t*, const phase1_t*, phase2b_setPhase1, NULL, NULL, NULL, NULL); - serviceDependency_setRequired(dep, true); - serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING); - component_addServiceDependency(cmp, dep); + celix_dm_service_dependency_t *dep = celix_dmServiceDependency_create(); + celix_dmServiceDependency_setService(dep, PHASE1_NAME, PHASE1_RANGE_EXACT, NULL); + celix_dmServiceDependency_setCallback(dep, (void*)phase2b_setPhase1); + celix_dmServiceDependency_setRequired(dep, true); + celix_dmServiceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING); + celix_dmComponent_addServiceDependency(cmp, dep); - dependencyManager_add(manager, cmp); + celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx); + celix_dependencyManager_add(mng, cmp); } else { status = CELIX_ENOMEM; } - return status; + return status; } -celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("phase2b: dm-destroy\n"); - - struct phase2b_activator_struct *act = (struct phase2b_activator_struct *)userData; +static celix_status_t stop(struct phase2b_activator_struct *act, celix_bundle_context_t *ctx) { + printf("phase2b: stop\n"); + celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx); + celix_dependencyManager_removeAllComponents(mng); if (act->phase2bCmp != NULL) { phase2b_destroy(act->phase2bCmp); } - free(act); - return CELIX_SUCCESS; } + + +CELIX_GEN_BUNDLE_ACTIVATOR(struct phase2b_activator_struct, start, stop) http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/phase3/src/phase3_activator.c ---------------------------------------------------------------------- diff --git a/examples/celix-examples/dm_example/phase3/src/phase3_activator.c b/examples/celix-examples/dm_example/phase3/src/phase3_activator.c index 64b7a0b..7401776 100644 --- a/examples/celix-examples/dm_example/phase3/src/phase3_activator.c +++ b/examples/celix-examples/dm_example/phase3/src/phase3_activator.c @@ -25,8 +25,7 @@ */ #include <stdlib.h> -#include "bundle_activator.h" -#include "dm_activator.h" +#include "celix_api.h" #include "phase2.h" #include "phase3_cmp.h" @@ -35,50 +34,45 @@ struct phase3_activator_struct { phase3_cmp_t *phase3Cmp; }; -celix_status_t dm_create(bundle_context_pt context, void **userData) { - printf("phase3: dm_create\n"); - *userData = calloc(1, sizeof(struct phase3_activator_struct)); - return *userData != NULL ? CELIX_SUCCESS : CELIX_ENOMEM; -} - -celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("phase3: dm_init\n"); - celix_status_t status = CELIX_SUCCESS; - - struct phase3_activator_struct *act = (struct phase3_activator_struct *)userData; - +static celix_status_t start(struct phase3_activator_struct *act, celix_bundle_context_t *ctx) { + celix_status_t status = CELIX_SUCCESS; + printf("phase3: start\n"); act->phase3Cmp = phase3_create(); if (act->phase3Cmp != NULL) { - dm_component_pt cmp; - component_create(context, "PHASE3_PROCESSING_COMPONENT", &cmp); - component_setImplementation(cmp, act->phase3Cmp); - component_setCallbacksSafe(cmp, phase3_cmp_t *, phase3_init, phase3_start, phase3_stop, phase3_deinit); + celix_dm_component_t *cmp = celix_dmComponent_create(ctx, "PHASE3_PROCESSING_COMPONENT"); + celix_dmComponent_setImplementation(cmp, act->phase3Cmp); + CELIX_DMCOMPONENT_SETCALLBACKS(cmp, phase3_cmp_t *, phase3_init, phase3_start, phase3_stop, phase3_deinit); - dm_service_dependency_pt dep; - serviceDependency_create(&dep); - serviceDependency_setService(dep, PHASE2_NAME, NULL, NULL); - serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND); //SUSPEND Strategy is default - serviceDependency_setCallbacksSafe(dep, phase3_cmp_t*, const phase2_t*, NULL, phase3_addPhase2, NULL, phase3_removePhase2, NULL); - serviceDependency_setRequired(dep, true); - component_addServiceDependency(cmp, dep); + celix_dm_service_dependency_t *dep = celix_dmServiceDependency_create(); + celix_dmServiceDependency_setService(dep, PHASE2_NAME, NULL, NULL); + celix_dmServiceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND); //SUSPEND Strategy is default + celix_dm_service_dependency_callback_options_t opts = CELIX_EMPTY_DM_SERVICE_DEPENDENCY_CALLBACK_OPTIONS; + opts.add = (void*)phase3_addPhase2; + opts.remove = (void*)phase3_removePhase2; + celix_dmServiceDependency_setCallbacksWithOptions(dep, &opts); + celix_dmServiceDependency_setRequired(dep, true); + celix_dmComponent_addServiceDependency(cmp, dep); - dependencyManager_add(manager, cmp); + celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx); + celix_dependencyManager_add(mng, cmp); } else { status = CELIX_ENOMEM; } + return status; - return status; } -celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) { - printf("phase3: dm-destroy\n"); - - struct phase3_activator_struct *act = (struct phase3_activator_struct *)userData; +static celix_status_t stop(struct phase3_activator_struct *act, celix_bundle_context_t *ctx) { + celix_status_t status = CELIX_SUCCESS; + printf("phase3: stop\n"); + celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx); + celix_dependencyManager_removeAllComponents(mng); if (act->phase3Cmp != NULL) { phase3_destroy(act->phase3Cmp); } - free(act); - - return CELIX_SUCCESS; + return status; } + + +CELIX_GEN_BUNDLE_ACTIVATOR(struct phase3_activator_struct, start, stop); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/phase3/src/phase3_cmp.c ---------------------------------------------------------------------- diff --git a/examples/celix-examples/dm_example/phase3/src/phase3_cmp.c b/examples/celix-examples/dm_example/phase3/src/phase3_cmp.c index 47cb720..e4e6902 100644 --- a/examples/celix-examples/dm_example/phase3/src/phase3_cmp.c +++ b/examples/celix-examples/dm_example/phase3/src/phase3_cmp.c @@ -38,7 +38,7 @@ struct phase3_cmp_struct { celix_thread_t thread; bool running; double currentValue; - array_list_pt phase2Services; //phase2_t * + celix_array_list_t *phase2Services; //phase2_t * }; static void *phase3_thread(void *data); http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc ---------------------------------------------------------------------- diff --git a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc index 61443dd..c4895e4 100644 --- a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc +++ b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc @@ -41,7 +41,7 @@ struct InvalidCServ { }; void Phase1Activator::init() { - auto cmp = std::unique_ptr<Phase1Cmp>(new Phase1Cmp()); + auto cmp = std::shared_ptr<Phase1Cmp>(new Phase1Cmp()); Properties cmdProps; cmdProps[OSGI_SHELL_COMMAND_NAME] = "phase1_info"; @@ -87,7 +87,7 @@ void Phase1Activator::init() { tst->handle = cmp.get(); - phase1cmp = &mng.createComponent(std::move(cmp)) //using a pointer a instance. Also supported is lazy initialization (default constructor needed) or a rvalue reference (move) + phase1cmp = &mng.createComponent(cmp) //using a pointer a instance. Also supported is lazy initialization (default constructor needed) or a rvalue reference (move) .addInterface<IPhase1>(IPHASE1_VERSION) //.addInterface<IPhase2>() -> Compile error (static assert), because Phase1Cmp does not implement IPhase2 .addCInterface(&cmd, OSGI_SHELL_COMMAND_SERVICE_NAME, "", cmdProps) @@ -96,8 +96,4 @@ void Phase1Activator::init() { //.addCInterface(tst.get(), "TEST_SRV") -> Compile error (static assert), because InvalidCServ is not a pod .addInterface<srv::info::IName>(INAME_VERSION) .setCallbacks(&Phase1Cmp::init, &Phase1Cmp::start, &Phase1Cmp::stop, &Phase1Cmp::deinit); -} - -void Phase1Activator::deinit() { - phase1cmp->removeCallbacks(); } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h ---------------------------------------------------------------------- diff --git a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h index a3b062b..76ba839 100644 --- a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h +++ b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h @@ -39,7 +39,6 @@ class Phase1Activator : public DmActivator { Phase1Activator(const Phase1Activator&) = delete; Phase1Activator& operator=(const Phase1Activator&) = delete; virtual void init(); - virtual void deinit(); }; #endif //CELIX_PHASE1ACTIVATOR_H http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/embedding/private/src/main.c ---------------------------------------------------------------------- diff --git a/examples/celix-examples/embedding/private/src/main.c b/examples/celix-examples/embedding/private/src/main.c index b77cb22..d1ef0d6 100644 --- a/examples/celix-examples/embedding/private/src/main.c +++ b/examples/celix-examples/embedding/private/src/main.c @@ -43,18 +43,18 @@ celix_status_t embedded_foo(); int main(void) { - framework_pt framework = NULL; + celix_framework_t *framework = NULL; - properties_pt config = properties_create(); + celix_properties_t *config = properties_create(); int rc = celixLauncher_launchWithProperties(config, &framework); if (rc == 0) { - bundle_pt fwBundle = NULL; + celix_bundle_t *fwBundle = NULL; if(framework_getFrameworkBundle(framework, &fwBundle) == CELIX_SUCCESS){ if(bundle_start(fwBundle) == CELIX_SUCCESS){ - bundle_context_pt context = NULL; + celix_bundle_context_t *context = NULL; bundle_getContext(fwBundle, &context); struct foo *f = calloc(1, sizeof(*f)); http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/hello_world/private/src/activator.c ---------------------------------------------------------------------- diff --git a/examples/celix-examples/hello_world/private/src/activator.c b/examples/celix-examples/hello_world/private/src/activator.c index 37cf782..f19118b 100644 --- a/examples/celix-examples/hello_world/private/src/activator.c +++ b/examples/celix-examples/hello_world/private/src/activator.c @@ -35,7 +35,7 @@ struct userData { char * word; }; -celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) { +celix_status_t bundleActivator_create(celix_bundle_context_t *context, void **userData) { celix_status_t status = CELIX_SUCCESS; *userData = malloc(sizeof(struct userData)); if (*userData != NULL) { @@ -46,7 +46,7 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData return status; } -celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) { +celix_status_t bundleActivator_start(void * userData, celix_bundle_context_t *context) { struct userData * data = (struct userData *) userData; printf("Hello %s\n", data->word); @@ -56,13 +56,13 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) return CELIX_SUCCESS; } -celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) { +celix_status_t bundleActivator_stop(void * userData, celix_bundle_context_t *context) { struct userData * data = (struct userData *) userData; printf("Goodbye %s\n", data->word); return CELIX_SUCCESS; } -celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) { +celix_status_t bundleActivator_destroy(void * userData, celix_bundle_context_t *context) { free(userData); return CELIX_SUCCESS; } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/hello_world_test/private/src/activator.c ---------------------------------------------------------------------- diff --git a/examples/celix-examples/hello_world_test/private/src/activator.c b/examples/celix-examples/hello_world_test/private/src/activator.c index 2185e16..8ec3546 100644 --- a/examples/celix-examples/hello_world_test/private/src/activator.c +++ b/examples/celix-examples/hello_world_test/private/src/activator.c @@ -33,7 +33,7 @@ struct userData { char * word; }; -celix_status_t bundleActivator_create(bundle_context_pt __attribute__((unused)) context, void **userData) { +celix_status_t bundleActivator_create(celix_bundle_context_t __attribute__((unused)) *context, void **userData) { celix_status_t status = CELIX_SUCCESS; *userData = malloc(sizeof(struct userData)); if (*userData != NULL) { @@ -44,20 +44,20 @@ celix_status_t bundleActivator_create(bundle_context_pt __attribute__((unused)) return status; } -celix_status_t bundleActivator_start(void * userData, bundle_context_pt __attribute__((unused)) context) { +celix_status_t bundleActivator_start(void * userData, celix_bundle_context_t __attribute__((unused)) *context) { struct userData * data = (struct userData *) userData; printf("Hello %s\n", data->word); return CELIX_SUCCESS; } -celix_status_t bundleActivator_stop(void * userData, bundle_context_pt __attribute__((unused)) context) { +celix_status_t bundleActivator_stop(void * userData, celix_bundle_context_t __attribute__((unused)) *context) { struct userData * data = (struct userData *) userData; printf("Goodbye %s\n", data->word); return CELIX_SUCCESS; } -celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt __attribute__((unused)) context) { +celix_status_t bundleActivator_destroy(void * userData, celix_bundle_context_t __attribute__((unused)) *context) { free(userData); return CELIX_SUCCESS; } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/log_service_example/src/activator.c ---------------------------------------------------------------------- diff --git a/examples/celix-examples/log_service_example/src/activator.c b/examples/celix-examples/log_service_example/src/activator.c index 75eaf59..ac7e707 100644 --- a/examples/celix-examples/log_service_example/src/activator.c +++ b/examples/celix-examples/log_service_example/src/activator.c @@ -37,7 +37,7 @@ struct userData { static void *loggerThread(void *userData); -celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) { +celix_status_t bundleActivator_create(celix_bundle_context_t *context, void **userData) { celix_status_t status = CELIX_SUCCESS; *userData = calloc(1, sizeof(struct userData)); if (*userData != NULL) { @@ -50,7 +50,7 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData } -celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) { +celix_status_t bundleActivator_start(void * userData, celix_bundle_context_t *context) { struct userData * data = (struct userData *) userData; printf("Started log example\n"); logHelper_start(data->log_helper); @@ -59,7 +59,7 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) return CELIX_SUCCESS; } -celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) { +celix_status_t bundleActivator_stop(void * userData, celix_bundle_context_t *context) { struct userData * data = (struct userData *) userData; printf("Stopping logger example\n"); data->running = false; @@ -68,7 +68,7 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) return CELIX_SUCCESS; } -celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) { +celix_status_t bundleActivator_destroy(void * userData, celix_bundle_context_t *context) { struct userData * data = (struct userData *) userData; logHelper_destroy(&data->log_helper); free(userData); http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/service_hook_example/src/activator.c ---------------------------------------------------------------------- diff --git a/examples/celix-examples/service_hook_example/src/activator.c b/examples/celix-examples/service_hook_example/src/activator.c index f2d2a15..8fe56f2 100644 --- a/examples/celix-examples/service_hook_example/src/activator.c +++ b/examples/celix-examples/service_hook_example/src/activator.c @@ -42,7 +42,7 @@ struct userData { }; -celix_status_t tracker_added(void*hook, array_list_pt listeners) { +celix_status_t tracker_added(void*hook, celix_array_list_t *listeners) { for(unsigned int i = 0; i < arrayList_size(listeners); i++) { listener_hook_info_pt info = arrayList_get(listeners, i); printf("Added tracker for service %s\n", info->filter); @@ -51,7 +51,7 @@ celix_status_t tracker_added(void*hook, array_list_pt listeners) { return CELIX_SUCCESS; } -celix_status_t tracker_removed(void*hook, array_list_pt listeners) { +celix_status_t tracker_removed(void*hook, celix_array_list_t *listeners) { for(unsigned int i = 0; i < arrayList_size(listeners); i++) { listener_hook_info_pt info = arrayList_get(listeners, i); printf("Removed tracker for service %s\n", info->filter); @@ -60,7 +60,7 @@ celix_status_t tracker_removed(void*hook, array_list_pt listeners) { return CELIX_SUCCESS; } -celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) { +celix_status_t bundleActivator_create(celix_bundle_context_t *context, void **userData) { celix_status_t status = CELIX_SUCCESS; *userData = malloc(sizeof(struct userData)); if (*userData != NULL) { @@ -71,7 +71,7 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData return status; } -celix_status_t bundleActivator_start(void * handle, bundle_context_pt context) { +celix_status_t bundleActivator_start(void * handle, celix_bundle_context_t *context) { printf("Starting hook example bundle\n"); struct userData *userData = (struct userData*)handle; @@ -116,7 +116,7 @@ celix_status_t bundleActivator_start(void * handle, bundle_context_pt context) { return CELIX_SUCCESS; } -celix_status_t bundleActivator_stop(void * handle, bundle_context_pt context) { +celix_status_t bundleActivator_stop(void * handle, celix_bundle_context_t *context) { printf("Stopping hook example bundle\n"); struct userData *userData = (struct userData*)handle; @@ -131,7 +131,7 @@ celix_status_t bundleActivator_stop(void * handle, bundle_context_pt context) { return CELIX_SUCCESS; } -celix_status_t bundleActivator_destroy(void * handle, bundle_context_pt context) { +celix_status_t bundleActivator_destroy(void * handle, celix_bundle_context_t *context) { free(handle); return CELIX_SUCCESS; } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/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 1b09ab9..1c3a289 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 @@ -63,7 +63,7 @@ void * run(void *handle) { bool up = true; while (isRunning(data)) { if (up) { - properties_t *props = properties_create(); + celix_properties_t *props = properties_create(); celix_properties_setLong(props, OSGI_FRAMEWORK_SERVICE_RANKING, rand()); data->svcIds[i++] = celix_bundleContext_registerService(data->ctx, &data->svc, EXAMPLE_CALC_NAME, props); } else { //down http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/dependency_manager_cxx/src/dm_activator.cc ---------------------------------------------------------------------- diff --git a/libs/dependency_manager_cxx/src/dm_activator.cc b/libs/dependency_manager_cxx/src/dm_activator.cc index b7669e3..6ac02c5 100644 --- a/libs/dependency_manager_cxx/src/dm_activator.cc +++ b/libs/dependency_manager_cxx/src/dm_activator.cc @@ -30,7 +30,7 @@ struct BundleActivatorData { std::unique_ptr<celix::dm::DmActivator> act; }; -extern "C" celix_status_t bundleActivator_create(bundle_context_pt context, void** userData) { +extern "C" celix_status_t bundleActivator_create(celix_bundle_context_t *context, void** userData) { int status = CELIX_SUCCESS; BundleActivatorData* data = nullptr; @@ -52,9 +52,8 @@ extern "C" celix_status_t bundleActivator_create(bundle_context_pt context, void if (data == nullptr || data->act == nullptr) { status = CELIX_ENOMEM; if (data != nullptr) { - data->act = nullptr; + delete data; } - delete data; *userData = nullptr; } else { *userData = data; @@ -62,7 +61,7 @@ extern "C" celix_status_t bundleActivator_create(bundle_context_pt context, void return status; } -extern "C" celix_status_t bundleActivator_start(void* userData, [[gnu::unused]] bundle_context_pt context) { +extern "C" celix_status_t bundleActivator_start(void* userData, celix_bundle_context_t *) { int status = CELIX_SUCCESS; auto* data = static_cast<BundleActivatorData*>(userData); if (data != nullptr) { @@ -71,21 +70,20 @@ extern "C" celix_status_t bundleActivator_start(void* userData, [[gnu::unused]] return status; } -extern "C" celix_status_t bundleActivator_stop(void* userData, [[gnu::unused]] bundle_context_pt context) { +extern "C" celix_status_t bundleActivator_stop(void* userData, celix_bundle_context_t *) { int status = CELIX_SUCCESS; auto* data = static_cast<BundleActivatorData*>(userData); if (data != nullptr) { status = data->act->stop(); + data->act = nullptr; } return status; } -extern "C" celix_status_t bundleActivator_destroy([[gnu::unused]] void* userData,[[gnu::unused]] bundle_context_pt context ) { - int status = CELIX_SUCCESS; +extern "C" celix_status_t bundleActivator_destroy(void *userData, celix_bundle_context_t* ) { auto* data = static_cast<BundleActivatorData*>(userData); if (data != nullptr) { - data->act = nullptr; + delete data; } - delete data; - return status; + return CELIX_SUCCESS; } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/bundle.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/bundle.h b/libs/framework/include/bundle.h index 676c8b4..7ea0d1e 100644 --- a/libs/framework/include/bundle.h +++ b/libs/framework/include/bundle.h @@ -40,85 +40,85 @@ extern "C" { 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 bundle_create(celix_bundle_t **bundle); FRAMEWORK_EXPORT celix_status_t -bundle_createFromArchive(bundle_pt *bundle, framework_pt framework, bundle_archive_pt archive); +bundle_createFromArchive(celix_bundle_t **bundle, celix_framework_t *framework, bundle_archive_pt archive); -FRAMEWORK_EXPORT celix_status_t bundle_destroy(bundle_pt bundle); +FRAMEWORK_EXPORT celix_status_t bundle_destroy(celix_bundle_t *bundle); -FRAMEWORK_EXPORT celix_status_t bundle_isSystemBundle(bundle_pt bundle, bool *systemBundle); +FRAMEWORK_EXPORT celix_status_t bundle_isSystemBundle(celix_bundle_t *bundle, bool *systemBundle); -FRAMEWORK_EXPORT celix_status_t bundle_getArchive(bundle_pt bundle, bundle_archive_pt *archive); +FRAMEWORK_EXPORT celix_status_t bundle_getArchive(celix_bundle_t *bundle, bundle_archive_pt *archive); -FRAMEWORK_EXPORT celix_status_t bundle_getCurrentModule(bundle_pt bundle, module_pt *module); +FRAMEWORK_EXPORT celix_status_t bundle_getCurrentModule(celix_bundle_t *bundle, module_pt *module); -FRAMEWORK_EXPORT array_list_pt bundle_getModules(bundle_pt bundle); +FRAMEWORK_EXPORT celix_array_list_t *bundle_getModules(celix_bundle_t *bundle); -FRAMEWORK_EXPORT void *bundle_getHandle(bundle_pt bundle); +FRAMEWORK_EXPORT void *bundle_getHandle(celix_bundle_t *bundle); -FRAMEWORK_EXPORT void bundle_setHandle(bundle_pt bundle, void *handle); +FRAMEWORK_EXPORT void bundle_setHandle(celix_bundle_t *bundle, void *handle); -FRAMEWORK_EXPORT celix_bundle_activator_t *bundle_getActivator(bundle_pt bundle); +FRAMEWORK_EXPORT celix_bundle_activator_t *bundle_getActivator(celix_bundle_t *bundle); -FRAMEWORK_EXPORT celix_status_t bundle_setActivator(bundle_pt bundle, celix_bundle_activator_t *activator); +FRAMEWORK_EXPORT celix_status_t bundle_setActivator(celix_bundle_t *bundle, celix_bundle_activator_t *activator); -FRAMEWORK_EXPORT celix_status_t bundle_getContext(bundle_pt bundle, bundle_context_pt *context); +FRAMEWORK_EXPORT celix_status_t bundle_getContext(celix_bundle_t *bundle, celix_bundle_context_t **context); -FRAMEWORK_EXPORT celix_status_t bundle_setContext(bundle_pt bundle, bundle_context_pt context); +FRAMEWORK_EXPORT celix_status_t bundle_setContext(celix_bundle_t *bundle, celix_bundle_context_t *context); -FRAMEWORK_EXPORT celix_status_t bundle_getEntry(bundle_pt bundle, const char *name, char **entry); +FRAMEWORK_EXPORT celix_status_t bundle_getEntry(celix_bundle_t *bundle, const char *name, char **entry); -FRAMEWORK_EXPORT celix_status_t bundle_start(bundle_pt bundle); +FRAMEWORK_EXPORT celix_status_t bundle_start(celix_bundle_t *bundle); -FRAMEWORK_EXPORT celix_status_t bundle_startWithOptions(bundle_pt bundle, int options); +FRAMEWORK_EXPORT celix_status_t bundle_startWithOptions(celix_bundle_t *bundle, int options); -FRAMEWORK_EXPORT celix_status_t bundle_update(bundle_pt bundle, const char *inputFile); +FRAMEWORK_EXPORT celix_status_t bundle_update(celix_bundle_t *bundle, const char *inputFile); -FRAMEWORK_EXPORT celix_status_t bundle_stop(bundle_pt bundle); +FRAMEWORK_EXPORT celix_status_t bundle_stop(celix_bundle_t *bundle); -FRAMEWORK_EXPORT celix_status_t bundle_stopWithOptions(bundle_pt bundle, int options); +FRAMEWORK_EXPORT celix_status_t bundle_stopWithOptions(celix_bundle_t *bundle, int options); -FRAMEWORK_EXPORT celix_status_t bundle_uninstall(bundle_pt bundle); +FRAMEWORK_EXPORT celix_status_t bundle_uninstall(celix_bundle_t *bundle); -FRAMEWORK_EXPORT celix_status_t bundle_setState(bundle_pt bundle, bundle_state_e state); +FRAMEWORK_EXPORT celix_status_t bundle_setState(celix_bundle_t *bundle, bundle_state_e state); -FRAMEWORK_EXPORT celix_status_t bundle_setPersistentStateInactive(bundle_pt bundle); +FRAMEWORK_EXPORT celix_status_t bundle_setPersistentStateInactive(celix_bundle_t *bundle); -FRAMEWORK_EXPORT celix_status_t bundle_setPersistentStateUninstalled(bundle_pt bundle); +FRAMEWORK_EXPORT celix_status_t bundle_setPersistentStateUninstalled(celix_bundle_t *bundle); -FRAMEWORK_EXPORT void uninstallBundle(bundle_pt bundle); +FRAMEWORK_EXPORT void uninstallBundle(celix_bundle_t *bundle); -FRAMEWORK_EXPORT celix_status_t bundle_revise(bundle_pt bundle, const char *location, const char *inputFile); +FRAMEWORK_EXPORT celix_status_t bundle_revise(celix_bundle_t *bundle, const char *location, const char *inputFile); -FRAMEWORK_EXPORT celix_status_t bundle_addModule(bundle_pt bundle, module_pt module); +FRAMEWORK_EXPORT celix_status_t bundle_addModule(celix_bundle_t *bundle, module_pt module); -FRAMEWORK_EXPORT celix_status_t bundle_closeModules(bundle_pt bundle); +FRAMEWORK_EXPORT celix_status_t bundle_closeModules(celix_bundle_t *bundle); // Service Reference Functions -FRAMEWORK_EXPORT array_list_pt getUsingBundles(service_reference_pt reference); +FRAMEWORK_EXPORT celix_array_list_t *getUsingBundles(service_reference_pt reference); FRAMEWORK_EXPORT int compareTo(service_reference_pt a, service_reference_pt b); -FRAMEWORK_EXPORT celix_status_t bundle_getState(bundle_pt bundle, bundle_state_e *state); +FRAMEWORK_EXPORT celix_status_t bundle_getState(celix_bundle_t *bundle, bundle_state_e *state); -FRAMEWORK_EXPORT celix_status_t bundle_closeAndDelete(bundle_pt bundle); +FRAMEWORK_EXPORT celix_status_t bundle_closeAndDelete(celix_bundle_t *bundle); -FRAMEWORK_EXPORT celix_status_t bundle_close(bundle_pt bundle); +FRAMEWORK_EXPORT celix_status_t bundle_close(celix_bundle_t *bundle); -FRAMEWORK_EXPORT celix_status_t bundle_refresh(bundle_pt bundle); +FRAMEWORK_EXPORT celix_status_t bundle_refresh(celix_bundle_t *bundle); -FRAMEWORK_EXPORT celix_status_t bundle_getBundleId(bundle_pt bundle, long *id); +FRAMEWORK_EXPORT celix_status_t bundle_getBundleId(celix_bundle_t *bundle, long *id); -FRAMEWORK_EXPORT celix_status_t bundle_getRegisteredServices(bundle_pt bundle, array_list_pt *list); +FRAMEWORK_EXPORT celix_status_t bundle_getRegisteredServices(celix_bundle_t *bundle, celix_array_list_t **list); -FRAMEWORK_EXPORT celix_status_t bundle_getServicesInUse(bundle_pt bundle, array_list_pt *list); +FRAMEWORK_EXPORT celix_status_t bundle_getServicesInUse(celix_bundle_t *bundle, celix_array_list_t **list); -FRAMEWORK_EXPORT celix_status_t bundle_setFramework(bundle_pt bundle, framework_pt framework); +FRAMEWORK_EXPORT celix_status_t bundle_setFramework(celix_bundle_t *bundle, celix_framework_t *framework); -FRAMEWORK_EXPORT celix_status_t bundle_getFramework(bundle_pt bundle, framework_pt *framework); +FRAMEWORK_EXPORT celix_status_t bundle_getFramework(celix_bundle_t *bundle, celix_framework_t **framework); -FRAMEWORK_EXPORT celix_status_t bundle_getBundleLocation(bundle_pt bundle, const char **location); +FRAMEWORK_EXPORT celix_status_t bundle_getBundleLocation(celix_bundle_t *bundle, const char **location); #ifdef __cplusplus http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/bundle_activator.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/bundle_activator.h b/libs/framework/include/bundle_activator.h index 99ef6bc..ce0e33c 100644 --- a/libs/framework/include/bundle_activator.h +++ b/libs/framework/include/bundle_activator.h @@ -36,7 +36,7 @@ extern "C" { * The activator instance is handle as a void pointer by the framework, the implementation must cast it to the * implementation specific type. * - * @param context The execution context of the bundle being started. + * @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: @@ -44,7 +44,7 @@ extern "C" { * - 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. */ -ACTIVATOR_EXPORT celix_status_t bundleActivator_create(bundle_context_t *context_ptr, void **userData); +ACTIVATOR_EXPORT celix_status_t 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 @@ -55,14 +55,14 @@ ACTIVATOR_EXPORT celix_status_t bundleActivator_create(bundle_context_t *context * This method must complete and return to its caller in a timely manner. * * @param userData The activator instance to be used. - * @param context The execution context of the bundle being started. + * @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. */ -ACTIVATOR_EXPORT celix_status_t bundleActivator_start(void *userData, bundle_context_t *context); +ACTIVATOR_EXPORT celix_status_t 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 @@ -74,14 +74,14 @@ ACTIVATOR_EXPORT celix_status_t bundleActivator_start(void *userData, bundle_con * This method must complete and return to its caller in a timely manner. * * @param userData The activator instance to be used. - * @param context The execution context of the bundle being stopped. + * @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. */ -ACTIVATOR_EXPORT celix_status_t bundleActivator_stop(void *userData, bundle_context_t *context); +ACTIVATOR_EXPORT celix_status_t 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 @@ -91,7 +91,7 @@ ACTIVATOR_EXPORT celix_status_t bundleActivator_stop(void *userData, bundle_cont * This method must complete and return to its caller in a timely manner. * * @param userData The activator instance to be used. - * @param context The execution context of the bundle being stopped. + * @param ctx The execution context of the bundle being stopped. * * @return Status code indication failure or success: * - CELIX_SUCCESS when no errors are encountered. @@ -99,7 +99,7 @@ ACTIVATOR_EXPORT celix_status_t bundleActivator_stop(void *userData, bundle_cont * bundle's listeners, unregister all services, and release all services used by this bundle. */ ACTIVATOR_EXPORT celix_status_t -bundleActivator_destroy(void *userData, bundle_context_t* context); +bundleActivator_destroy(void *userData, celix_bundle_context_t* ctx); #ifdef __cplusplus } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/bundle_context.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/bundle_context.h b/libs/framework/include/bundle_context.h index 97a264b..8c2e3aa 100644 --- a/libs/framework/include/bundle_context.h +++ b/libs/framework/include/bundle_context.h @@ -44,27 +44,27 @@ extern "C" { #endif celix_status_t -bundleContext_create(framework_pt framework, framework_logger_pt, bundle_pt bundle, bundle_context_pt *bundle_context); +bundleContext_create(celix_framework_t *framework, framework_logger_pt, celix_bundle_t *bundle, celix_bundle_context_t **bundle_context); -celix_status_t bundleContext_destroy(bundle_context_pt context); +celix_status_t bundleContext_destroy(celix_bundle_context_t *context); -FRAMEWORK_EXPORT celix_status_t bundleContext_getBundle(bundle_context_pt context, bundle_pt *bundle); +FRAMEWORK_EXPORT celix_status_t bundleContext_getBundle(celix_bundle_context_t *context, celix_bundle_t **bundle); -FRAMEWORK_EXPORT celix_status_t bundleContext_getFramework(bundle_context_pt context, framework_pt *framework); +FRAMEWORK_EXPORT celix_status_t bundleContext_getFramework(celix_bundle_context_t *context, celix_framework_t **framework); FRAMEWORK_EXPORT celix_status_t -bundleContext_installBundle(bundle_context_pt context, const char *location, bundle_pt *bundle); +bundleContext_installBundle(celix_bundle_context_t *context, const char *location, celix_bundle_t **bundle); FRAMEWORK_EXPORT celix_status_t -bundleContext_installBundle2(bundle_context_pt context, const char *location, const char *inputFile, bundle_pt *bundle); +bundleContext_installBundle2(celix_bundle_context_t *context, const char *location, const char *inputFile, celix_bundle_t **bundle); FRAMEWORK_EXPORT celix_status_t -bundleContext_registerService(bundle_context_pt context, const char *serviceName, const void *svcObj, - properties_pt properties, service_registration_pt *service_registration); +bundleContext_registerService(celix_bundle_context_t *context, const char *serviceName, const void *svcObj, + celix_properties_t *properties, service_registration_pt *service_registration); FRAMEWORK_EXPORT celix_status_t -bundleContext_registerServiceFactory(bundle_context_pt context, const char *serviceName, service_factory_pt factory, - properties_pt properties, service_registration_pt *service_registration); +bundleContext_registerServiceFactory(celix_bundle_context_t *context, const char *serviceName, service_factory_pt factory, + celix_properties_t *properties, service_registration_pt *service_registration); /** * Get a service reference for the bundle context. When the service reference is no longer needed use bundleContext_ungetServiceReference. @@ -75,7 +75,7 @@ bundleContext_registerServiceFactory(bundle_context_pt context, const char *serv * @param service_reference _output_ The found service reference, or NULL when no service is found. * @return CELIX_SUCCESS on success */ -FRAMEWORK_EXPORT celix_status_t bundleContext_getServiceReference(bundle_context_pt context, const char *serviceName, +FRAMEWORK_EXPORT celix_status_t bundleContext_getServiceReference(celix_bundle_context_t *context, const char *serviceName, service_reference_pt *service_reference); /** Same as bundleContext_getServiceReference, but than for a optional serviceName combined with a optional filter. @@ -88,8 +88,8 @@ FRAMEWORK_EXPORT celix_status_t bundleContext_getServiceReference(bundle_context * @return CELIX_SUCCESS on success */ FRAMEWORK_EXPORT celix_status_t -bundleContext_getServiceReferences(bundle_context_pt context, const char *serviceName, const char *filter, - array_list_pt *service_references); +bundleContext_getServiceReferences(celix_bundle_context_t *context, const char *serviceName, const char *filter, + celix_array_list_t **service_references); /** * Retains (increases the ref count) the provided service reference. Can be used to retain a service reference. @@ -100,7 +100,7 @@ bundleContext_getServiceReferences(bundle_context_pt context, const char *servic * @return CELIX_SUCCES on success */ FRAMEWORK_EXPORT celix_status_t -bundleContext_retainServiceReference(bundle_context_pt context, service_reference_pt reference); +bundleContext_retainServiceReference(celix_bundle_context_t *context, service_reference_pt reference); /** * Ungets the service references. If the ref counter of the service refernce goes to 0, the reference will be destroyed. @@ -112,34 +112,34 @@ bundleContext_retainServiceReference(bundle_context_pt context, service_referenc * @return CELIX_SUCCESS on success. */ FRAMEWORK_EXPORT celix_status_t -bundleContext_ungetServiceReference(bundle_context_pt context, service_reference_pt reference); +bundleContext_ungetServiceReference(celix_bundle_context_t *context, service_reference_pt reference); FRAMEWORK_EXPORT celix_status_t -bundleContext_getService(bundle_context_pt context, service_reference_pt reference, void **service_instance); +bundleContext_getService(celix_bundle_context_t *context, service_reference_pt reference, void **service_instance); FRAMEWORK_EXPORT celix_status_t -bundleContext_ungetService(bundle_context_pt context, service_reference_pt reference, bool *result); +bundleContext_ungetService(celix_bundle_context_t *context, service_reference_pt reference, bool *result); -FRAMEWORK_EXPORT celix_status_t bundleContext_getBundles(bundle_context_pt context, array_list_pt *bundles); +FRAMEWORK_EXPORT celix_status_t bundleContext_getBundles(celix_bundle_context_t *context, celix_array_list_t **bundles); -FRAMEWORK_EXPORT celix_status_t bundleContext_getBundleById(bundle_context_pt context, long id, bundle_pt *bundle); +FRAMEWORK_EXPORT celix_status_t bundleContext_getBundleById(celix_bundle_context_t *context, long id, celix_bundle_t **bundle); FRAMEWORK_EXPORT celix_status_t -bundleContext_addServiceListener(bundle_context_pt context, celix_service_listener_t *listener, const char *filter); +bundleContext_addServiceListener(celix_bundle_context_t *context, celix_service_listener_t *listener, const char *filter); FRAMEWORK_EXPORT celix_status_t -bundleContext_removeServiceListener(bundle_context_pt context, celix_service_listener_t *listener); +bundleContext_removeServiceListener(celix_bundle_context_t *context, celix_service_listener_t *listener); -FRAMEWORK_EXPORT celix_status_t bundleContext_addBundleListener(bundle_context_pt context, bundle_listener_pt listener); +FRAMEWORK_EXPORT celix_status_t bundleContext_addBundleListener(celix_bundle_context_t *context, bundle_listener_pt listener); FRAMEWORK_EXPORT celix_status_t -bundleContext_removeBundleListener(bundle_context_pt context, bundle_listener_pt listener); +bundleContext_removeBundleListener(celix_bundle_context_t *context, bundle_listener_pt listener); FRAMEWORK_EXPORT celix_status_t -bundleContext_addFrameworkListener(bundle_context_pt context, framework_listener_pt listener); +bundleContext_addFrameworkListener(celix_bundle_context_t *context, framework_listener_pt listener); FRAMEWORK_EXPORT celix_status_t -bundleContext_removeFrameworkListener(bundle_context_pt context, framework_listener_pt listener); +bundleContext_removeFrameworkListener(celix_bundle_context_t *context, framework_listener_pt listener); /** * Gets the config property - or environment variable if the config property does not exist - for the provided name. @@ -150,7 +150,7 @@ bundleContext_removeFrameworkListener(bundle_context_pt context, framework_liste * @return 0 if successful. */ FRAMEWORK_EXPORT celix_status_t -bundleContext_getProperty(bundle_context_pt context, const char *name, const char **value); +bundleContext_getProperty(celix_bundle_context_t *context, const char *name, const char **value); /** * Gets the config property - or environment variable if the config property does not exist - for the provided name. @@ -162,7 +162,7 @@ bundleContext_getProperty(bundle_context_pt context, const char *name, const cha * @return 0 if successful. */ FRAMEWORK_EXPORT celix_status_t -bundleContext_getPropertyWithDefault(bundle_context_pt context, const char *name, const char *defaultValue, const char **value); +bundleContext_getPropertyWithDefault(celix_bundle_context_t *context, const char *name, const char *defaultValue, const char **value); #ifdef __cplusplus http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/bundle_revision.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/bundle_revision.h b/libs/framework/include/bundle_revision.h index 7c67a94..b18eb45 100644 --- a/libs/framework/include/bundle_revision.h +++ b/libs/framework/include/bundle_revision.h @@ -123,13 +123,13 @@ celix_status_t bundleRevision_getManifest(bundle_revision_pt revision, manifest_ * Retrieves the handles of the installed libraries for this revision. * * @param revision The revision to get the manifest for. - * @param[out] handles array_list_pt containing the handles. + * @param[out] handles celix_array_list_t *containing the handles. * * @return Status code indication failure or success: * - CELIX_SUCCESS when no errors are encountered. * - CELIX_ILLEGAL_ARGUMENT If <code>revision</code> is illegal. */ -celix_status_t bundleRevision_getHandles(bundle_revision_pt revision, array_list_pt *handles); +celix_status_t bundleRevision_getHandles(bundle_revision_pt revision, celix_array_list_t **handles); #ifdef __cplusplus } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix/dm/Component.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix/dm/Component.h b/libs/framework/include/celix/dm/Component.h index 85723f9..d5df319 100644 --- a/libs/framework/include/celix/dm/Component.h +++ b/libs/framework/include/celix/dm/Component.h @@ -31,12 +31,12 @@ namespace celix { namespace dm { class BaseComponent { private: - bundle_context_pt context {nullptr}; - dm_component_pt cCmp {nullptr}; + celix_bundle_context_t *context {nullptr}; + celix_dm_component_t *cCmp {nullptr}; public: - BaseComponent(const bundle_context_pt con, std::string name) : context{con}, cCmp{nullptr} { - component_create(this->context, name.c_str(), &this->cCmp); - component_setImplementation(this->cCmp, this); + BaseComponent(celix_bundle_context_t *con, std::string name) : context{con}, cCmp{nullptr} { + this->cCmp = celix_dmComponent_create(this->context, name.c_str()); + celix_dmComponent_setImplementation(this->cCmp, this); } virtual ~BaseComponent() {} @@ -46,12 +46,12 @@ namespace celix { namespace dm { /** * Returns the C DM Component */ - dm_component_pt cComponent() const { return this->cCmp; } + celix_dm_component_t* cComponent() const { return this->cCmp; } /** * Returns the C bundle context */ - bundle_context_pt bundleContext() const { return this->context; } + celix_bundle_context_t* bundleContext() const { return this->context; } }; @@ -74,7 +74,7 @@ namespace celix { namespace dm { int (T::*stopFpNoExc)() = {}; int (T::*deinitFpNoExc)() = {}; public: - Component(const bundle_context_pt context, std::string name); + Component(celix_bundle_context_t *context, std::string name); virtual ~Component(); /** @@ -83,14 +83,14 @@ namespace celix { namespace dm { * Will use new(nothrow) if exceptions are disabled. * @return newly created DM Component or nullptr */ - static Component<T>* create(bundle_context_pt, std::string name); + static Component<T>* create(celix_bundle_context_t*, std::string name); /** * Creates a Component using the provided bundle context. * Will use new(nothrow) if exceptions are disabled. * @return newly created DM Component or nullptr */ - static Component<T>* create(bundle_context_pt); + static Component<T>* create(celix_bundle_context_t*); /** * Wether the component is valid. Invalid component can occurs when no new components can be created and
