From beacc18e8152f2940371940e56c37cda9e8dc5be Mon Sep 17 00:00:00 2001 From: Pepijn Noltes Date: Sun, 31 Dec 2023 20:00:49 +0100 Subject: [PATCH 1/2] Remove properties.h and its usage --- .../rsa_spi/include/endpoint_description.h | 2 +- .../rsa_spi/include/endpoint_listener.h | 2 +- .../topology_manager/src/scope.h | 2 +- .../CelixBundleContextServicesTestSuite.cc | 16 ++-- libs/framework/include/celix_api.h | 2 +- .../include_deprecated/bundle_context.h | 1 - .../include_deprecated/dm_component.h | 2 +- libs/framework/include_deprecated/framework.h | 2 +- libs/framework/include_deprecated/manifest.h | 3 +- .../include_deprecated/service_registry.h | 2 +- libs/framework/src/bundle_context.c | 4 +- libs/framework/src/dm_component_impl.c | 4 +- libs/framework/src/framework.c | 8 +- libs/framework/src/framework_private.h | 6 +- libs/framework/src/manifest.c | 6 +- libs/framework/src/service_reference.c | 4 +- libs/framework/src/service_registration.c | 10 +-- .../src/service_registration_private.h | 6 +- libs/framework/src/service_registry.c | 12 +-- libs/framework/src/service_tracker.c | 4 +- libs/framework/src/service_tracker_private.h | 18 ++--- libs/utils/gtest/src/PropertiesTestSuite.cc | 28 ------- .../include_deprecated/celix_utils_api.h | 2 +- libs/utils/include_deprecated/filter.h | 1 - libs/utils/include_deprecated/properties.h | 75 ------------------- libs/utils/src/properties.c | 53 ++----------- 26 files changed, 67 insertions(+), 208 deletions(-) delete mode 100644 libs/utils/include_deprecated/properties.h diff --git a/bundles/remote_services/rsa_spi/include/endpoint_description.h b/bundles/remote_services/rsa_spi/include/endpoint_description.h index e9ba63e5d..6753c0dcb 100644 --- a/bundles/remote_services/rsa_spi/include/endpoint_description.h +++ b/bundles/remote_services/rsa_spi/include/endpoint_description.h @@ -27,7 +27,7 @@ #ifndef ENDPOINT_DESCRIPTION_H_ #define ENDPOINT_DESCRIPTION_H_ -#include "properties.h" +#include "celix_properties.h" #include "array_list.h" #include "celix_cleanup.h" #include diff --git a/bundles/remote_services/rsa_spi/include/endpoint_listener.h b/bundles/remote_services/rsa_spi/include/endpoint_listener.h index 68bad113e..4cf164573 100644 --- a/bundles/remote_services/rsa_spi/include/endpoint_listener.h +++ b/bundles/remote_services/rsa_spi/include/endpoint_listener.h @@ -28,7 +28,7 @@ #define ENDPOINT_LISTENER_H_ #include "array_list.h" -#include "properties.h" +#include "celix_properties.h" #include "endpoint_description.h" diff --git a/bundles/remote_services/topology_manager/src/scope.h b/bundles/remote_services/topology_manager/src/scope.h index 5e6542e8f..3ea256709 100644 --- a/bundles/remote_services/topology_manager/src/scope.h +++ b/bundles/remote_services/topology_manager/src/scope.h @@ -33,7 +33,7 @@ #include "celix_threads.h" #include "hash_map.h" #include "endpoint_description.h" -#include "properties.h" +#include "celix_properties.h" #include "service_reference.h" #include "tm_scope.h" diff --git a/libs/framework/gtest/src/CelixBundleContextServicesTestSuite.cc b/libs/framework/gtest/src/CelixBundleContextServicesTestSuite.cc index 02c8e07e0..54843a687 100644 --- a/libs/framework/gtest/src/CelixBundleContextServicesTestSuite.cc +++ b/libs/framework/gtest/src/CelixBundleContextServicesTestSuite.cc @@ -764,13 +764,13 @@ TEST_F(CelixBundleContextServicesTestSuite, ServicesTrackerTestWithAlreadyRegist TEST_F(CelixBundleContextServicesTestSuite, ServicesTrackerTestWithProperties) { int count = 0; int count2 = 0; - auto add = [](void *handle, void *svc, const properties_t *props) { + auto add = [](void *handle, void *svc, const celix_properties_t *props) { ASSERT_TRUE(svc != nullptr); ASSERT_TRUE(props != nullptr); int *c = static_cast(handle); *c += 1; }; - auto remove = [](void *handle, void *svc, const properties_t *props) { + auto remove = [](void *handle, void *svc, const celix_properties_t *props) { ASSERT_TRUE(svc != nullptr); ASSERT_TRUE(props != nullptr); int *c = static_cast(handle); @@ -813,14 +813,14 @@ TEST_F(CelixBundleContextServicesTestSuite, ServicesTrackerTestWithProperties) { TEST_F(CelixBundleContextServicesTestSuite, ServicesTrackerTestWithOwner) { int count = 0; - auto add = [](void *handle, void *svc, const properties_t *props, const bundle_t *svcOwner) { + auto add = [](void *handle, void *svc, const celix_properties_t *props, const bundle_t *svcOwner) { ASSERT_TRUE(svc != nullptr); ASSERT_TRUE(props != nullptr); ASSERT_TRUE(celix_bundle_getId(svcOwner) >= 0); int *c = static_cast(handle); *c += 1; }; - auto remove = [](void *handle, void *svc, const properties_t *props, const bundle_t *svcOwner) { + auto remove = [](void *handle, void *svc, const celix_properties_t *props, const bundle_t *svcOwner) { ASSERT_TRUE(svc != nullptr); ASSERT_TRUE(props != nullptr); ASSERT_TRUE(celix_bundle_getId(svcOwner) >= 0); @@ -1029,12 +1029,12 @@ TEST_F(CelixBundleContextServicesTestSuite, ServicesTrackerSetTest) { ASSERT_TRUE(trackerId >= 0); //register svc3 should lead to second set call - properties_t *props3 = celix_properties_create(); + celix_properties_t *props3 = celix_properties_create(); celix_properties_set(props3, CELIX_FRAMEWORK_SERVICE_RANKING, "10"); long svcId3 = celix_bundleContext_registerService(ctx, svc3, "NA", props3); //call 2 //register svc4 should lead to no set (lower ranking) - properties_t *props4 = celix_properties_create(); + celix_properties_t *props4 = celix_properties_create(); celix_properties_set(props4, CELIX_FRAMEWORK_SERVICE_RANKING, "10"); long svcId4 = celix_bundleContext_registerService(ctx, svc4, "NA", props4); //no update @@ -1087,12 +1087,12 @@ TEST_F(CelixBundleContextServicesTestSuite, TrackerOfAllServicesSetTest) { ASSERT_TRUE(trackerId >= 0); //register svc3 should lead to second set call - properties_t *props3 = celix_properties_create(); + celix_properties_t *props3 = celix_properties_create(); celix_properties_set(props3, CELIX_FRAMEWORK_SERVICE_RANKING, "10"); long svcId3 = celix_bundleContext_registerService(ctx, svc3, "NA", props3); //call 2 //register svc4 should lead to no set (lower ranking) - properties_t *props4 = celix_properties_create(); + celix_properties_t *props4 = celix_properties_create(); celix_properties_set(props4, CELIX_FRAMEWORK_SERVICE_RANKING, "10"); long svcId4 = celix_bundleContext_registerService(ctx, svc4, "NA", props4); //no update diff --git a/libs/framework/include/celix_api.h b/libs/framework/include/celix_api.h index 84f1b31fa..f5caf0d9a 100644 --- a/libs/framework/include/celix_api.h +++ b/libs/framework/include/celix_api.h @@ -20,7 +20,7 @@ #ifndef CELIX_CELIX_API_H_ #define CELIX_CELIX_API_H_ -#include "properties.h" +#include "celix_properties.h" #include "array_list.h" #include "bundle.h" diff --git a/libs/framework/include_deprecated/bundle_context.h b/libs/framework/include_deprecated/bundle_context.h index 1ee6bfe33..e1a83c7b8 100644 --- a/libs/framework/include_deprecated/bundle_context.h +++ b/libs/framework/include_deprecated/bundle_context.h @@ -34,7 +34,6 @@ #include "celix_service_listener.h" #include "bundle_listener.h" #include "framework_listener.h" -#include "properties.h" #include "array_list.h" #include "celix_service_listener.h" diff --git a/libs/framework/include_deprecated/dm_component.h b/libs/framework/include_deprecated/dm_component.h index abe1e42ed..1c397eb06 100644 --- a/libs/framework/include_deprecated/dm_component.h +++ b/libs/framework/include_deprecated/dm_component.h @@ -31,7 +31,7 @@ #include "celix_types.h" #include "celix_errno.h" -#include "properties.h" +#include "celix_properties.h" #include "array_list.h" #include "celix_dm_info.h" #include "celix_dm_component.h" diff --git a/libs/framework/include_deprecated/framework.h b/libs/framework/include_deprecated/framework.h index e3c45ada3..3ef46bc9a 100644 --- a/libs/framework/include_deprecated/framework.h +++ b/libs/framework/include_deprecated/framework.h @@ -22,7 +22,7 @@ #include "celix_errno.h" #include "bundle.h" -#include "properties.h" +#include "celix_properties.h" #include "bundle_context.h" #include "celix_framework_export.h" diff --git a/libs/framework/include_deprecated/manifest.h b/libs/framework/include_deprecated/manifest.h index e4c4d629f..60da8dedf 100644 --- a/libs/framework/include_deprecated/manifest.h +++ b/libs/framework/include_deprecated/manifest.h @@ -30,10 +30,11 @@ #include #include -#include "properties.h" #include "celix_cleanup.h" #include "celix_errno.h" #include "celix_framework_export.h" +#include "celix_properties.h" +#include "hash_map.h" #ifdef __cplusplus extern "C" { diff --git a/libs/framework/include_deprecated/service_registry.h b/libs/framework/include_deprecated/service_registry.h index 40e568cca..fb20c826d 100644 --- a/libs/framework/include_deprecated/service_registry.h +++ b/libs/framework/include_deprecated/service_registry.h @@ -20,7 +20,7 @@ #ifndef SERVICE_REGISTRY_H_ #define SERVICE_REGISTRY_H_ -#include "properties.h" +#include "celix_properties.h" #include "filter.h" #include "service_factory.h" #include "celix_service_event.h" diff --git a/libs/framework/src/bundle_context.c b/libs/framework/src/bundle_context.c index 7985fcf3a..4a400a9c0 100644 --- a/libs/framework/src/bundle_context.c +++ b/libs/framework/src/bundle_context.c @@ -164,7 +164,7 @@ celix_status_t bundleContext_installBundle2(bundle_context_pt context, } celix_status_t bundleContext_registerService(bundle_context_pt context, const char * serviceName, const void * svcObj, - properties_pt properties, service_registration_pt *service_registration) { + celix_properties_t* properties, service_registration_pt *service_registration) { if (context == NULL || service_registration == NULL) { return CELIX_ILLEGAL_ARGUMENT; } @@ -173,7 +173,7 @@ celix_status_t bundleContext_registerService(bundle_context_pt context, const ch } celix_status_t bundleContext_registerServiceFactory(bundle_context_pt context, const char * serviceName, service_factory_pt factory, - properties_pt properties, service_registration_pt *service_registration) { + celix_properties_t* properties, service_registration_pt *service_registration) { if (context == NULL || service_registration == NULL) { return CELIX_ILLEGAL_ARGUMENT; } diff --git a/libs/framework/src/dm_component_impl.c b/libs/framework/src/dm_component_impl.c index d4c3ea60e..998f05888 100644 --- a/libs/framework/src/dm_component_impl.c +++ b/libs/framework/src/dm_component_impl.c @@ -442,7 +442,7 @@ celix_status_t celix_dmComponent_setCLanguageProperty(celix_dm_component_t *comp return CELIX_SUCCESS; } -celix_status_t component_addInterface(celix_dm_component_t *component, const char* serviceName, const char* serviceVersion, const void* service, properties_pt properties) { +celix_status_t component_addInterface(celix_dm_component_t *component, const char* serviceName, const char* serviceVersion, const void* service, celix_properties_t* properties) { return celix_dmComponent_addInterface(component, serviceName, serviceVersion, service, properties); } @@ -1151,7 +1151,7 @@ void celix_dmComponent_destroyComponentInfo(celix_dm_component_info_t* info) { for (i = 0; i < size; i += 1) { dm_interface_info_pt intfInfo = celix_arrayList_get(info->interfaces, i); free(intfInfo->name); - properties_destroy(intfInfo->properties); + celix_properties_destroy(intfInfo->properties); free(intfInfo); } celix_arrayList_destroy(info->interfaces); diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c index 227eb77ea..f21b53296 100644 --- a/libs/framework/src/framework.c +++ b/libs/framework/src/framework.c @@ -371,7 +371,7 @@ celix_status_t framework_destroy(framework_pt framework) { celix_frameworkLogger_destroy(framework->logger); - properties_destroy(framework->configurationMap); + celix_properties_destroy(framework->configurationMap); free(framework->dispatcher.eventQueue); free(framework); @@ -778,7 +778,7 @@ celix_status_t fw_registerService(framework_pt framework, service_registration_p return status; } -celix_status_t fw_registerServiceFactory(framework_pt framework, service_registration_pt *registration, long bndId, const char* serviceName, service_factory_pt factory, properties_pt properties) { +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) { celix_status_t status = CELIX_SUCCESS; char *error = NULL; if (serviceName == NULL || factory == NULL) { @@ -816,11 +816,11 @@ celix_status_t fw_getServiceReferences(framework_pt framework, array_list_pt *re service_reference_pt ref = (service_reference_pt) arrayList_get(*references, refIdx); service_registration_pt reg = NULL; const char* serviceNameObjectClass; - properties_pt props = NULL; + celix_properties_t* props = NULL; status = CELIX_DO_IF(status, serviceReference_getServiceRegistration(ref, ®)); status = CELIX_DO_IF(status, serviceRegistration_getProperties(reg, &props)); if (status == CELIX_SUCCESS) { - serviceNameObjectClass = properties_get(props, CELIX_FRAMEWORK_SERVICE_NAME); + serviceNameObjectClass = celix_properties_get(props, CELIX_FRAMEWORK_SERVICE_NAME, NULL); if (!serviceReference_isAssignableTo(ref, bundle, serviceNameObjectClass)) { serviceReference_release(ref, NULL); arrayList_remove(*references, refIdx); diff --git a/libs/framework/src/framework_private.h b/libs/framework/src/framework_private.h index a5b299ff0..3dfe7bdaf 100644 --- a/libs/framework/src/framework_private.h +++ b/libs/framework/src/framework_private.h @@ -162,7 +162,7 @@ struct celix_framework { } installedBundles; - properties_pt configurationMap; + celix_properties_t* configurationMap; struct { @@ -264,8 +264,8 @@ bool celix_framework_getConfigPropertyAsBool(celix_framework_t* framework, const celix_status_t celix_framework_installBundleInternal(celix_framework_t* framework, const char* bndLoc, long* bndId); -celix_status_t fw_registerService(framework_pt framework, service_registration_pt * registration, long bundleId, const char* serviceName, const void* svcObj, properties_pt properties); -celix_status_t fw_registerServiceFactory(framework_pt framework, service_registration_pt * registration, long bundleId, const char* serviceName, service_factory_pt factory, properties_pt properties); +celix_status_t fw_registerService(framework_pt framework, service_registration_pt * registration, long bundleId, const char* serviceName, const void* svcObj, celix_properties_t* properties); +celix_status_t fw_registerServiceFactory(framework_pt framework, service_registration_pt * registration, long bundleId, const char* serviceName, service_factory_pt factory, celix_properties_t* properties); celix_status_t fw_getServiceReferences(framework_pt framework, array_list_pt *references, bundle_pt bundle, const char* serviceName, const char* filter); celix_status_t fw_getBundleRegisteredServices(framework_pt framework, bundle_pt bundle, array_list_pt *services); diff --git a/libs/framework/src/manifest.c b/libs/framework/src/manifest.c index 1ba4f9abf..709d94351 100644 --- a/libs/framework/src/manifest.c +++ b/libs/framework/src/manifest.c @@ -96,7 +96,7 @@ manifest_pt manifest_clone(manifest_pt manifest) { celix_status_t manifest_destroy(manifest_pt manifest) { if (manifest != NULL) { - properties_destroy(manifest->mainAttributes); + celix_properties_destroy(manifest->mainAttributes); hash_map_iterator_t iter = hashMapIterator_construct(manifest->attributes); while (hashMapIterator_hasNext(&iter)) { hash_map_entry_pt entry = hashMapIterator_nextEntry(&iter); @@ -133,7 +133,7 @@ void manifest_clear(manifest_pt manifest) { } //LCOV_EXCL_STOP -properties_pt manifest_getMainAttributes(manifest_pt manifest) { + celix_properties_t* manifest_getMainAttributes(manifest_pt manifest) { return manifest->mainAttributes; } @@ -307,7 +307,7 @@ void manifest_write(manifest_pt manifest, const char * filename) { //LCOV_EXCL_STOP const char* manifest_getValue(manifest_pt manifest, const char* name) { - const char* val = properties_get(manifest->mainAttributes, name); + const char* val = celix_properties_get(manifest->mainAttributes, name, NULL); bool isEmpty = utils_isStringEmptyOrNull(val); return isEmpty ? NULL : val; } diff --git a/libs/framework/src/service_reference.c b/libs/framework/src/service_reference.c index 21d1a2829..aa6b5ebd7 100644 --- a/libs/framework/src/service_reference.c +++ b/libs/framework/src/service_reference.c @@ -184,10 +184,10 @@ long serviceReference_getServiceId(service_reference_pt ref) { celix_status_t serviceReference_getPropertyWithDefault(service_reference_pt ref, const char *key, const char* def, const char **value) { celix_status_t status = CELIX_SUCCESS; - properties_pt props = NULL; + celix_properties_t* props = NULL; status = serviceRegistration_getProperties(ref->registration, &props); if (status == CELIX_SUCCESS) { - *value = (char*) properties_getWithDefault(props, key, def); + *value = (char*) celix_properties_get(props, key, def); } return status; } diff --git a/libs/framework/src/service_registration.c b/libs/framework/src/service_registration.c index 45b89c6e2..5744bd1e3 100644 --- a/libs/framework/src/service_registration.c +++ b/libs/framework/src/service_registration.c @@ -39,13 +39,13 @@ static celix_status_t serviceRegistration_createInternal(registry_callback_t cal enum celix_service_type svcType, service_registration_t** out); -service_registration_pt serviceRegistration_create(registry_callback_t callback, bundle_pt bundle, const char* serviceName, long serviceId, const void * serviceObject, properties_pt dictionary) { +service_registration_pt serviceRegistration_create(registry_callback_t callback, bundle_pt bundle, const char* serviceName, long serviceId, const void * serviceObject, celix_properties_t* dictionary) { service_registration_pt registration = NULL; serviceRegistration_createInternal(callback, bundle, serviceName, serviceId, serviceObject, dictionary, CELIX_PLAIN_SERVICE, ®istration); return registration; } -service_registration_pt serviceRegistration_createServiceFactory(registry_callback_t callback, bundle_pt bundle, const char* serviceName, long serviceId, const void * serviceObject, properties_pt dictionary) { +service_registration_pt serviceRegistration_createServiceFactory(registry_callback_t callback, bundle_pt bundle, const char* serviceName, long serviceId, const void * serviceObject, celix_properties_t* dictionary) { service_registration_pt registration = NULL; serviceRegistration_createInternal(callback, bundle, serviceName, serviceId, serviceObject, dictionary, CELIX_DEPRECATED_FACTORY_SERVICE, ®istration); return registration; @@ -99,7 +99,7 @@ static bool serviceRegistration_destroy(struct celix_ref *refCount) { free(registration->className); registration->className = NULL; registration->callback.unregister = NULL; - properties_destroy(registration->properties); + celix_properties_destroy(registration->properties); celixThreadRwlock_destroy(®istration->lock); free(registration); return true; @@ -121,7 +121,7 @@ static celix_status_t serviceRegistration_initializeProperties(service_registrat registration->properties = props; } else { celix_err_push("Cannot initialize service registration properties"); - properties_destroy(props); + celix_properties_destroy(props); } return CELIX_SUCCESS; @@ -206,7 +206,7 @@ celix_status_t serviceRegistration_ungetService(service_registration_pt registra return status; } -celix_status_t serviceRegistration_getProperties(service_registration_pt registration, properties_pt *properties) { +celix_status_t serviceRegistration_getProperties(service_registration_pt registration, celix_properties_t** properties) { celix_status_t status = CELIX_SUCCESS; if (registration != NULL) { diff --git a/libs/framework/src/service_registration_private.h b/libs/framework/src/service_registration_private.h index 0e896df22..8f00b7541 100644 --- a/libs/framework/src/service_registration_private.h +++ b/libs/framework/src/service_registration_private.h @@ -37,7 +37,7 @@ struct serviceRegistration { char* className; // read-only bundle_pt bundle; // read-only - properties_pt properties; // read-only + celix_properties_t* properties; // read-only long serviceId; // read-only bool isUnregistering; @@ -52,8 +52,8 @@ struct serviceRegistration { celix_thread_rwlock_t lock; // protects the service object }; -service_registration_pt serviceRegistration_create(registry_callback_t callback, bundle_pt bundle, const char* serviceName, long serviceId, const void * serviceObject, properties_pt dictionary); -service_registration_pt serviceRegistration_createServiceFactory(registry_callback_t callback, bundle_pt bundle, const char* serviceName, long serviceId, const void * serviceObject, properties_pt dictionary); +service_registration_pt serviceRegistration_create(registry_callback_t callback, bundle_pt bundle, const char* serviceName, long serviceId, const void * serviceObject, celix_properties_t* dictionary); +service_registration_pt serviceRegistration_createServiceFactory(registry_callback_t callback, bundle_pt bundle, const char* serviceName, long serviceId, const void * serviceObject, celix_properties_t* dictionary); void serviceRegistration_retain(service_registration_pt registration); void serviceRegistration_release(service_registration_pt registration); diff --git a/libs/framework/src/service_registry.c b/libs/framework/src/service_registry.c index 7f1958703..c84fe27c3 100644 --- a/libs/framework/src/service_registry.c +++ b/libs/framework/src/service_registry.c @@ -32,7 +32,7 @@ #include "service_reference_private.h" #include "framework_private.h" -static celix_status_t serviceRegistry_registerServiceInternal(service_registry_pt registry, bundle_pt bundle, const char* serviceName, const void * serviceObject, properties_pt dictionary, long reservedId, enum celix_service_type svcType, service_registration_pt *registration); +static celix_status_t serviceRegistry_registerServiceInternal(service_registry_pt registry, bundle_pt bundle, const char* serviceName, const void * serviceObject, celix_properties_t* dictionary, long reservedId, enum celix_service_type svcType, service_registration_pt *registration); static celix_status_t serviceRegistry_unregisterService(service_registry_pt registry, bundle_pt bundle, service_registration_pt registration); static bool serviceRegistry_tryRemoveServiceReference(service_registry_pt registry, service_reference_pt ref); static celix_status_t serviceRegistry_addHooks(service_registry_pt registry, const char* serviceName, const void *serviceObject, service_registration_pt registration); @@ -169,15 +169,15 @@ celix_status_t serviceRegistry_getRegisteredServices(service_registry_pt registr return status; } -celix_status_t serviceRegistry_registerService(service_registry_pt registry, bundle_pt bundle, const char* serviceName, const void* serviceObject, properties_pt dictionary, service_registration_pt *registration) { +celix_status_t serviceRegistry_registerService(service_registry_pt registry, bundle_pt bundle, const char* serviceName, const void* serviceObject, celix_properties_t* dictionary, service_registration_pt *registration) { return serviceRegistry_registerServiceInternal(registry, bundle, serviceName, serviceObject, dictionary, 0 /*TODO*/, CELIX_PLAIN_SERVICE, registration); } -celix_status_t serviceRegistry_registerServiceFactory(service_registry_pt registry, bundle_pt bundle, const char* serviceName, service_factory_pt factory, properties_pt dictionary, service_registration_pt *registration) { +celix_status_t serviceRegistry_registerServiceFactory(service_registry_pt registry, bundle_pt bundle, const char* serviceName, service_factory_pt factory, celix_properties_t* dictionary, service_registration_pt *registration) { return serviceRegistry_registerServiceInternal(registry, bundle, serviceName, (const void *) factory, dictionary, 0 /*TODO*/, CELIX_DEPRECATED_FACTORY_SERVICE, registration); } -static celix_status_t serviceRegistry_registerServiceInternal(service_registry_pt registry, bundle_pt bundle, const char* serviceName, const void * serviceObject, properties_pt dictionary, long reservedId, enum celix_service_type svcType, service_registration_pt *registration) { +static celix_status_t serviceRegistry_registerServiceInternal(service_registry_pt registry, bundle_pt bundle, const char* serviceName, const void * serviceObject, celix_properties_t* dictionary, long reservedId, enum celix_service_type svcType, service_registration_pt *registration) { array_list_pt regs; long svcId = reservedId > 0 ? reservedId : celix_serviceRegistry_nextSvcId(registry); @@ -341,7 +341,7 @@ celix_status_t serviceRegistry_getServiceReferences(service_registry_pt registry unsigned int regIdx; for (regIdx = 0; (regs != NULL) && regIdx < arrayList_size(regs); regIdx++) { service_registration_pt registration = (service_registration_pt) arrayList_get(regs, regIdx); - properties_pt props = NULL; + celix_properties_t* props = NULL; status = serviceRegistration_getProperties(registration, &props); if (status == CELIX_SUCCESS) { @@ -1000,7 +1000,7 @@ celix_status_t celix_serviceRegistry_addServiceListener(celix_service_registry_t celix_array_list_t *regs = (array_list_pt) hashMapIterator_nextValue(&iter); for (int regIdx = 0; (regs != NULL) && regIdx < celix_arrayList_size(regs); ++regIdx) { service_registration_pt registration = celix_arrayList_get(regs, regIdx); - properties_pt props = NULL; + celix_properties_t* props = NULL; serviceRegistration_getProperties(registration, &props); if (celix_filter_match(filter, props)) { long svcId = serviceRegistration_getServiceId(registration); diff --git a/libs/framework/src/service_tracker.c b/libs/framework/src/service_tracker.c index 18d07cd4e..08ecb845b 100644 --- a/libs/framework/src/service_tracker.c +++ b/libs/framework/src/service_tracker.c @@ -41,7 +41,7 @@ static void serviceTracker_untrackTracked(service_tracker_t *tracker, celix_trac static celix_status_t serviceTracker_invokeAddingService(service_tracker_t *tracker, service_reference_pt ref, void **svcOut); static celix_status_t serviceTracker_invokeAddService(service_tracker_t *tracker, celix_tracked_entry_t *tracked); static celix_status_t serviceTracker_invokeRemovingService(service_tracker_t *tracker, celix_tracked_entry_t *tracked); -static void serviceTracker_checkAndInvokeSetService(void *handle, void *highestSvc, const properties_t *props, const bundle_t *bnd); +static void serviceTracker_checkAndInvokeSetService(void *handle, void *highestSvc, const celix_properties_t *props, const bundle_t *bnd); static void serviceTracker_serviceChanged(void *handle, celix_service_event_t *event); @@ -400,7 +400,7 @@ static celix_status_t serviceTracker_track(service_tracker_t* tracker, service_r assert(reference != NULL); service_registration_t *reg = NULL; - properties_t *props = NULL; + celix_properties_t *props = NULL; bundle_t *bnd = NULL; serviceReference_getBundle(reference, &bnd); diff --git a/libs/framework/src/service_tracker_private.h b/libs/framework/src/service_tracker_private.h index 196c3c5f5..a2ca4fccc 100644 --- a/libs/framework/src/service_tracker_private.h +++ b/libs/framework/src/service_tracker_private.h @@ -46,15 +46,15 @@ struct celix_serviceTracker { void (*remove)(void *handle, void *svc); void (*modified)(void *handle, void *svc); - void (*setWithProperties)(void *handle, void *svc, const properties_t *props); //highest ranking - void (*addWithProperties)(void *handle, void *svc, const properties_t *props); - void (*removeWithProperties)(void *handle, void *svc, const properties_t *props); - void (*modifiedWithProperties)(void *handle, void *svc, const properties_t *props); + void (*setWithProperties)(void *handle, void *svc, const celix_properties_t* props); //highest ranking + void (*addWithProperties)(void *handle, void *svc, const celix_properties_t* props); + void (*removeWithProperties)(void *handle, void *svc, const celix_properties_t* props); + void (*modifiedWithProperties)(void *handle, void *svc, const celix_properties_t* props); - void (*setWithOwner)(void *handle, void *svc, const properties_t *props, const bundle_t *owner); //highest ranking - void (*addWithOwner)(void *handle, void *svc, const properties_t *props, const bundle_t *owner); - void (*removeWithOwner)(void *handle, void *svc, const properties_t *props, const bundle_t *owner); - void (*modifiedWithOwner)(void *handle, void *svc, const properties_t *props, const bundle_t *owner); + void (*setWithOwner)(void *handle, void *svc, const celix_properties_t* props, const bundle_t *owner); //highest ranking + void (*addWithOwner)(void *handle, void *svc, const celix_properties_t* props, const bundle_t *owner); + void (*removeWithOwner)(void *handle, void *svc, const celix_properties_t* props, const bundle_t *owner); + void (*modifiedWithOwner)(void *handle, void *svc, const celix_properties_t* props, const bundle_t *owner); struct { celix_thread_mutex_t mutex; //projects below @@ -78,7 +78,7 @@ typedef struct celix_tracked_entry { long serviceId; //cached service.id of the service long serviceRanking; //cached service.ranking of the service const char *serviceName; - properties_t *properties; + celix_properties_t *properties; bundle_t *serviceOwner; celix_thread_mutex_t mutex; //protects useCount diff --git a/libs/utils/gtest/src/PropertiesTestSuite.cc b/libs/utils/gtest/src/PropertiesTestSuite.cc index 3e395908e..1d366173b 100644 --- a/libs/utils/gtest/src/PropertiesTestSuite.cc +++ b/libs/utils/gtest/src/PropertiesTestSuite.cc @@ -25,7 +25,6 @@ #include "celix_properties.h" #include "celix_properties_internal.h" #include "celix_utils.h" -#include "properties.h" using ::testing::MatchesRegex; @@ -599,33 +598,6 @@ TEST_F(PropertiesTestSuite, SetEntryTest) { celix_properties_destroy(props2); } -TEST_F(PropertiesTestSuite, DeprecatedApiTest) { - //Check if the deprecated api can still be used - auto* props = properties_create(); - properties_set(props, "key", "value"); - EXPECT_EQ(1, celix_properties_size(props)); - EXPECT_STREQ("value", properties_get(props, "key")); - EXPECT_STREQ("notfound", properties_getWithDefault(props, "non-existing", "notfound")); - properties_unset(props, "key"); - EXPECT_EQ(0, celix_properties_size(props)); - celix_properties_t * copy = nullptr; - EXPECT_EQ(CELIX_SUCCESS, properties_copy(props, ©)); - properties_destroy(copy); - - - properties_store(props, "deprecated-api-stored.properties", ""); - auto* loaded = properties_load("deprecated-api-stored.properties"); - EXPECT_NE(nullptr, loaded); - properties_destroy(loaded); - - loaded = properties_loadFromString("key=value"); - EXPECT_EQ(1, celix_properties_size(loaded)); - properties_destroy(loaded); - - - properties_destroy(props); -} - TEST_F(PropertiesTestSuite, PropertiesAutoCleanupTest) { celix_autoptr(celix_properties_t) props = celix_properties_create(); } diff --git a/libs/utils/include_deprecated/celix_utils_api.h b/libs/utils/include_deprecated/celix_utils_api.h index ef3153066..61c2df4f9 100644 --- a/libs/utils/include_deprecated/celix_utils_api.h +++ b/libs/utils/include_deprecated/celix_utils_api.h @@ -26,7 +26,7 @@ #include "celix_threads.h" #include "array_list.h" #include "hash_map.h" -#include "properties.h" +#include "celix_properties.h" #include "utils.h" #include "celix_utils.h" #include "version.h" diff --git a/libs/utils/include_deprecated/filter.h b/libs/utils/include_deprecated/filter.h index 37fa84ac6..c49efbbdf 100644 --- a/libs/utils/include_deprecated/filter.h +++ b/libs/utils/include_deprecated/filter.h @@ -21,7 +21,6 @@ #define FILTER_H_ #include "celix_errno.h" -#include "properties.h" #include "celix_properties.h" #include "celix_filter.h" #include "celix_utils_export.h" diff --git a/libs/utils/include_deprecated/properties.h b/libs/utils/include_deprecated/properties.h deleted file mode 100644 index d03f5f940..000000000 --- a/libs/utils/include_deprecated/properties.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/** - * properties.h - * - * \date Apr 27, 2010 - * \author Apache Celix Project Team - * \copyright Apache License, Version 2.0 - */ - -#ifndef PROPERTIES_H_ -#define PROPERTIES_H_ - -#include - -#include "celix_properties.h" -#include "hash_map.h" -#include "celix_utils_export.h" -#include "celix_errno.h" -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct celix_properties* properties_pt __attribute__((deprecated("properties is deprecated use celix_properties instead"))); -typedef struct celix_properties properties_t __attribute__((deprecated("properties is deprecated use celix_properties instead"))); - -CELIX_UTILS_DEPRECATED_EXPORT celix_properties_t* properties_create(void); - -CELIX_UTILS_DEPRECATED_EXPORT void properties_destroy(celix_properties_t *properties); - -CELIX_UTILS_DEPRECATED_EXPORT celix_properties_t* properties_load(const char *filename); - -CELIX_UTILS_DEPRECATED_EXPORT celix_properties_t* properties_loadWithStream(FILE *stream); - -CELIX_UTILS_DEPRECATED_EXPORT celix_properties_t* properties_loadFromString(const char *input); - -CELIX_UTILS_DEPRECATED_EXPORT void properties_store(celix_properties_t *properties, const char *file, const char *header); - -CELIX_UTILS_DEPRECATED_EXPORT const char* properties_get(celix_properties_t *properties, const char *key); - -CELIX_UTILS_DEPRECATED_EXPORT const char* properties_getWithDefault(celix_properties_t *properties, const char *key, const char *defaultValue); - -CELIX_UTILS_DEPRECATED_EXPORT void properties_set(celix_properties_t *properties, const char *key, const char *value); - -CELIX_UTILS_DEPRECATED_EXPORT void properties_unset(celix_properties_t *properties, const char *key); - -CELIX_UTILS_DEPRECATED_EXPORT celix_status_t properties_copy(celix_properties_t *properties, celix_properties_t **copy); - -/** TODO refactor -#define PROPERTIES_FOR_EACH(props, key) \ - for(hash_map_iterator_t iter = hashMapIterator_construct(props); \ - hashMapIterator_hasNext(&iter), (key) = (const char*)hashMapIterator_nextKey(&iter);) -*/ - -#ifdef __cplusplus -} -#endif - -#endif /* PROPERTIES_H_ */ diff --git a/libs/utils/src/properties.c b/libs/utils/src/properties.c index 8d3a2dfac..1efc76c6e 100644 --- a/libs/utils/src/properties.c +++ b/libs/utils/src/properties.c @@ -17,7 +17,6 @@ * under the License. */ -#include "properties.h" #include "celix_properties.h" #include "celix_properties_private.h" #include "celix_properties_internal.h" @@ -79,44 +78,8 @@ struct celix_properties { static celix_status_t celix_properties_parseLine(const char* line, celix_properties_t* props); -properties_pt properties_create(void) { return celix_properties_create(); } - -void properties_destroy(properties_pt properties) { celix_properties_destroy(properties); } - -properties_pt properties_load(const char* filename) { return celix_properties_load(filename); } - -properties_pt properties_loadWithStream(FILE* file) { return celix_properties_loadWithStream(file); } - -properties_pt properties_loadFromString(const char* input) { return celix_properties_loadFromString(input); } - -/** - * Header is ignored for now, cannot handle comments yet - */ -void properties_store(properties_pt properties, const char* filename, const char* header) { - celix_properties_store(properties, filename, header); -} - -celix_status_t properties_copy(properties_pt properties, properties_pt* out) { - celix_properties_t* copy = celix_properties_copy(properties); - *out = copy; - return copy == NULL ? CELIX_ENOMEM : CELIX_SUCCESS; -} - -const char* properties_get(properties_pt properties, const char* key) { - return celix_properties_get(properties, key, NULL); -} - -const char* properties_getWithDefault(properties_pt properties, const char* key, const char* defaultValue) { - return celix_properties_get(properties, key, defaultValue); -} - -void properties_set(properties_pt properties, const char* key, const char* value) { - celix_properties_set(properties, key, value); -} - -void properties_unset(properties_pt properties, const char* key) { celix_properties_unset(properties, key); } - -static void updateBuffers(char** key, char** value, char** output, int outputPos, int* key_len, int* value_len) { +static void +celix_properties_updateBuffers(char** key, char** value, char** output, int outputPos, int* key_len, int* value_len) { if (*output == *key) { if (outputPos == (*key_len) - 1) { (*key_len) += MALLOC_BLOCK_SIZE; @@ -426,7 +389,7 @@ static celix_status_t celix_properties_parseLine(const char* line, celix_propert if (precedingCharIsBackslash) { // escaped special character output[outputPos++] = line[linePos]; - updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len); + celix_properties_updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len); precedingCharIsBackslash = false; } else { if (line[linePos] == '#' || line[linePos] == '!') { @@ -435,15 +398,15 @@ static celix_status_t celix_properties_parseLine(const char* line, celix_propert return CELIX_SUCCESS; } else { output[outputPos++] = line[linePos]; - updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len); + celix_properties_updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len); } } else { // = or : if (output == value) { // already have a seperator output[outputPos++] = line[linePos]; - updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len); + celix_properties_updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len); } else { output[outputPos++] = '\0'; - updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len); + celix_properties_updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len); output = value; outputPos = 0; } @@ -452,13 +415,13 @@ static celix_status_t celix_properties_parseLine(const char* line, celix_propert } else if (line[linePos] == '\\') { if (precedingCharIsBackslash) { // double backslash -> backslash output[outputPos++] = '\\'; - updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len); + celix_properties_updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len); } precedingCharIsBackslash = true; } else { // normal character precedingCharIsBackslash = false; output[outputPos++] = line[linePos]; - updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len); + celix_properties_updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len); } linePos += 1; } From 11d93379efde4e6b1bf1c7ee4a264e20012d2c7b Mon Sep 17 00:00:00 2001 From: Pepijn Noltes Date: Sun, 31 Dec 2023 20:05:48 +0100 Subject: [PATCH 2/2] Update CHANGES.md for properties.h removal --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 80491886e..7bad664dc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -54,6 +54,7 @@ limitations under the License. - celix_string/long_hashmap put functions now return a celix_status_t instead of bool (value replaced). THe celix_status_t is used to indicate an ENOMEM error. - Embedded bundles are no longer supported. +- properties.h is removed and no longer supported. Use celix_properties.h instead. ## New Features