This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/685-refactor-manifest-format in repository https://gitbox.apache.org/repos/asf/celix.git
commit 203cbfc341bdfca361d424d025feba4cb889e3cf Merge: 26d14ff59 81d3b6b31 Author: Pepijn Noltes <pnol...@apache.org> AuthorDate: Mon Jul 22 13:28:47 2024 +0200 Merge remote-tracking branch 'origin/master' into feature/685-refactor-manifest-format .github/workflows/conan_create.yml | 2 +- .github/workflows/macos.yml | 2 +- .github/workflows/ubuntu.yml | 4 +- CMakeLists.txt | 5 - .../gtest/src/CelixEventAdminTestSuite.cc | 41 ++-- .../gtest/src/CelixEventAdminTestSuiteBaseClass.h | 17 +- .../gtest/src/RsaShmClientServerUnitTestSuite.cc | 40 ++++ .../rsa_shm/src/rsa_shm_client.c | 2 + .../rsa_shm/src/rsa_shm_server.c | 1 + bundles/shell/remote_shell/src/shell_mediator.c | 2 - cmake/cmake_celix/ContainerPackaging.cmake | 1 - libs/framework/gtest/CMakeLists.txt | 10 +- .../BundleArchiveWithErrorInjectionTestSuite.cc | 4 +- .../src/CelixBundleContextBundlesTestSuite.cc | 9 + libs/framework/gtest/src/CelixLauncherTestSuite.cc | 24 +- .../framework/gtest/src/ScheduledEventTestSuite.cc | 37 +++ libs/framework/gtest/src/activator_stop.c | 36 +++ libs/framework/include/celix_launcher.h | 16 +- libs/framework/src/bundle.c | 2 +- libs/framework/src/bundle_archive.c | 4 +- libs/framework/src/bundle_archive_private.h | 2 +- libs/framework/src/bundle_context.c | 2 +- libs/framework/src/celix_bundle_cache.c | 8 +- libs/framework/src/celix_launcher.c | 170 +++++++++----- libs/framework/src/celix_launcher_private.h | 11 +- libs/framework/src/framework.c | 248 +++++++++++---------- .../src/framework_bundle_lifecycle_handler.c | 27 ++- libs/framework/src/framework_private.h | 62 ++++-- .../error_injector/celix_properties/CMakeLists.txt | 1 + .../celix_properties/include/celix_properties_ei.h | 1 + .../celix_properties/src/celix_properties_ei.cc | 9 + libs/utils/include/celix_threads.h | 5 +- 32 files changed, 546 insertions(+), 259 deletions(-) diff --cc bundles/shell/remote_shell/src/shell_mediator.c index c4ae07ced,5ad3e6212..8d6e02f32 --- a/bundles/shell/remote_shell/src/shell_mediator.c +++ b/bundles/shell/remote_shell/src/shell_mediator.c @@@ -78,48 -83,51 +78,46 @@@ celix_status_t shellMediator_stop(shell } celix_status_t shellMediator_destroy(shell_mediator_pt instance) { - celix_status_t status = CELIX_SUCCESS; + celix_status_t status = CELIX_SUCCESS; - celixThreadMutex_lock(&instance->mutex); - - instance->shellService = NULL; - serviceTracker_destroy(instance->tracker); + instance->shellService = NULL; + serviceTracker_destroy(instance->tracker); celix_logHelper_destroy(instance->loghelper); - celixThreadMutex_destroy(&instance->mutex); + celixThreadMutex_destroy(&instance->mutex); + free(instance); - free(instance); - - - return status; + return status; } -celix_status_t shellMediator_executeCommand(shell_mediator_pt instance, char *command, FILE *out, FILE *err) { - celix_status_t status = CELIX_SUCCESS; - - celixThreadMutex_lock(&instance->mutex); +celix_status_t shellMediator_executeCommand(shell_mediator_pt instance, char* command, FILE* out, FILE* err) { + celix_status_t status = CELIX_SUCCESS; + celixThreadMutex_lock(&instance->mutex); - if (instance->shellService != NULL) { - instance->shellService->executeCommand(instance->shellService->handle, command, out, err); - } + if (instance->shellService != NULL) { + instance->shellService->executeCommand(instance->shellService->handle, command, out, err); + } - celixThreadMutex_unlock(&instance->mutex); + celixThreadMutex_unlock(&instance->mutex); - return status; + return status; } -static celix_status_t shellMediator_addedService(void *handler, service_reference_pt reference, void * service) { - celix_status_t status = CELIX_SUCCESS; - shell_mediator_pt instance = (shell_mediator_pt) handler; - celixThreadMutex_lock(&instance->mutex); - instance->shellService = (celix_shell_t*) service; - celixThreadMutex_unlock(&instance->mutex); - return status; +static celix_status_t shellMediator_addedService(void* handler, service_reference_pt reference, void* service) { + celix_status_t status = CELIX_SUCCESS; + shell_mediator_pt instance = (shell_mediator_pt)handler; + celixThreadMutex_lock(&instance->mutex); + instance->shellService = (celix_shell_t*)service; + celixThreadMutex_unlock(&instance->mutex); + return status; } - -static celix_status_t shellMediator_removedService(void *handler, service_reference_pt reference, void * service) { - celix_status_t status = CELIX_SUCCESS; - shell_mediator_pt instance = (shell_mediator_pt) handler; - celixThreadMutex_lock(&instance->mutex); - instance->shellService = NULL; - celixThreadMutex_unlock(&instance->mutex); - return status; +static celix_status_t shellMediator_removedService(void* handler, service_reference_pt reference, void* service) { + celix_status_t status = CELIX_SUCCESS; + shell_mediator_pt instance = (shell_mediator_pt)handler; + celixThreadMutex_lock(&instance->mutex); + instance->shellService = NULL; + celixThreadMutex_unlock(&instance->mutex); + return status; } - diff --cc libs/framework/gtest/CMakeLists.txt index 6770f7e03,3efab0dac..3a5016756 --- a/libs/framework/gtest/CMakeLists.txt +++ b/libs/framework/gtest/CMakeLists.txt @@@ -19,12 -19,12 +19,14 @@@ add_celix_bundle(simple_test_bundle1 NO celix_bundle_name(simple_test_bundle1 "Simple Test Bundle") celix_bundle_group(simple_test_bundle1 "test/group") celix_bundle_description(simple_test_bundle1 "Test Description") +celix_bundle_headers(simple_test_bundle1 "Extra-Header1: value1" "Extra-Header2: value2") +celix_bundle_headers(simple_test_bundle1 "Extra-Header3: value3") + add_celix_bundle(dup_symbolic_name_bundle NO_ACTIVATOR VERSION 1.0.0 SYMBOLIC_NAME simple_test_bundle1) + add_celix_bundle(simple_test_bundle2 NO_ACTIVATOR VERSION 1.0.0) add_celix_bundle(simple_test_bundle3 NO_ACTIVATOR VERSION 1.0.0) -add_celix_bundle(bundle_with_exception SOURCES src/nop_activator.c VERSION 1.0.0) +add_celix_bundle(bundle_with_exception SOURCES src/activator_with_exception.c VERSION 1.0.0) add_celix_bundle(bundle_with_bad_export NO_ACTIVATOR VERSION 1.0.0) celix_bundle_headers(bundle_with_bad_export "Export-Library: $<SEMICOLON>") add_celix_bundle(simple_cxx_bundle SOURCES src/HelloWorldCxxActivator.cc VERSION 1.0.0) @@@ -34,8 -34,9 +36,9 @@@ add_celix_bundle(cmp_test_bundle SOURCE add_celix_bundle(cond_test_bundle SOURCES src/CondTestBundleActivator.cc VERSION 1.0.0) add_subdirectory(subdir) #simple_test_bundle4, simple_test_bundle5 and sublib add_celix_bundle(celix_err_test_bundle SOURCES src/activator_with_celix_err.c VERSION 1.0.0) + add_celix_bundle(immediate_stop_bundle SOURCES src/activator_stop.c VERSION 1.0.0) -add_celix_bundle(unresolvable_bundle SOURCES src/nop_activator.c VERSION 1.0.0) +add_celix_bundle(unresolvable_bundle SOURCES src/activator_with_exception.c VERSION 1.0.0) if (CMAKE_BUILD_TYPE STREQUAL "Debug") set(POSTFIX ${CMAKE_DEBUG_POSTFIX}) endif() diff --cc libs/framework/src/framework.c index 459834532,4706a4ae6..e36a928ff --- a/libs/framework/src/framework.c +++ b/libs/framework/src/framework.c @@@ -262,10 -263,10 +263,10 @@@ celix_status_t framework_create(framewo framework->registry = celix_serviceRegistry_create(framework); bundle_context_t *context = NULL; status = CELIX_DO_IF(status, bundleContext_create(framework, framework->logger, framework->bundle, &context)); - status = CELIX_DO_IF(status, bundle_setContext(framework->bundle, context)); + CELIX_DO_IF(status, celix_bundle_setContext(framework->bundle, context)); //create framework bundle entry - celix_framework_bundle_entry_t *entry = fw_bundleEntry_create(framework->bundle); + celix_bundle_entry_t*entry = fw_bundleEntry_create(framework->bundle); celixThreadMutex_lock(&framework->installedBundles.mutex); celix_arrayList_add(framework->installedBundles.entries, entry); celixThreadMutex_unlock(&framework->installedBundles.mutex); @@@ -730,76 -729,76 +730,76 @@@ bool celix_framework_isBundleAlreadyIns return alreadyExists; } -celix_status_t fw_getDependentBundles(framework_pt framework, bundle_pt exporter, celix_array_list_t** list) { - celix_status_t status = CELIX_SUCCESS; - - if (*list != NULL || exporter == NULL || framework == NULL) { - return CELIX_ILLEGAL_ARGUMENT; - } - - celix_array_list_t* modules; - unsigned int modIdx = 0; - *list = celix_arrayList_create(); - - modules = bundle_getModules(exporter); - for (modIdx = 0; modIdx < celix_arrayList_size(modules); modIdx++) { - module_pt module = (module_pt)celix_arrayList_get(modules, modIdx); - celix_array_list_t* dependents = module_getDependents(module); - if (dependents != NULL) { - unsigned int depIdx = 0; - for (depIdx = 0; depIdx < celix_arrayList_size(dependents); depIdx++) { - module_pt dependent = (module_pt)celix_arrayList_get(dependents, depIdx); - celix_arrayList_add(*list, module_getBundle(dependent)); - } - celix_arrayList_destroy(dependents); - } - } - - framework_logIfError(framework->logger, status, NULL, "Cannot get dependent bundles"); - - return status; -} - -celix_status_t fw_populateDependentGraph(framework_pt framework, bundle_pt exporter, hash_map_pt* map) { - celix_status_t status = CELIX_SUCCESS; - - if (framework == NULL || exporter == NULL) { - return CELIX_ILLEGAL_ARGUMENT; - } - - celix_array_list_t* dependents = NULL; - if ((status = fw_getDependentBundles(framework, exporter, &dependents)) == CELIX_SUCCESS) { - if (dependents != NULL) { - unsigned int depIdx = 0; - for (depIdx = 0; depIdx < celix_arrayList_size(dependents); depIdx++) { - if (!hashMap_containsKey(*map, celix_arrayList_get(dependents, depIdx))) { - hashMap_put(*map, celix_arrayList_get(dependents, depIdx), celix_arrayList_get(dependents, depIdx)); - fw_populateDependentGraph(framework, (bundle_pt)celix_arrayList_get(dependents, depIdx), map); - } - } - celix_arrayList_destroy(dependents); - } - } - - framework_logIfError(framework->logger, status, NULL, "Cannot populate dependent graph"); - - return status; -} +//celix_status_t fw_getDependentBundles(framework_pt framework, bundle_pt exporter, celix_array_list_t** list) { +// celix_status_t status = CELIX_SUCCESS; +// +// if (*list != NULL || exporter == NULL || framework == NULL) { +// return CELIX_ILLEGAL_ARGUMENT; +// } +// +// celix_array_list_t* modules; +// unsigned int modIdx = 0; +// *list = celix_arrayList_create(); +// +// modules = bundle_getModules(exporter); +// for (modIdx = 0; modIdx < celix_arrayList_size(modules); modIdx++) { +// celix_module_t* module = celix_arrayList_get(modules, modIdx); +// celix_array_list_t* dependents = module_getDependents(module); +// if (dependents != NULL) { +// unsigned int depIdx = 0; +// for (depIdx = 0; depIdx < celix_arrayList_size(dependents); depIdx++) { +// celix_module_t* dependent = celix_arrayList_get(dependents, depIdx); +// celix_arrayList_add(*list, module_getBundle(dependent)); +// } +// celix_arrayList_destroy(dependents); +// } +// } +// +// framework_logIfError(framework->logger, status, NULL, "Cannot get dependent bundles"); +// +// return status; +//} + +//celix_status_t fw_populateDependentGraph(framework_pt framework, bundle_pt exporter, hash_map_pt* map) { +// celix_status_t status = CELIX_SUCCESS; +// +// if (framework == NULL || exporter == NULL) { +// return CELIX_ILLEGAL_ARGUMENT; +// } +// +// celix_array_list_t* dependents = NULL; +// if ((status = fw_getDependentBundles(framework, exporter, &dependents)) == CELIX_SUCCESS) { +// if (dependents != NULL) { +// unsigned int depIdx = 0; +// for (depIdx = 0; depIdx < celix_arrayList_size(dependents); depIdx++) { +// if (!hashMap_containsKey(*map, celix_arrayList_get(dependents, depIdx))) { +// hashMap_put(*map, celix_arrayList_get(dependents, depIdx), celix_arrayList_get(dependents, depIdx)); +// fw_populateDependentGraph(framework, (bundle_pt)celix_arrayList_get(dependents, depIdx), map); +// } +// } +// celix_arrayList_destroy(dependents); +// } +// } +// +// framework_logIfError(framework->logger, status, NULL, "Cannot populate dependent graph"); +// +// return status; +//} celix_status_t fw_registerService(framework_pt framework, service_registration_pt *registration, long bndId, const char* serviceName, const void* svcObj, celix_properties_t *properties) { - celix_status_t status = CELIX_SUCCESS; - char *error = NULL; - if (serviceName == NULL || svcObj == NULL) { - status = CELIX_ILLEGAL_ARGUMENT; - error = "ServiceName and SvcObj cannot be null"; - } + celix_status_t status = CELIX_SUCCESS; + char *error = NULL; + if (serviceName == NULL || svcObj == NULL) { + status = CELIX_ILLEGAL_ARGUMENT; + error = "ServiceName and SvcObj cannot be null"; + } - celix_framework_bundle_entry_t *entry = celix_framework_bundleEntry_getBundleEntryAndIncreaseUseCount(framework, - bndId); + celix_bundle_entry_t*entry = celix_framework_bundleEntry_getBundleEntryAndIncreaseUseCount(framework, + bndId); status = CELIX_DO_IF(status, serviceRegistry_registerService(framework->registry, entry->bnd, serviceName, svcObj, properties, registration)); - celix_framework_bundleEntry_decreaseUseCount(entry); + celix_bundleEntry_decreaseUseCount(entry); framework_logIfError(framework->logger, status, error, "Cannot register service: %s", serviceName); - return status; + return status; } celix_status_t fw_registerServiceFactory(framework_pt framework, service_registration_pt *registration, long bndId, const char* serviceName, service_factory_pt factory, celix_properties_t* properties) {