You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2023/12/30 18:40:32 UTC
(celix) 04/09: Remove deprecated array_list and its usage
This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch feature/509-remove-cpputests
in repository https://gitbox.apache.org/repos/asf/celix.git
commit daa0060a4b53968e06602713acb95444ac2f582d
Author: Pepijn Noltes <pn...@apache.org>
AuthorDate: Sat Dec 23 19:07:37 2023 +0100
Remove deprecated array_list and its usage
---
bundles/http_admin/http_admin/src/http_admin.c | 17 +-
.../private/include/pubsub_websocket_private.h | 4 +-
.../private/src/ps_websocket_activator.c | 6 +-
.../private/src/pubsub_websocket_example.c | 2 +-
.../pubsub_admin_tcp/src/pubsub_tcp_handler.c | 1 -
.../pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c | 1 +
.../src/pubsub_zmq_topic_receiver.c | 2 +
.../pubsub_discovery/src/pubsub_discovery_impl.c | 2 +-
bundles/pubsub/pubsub_utils/src/pubsub_utils.c | 22 +-
.../include/endpoint_descriptor_reader.h | 4 +-
.../include/endpoint_descriptor_writer.h | 4 +-
.../include/endpoint_discovery_poller.h | 2 +-
.../src/endpoint_descriptor_reader.c | 33 +-
.../src/endpoint_descriptor_writer.c | 6 +-
.../src/endpoint_discovery_poller.c | 210 ++++++-------
.../src/endpoint_discovery_server.c | 23 +-
.../gtest/src/rsa_tests.cc | 8 +-
.../src/remote_service_admin_dfi.c | 34 +--
.../src/remote_service_admin_dfi.h | 6 +-
.../rsa_common/src/import_registration_impl.c | 5 +-
.../rsa_common/src/import_registration_impl.h | 2 +-
.../rsa_common/src/remote_interceptors_handler.c | 31 +-
.../rsa_common/src/remote_service_admin_impl.h | 6 +-
.../rsa_spi/include/endpoint_description.h | 1 -
.../rsa_spi/include/endpoint_listener.h | 1 -
.../rsa_spi/include/remote_service_admin.h | 6 +-
.../remote_services/topology_manager/src/scope.c | 60 ++--
.../topology_manager/src/topology_manager.c | 12 +-
.../topology_manager/src/topology_manager.h | 4 +-
.../tms_tst/disc_mock/disc_mock_activator.c | 10 +-
.../tms_tst/disc_mock/disc_mock_service.c | 4 +-
.../tms_tst/disc_mock/disc_mock_service.h | 4 +-
.../topology_manager/tms_tst/tms_tests.cpp | 30 +-
bundles/shell/remote_shell/src/remote_shell.c | 55 ++--
bundles/shell/remote_shell/src/remote_shell.h | 2 +-
.../src/CelixBundleContextServicesTestSuite.cc | 6 +-
libs/framework/include/celix_api.h | 10 +-
libs/framework/include_deprecated/bundle_context.h | 1 -
.../framework/include_deprecated/bundle_revision.h | 2 +-
libs/framework/include_deprecated/dm_component.h | 2 +-
.../include_deprecated/dm_dependency_manager.h | 1 -
libs/framework/include_deprecated/module.h | 1 -
.../include_deprecated/service_reference.h | 1 -
.../include_deprecated/service_registration.h | 1 -
.../include_deprecated/service_registry.h | 2 +-
.../framework/include_deprecated/service_tracker.h | 1 -
libs/framework/src/bundle.c | 30 +-
libs/framework/src/bundle_context.c | 16 +-
libs/framework/src/bundle_context_private.h | 2 +-
libs/framework/src/bundle_private.h | 2 +-
libs/framework/src/dm_component_impl.c | 10 +-
libs/framework/src/dm_dependency_manager_impl.c | 8 +-
libs/framework/src/framework.c | 109 ++++---
libs/framework/src/framework_private.h | 14 +-
libs/framework/src/module.c | 6 +-
libs/framework/src/registry_callback_private.h | 2 +-
libs/framework/src/service_reference.c | 2 +-
libs/framework/src/service_registry.c | 226 +++++++-------
libs/framework/src/service_tracker.c | 26 +-
libs/utils/benchmark/src/StringHashmapBenchmark.cc | 2 +-
libs/utils/include_deprecated/array_list.h | 97 ------
libs/utils/include_deprecated/celix_utils_api.h | 8 +-
libs/utils/src/array_list.c | 337 ++-------------------
libs/utils/src/array_list_private.h | 14 -
64 files changed, 583 insertions(+), 976 deletions(-)
diff --git a/bundles/http_admin/http_admin/src/http_admin.c b/bundles/http_admin/http_admin/src/http_admin.c
index fb7ac6be..ee303022 100755
--- a/bundles/http_admin/http_admin/src/http_admin.c
+++ b/bundles/http_admin/http_admin/src/http_admin.c
@@ -17,9 +17,10 @@
* under the License.
*/
-#include <stdlib.h>
-#include <memory.h>
+#include <ctype.h>
#include <limits.h>
+#include <memory.h>
+#include <stdlib.h>
#include <unistd.h>
#include "http_admin.h"
@@ -355,9 +356,9 @@ static void httpAdmin_updateInfoSvc(http_admin_manager_t *admin) {
size_t resources_urls_size;
FILE *stream = open_memstream(&resources_urls, &resources_urls_size);
- unsigned int size = arrayList_size(admin->aliasList);
+ unsigned int size = celix_arrayList_size(admin->aliasList);
for (unsigned int i = 0; i < size; ++i) {
- http_alias_t *alias = arrayList_get(admin->aliasList, i);
+ http_alias_t *alias = celix_arrayList_get(admin->aliasList, i);
bool isLast = (i == size-1);
const char *separator = isLast ? "" : ",";
fprintf(stream, "%s%s", alias->url, separator);
@@ -456,9 +457,9 @@ static void createAliasesSymlink(const char *aliases, const char *admin_root, co
* @return true if alias is already in the list, false if not.
*/
static bool aliasList_containsAlias(celix_array_list_t *alias_list, const char *alias) {
- unsigned int size = arrayList_size(alias_list);
+ unsigned int size = celix_arrayList_size(alias_list);
for(unsigned int i = 0; i < size; i++) {
- http_alias_t *http_alias = arrayList_get(alias_list, i);
+ http_alias_t *http_alias = celix_arrayList_get(alias_list, i);
if(strcmp(http_alias->alias_path, alias) == 0) {
return true;
}
@@ -492,9 +493,9 @@ void http_admin_stopBundle(void *data, const celix_bundle_t *bundle) {
long bundle_id = celix_bundle_getId(bundle);
//Remove all aliases which are connected to this bundle
- unsigned int size = arrayList_size(admin->aliasList);
+ unsigned int size = celix_arrayList_size(admin->aliasList);
for (unsigned int i = (size - 1); i < size; i--) {
- http_alias_t *alias = arrayList_get(admin->aliasList, i);
+ http_alias_t *alias = celix_arrayList_get(admin->aliasList, i);
if(alias->bundle_id == bundle_id) {
remove(alias->alias_path); //Delete alias in cache directory
free(alias->url);
diff --git a/bundles/pubsub/examples/pubsub/pubsub_websocket/private/include/pubsub_websocket_private.h b/bundles/pubsub/examples/pubsub/pubsub_websocket/private/include/pubsub_websocket_private.h
index 5a26a684..f41dc1ed 100644
--- a/bundles/pubsub/examples/pubsub/pubsub_websocket/private/include/pubsub_websocket_private.h
+++ b/bundles/pubsub/examples/pubsub/pubsub_websocket/private/include/pubsub_websocket_private.h
@@ -36,7 +36,7 @@
#include "pubsub/publisher.h"
struct pubsub_sender{
- array_list_t *trackers;
+ celix_array_list_t *trackers;
const char *ident;
hash_map_t *tid_map; //service -> tid
long bundleId;
@@ -73,7 +73,7 @@ struct send_thread_struct {
};
typedef struct send_thread_struct send_thread_struct_t;
-pubsub_sender_t* publisher_create(array_list_pt trackers, const char* ident,long bundleId);
+pubsub_sender_t* publisher_create(celix_array_list_t* trackers, const char* ident,long bundleId);
void publisher_start(pubsub_sender_t *client);
void publisher_stop(pubsub_sender_t *client);
diff --git a/bundles/pubsub/examples/pubsub/pubsub_websocket/private/src/ps_websocket_activator.c b/bundles/pubsub/examples/pubsub/pubsub_websocket/private/src/ps_websocket_activator.c
index 5cd72d3e..0e7eeaab 100644
--- a/bundles/pubsub/examples/pubsub/pubsub_websocket/private/src/ps_websocket_activator.c
+++ b/bundles/pubsub/examples/pubsub/pubsub_websocket/private/src/ps_websocket_activator.c
@@ -49,9 +49,9 @@ static const char * SUB_TOPICS[] = {
struct ps_websocketActivator {
pubsub_info_t *pubsub;
//Publisher vars
- array_list_t *trackerList;//List<service_tracker_pt>
+ celix_array_list_t *trackerList;//List<service_tracker_pt>
//Subscriber vars
- array_list_t *registrationList; //List<service_registration_pt>
+ celix_array_list_t *registrationList; //List<service_registration_pt>
pubsub_subscriber_t *subsvc;
};
@@ -119,7 +119,7 @@ static int pubsub_start(struct ps_websocketActivator *act, celix_bundle_context_
#endif
service_registration_pt reg = NULL;
bundleContext_registerService(ctx, PUBSUB_SUBSCRIBER_SERVICE_NAME, subsvc, props, ®);
- arrayList_add(act->registrationList,reg);
+ celix_arrayList_add(act->registrationList,reg);
}
subscriber_start((pubsub_receiver_t *) act->subsvc->handle);
diff --git a/bundles/pubsub/examples/pubsub/pubsub_websocket/private/src/pubsub_websocket_example.c b/bundles/pubsub/examples/pubsub/pubsub_websocket/private/src/pubsub_websocket_example.c
index 528b0d33..3f2b7d3a 100644
--- a/bundles/pubsub/examples/pubsub/pubsub_websocket/private/src/pubsub_websocket_example.c
+++ b/bundles/pubsub/examples/pubsub/pubsub_websocket/private/src/pubsub_websocket_example.c
@@ -110,7 +110,7 @@ static void* send_thread(void* arg) {
return NULL;
}
-pubsub_sender_t* publisher_create(array_list_pt trackers,const char* ident,long bundleId) {
+pubsub_sender_t* publisher_create(celix_array_list_t* trackers,const char* ident,long bundleId) {
pubsub_sender_t *publisher = malloc(sizeof(*publisher));
publisher->trackers = trackers;
diff --git a/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_handler.c b/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_handler.c
index 464e6019..dfd349ac 100644
--- a/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_handler.c
+++ b/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_handler.c
@@ -29,7 +29,6 @@
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
-#include <array_list.h>
#include <pthread.h>
#if defined(__APPLE__)
#include <sys/types.h>
diff --git a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c
index 7b101b80..112668f2 100644
--- a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c
+++ b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c
@@ -38,6 +38,7 @@
#include "pubsub_psa_zmq_constants.h"
#include "pubsub_zmq_topic_sender.h"
#include "pubsub_zmq_topic_receiver.h"
+#include "utils.h"
#define L_DEBUG(...) \
celix_logHelper_log(psa->log, CELIX_LOG_LEVEL_DEBUG, __VA_ARGS__)
diff --git a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c
index 97debaae..70fd1228 100644
--- a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c
+++ b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c
@@ -22,6 +22,8 @@
#include <pubsub/subscriber.h>
#include <memory.h>
#include <pubsub_constants.h>
+#include "utils.h"
+
#if !defined(__APPLE__)
#include <sys/epoll.h>
#endif
diff --git a/bundles/pubsub/pubsub_discovery/src/pubsub_discovery_impl.c b/bundles/pubsub/pubsub_discovery/src/pubsub_discovery_impl.c
index f4730a8a..d0d1854d 100644
--- a/bundles/pubsub/pubsub_discovery/src/pubsub_discovery_impl.c
+++ b/bundles/pubsub/pubsub_discovery/src/pubsub_discovery_impl.c
@@ -33,7 +33,7 @@
#include "celix_properties.h"
#include "celix_constants.h"
#include "celix_threads.h"
-#include "array_list.h"
+#include "celix_array_list.h"
#include "utils.h"
#include "celix_errno.h"
#include "filter.h"
diff --git a/bundles/pubsub/pubsub_utils/src/pubsub_utils.c b/bundles/pubsub/pubsub_utils/src/pubsub_utils.c
index a2cc2a26..9fa546a5 100644
--- a/bundles/pubsub/pubsub_utils/src/pubsub_utils.c
+++ b/bundles/pubsub/pubsub_utils/src/pubsub_utils.c
@@ -19,24 +19,20 @@
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdint.h>
#include "celix_constants.h"
#include "celix_filter.h"
#include "filter.h"
-
#include "pubsub/publisher.h"
#include "pubsub_utils.h"
#include "bundle_context.h"
-
-#include "array_list.h"
#include "celix_bundle.h"
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <stdint.h>
#include "celix_utils.h"
+#include "celix_array_list.h"
#define MAX_KEYBUNDLE_LENGTH 256
@@ -86,14 +82,14 @@ celix_status_t pubsub_getPubSubInfoFromFilter(const char* filterstr, char **scop
* Caller is responsible for freeing the object
*/
char* pubsub_getKeysBundleDir(celix_bundle_context_t *ctx) {
- array_list_pt bundles = NULL;
+ celix_array_list_t* bundles = NULL;
bundleContext_getBundles(ctx, &bundles);
- uint32_t nrOfBundles = arrayList_size(bundles);
+ uint32_t nrOfBundles = celix_arrayList_size(bundles);
long bundle_id = -1;
char* result = NULL;
for (int i = 0; i < nrOfBundles; i++) {
- celix_bundle_t *b = arrayList_get(bundles, i);
+ celix_bundle_t *b = celix_arrayList_get(bundles, i);
/* Skip bundle 0 (framework bundle) since it has no path nor revisions */
bundle_getBundleId(b, &bundle_id);
@@ -119,7 +115,7 @@ char* pubsub_getKeysBundleDir(celix_bundle_context_t *ctx) {
free(dir);
}
- arrayList_destroy(bundles);
+ celix_arrayList_destroy(bundles);
return result;
}
diff --git a/bundles/remote_services/discovery_common/include/endpoint_descriptor_reader.h b/bundles/remote_services/discovery_common/include/endpoint_descriptor_reader.h
index 38ff23f0..5f297562 100644
--- a/bundles/remote_services/discovery_common/include/endpoint_descriptor_reader.h
+++ b/bundles/remote_services/discovery_common/include/endpoint_descriptor_reader.h
@@ -29,14 +29,14 @@
#include "endpoint_discovery_poller.h"
#include "celix_errno.h"
-#include "array_list.h"
+#include "celix_array_list.h"
typedef struct endpoint_descriptor_reader endpoint_descriptor_reader_t;
celix_status_t endpointDescriptorReader_create(endpoint_discovery_poller_t *poller, endpoint_descriptor_reader_t * *reader);
celix_status_t endpointDescriptorReader_destroy(endpoint_descriptor_reader_t * reader);
-celix_status_t endpointDescriptorReader_parseDocument(endpoint_descriptor_reader_t * reader, char *document, array_list_pt *endpoints);
+celix_status_t endpointDescriptorReader_parseDocument(endpoint_descriptor_reader_t * reader, char *document, celix_array_list_t** endpoints);
#endif /* ENDPOINT_DESCRIPTOR_READER_H_ */
diff --git a/bundles/remote_services/discovery_common/include/endpoint_descriptor_writer.h b/bundles/remote_services/discovery_common/include/endpoint_descriptor_writer.h
index ea98fc30..5d4fa518 100644
--- a/bundles/remote_services/discovery_common/include/endpoint_descriptor_writer.h
+++ b/bundles/remote_services/discovery_common/include/endpoint_descriptor_writer.h
@@ -28,12 +28,12 @@
#define ENDPOINT_DESCRIPTOR_WRITER_H_
#include "celix_errno.h"
-#include "array_list.h"
+#include "celix_array_list.h"
typedef struct endpoint_descriptor_writer endpoint_descriptor_writer_t;
celix_status_t endpointDescriptorWriter_create(endpoint_descriptor_writer_t **writer);
celix_status_t endpointDescriptorWriter_destroy(endpoint_descriptor_writer_t *writer);
-celix_status_t endpointDescriptorWriter_writeDocument(endpoint_descriptor_writer_t *writer, array_list_pt endpoints, char **document);
+celix_status_t endpointDescriptorWriter_writeDocument(endpoint_descriptor_writer_t *writer, celix_array_list_t* endpoints, char **document);
#endif /* ENDPOINT_DESCRIPTOR_WRITER_H_ */
diff --git a/bundles/remote_services/discovery_common/include/endpoint_discovery_poller.h b/bundles/remote_services/discovery_common/include/endpoint_discovery_poller.h
index 9cf03291..a500b714 100644
--- a/bundles/remote_services/discovery_common/include/endpoint_discovery_poller.h
+++ b/bundles/remote_services/discovery_common/include/endpoint_discovery_poller.h
@@ -55,6 +55,6 @@ celix_status_t endpointDiscoveryPoller_destroy(endpoint_discovery_poller_t *poll
celix_status_t endpointDiscoveryPoller_addDiscoveryEndpoint(endpoint_discovery_poller_t *poller, char *url);
celix_status_t endpointDiscoveryPoller_removeDiscoveryEndpoint(endpoint_discovery_poller_t *poller, char *url);
-celix_status_t endpointDiscoveryPoller_getDiscoveryEndpoints(endpoint_discovery_poller_t *poller, array_list_pt urls);
+celix_status_t endpointDiscoveryPoller_getDiscoveryEndpoints(endpoint_discovery_poller_t *poller, celix_array_list_t* urls);
#endif /* ENDPOINT_DISCOVERY_POLLER_H_ */
diff --git a/bundles/remote_services/discovery_common/src/endpoint_descriptor_reader.c b/bundles/remote_services/discovery_common/src/endpoint_descriptor_reader.c
index 1caa0dc2..cf87fe59 100644
--- a/bundles/remote_services/discovery_common/src/endpoint_descriptor_reader.c
+++ b/bundles/remote_services/discovery_common/src/endpoint_descriptor_reader.c
@@ -70,13 +70,13 @@ void endpointDescriptorReader_addSingleValuedProperty(celix_properties_t *proper
celix_properties_set(properties, (char *) name, (char*) value);
}
-void endpointDescriptorReader_addMultiValuedProperty(celix_properties_t *properties, const xmlChar* name, array_list_pt values) {
+void endpointDescriptorReader_addMultiValuedProperty(celix_properties_t *properties, const xmlChar* name, celix_array_list_t* values) {
char *value = calloc(256, sizeof(*value));
if (value) {
- unsigned int size = arrayList_size(values);
+ unsigned int size = celix_arrayList_size(values);
unsigned int i;
for (i = 0; i < size; i++) {
- char* item = (char*) arrayList_get(values, i);
+ char* item = (char*) celix_arrayList_get(values, i);
if (i > 0) {
value = strcat(value, ",");
}
@@ -89,7 +89,7 @@ void endpointDescriptorReader_addMultiValuedProperty(celix_properties_t *propert
}
}
-celix_status_t endpointDescriptorReader_parseDocument(endpoint_descriptor_reader_t *reader, char *document, array_list_pt *endpoints) {
+celix_status_t endpointDescriptorReader_parseDocument(endpoint_descriptor_reader_t *reader, char *document, celix_array_list_t** endpoints) {
celix_status_t status = CELIX_SUCCESS;
reader->reader = xmlReaderForMemory(document, (int) strlen(document), NULL, "UTF-8", 0);
@@ -109,15 +109,14 @@ celix_status_t endpointDescriptorReader_parseDocument(endpoint_descriptor_reader
xmlChar *valueBuffer = xmlMalloc(256);
valueBuffer[0] = '\0';
- array_list_pt propertyValues = NULL;
- arrayList_create(&propertyValues);
+ celix_array_list_t* propertyValues = celix_arrayList_create();
- array_list_pt endpointDescriptions = NULL;
+ celix_array_list_t* endpointDescriptions = NULL;
if (*endpoints) {
// use the given arraylist...
endpointDescriptions = *endpoints;
} else {
- arrayList_create(&endpointDescriptions);
+ endpointDescriptions = celix_arrayList_create();
// return the read endpoints...
*endpoints = endpointDescriptions;
}
@@ -163,7 +162,7 @@ celix_status_t endpointDescriptorReader_parseDocument(endpoint_descriptor_reader
propertyValue = xmlTextReaderGetAttribute(reader->reader, VALUE);
xmlChar *vtype = xmlTextReaderGetAttribute(reader->reader, VALUE_TYPE);
propertyType = valueTypeFromString((char*) vtype);
- arrayList_clear(propertyValues);
+ celix_arrayList_clear(propertyValues);
if (xmlTextReaderIsEmptyElement(reader->reader)) {
inProperty = false;
@@ -200,7 +199,7 @@ celix_status_t endpointDescriptorReader_parseDocument(endpoint_descriptor_reader
endpoint_description_t *endpointDescription = NULL;
// Completely parsed endpoint description, add it to our list of results...
if(endpointDescription_create(endpointProperties, &endpointDescription) == CELIX_SUCCESS){
- arrayList_add(endpointDescriptions, endpointDescription);
+ celix_arrayList_add(endpointDescriptions, endpointDescription);
}
endpointProperties = celix_properties_create();
@@ -224,10 +223,10 @@ celix_status_t endpointDescriptorReader_parseDocument(endpoint_descriptor_reader
xmlFree((void *) propertyName);
unsigned int k=0;
- for(;k<arrayList_size(propertyValues);k++){
- free(arrayList_get(propertyValues,k));
+ for(;k<celix_arrayList_size(propertyValues);k++){
+ free(celix_arrayList_get(propertyValues,k));
}
- arrayList_clear(propertyValues);
+ celix_arrayList_clear(propertyValues);
propertyType = VALUE_TYPE_STRING;
inArray = false;
@@ -235,7 +234,7 @@ celix_status_t endpointDescriptorReader_parseDocument(endpoint_descriptor_reader
inSet = false;
inXml = false;
} else if (xmlStrcmp(localname, VALUE) == 0) {
- arrayList_add(propertyValues, strdup((char*) valueBuffer));
+ celix_arrayList_add(propertyValues, strdup((char*) valueBuffer));
valueBuffer[0] = 0;
inValue = false;
}
@@ -255,10 +254,10 @@ celix_status_t endpointDescriptorReader_parseDocument(endpoint_descriptor_reader
}
unsigned int k=0;
- for(;k<arrayList_size(propertyValues);k++){
- free(arrayList_get(propertyValues,k));
+ for(;k<celix_arrayList_size(propertyValues);k++){
+ free(celix_arrayList_get(propertyValues,k));
}
- arrayList_destroy(propertyValues);
+ celix_arrayList_destroy(propertyValues);
xmlFree(valueBuffer);
xmlFreeTextReader(reader->reader);
diff --git a/bundles/remote_services/discovery_common/src/endpoint_descriptor_writer.c b/bundles/remote_services/discovery_common/src/endpoint_descriptor_writer.c
index 2c8d3221..b816c849 100644
--- a/bundles/remote_services/discovery_common/src/endpoint_descriptor_writer.c
+++ b/bundles/remote_services/discovery_common/src/endpoint_descriptor_writer.c
@@ -72,7 +72,7 @@ celix_status_t endpointDescriptorWriter_destroy(endpoint_descriptor_writer_t *wr
return CELIX_SUCCESS;
}
-celix_status_t endpointDescriptorWriter_writeDocument(endpoint_descriptor_writer_t *writer, array_list_pt endpoints, char **document) {
+celix_status_t endpointDescriptorWriter_writeDocument(endpoint_descriptor_writer_t *writer, celix_array_list_t* endpoints, char **document) {
celix_status_t status = CELIX_SUCCESS;
int rc;
@@ -85,8 +85,8 @@ celix_status_t endpointDescriptorWriter_writeDocument(endpoint_descriptor_writer
status = CELIX_BUNDLE_EXCEPTION;
} else {
unsigned int i;
- for (i = 0; i < arrayList_size(endpoints); i++) {
- endpoint_description_t *endpoint = arrayList_get(endpoints, i);
+ for (i = 0; i < celix_arrayList_size(endpoints); i++) {
+ endpoint_description_t *endpoint = celix_arrayList_get(endpoints, i);
status = endpointDescriptorWriter_writeEndpoint(writer, endpoint);
}
if (status == CELIX_SUCCESS) {
diff --git a/bundles/remote_services/discovery_common/src/endpoint_discovery_poller.c b/bundles/remote_services/discovery_common/src/endpoint_discovery_poller.c
index 5589c846..c286d43e 100644
--- a/bundles/remote_services/discovery_common/src/endpoint_discovery_poller.c
+++ b/bundles/remote_services/discovery_common/src/endpoint_discovery_poller.c
@@ -48,9 +48,10 @@
#define DEFAULT_POLL_TIMEOUT "10" // seconds
static void *endpointDiscoveryPoller_performPeriodicPoll(void *data);
-celix_status_t endpointDiscoveryPoller_poll(endpoint_discovery_poller_t *poller, char *url, array_list_pt currentEndpoints);
-static celix_status_t endpointDiscoveryPoller_getEndpoints(endpoint_discovery_poller_t *poller, char *url, array_list_pt *updatedEndpoints);
-static celix_status_t endpointDiscoveryPoller_endpointDescriptionEquals(const void *endpointPtr, const void *comparePtr, bool *equals);
+celix_status_t endpointDiscoveryPoller_poll(endpoint_discovery_poller_t *poller, char *url, celix_array_list_t* currentEndpoints);
+static celix_status_t endpointDiscoveryPoller_getEndpoints(endpoint_discovery_poller_t *poller, char *url, celix_array_list_t** updatedEndpoints);
+static bool endpointDiscoveryPoller_endpointDescriptionEquals(celix_array_list_entry_t endpointEntry,
+ celix_array_list_entry_t compareEntry);
/**
* Allocates memory and initializes a new endpoint_discovery_poller instance.
@@ -162,7 +163,7 @@ celix_status_t endpointDiscoveryPoller_destroy(endpoint_discovery_poller_t *poll
}
-celix_status_t endpointDiscoveryPoller_getDiscoveryEndpoints(endpoint_discovery_poller_t *poller, array_list_pt urls) {
+celix_status_t endpointDiscoveryPoller_getDiscoveryEndpoints(endpoint_discovery_poller_t *poller, celix_array_list_t* urls) {
celixThreadMutex_lock(&(poller)->pollerLock);
hash_map_iterator_pt iterator = hashMapIterator_create(poller->entries);
@@ -170,7 +171,7 @@ celix_status_t endpointDiscoveryPoller_getDiscoveryEndpoints(endpoint_discovery_
while(hashMapIterator_hasNext(iterator)) {
hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
char* toAdd = strdup((char*) hashMapEntry_getKey(entry));
- arrayList_add(urls, toAdd);
+ celix_arrayList_add(urls, toAdd);
}
hashMapIterator_destroy(iterator);
@@ -183,111 +184,118 @@ celix_status_t endpointDiscoveryPoller_getDiscoveryEndpoints(endpoint_discovery_
/**
* Adds a new endpoint URL to the list of polled endpoints.
*/
-celix_status_t endpointDiscoveryPoller_addDiscoveryEndpoint(endpoint_discovery_poller_t *poller, char *url) {
- celix_status_t status;
+celix_status_t endpointDiscoveryPoller_addDiscoveryEndpoint(endpoint_discovery_poller_t* poller, char* url) {
+ celix_status_t status;
- status = celixThreadMutex_lock(&(poller)->pollerLock);
- if (status != CELIX_SUCCESS) {
- return CELIX_BUNDLE_EXCEPTION;
- }
+ status = celixThreadMutex_lock(&(poller)->pollerLock);
+ if (status != CELIX_SUCCESS) {
+ return CELIX_BUNDLE_EXCEPTION;
+ }
- // Avoid memory leaks when adding an already existing URL...
- array_list_pt endpoints = hashMap_get(poller->entries, url);
- if (endpoints == NULL) {
- status = arrayList_createWithEquals(endpointDiscoveryPoller_endpointDescriptionEquals, &endpoints);
+ // Avoid memory leaks when adding an already existing URL...
+ celix_array_list_t* endpoints = hashMap_get(poller->entries, url);
+ if (endpoints == NULL) {
+ endpoints = celix_arrayList_createWithEquals(endpointDiscoveryPoller_endpointDescriptionEquals);
- if (status == CELIX_SUCCESS) {
+ if (endpoints) {
celix_logHelper_debug(*poller->loghelper, "ENDPOINT_POLLER: add new discovery endpoint with url %s", url);
- hashMap_put(poller->entries, strdup(url), endpoints);
- endpointDiscoveryPoller_poll(poller, url, endpoints);
- }
- }
+ hashMap_put(poller->entries, strdup(url), endpoints);
+ endpointDiscoveryPoller_poll(poller, url, endpoints);
+ }
+ }
- status = celixThreadMutex_unlock(&poller->pollerLock);
+ status = celixThreadMutex_unlock(&poller->pollerLock);
- return status;
+ return status;
}
/**
* Removes an endpoint URL from the list of polled endpoints.
*/
-celix_status_t endpointDiscoveryPoller_removeDiscoveryEndpoint(endpoint_discovery_poller_t *poller, char *url) {
- celix_status_t status = CELIX_SUCCESS;
-
- if (celixThreadMutex_lock(&poller->pollerLock) != CELIX_SUCCESS) {
- status = CELIX_BUNDLE_EXCEPTION;
- } else {
- hash_map_entry_pt entry = hashMap_getEntry(poller->entries, url);
-
- if (entry == NULL) {
- celix_logHelper_debug(*poller->loghelper, "ENDPOINT_POLLER: There was no entry found belonging to url %s - maybe already removed?", url);
- } else {
- char* origKey = hashMapEntry_getKey(entry);
+celix_status_t endpointDiscoveryPoller_removeDiscoveryEndpoint(endpoint_discovery_poller_t* poller, char* url) {
+ celix_status_t status = CELIX_SUCCESS;
+
+ if (celixThreadMutex_lock(&poller->pollerLock) != CELIX_SUCCESS) {
+ status = CELIX_BUNDLE_EXCEPTION;
+ } else {
+ hash_map_entry_pt entry = hashMap_getEntry(poller->entries, url);
+
+ if (entry == NULL) {
+ celix_logHelper_debug(
+ *poller->loghelper,
+ "ENDPOINT_POLLER: There was no entry found belonging to url %s - maybe already removed?",
+ url);
+ } else {
+ char* origKey = hashMapEntry_getKey(entry);
celix_logHelper_debug(*poller->loghelper, "ENDPOINT_POLLER: remove discovery endpoint with url %s", url);
- array_list_pt entries = hashMap_remove(poller->entries, url);
+ celix_array_list_t* entries = hashMap_remove(poller->entries, url);
- if (entries != NULL) {
- for (unsigned int i = arrayList_size(entries); i > 0; i--) {
- endpoint_description_t *endpoint = arrayList_get(entries, i - 1);
- discovery_removeDiscoveredEndpoint(poller->discovery, endpoint);
- arrayList_remove(entries, i - 1);
- endpointDescription_destroy(endpoint);
- }
- arrayList_destroy(entries);
- }
+ if (entries != NULL) {
+ for (unsigned int i = celix_arrayList_size(entries); i > 0; i--) {
+ endpoint_description_t* endpoint = celix_arrayList_get(entries, i - 1);
+ discovery_removeDiscoveredEndpoint(poller->discovery, endpoint);
+ celix_arrayList_removeAt(entries, i - 1);
+ endpointDescription_destroy(endpoint);
+ }
+ celix_arrayList_destroy(entries);
+ }
- free(origKey);
- }
- status = celixThreadMutex_unlock(&poller->pollerLock);
- }
+ free(origKey);
+ }
+ status = celixThreadMutex_unlock(&poller->pollerLock);
+ }
- return status;
+ return status;
}
-
-
-
-celix_status_t endpointDiscoveryPoller_poll(endpoint_discovery_poller_t *poller, char *url, array_list_pt currentEndpoints) {
- celix_status_t status;
- array_list_pt updatedEndpoints = NULL;
-
- // create an arraylist with a custom equality test to ensure we can find endpoints properly...
- arrayList_createWithEquals(endpointDiscoveryPoller_endpointDescriptionEquals, &updatedEndpoints);
- status = endpointDiscoveryPoller_getEndpoints(poller, url, &updatedEndpoints);
-
- if (status == CELIX_SUCCESS) {
- if (updatedEndpoints != NULL) {
- for (unsigned int i = arrayList_size(currentEndpoints); i > 0; i--) {
- endpoint_description_t *endpoint = arrayList_get(currentEndpoints, i - 1);
-
- if (!arrayList_contains(updatedEndpoints, endpoint)) {
- status = discovery_removeDiscoveredEndpoint(poller->discovery, endpoint);
- arrayList_remove(currentEndpoints, i - 1);
- endpointDescription_destroy(endpoint);
- }
- }
-
- for (int i = arrayList_size(updatedEndpoints); i > 0; i--) {
- endpoint_description_t *endpoint = arrayList_remove(updatedEndpoints, 0);
-
- if (!arrayList_contains(currentEndpoints, endpoint)) {
- arrayList_add(currentEndpoints, endpoint);
- status = discovery_addDiscoveredEndpoint(poller->discovery, endpoint);
- } else {
- endpointDescription_destroy(endpoint);
-
- }
- }
- }
- }
-
- if (updatedEndpoints != NULL) {
- arrayList_destroy(updatedEndpoints);
- }
-
- return status;
+celix_status_t
+endpointDiscoveryPoller_poll(endpoint_discovery_poller_t* poller, char* url, celix_array_list_t* currentEndpoints) {
+ celix_status_t status;
+ celix_array_list_t* updatedEndpoints = NULL;
+
+ // create an arraylist with a custom equality test to ensure we can find endpoints properly...
+ updatedEndpoints = celix_arrayList_createWithEquals(endpointDiscoveryPoller_endpointDescriptionEquals);
+ status = endpointDiscoveryPoller_getEndpoints(poller, url, &updatedEndpoints);
+
+ if (updatedEndpoints && status == CELIX_SUCCESS) {
+ if (updatedEndpoints != NULL) {
+ for (int i = celix_arrayList_size(currentEndpoints); i > 0; i--) {
+ endpoint_description_t* endpoint = celix_arrayList_get(currentEndpoints, i - 1);
+
+ celix_array_list_entry_t entry;
+ memset(&entry, 0, sizeof(entry));
+ entry.voidPtrVal = endpoint;
+
+ if (celix_arrayList_indexOf(updatedEndpoints, entry) < 0) {
+ status = discovery_removeDiscoveredEndpoint(poller->discovery, endpoint);
+ celix_arrayList_removeAt(currentEndpoints, i - 1);
+ endpointDescription_destroy(endpoint);
+ }
+ }
+
+ for (int i = 0; i < celix_arrayList_size(updatedEndpoints); i++) {
+ endpoint_description_t* endpoint = celix_arrayList_get(updatedEndpoints, i);
+ celix_array_list_entry_t entry;
+ memset(&entry, 0, sizeof(entry));
+ entry.voidPtrVal = endpoint;
+ if (celix_arrayList_indexOf(currentEndpoints, entry) < 0) {
+ celix_arrayList_add(currentEndpoints, endpoint);
+ status = discovery_addDiscoveredEndpoint(poller->discovery, endpoint);
+ } else {
+ endpointDescription_destroy(endpoint);
+ }
+ }
+ celix_arrayList_clear(updatedEndpoints);
+ }
+ }
+
+ if (updatedEndpoints != NULL) {
+ celix_arrayList_destroy(updatedEndpoints);
+ }
+
+ return status;
}
static void *endpointDiscoveryPoller_performPeriodicPoll(void *data) {
@@ -308,7 +316,7 @@ static void *endpointDiscoveryPoller_performPeriodicPoll(void *data) {
hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
char *url = hashMapEntry_getKey(entry);
- array_list_pt currentEndpoints = hashMapEntry_getValue(entry);
+ celix_array_list_t* currentEndpoints = hashMapEntry_getValue(entry);
endpointDiscoveryPoller_poll(poller, url, currentEndpoints);
}
@@ -349,7 +357,7 @@ static size_t endpointDiscoveryPoller_writeMemory(void *contents, size_t size, s
return realsize;
}
-static celix_status_t endpointDiscoveryPoller_getEndpoints(endpoint_discovery_poller_t *poller, char *url, array_list_pt *updatedEndpoints) {
+static celix_status_t endpointDiscoveryPoller_getEndpoints(endpoint_discovery_poller_t *poller, char *url, celix_array_list_t** updatedEndpoints) {
celix_status_t status = CELIX_SUCCESS;
@@ -399,15 +407,9 @@ static celix_status_t endpointDiscoveryPoller_getEndpoints(endpoint_discovery_po
return status;
}
-static celix_status_t endpointDiscoveryPoller_endpointDescriptionEquals(const void *endpointPtr, const void *comparePtr, bool *equals) {
- endpoint_description_t *endpoint = (endpoint_description_t *) endpointPtr;
- endpoint_description_t *compare = (endpoint_description_t *) comparePtr;
-
- if (strcmp(endpoint->id, compare->id) == 0) {
- *equals = true;
- } else {
- *equals = false;
- }
-
- return CELIX_SUCCESS;
+static bool endpointDiscoveryPoller_endpointDescriptionEquals(celix_array_list_entry_t endpointEntry,
+ celix_array_list_entry_t compareEntry) {
+ endpoint_description_t* endpoint = (endpoint_description_t*)endpointEntry.voidPtrVal;
+ endpoint_description_t* compare = (endpoint_description_t*)compareEntry.voidPtrVal;
+ return strcmp(endpoint->id, compare->id) == 0;
}
diff --git a/bundles/remote_services/discovery_common/src/endpoint_discovery_server.c b/bundles/remote_services/discovery_common/src/endpoint_discovery_server.c
index a845f826..4d6043cc 100644
--- a/bundles/remote_services/discovery_common/src/endpoint_discovery_server.c
+++ b/bundles/remote_services/discovery_common/src/endpoint_discovery_server.c
@@ -306,11 +306,9 @@ static char* format_path(const char* path) {
return result;
}
-static celix_status_t endpointDiscoveryServer_getEndpoints(endpoint_discovery_server_t *server, const char* the_endpoint_id, array_list_pt *endpoints) {
- celix_status_t status;
-
- status = arrayList_create(endpoints);
- if (status != CELIX_SUCCESS) {
+static celix_status_t endpointDiscoveryServer_getEndpoints(endpoint_discovery_server_t *server, const char* the_endpoint_id, celix_array_list_t** endpoints) {
+ *endpoints = celix_arrayList_create();
+ if (!(*endpoints)) {
return CELIX_ENOMEM;
}
@@ -323,15 +321,15 @@ static celix_status_t endpointDiscoveryServer_getEndpoints(endpoint_discovery_se
if (the_endpoint_id == NULL || strcmp(the_endpoint_id, endpoint_id) == 0) {
endpoint_description_t *endpoint = hashMapEntry_getValue(entry);
- arrayList_add(*endpoints, endpoint);
+ celix_arrayList_add(*endpoints, endpoint);
}
}
hashMapIterator_destroy(iter);
- return status;
+ return CELIX_SUCCESS;
}
-static int endpointDiscoveryServer_writeEndpoints(struct mg_connection* conn, array_list_pt endpoints) {
+static int endpointDiscoveryServer_writeEndpoints(struct mg_connection* conn, celix_array_list_t* endpoints) {
celix_status_t status;
int rv = CIVETWEB_REQUEST_NOT_HANDLED;
@@ -360,14 +358,14 @@ static int endpointDiscoveryServer_writeEndpoints(struct mg_connection* conn, ar
static int endpointDiscoveryServer_returnAllEndpoints(endpoint_discovery_server_t *server, struct mg_connection* conn) {
int status = CIVETWEB_REQUEST_NOT_HANDLED;
- array_list_pt endpoints = NULL;
+ celix_array_list_t* endpoints = NULL;
if (celixThreadMutex_lock(&server->serverLock) == CELIX_SUCCESS) {
endpointDiscoveryServer_getEndpoints(server, NULL, &endpoints);
if (endpoints) {
status = endpointDiscoveryServer_writeEndpoints(conn, endpoints);
- arrayList_destroy(endpoints);
+ celix_arrayList_destroy(endpoints);
}
@@ -381,14 +379,13 @@ static int endpointDiscoveryServer_returnAllEndpoints(endpoint_discovery_server_
static int endpointDiscoveryServer_returnEndpoint(endpoint_discovery_server_t *server, struct mg_connection* conn, const char* endpoint_id) {
int status = CIVETWEB_REQUEST_NOT_HANDLED;
- array_list_pt endpoints = NULL;
+ celix_array_list_t* endpoints = NULL;
if (celixThreadMutex_lock(&server->serverLock) == CELIX_SUCCESS) {
endpointDiscoveryServer_getEndpoints(server, endpoint_id, &endpoints);
if (endpoints) {
status = endpointDiscoveryServer_writeEndpoints(conn, endpoints);
-
- arrayList_destroy(endpoints);
+ celix_arrayList_destroy(endpoints);
}
celixThreadMutex_unlock(&server->serverLock);
diff --git a/bundles/remote_services/remote_service_admin_dfi/gtest/src/rsa_tests.cc b/bundles/remote_services/remote_service_admin_dfi/gtest/src/rsa_tests.cc
index 966a4c4d..c0ebdd60 100644
--- a/bundles/remote_services/remote_service_admin_dfi/gtest/src/rsa_tests.cc
+++ b/bundles/remote_services/remote_service_admin_dfi/gtest/src/rsa_tests.cc
@@ -93,7 +93,7 @@ extern "C" {
ASSERT_EQ(1, celix_arrayList_size(svcRegistration));
- rc = rsa->exportRegistration_close(rsa->admin,(export_registration_t *)(arrayList_get(svcRegistration,0)));
+ rc = rsa->exportRegistration_close(rsa->admin,(export_registration_t *)(celix_arrayList_get(svcRegistration,0)));
ASSERT_EQ(CELIX_SUCCESS, rc);
celix_arrayList_destroy(svcRegistration);
}
@@ -155,11 +155,11 @@ extern "C" {
}
static void testBundles(void) {
- array_list_pt bundles = NULL;
+ celix_array_list_t* bundles = NULL;
int rc = bundleContext_getBundles(context, &bundles);
ASSERT_EQ(0, rc);
- ASSERT_EQ(3, arrayList_size(bundles)); //framework, rsa_dfi & calc
+ ASSERT_EQ(3, celix_arrayList_size(bundles)); //framework, rsa_dfi & calc
/*
int size = arrayList_size(bundles);
@@ -175,7 +175,7 @@ extern "C" {
printf("got bundle with symbolic name '%s'", name);
}*/
- arrayList_destroy(bundles);
+ celix_arrayList_destroy(bundles);
}
}
diff --git a/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c b/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c
index e8c34e3e..d0ea9891 100644
--- a/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c
+++ b/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c
@@ -86,7 +86,7 @@ struct remote_service_admin {
celix_thread_t stopExportsThread;
celix_thread_mutex_t importedServicesLock;
- array_list_pt importedServices;
+ celix_array_list_t* importedServices;
char *port;
char *ip;
@@ -190,7 +190,7 @@ celix_status_t remoteServiceAdmin_create(celix_bundle_context_t *context, remote
} else {
(*admin)->context = context;
(*admin)->exportedServices = hashMap_create(NULL, NULL, NULL, NULL);
- arrayList_create(&(*admin)->importedServices);
+ (*admin)->importedServices = celix_arrayList_create();
celixThreadRwlock_create(&(*admin)->exportedServicesLock, NULL);
celixThreadMutex_create(&(*admin)->importedServicesLock, NULL);
@@ -427,9 +427,9 @@ celix_status_t remoteServiceAdmin_stop(remote_service_admin_t *admin) {
celixThreadMutex_lock(&admin->importedServicesLock);
int i;
- int size = arrayList_size(admin->importedServices);
+ int size = celix_arrayList_size(admin->importedServices);
for (i = 0; i < size ; i += 1) {
- import_registration_t *import = arrayList_get(admin->importedServices, i);
+ import_registration_t *import = celix_arrayList_get(admin->importedServices, i);
if (import != NULL) {
importRegistration_destroy(import);
}
@@ -443,7 +443,7 @@ celix_status_t remoteServiceAdmin_stop(remote_service_admin_t *admin) {
}
hashMap_destroy(admin->exportedServices, false, false);
- arrayList_destroy(admin->importedServices);
+ celix_arrayList_destroy(admin->importedServices);
celix_logHelper_destroy(admin->loghelper);
@@ -577,7 +577,7 @@ static int remoteServiceAdmin_callback(struct mg_connection *conn) {
return result;
}
-celix_status_t remoteServiceAdmin_exportService(remote_service_admin_t *admin, char *serviceId, celix_properties_t *properties, array_list_pt *registrationsOut) {
+celix_status_t remoteServiceAdmin_exportService(remote_service_admin_t *admin, char *serviceId, celix_properties_t *properties, celix_array_list_t** registrationsOut) {
celix_status_t status = CELIX_SUCCESS;
bool export = false;
@@ -607,7 +607,7 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_t *admin, c
celix_array_list_t *registrations = NULL;
if (export) {
registrations = celix_arrayList_create();
- array_list_pt references = NULL;
+ celix_array_list_t* references = NULL;
service_reference_pt reference = NULL;
char filter[256];
@@ -618,15 +618,15 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_t *admin, c
celix_logHelper_log(admin->loghelper, CELIX_LOG_LEVEL_DEBUG, "RSA: exportService called for serviceId %s", serviceId);
int i;
- int size = arrayList_size(references);
+ int size = celix_arrayList_size(references);
for (i = 0; i < size; i += 1) {
if (i == 0) {
- reference = arrayList_get(references, i);
+ reference = celix_arrayList_get(references, i);
} else {
- bundleContext_ungetServiceReference(admin->context, arrayList_get(references, i));
+ bundleContext_ungetServiceReference(admin->context, celix_arrayList_get(references, i));
}
}
- arrayList_destroy(references);
+ celix_arrayList_destroy(references);
if (reference == NULL) {
celix_logHelper_log(admin->loghelper, CELIX_LOG_LEVEL_ERROR, "ERROR: expected a reference for service id %s.",
@@ -860,12 +860,12 @@ celix_status_t remoteServiceAdmin_destroyEndpointDescription(endpoint_descriptio
}
-celix_status_t remoteServiceAdmin_getExportedServices(remote_service_admin_t *admin, array_list_pt *services) {
+celix_status_t remoteServiceAdmin_getExportedServices(remote_service_admin_t *admin, celix_array_list_t** services) {
celix_status_t status = CELIX_SUCCESS;
return status;
}
-celix_status_t remoteServiceAdmin_getImportedEndpoints(remote_service_admin_t *admin, array_list_pt *services) {
+celix_status_t remoteServiceAdmin_getImportedEndpoints(remote_service_admin_t *admin, celix_array_list_t** services) {
celix_status_t status = CELIX_SUCCESS;
return status;
}
@@ -919,7 +919,7 @@ celix_status_t remoteServiceAdmin_importService(remote_service_admin_t *admin, e
}
celixThreadMutex_lock(&admin->importedServicesLock);
- arrayList_add(admin->importedServices, import);
+ celix_arrayList_add(admin->importedServices, import);
celixThreadMutex_unlock(&admin->importedServicesLock);
if (status == CELIX_SUCCESS) {
@@ -937,12 +937,12 @@ celix_status_t remoteServiceAdmin_removeImportedService(remote_service_admin_t *
celixThreadMutex_lock(&admin->importedServicesLock);
int i;
- int size = arrayList_size(admin->importedServices);
+ int size = celix_arrayList_size(admin->importedServices);
import_registration_t * current = NULL;
for (i = 0; i < size; i += 1) {
- current = arrayList_get(admin->importedServices, i);
+ current = celix_arrayList_get(admin->importedServices, i);
if (current == registration) {
- arrayList_remove(admin->importedServices, i);
+ celix_arrayList_removeAt(admin->importedServices, i);
importRegistration_destroy(current);
break;
}
diff --git a/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.h b/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.h
index af9694c6..9661b424 100644
--- a/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.h
+++ b/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.h
@@ -34,10 +34,10 @@ celix_status_t remoteServiceAdmin_destroy(remote_service_admin_t **admin);
celix_status_t remoteServiceAdmin_stop(remote_service_admin_t *admin);
-celix_status_t remoteServiceAdmin_exportService(remote_service_admin_t *admin, char *serviceId, celix_properties_t *properties, array_list_pt *registrations);
+celix_status_t remoteServiceAdmin_exportService(remote_service_admin_t *admin, char *serviceId, celix_properties_t *properties, celix_array_list_t** registrations);
celix_status_t remoteServiceAdmin_removeExportedService(remote_service_admin_t *admin, export_registration_t *registration);
-celix_status_t remoteServiceAdmin_getExportedServices(remote_service_admin_t *admin, array_list_pt *services);
-celix_status_t remoteServiceAdmin_getImportedEndpoints(remote_service_admin_t *admin, array_list_pt *services);
+celix_status_t remoteServiceAdmin_getExportedServices(remote_service_admin_t *admin, celix_array_list_t** services);
+celix_status_t remoteServiceAdmin_getImportedEndpoints(remote_service_admin_t *admin, celix_array_list_t** services);
celix_status_t remoteServiceAdmin_importService(remote_service_admin_t *admin, endpoint_description_t *endpoint, import_registration_t **registration);
celix_status_t remoteServiceAdmin_removeImportedService(remote_service_admin_t *admin, import_registration_t *registration);
diff --git a/bundles/remote_services/rsa_common/src/import_registration_impl.c b/bundles/remote_services/rsa_common/src/import_registration_impl.c
index 95c67db8..afd4c5b6 100644
--- a/bundles/remote_services/rsa_common/src/import_registration_impl.c
+++ b/bundles/remote_services/rsa_common/src/import_registration_impl.c
@@ -84,8 +84,7 @@ celix_status_t importRegistrationFactory_create(celix_log_helper_t *helper, char
(*registration_factory)->context = context;
(*registration_factory)->bundle = NULL;
(*registration_factory)->loghelper = helper;
-
- arrayList_create(&(*registration_factory)->registrations);
+ (*registration_factory)->registrations = celix_arrayList_create();
}
return status;
@@ -99,7 +98,7 @@ celix_status_t importRegistrationFactory_destroy(import_registration_factory_t *
if (*registration_factory != NULL)
{
free((*registration_factory)->serviceName);
- arrayList_destroy((*registration_factory)->registrations);
+ celix_arrayList_destroy((*registration_factory)->registrations);
serviceTracker_destroy((*registration_factory)->proxyFactoryTracker);
free(*registration_factory);
diff --git a/bundles/remote_services/rsa_common/src/import_registration_impl.h b/bundles/remote_services/rsa_common/src/import_registration_impl.h
index 1a11ccd3..1740fe46 100644
--- a/bundles/remote_services/rsa_common/src/import_registration_impl.h
+++ b/bundles/remote_services/rsa_common/src/import_registration_impl.h
@@ -53,7 +53,7 @@ struct import_registration_factory {
remote_proxy_factory_service_t *trackedFactory;
service_tracker_t *proxyFactoryTracker;
celix_bundle_context_t *context;
- array_list_pt registrations;
+ celix_array_list_t* registrations;
celix_bundle_t *bundle;
};
diff --git a/bundles/remote_services/rsa_common/src/remote_interceptors_handler.c b/bundles/remote_services/rsa_common/src/remote_interceptors_handler.c
index 234b40fb..65c25207 100644
--- a/bundles/remote_services/rsa_common/src/remote_interceptors_handler.c
+++ b/bundles/remote_services/rsa_common/src/remote_interceptors_handler.c
@@ -24,7 +24,6 @@
#include "celix_array_list.h"
#include "celix_threads.h"
#include "celix_utils.h"
-#include "array_list.h"
#include "remote_interceptors_handler.h"
@@ -93,8 +92,8 @@ void remoteInterceptorsHandler_addInterceptor(void *handle, void *svc, const cel
celixThreadMutex_lock(&handler->lock);
bool exists = false;
- for (uint32_t i = 0; i < arrayList_size(handler->interceptors); i++) {
- entry_t *entry = arrayList_get(handler->interceptors, i);
+ for (uint32_t i = 0; i < celix_arrayList_size(handler->interceptors); i++) {
+ entry_t *entry = celix_arrayList_get(handler->interceptors, i);
if (entry->interceptor == svc) {
exists = true;
}
@@ -116,10 +115,10 @@ void remoteInterceptorsHandler_removeInterceptor(void *handle, void *svc, const
celixThreadMutex_lock(&handler->lock);
- for (uint32_t i = 0; i < arrayList_size(handler->interceptors); i++) {
- entry_t *entry = arrayList_get(handler->interceptors, i);
+ for (int i = 0; i < celix_arrayList_size(handler->interceptors); i++) {
+ entry_t *entry = celix_arrayList_get(handler->interceptors, i);
if (entry->interceptor == svc) {
- arrayList_remove(handler->interceptors, i);
+ celix_arrayList_removeAt(handler->interceptors, i);
free(entry);
break;
}
@@ -133,12 +132,12 @@ bool remoteInterceptorHandler_invokePreExportCall(remote_interceptors_handler_t
celixThreadMutex_lock(&handler->lock);
- if (*metadata == NULL && arrayList_size(handler->interceptors) > 0) {
+ if (*metadata == NULL && celix_arrayList_size(handler->interceptors) > 0) {
*metadata = celix_properties_create();
}
- for (uint32_t i = arrayList_size(handler->interceptors); i > 0; i--) {
- entry_t *entry = arrayList_get(handler->interceptors, i - 1);
+ for (uint32_t i = celix_arrayList_size(handler->interceptors); i > 0; i--) {
+ entry_t *entry = celix_arrayList_get(handler->interceptors, i - 1);
cont = entry->interceptor->preExportCall(entry->interceptor->handle, svcProperties, functionName, *metadata);
if (!cont) {
@@ -154,8 +153,8 @@ bool remoteInterceptorHandler_invokePreExportCall(remote_interceptors_handler_t
void remoteInterceptorHandler_invokePostExportCall(remote_interceptors_handler_t *handler, const celix_properties_t *svcProperties, const char *functionName, celix_properties_t *metadata) {
celixThreadMutex_lock(&handler->lock);
- for (uint32_t i = arrayList_size(handler->interceptors); i > 0; i--) {
- entry_t *entry = arrayList_get(handler->interceptors, i - 1);
+ for (uint32_t i = celix_arrayList_size(handler->interceptors); i > 0; i--) {
+ entry_t *entry = celix_arrayList_get(handler->interceptors, i - 1);
entry->interceptor->postExportCall(entry->interceptor->handle, svcProperties, functionName, metadata);
}
@@ -168,12 +167,12 @@ bool remoteInterceptorHandler_invokePreProxyCall(remote_interceptors_handler_t *
celixThreadMutex_lock(&handler->lock);
- if (*metadata == NULL && arrayList_size(handler->interceptors) > 0) {
+ if (*metadata == NULL && celix_arrayList_size(handler->interceptors) > 0) {
*metadata = celix_properties_create();
}
- for (uint32_t i = 0; i < arrayList_size(handler->interceptors); i++) {
- entry_t *entry = arrayList_get(handler->interceptors, i);
+ for (uint32_t i = 0; i < celix_arrayList_size(handler->interceptors); i++) {
+ entry_t *entry = celix_arrayList_get(handler->interceptors, i);
cont = entry->interceptor->preProxyCall(entry->interceptor->handle, svcProperties, functionName, *metadata);
if (!cont) {
@@ -189,8 +188,8 @@ bool remoteInterceptorHandler_invokePreProxyCall(remote_interceptors_handler_t *
void remoteInterceptorHandler_invokePostProxyCall(remote_interceptors_handler_t *handler, const celix_properties_t *svcProperties, const char *functionName, celix_properties_t *metadata) {
celixThreadMutex_lock(&handler->lock);
- for (uint32_t i = 0; i < arrayList_size(handler->interceptors); i++) {
- entry_t *entry = arrayList_get(handler->interceptors, i);
+ for (uint32_t i = 0; i < celix_arrayList_size(handler->interceptors); i++) {
+ entry_t *entry = celix_arrayList_get(handler->interceptors, i);
entry->interceptor->postProxyCall(entry->interceptor->handle, svcProperties, functionName, metadata);
}
diff --git a/bundles/remote_services/rsa_common/src/remote_service_admin_impl.h b/bundles/remote_services/rsa_common/src/remote_service_admin_impl.h
index 00420d5f..4d3a420a 100644
--- a/bundles/remote_services/rsa_common/src/remote_service_admin_impl.h
+++ b/bundles/remote_services/rsa_common/src/remote_service_admin_impl.h
@@ -37,10 +37,10 @@ celix_status_t remoteServiceAdmin_destroy(remote_service_admin_t **admin);
celix_status_t remoteServiceAdmin_send(remote_service_admin_t *rsa, endpoint_description_t *endpointDescription, char *methodSignature, char **reply, int* replyStatus);
-celix_status_t remoteServiceAdmin_exportService(remote_service_admin_t *admin, char *serviceId, celix_properties_t *properties, array_list_pt *registrations);
+celix_status_t remoteServiceAdmin_exportService(remote_service_admin_t *admin, char *serviceId, celix_properties_t *properties, celix_array_list_t** registrations);
celix_status_t remoteServiceAdmin_removeExportedService(remote_service_admin_t *admin, export_registration_t *registration);
-celix_status_t remoteServiceAdmin_getExportedServices(remote_service_admin_t *admin, array_list_pt *services);
-celix_status_t remoteServiceAdmin_getImportedEndpoints(remote_service_admin_t *admin, array_list_pt *services);
+celix_status_t remoteServiceAdmin_getExportedServices(remote_service_admin_t *admin, celix_array_list_t** services);
+celix_status_t remoteServiceAdmin_getImportedEndpoints(remote_service_admin_t *admin, celix_array_list_t** services);
celix_status_t remoteServiceAdmin_importService(remote_service_admin_t *admin, endpoint_description_t *endpoint, import_registration_t **registration);
celix_status_t remoteServiceAdmin_removeImportedService(remote_service_admin_t *admin, import_registration_t *registration);
diff --git a/bundles/remote_services/rsa_spi/include/endpoint_description.h b/bundles/remote_services/rsa_spi/include/endpoint_description.h
index e9ba63e5..e94517dc 100644
--- a/bundles/remote_services/rsa_spi/include/endpoint_description.h
+++ b/bundles/remote_services/rsa_spi/include/endpoint_description.h
@@ -28,7 +28,6 @@
#define ENDPOINT_DESCRIPTION_H_
#include "properties.h"
-#include "array_list.h"
#include "celix_cleanup.h"
#include <stdbool.h>
diff --git a/bundles/remote_services/rsa_spi/include/endpoint_listener.h b/bundles/remote_services/rsa_spi/include/endpoint_listener.h
index 68bad113..0d44440c 100644
--- a/bundles/remote_services/rsa_spi/include/endpoint_listener.h
+++ b/bundles/remote_services/rsa_spi/include/endpoint_listener.h
@@ -27,7 +27,6 @@
#ifndef ENDPOINT_LISTENER_H_
#define ENDPOINT_LISTENER_H_
-#include "array_list.h"
#include "properties.h"
#include "endpoint_description.h"
diff --git a/bundles/remote_services/rsa_spi/include/remote_service_admin.h b/bundles/remote_services/rsa_spi/include/remote_service_admin.h
index 346b1193..0bca98d3 100644
--- a/bundles/remote_services/rsa_spi/include/remote_service_admin.h
+++ b/bundles/remote_services/rsa_spi/include/remote_service_admin.h
@@ -41,10 +41,10 @@ typedef struct remote_service_admin remote_service_admin_t;
struct remote_service_admin_service {
remote_service_admin_t *admin;
- celix_status_t (*exportService)(remote_service_admin_t *admin, char *serviceId, celix_properties_t *properties, array_list_pt *registrations);
+ celix_status_t (*exportService)(remote_service_admin_t *admin, char *serviceId, celix_properties_t *properties, celix_array_list_t** registrations);
celix_status_t (*removeExportedService)(remote_service_admin_t *admin, export_registration_t *registration);
- celix_status_t (*getExportedServices)(remote_service_admin_t *admin, array_list_pt *services);
- celix_status_t (*getImportedEndpoints)(remote_service_admin_t *admin, array_list_pt *services);
+ celix_status_t (*getExportedServices)(remote_service_admin_t *admin, celix_array_list_t** services);
+ celix_status_t (*getImportedEndpoints)(remote_service_admin_t *admin, celix_array_list_t** services);
celix_status_t (*importService)(remote_service_admin_t *admin, endpoint_description_t *endpoint, import_registration_t **registration);
celix_status_t (*exportReference_getExportedEndpoint)(export_reference_t *reference, endpoint_description_t **endpoint);
diff --git a/bundles/remote_services/topology_manager/src/scope.c b/bundles/remote_services/topology_manager/src/scope.c
index cd5cf6b9..3c4af2a9 100644
--- a/bundles/remote_services/topology_manager/src/scope.c
+++ b/bundles/remote_services/topology_manager/src/scope.c
@@ -26,6 +26,8 @@
#include "utils.h"
#include "filter.h"
+static bool import_equal(celix_array_list_entry_t src, celix_array_list_entry_t dest);
+
struct scope_item {
celix_properties_t *props;
};
@@ -36,14 +38,12 @@ struct scope {
hash_map_pt exportScopes; // key is filter, value is scope_item (properties set)
celix_thread_mutex_t importScopeLock;
- array_list_pt importScopes; // list of filters
+ celix_array_list_t* importScopes; // list of filters
celix_status_t (*exportScopeChangedHandler)(void* manager, char *filter);
celix_status_t (*importScopeChangedHandler)(void* manager, char *filter);
};
-static celix_status_t import_equal(const void *, const void *, bool *equals);
-
/*
* SERVICES
*/
@@ -120,10 +120,13 @@ celix_status_t tm_addImportScope(void *handle, char *filter) {
return CELIX_ILLEGAL_ARGUMENT; // filter not parsable
}
if (celixThreadMutex_lock(&scope->importScopeLock) == CELIX_SUCCESS) {
- int index = arrayList_indexOf(scope->importScopes, new);
- filter_pt present = (filter_pt) arrayList_get(scope->importScopes, index);
+ celix_array_list_entry_t entry;
+ memset(&entry, 0, sizeof(entry));
+ entry.voidPtrVal = new;
+ int index = celix_arrayList_indexOf(scope->importScopes, entry);
+ filter_pt present = (filter_pt) celix_arrayList_get(scope->importScopes, index);
if (present == NULL) {
- arrayList_add(scope->importScopes, celix_steal_ptr(new));
+ celix_arrayList_add(scope->importScopes, celix_steal_ptr(new));
} else {
status = CELIX_ILLEGAL_ARGUMENT;
}
@@ -150,12 +153,15 @@ celix_status_t tm_removeImportScope(void *handle, char *filter) {
}
if (celixThreadMutex_lock(&scope->importScopeLock) == CELIX_SUCCESS) {
- int index = arrayList_indexOf(scope->importScopes, new);
- filter_pt present = (filter_pt) arrayList_get(scope->importScopes, index);
+ celix_array_list_entry_t entry;
+ memset(&entry, 0, sizeof(entry));
+ entry.voidPtrVal = new;
+ int index = celix_arrayList_indexOf(scope->importScopes, entry);
+ filter_pt present = (filter_pt) celix_arrayList_get(scope->importScopes, index);
if (present == NULL)
status = CELIX_ILLEGAL_ARGUMENT;
else {
- arrayList_removeElement(scope->importScopes, present);
+ celix_arrayList_remove(scope->importScopes, present);
filter_destroy(present);
}
celixThreadMutex_unlock(&scope->importScopeLock);
@@ -193,7 +199,9 @@ celix_status_t scope_scopeCreate(void *handle, scope_pt *scope) {
celixThreadMutex_create(&(*scope)->importScopeLock, NULL);
(*scope)->exportScopes = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
- arrayList_createWithEquals(import_equal, &((*scope)->importScopes));
+ celix_array_list_create_options_t opts = CELIX_EMPTY_ARRAY_LIST_CREATE_OPTIONS;
+ opts.equalsCallback = import_equal;
+ (*scope)->importScopes = celix_arrayList_createWithOptions(&opts);
(*scope)->exportScopeChangedHandler = NULL;
return status;
@@ -215,14 +223,11 @@ celix_status_t scope_scopeDestroy(scope_pt scope) {
}
if (celixThreadMutex_lock(&scope->importScopeLock) == CELIX_SUCCESS) {
- array_list_iterator_pt imp_iter = arrayListIterator_create(scope->importScopes);
- while (arrayListIterator_hasNext(imp_iter)) {
- filter_pt element = (filter_pt) arrayListIterator_next(imp_iter);
+ for (int i = 0; i < celix_arrayList_size(scope->importScopes); i++) {
+ filter_pt element = (filter_pt) celix_arrayList_get(scope->importScopes, i);
filter_destroy(element);
- // no need to call arrayList_removeElement(element) because complete list is destroyed
}
- arrayListIterator_destroy(imp_iter);
- arrayList_destroy(scope->importScopes);
+ celix_arrayList_destroy(scope->importScopes);
celixThreadMutex_unlock(&scope->importScopeLock);
}
@@ -235,29 +240,30 @@ celix_status_t scope_scopeDestroy(scope_pt scope) {
/*****************************************************************************
* STATIC FUNCTIONS
*****************************************************************************/
-static celix_status_t import_equal(const void *src, const void *dest, bool *equals) {
+static bool import_equal(celix_array_list_entry_t src, celix_array_list_entry_t dest) {
celix_status_t status;
- filter_pt src_filter = (filter_pt) src;
- filter_pt dest_filter = (filter_pt) dest;
- status = filter_match_filter(src_filter, dest_filter, equals);
- return status;
+ filter_pt src_filter = (filter_pt) src.voidPtrVal;
+ filter_pt dest_filter = (filter_pt) dest.voidPtrVal;
+ bool result;
+ status = filter_match_filter(src_filter, dest_filter, &result);
+ return (status == CELIX_SUCCESS) && result;
}
bool scope_allowImport(scope_pt scope, endpoint_description_t *endpoint) {
bool allowImport = false;
- array_list_iterator_pt iter;
if (celixThreadMutex_lock(&(scope->importScopeLock)) == CELIX_SUCCESS) {
- if (arrayList_size(scope->importScopes) == 0) {
+ if (celix_arrayList_size(scope->importScopes) == 0) {
allowImport = true;
} else {
- iter = arrayListIterator_create(scope->importScopes);
- while ((allowImport == false) && arrayListIterator_hasNext(iter)) {
- filter_pt element = (filter_pt) arrayListIterator_next(iter);
+ for (int i = 0; i < celix_arrayList_size(scope->importScopes); i++) {
+ filter_pt element = (filter_pt) celix_arrayList_get(scope->importScopes, i);
filter_match(element, endpoint->properties, &allowImport);
+ if (allowImport) {
+ break;
+ }
}
- arrayListIterator_destroy(iter);
}
celixThreadMutex_unlock(&scope->importScopeLock);
}
diff --git a/bundles/remote_services/topology_manager/src/topology_manager.c b/bundles/remote_services/topology_manager/src/topology_manager.c
index 5c91fefa..a152e669 100644
--- a/bundles/remote_services/topology_manager/src/topology_manager.c
+++ b/bundles/remote_services/topology_manager/src/topology_manager.c
@@ -836,12 +836,12 @@ static celix_status_t topologyManager_extendFilter(topology_manager_pt manager,
return status;
}
-celix_status_t topologyManager_listenerAdded(void *handle, array_list_pt listeners) {
+celix_status_t topologyManager_listenerAdded(void *handle, celix_array_list_t* listeners) {
celix_status_t status = CELIX_SUCCESS;
topology_manager_pt manager = handle;
- for (int i = 0; i < arrayList_size(listeners); i++) {
- listener_hook_info_pt info = arrayList_get(listeners, i);
+ for (int i = 0; i < celix_arrayList_size(listeners); i++) {
+ listener_hook_info_pt info = celix_arrayList_get(listeners, i);
celix_bundle_t *bundle = NULL, *self = NULL;
bundleContext_getBundle(info->context, &bundle);
bundleContext_getBundle(manager->context, &self);
@@ -886,12 +886,12 @@ celix_status_t topologyManager_listenerAdded(void *handle, array_list_pt listene
return status;
}
-celix_status_t topologyManager_listenerRemoved(void *handle, array_list_pt listeners) {
+celix_status_t topologyManager_listenerRemoved(void *handle, celix_array_list_t* listeners) {
celix_status_t status = CELIX_SUCCESS;
topology_manager_pt manager = handle;
- for (int i = 0; i < arrayList_size(listeners); i++) {
- listener_hook_info_pt info = arrayList_get(listeners, i);
+ for (int i = 0; i < celix_arrayList_size(listeners); i++) {
+ listener_hook_info_pt info = celix_arrayList_get(listeners, i);
celix_bundle_t *bundle = NULL, *self = NULL;
bundleContext_getBundle(info->context, &bundle);
diff --git a/bundles/remote_services/topology_manager/src/topology_manager.h b/bundles/remote_services/topology_manager/src/topology_manager.h
index e186d576..5c2cd938 100644
--- a/bundles/remote_services/topology_manager/src/topology_manager.h
+++ b/bundles/remote_services/topology_manager/src/topology_manager.h
@@ -60,7 +60,7 @@ celix_status_t topologyManager_removeImportedService(void *handle, endpoint_desc
celix_status_t topologyManager_addExportedService(void * handle, service_reference_pt reference, void * service);
celix_status_t topologyManager_removeExportedService(void * handle, service_reference_pt reference, void * service);
-celix_status_t topologyManager_listenerAdded(void *handle, array_list_pt listeners);
-celix_status_t topologyManager_listenerRemoved(void *handle, array_list_pt listeners);
+celix_status_t topologyManager_listenerAdded(void *handle, celix_array_list_t* listeners);
+celix_status_t topologyManager_listenerRemoved(void *handle, celix_array_list_t* listeners);
#endif /* TOPOLOGY_MANAGER_H_ */
diff --git a/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_activator.c b/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_activator.c
index bd5328bf..8c1574e8 100644
--- a/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_activator.c
+++ b/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_activator.c
@@ -44,12 +44,12 @@ celix_status_t celix_bundleActivator_create(celix_bundle_context_t *context, voi
discMockService_create(act, &act->serv);
act->endpointListener = NULL;
act->endpointListenerService = NULL;
- status = arrayList_create(&act->endpointList);
+ act->endpointList = celix_arrayList_create();
} else {
status = CELIX_ENOMEM;
}
- if (status == CELIX_SUCCESS) {
+ if (status == CELIX_SUCCESS && act->endpointList) {
*out = act;
} else if (act != NULL) {
free(act);
@@ -127,7 +127,7 @@ celix_status_t celix_bundleActivator_destroy(void * userData, celix_bundle_conte
discMockService_destroy(act->serv);
free(act->endpointListener);
- arrayList_destroy(act->endpointList);
+ celix_arrayList_destroy(act->endpointList);
free(act);
}
return CELIX_SUCCESS;
@@ -138,7 +138,7 @@ celix_status_t discovery_endpointAdded(void *handle, endpoint_description_t *end
struct disc_mock_activator *act = handle;
printf("%s\n", __func__);
- arrayList_add(act->endpointList, endpoint);
+ celix_arrayList_add(act->endpointList, endpoint);
return status;
}
@@ -147,7 +147,7 @@ celix_status_t discovery_endpointRemoved(void *handle, endpoint_description_t *e
celix_status_t status = CELIX_SUCCESS;
struct disc_mock_activator *act = handle;
printf("%s\n", __func__);
- arrayList_removeElement(act->endpointList, endpoint);
+ celix_arrayList_remove(act->endpointList, endpoint);
return status;
}
diff --git a/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_service.c b/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_service.c
index 047d90b3..b77f20cb 100644
--- a/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_service.c
+++ b/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_service.c
@@ -31,7 +31,7 @@
#include "disc_mock_service.h"
-celix_status_t test(void *handle, array_list_pt *descrList);
+celix_status_t test(void *handle, celix_array_list_t** descrList);
celix_status_t discMockService_create(void *handle, disc_mock_service_t **serv) {
*serv = calloc(1, sizeof(struct disc_mock_service));
@@ -49,7 +49,7 @@ celix_status_t discMockService_destroy(disc_mock_service_t *serv) {
return CELIX_SUCCESS;
}
-celix_status_t test(void *handle, array_list_pt *descrList) {
+celix_status_t test(void *handle, celix_array_list_t** descrList) {
struct disc_mock_activator *act = handle;
*descrList = act->endpointList;
diff --git a/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_service.h b/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_service.h
index 2635ae0a..7d3a0d24 100644
--- a/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_service.h
+++ b/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_service.h
@@ -28,7 +28,7 @@
typedef struct disc_mock_service {
void *handle;// disc_mock_activator_t*
- celix_status_t (*getEPDescriptors)(void *handle, array_list_pt *descrList);
+ celix_status_t (*getEPDescriptors)(void *handle, celix_array_list_t** descrList);
} disc_mock_service_t;
@@ -42,7 +42,7 @@ struct disc_mock_activator {
endpoint_listener_t *endpointListener;
service_registration_t *endpointListenerService;
- array_list_pt endpointList;
+ celix_array_list_t* endpointList;
};
diff --git a/bundles/remote_services/topology_manager/tms_tst/tms_tests.cpp b/bundles/remote_services/topology_manager/tms_tst/tms_tests.cpp
index 2636da9f..d70bda87 100644
--- a/bundles/remote_services/topology_manager/tms_tst/tms_tests.cpp
+++ b/bundles/remote_services/topology_manager/tms_tst/tms_tests.cpp
@@ -267,11 +267,11 @@ extern "C" {
/// \TEST_CASE_DESC Checks if 3 bundles are installed after the framework setup
static void testBundles(void) {
printf("Begin: %s\n", __func__);
- array_list_pt bundles = NULL;
+ celix_array_list_t* bundles = NULL;
int rc = bundleContext_getBundles(context, &bundles);
EXPECT_EQ(0, rc);
- EXPECT_EQ(5, arrayList_size(bundles)); //framework, scopeService & calc & rsa
+ EXPECT_EQ(5, celix_arrayList_size(bundles)); //framework, scopeService & calc & rsa
/*
int size = arrayList_size(bundles);
@@ -287,7 +287,7 @@ extern "C" {
printf("got bundle with symbolic name '%s'", name);
}*/
- arrayList_destroy(bundles);
+ celix_arrayList_destroy(bundles);
printf("End: %s\n", __func__);
}
@@ -384,7 +384,7 @@ extern "C" {
static void testScope(void) {
int nr_exported;
int nr_imported;
- array_list_pt epList;
+ celix_array_list_t* epList;
printf("\nBegin: %s\n", __func__);
scopeInit("scope.json", &nr_exported, &nr_imported);
@@ -393,9 +393,9 @@ extern "C" {
discMock->getEPDescriptors(discMock->handle, &epList);
// We export one service: Calculator, which has DFI bundle info
- EXPECT_EQ(1, arrayList_size(epList));
- for (unsigned int i = 0; i < arrayList_size(epList); i++) {
- endpoint_description_t *ep = (endpoint_description_t *) arrayList_get(epList, i);
+ EXPECT_EQ(1, celix_arrayList_size(epList));
+ for (int i = 0; i < celix_arrayList_size(epList); i++) {
+ endpoint_description_t *ep = (endpoint_description_t *) celix_arrayList_get(epList, i);
celix_properties_t *props = ep->properties;
const char* value = celix_properties_get(props, "key2", "");
EXPECT_STREQ("inaetics", value);
@@ -421,16 +421,16 @@ extern "C" {
static void testScope2(void) {
int nr_exported;
int nr_imported;
- array_list_pt epList;
+ celix_array_list_t* epList;
printf("\nBegin: %s\n", __func__);
scopeInit("scope2.json", &nr_exported, &nr_imported);
EXPECT_EQ(3, nr_exported);
EXPECT_EQ(1, nr_imported);
discMock->getEPDescriptors(discMock->handle, &epList);
// We export one service: Calculator, which has DFI bundle info
- EXPECT_EQ(1, arrayList_size(epList));
- for (unsigned int i = 0; i < arrayList_size(epList); i++) {
- endpoint_description_t *ep = (endpoint_description_t *) arrayList_get(epList, i);
+ EXPECT_EQ(1, celix_arrayList_size(epList));
+ for (int i = 0; i < celix_arrayList_size(epList); i++) {
+ endpoint_description_t *ep = (endpoint_description_t *) celix_arrayList_get(epList, i);
celix_properties_t *props = ep->properties;
const char* value = celix_properties_get(props, "key2", "");
EXPECT_STREQ("inaetics", value);
@@ -445,16 +445,16 @@ extern "C" {
static void testScope3(void) {
int nr_exported;
int nr_imported;
- array_list_pt epList;
+ celix_array_list_t* epList;
printf("\nBegin: %s\n", __func__);
scopeInit("scope3.json", &nr_exported, &nr_imported);
EXPECT_EQ(3, nr_exported);
EXPECT_EQ(1, nr_imported);
discMock->getEPDescriptors(discMock->handle, &epList);
// We export one service: Calculator, which has DFI bundle info
- EXPECT_EQ(1, arrayList_size(epList));
- for (unsigned int i = 0; i < arrayList_size(epList); i++) {
- endpoint_description_t *ep = (endpoint_description_t *) arrayList_get(epList, i);
+ EXPECT_EQ(1, celix_arrayList_size(epList));
+ for (int i = 0; i < celix_arrayList_size(epList); i++) {
+ endpoint_description_t *ep = (endpoint_description_t *) celix_arrayList_get(epList, i);
celix_properties_t *props = ep->properties;
const char* value = celix_properties_get(props, "key2", "");
EXPECT_STREQ("inaetics", value);
diff --git a/bundles/shell/remote_shell/src/remote_shell.c b/bundles/shell/remote_shell/src/remote_shell.c
index 86c281b5..cdff97b3 100644
--- a/bundles/shell/remote_shell/src/remote_shell.c
+++ b/bundles/shell/remote_shell/src/remote_shell.c
@@ -28,11 +28,11 @@
#include <string.h>
#include <unistd.h>
#include <utils.h>
-#include <array_list.h>
#include <sys/socket.h>
#include "celix_log_helper.h"
#include "celix_utils.h"
+#include "celix_array_list.h"
#include "remote_shell.h"
@@ -61,24 +61,29 @@ static celix_status_t remoteShell_connection_print(connection_pt connection, cha
static celix_status_t remoteShell_connection_execute(connection_pt connection, char *command);
static void* remoteShell_connection_run(void *data);
-celix_status_t remoteShell_create(shell_mediator_pt mediator, int maximumConnections, remote_shell_pt *instance) {
- celix_status_t status = CELIX_SUCCESS;
- (*instance) = calloc(1, sizeof(**instance));
- if ((*instance) != NULL) {
- (*instance)->mediator = mediator;
- (*instance)->maximumConnections = maximumConnections;
- (*instance)->connections = NULL;
- (*instance)->loghelper = &mediator->loghelper;
-
- status = celixThreadMutex_create(&(*instance)->mutex, NULL);
-
- if (status == CELIX_SUCCESS) {
- status = arrayList_create(&(*instance)->connections);
- }
- } else {
- status = CELIX_ENOMEM;
- }
- return status;
+celix_status_t remoteShell_create(shell_mediator_pt mediator, int maximumConnections, remote_shell_pt* instance) {
+ celix_status_t status = CELIX_SUCCESS;
+ (*instance) = calloc(1, sizeof(**instance));
+ if ((*instance) != NULL) {
+ (*instance)->mediator = mediator;
+ (*instance)->maximumConnections = maximumConnections;
+ (*instance)->connections = NULL;
+ (*instance)->loghelper = &mediator->loghelper;
+
+ status = celixThreadMutex_create(&(*instance)->mutex, NULL);
+
+ if (status == CELIX_SUCCESS) {
+ (*instance)->connections = celix_arrayList_create();
+ if (!(*instance)->connections) {
+ free(*instance);
+ (*instance) = NULL;
+ status = CELIX_ENOMEM;
+ }
+ }
+ } else {
+ status = CELIX_ENOMEM;
+ }
+ return status;
}
celix_status_t remoteShell_destroy(remote_shell_pt instance) {
@@ -87,7 +92,7 @@ celix_status_t remoteShell_destroy(remote_shell_pt instance) {
remoteShell_stopConnections(instance);
celixThreadMutex_lock(&instance->mutex);
- arrayList_destroy(instance->connections);
+ celix_arrayList_destroy(instance->connections);
celixThreadMutex_unlock(&instance->mutex);
return status;
@@ -106,9 +111,9 @@ celix_status_t remoteShell_addConnection(remote_shell_pt instance, int socket) {
celixThreadMutex_lock(&instance->mutex);
- if (arrayList_size(instance->connections) < instance->maximumConnections) {
+ if (celix_arrayList_size(instance->connections) < instance->maximumConnections) {
celix_thread_t connectionRunThread = celix_thread_default;
- arrayList_add(instance->connections, connection);
+ celix_arrayList_add(instance->connections, connection);
status = celixThread_create(&connectionRunThread, NULL, &remoteShell_connection_run, connection);
} else {
status = CELIX_BUNDLE_EXCEPTION;
@@ -139,10 +144,10 @@ celix_status_t remoteShell_stopConnections(remote_shell_pt instance) {
int i = 0;
celixThreadMutex_lock(&instance->mutex);
- length = arrayList_size(instance->connections);
+ length = celix_arrayList_size(instance->connections);
for (i = 0; i < length; i += 1) {
- connection_pt connection = arrayList_get(instance->connections, i);
+ connection_pt connection = celix_arrayList_get(instance->connections, i);
connection->threadRunning = false;
}
@@ -204,7 +209,7 @@ void *remoteShell_connection_run(void *data) {
celix_logHelper_log(*connection->parent->loghelper, CELIX_LOG_LEVEL_INFO, "REMOTE_SHELL: Closing socket");
celixThreadMutex_lock(&connection->parent->mutex);
- arrayList_removeElement(connection->parent->connections, connection);
+ celix_arrayList_remove(connection->parent->connections, connection);
celixThreadMutex_unlock(&connection->parent->mutex);
fclose(connection->socketStream);
diff --git a/bundles/shell/remote_shell/src/remote_shell.h b/bundles/shell/remote_shell/src/remote_shell.h
index ee32ca80..e95969fe 100644
--- a/bundles/shell/remote_shell/src/remote_shell.h
+++ b/bundles/shell/remote_shell/src/remote_shell.h
@@ -38,7 +38,7 @@ struct remote_shell {
celix_thread_mutex_t mutex;
int maximumConnections;
- array_list_pt connections;
+ celix_array_list_t* connections;
};
typedef struct remote_shell *remote_shell_pt;
diff --git a/libs/framework/gtest/src/CelixBundleContextServicesTestSuite.cc b/libs/framework/gtest/src/CelixBundleContextServicesTestSuite.cc
index 02c8e07e..c46f4824 100644
--- a/libs/framework/gtest/src/CelixBundleContextServicesTestSuite.cc
+++ b/libs/framework/gtest/src/CelixBundleContextServicesTestSuite.cc
@@ -1289,13 +1289,13 @@ TEST_F(CelixBundleContextServicesTestSuite, FindServicesTest) {
foundId = celix_bundleContext_findService(ctx, "example");
ASSERT_EQ(foundId, svcId1); //oldest should have highest ranking
- array_list_t *list = celix_bundleContext_findServices(ctx, "non existing service name");
+ celix_array_list_t *list = celix_bundleContext_findServices(ctx, "non existing service name");
ASSERT_EQ(0, celix_arrayList_size(list));
- arrayList_destroy(list);
+ celix_arrayList_destroy(list);
list = celix_bundleContext_findServices(ctx, "example");
ASSERT_EQ(4, celix_arrayList_size(list));
- arrayList_destroy(list);
+ celix_arrayList_destroy(list);
celix_bundleContext_unregisterService(ctx, svcId1);
celix_bundleContext_unregisterService(ctx, svcId3);
diff --git a/libs/framework/include/celix_api.h b/libs/framework/include/celix_api.h
index 84f1b31f..c4d5fcb8 100644
--- a/libs/framework/include/celix_api.h
+++ b/libs/framework/include/celix_api.h
@@ -20,12 +20,12 @@
#ifndef CELIX_CELIX_API_H_
#define CELIX_CELIX_API_H_
-#include "properties.h"
-#include "array_list.h"
+#include "celix_properties.h"
+#include "celix_array_list.h"
-#include "bundle.h"
-#include "bundle_context.h"
-#include "framework.h"
+#include "celix_bundle.h"
+#include "celix_bundle_context.h"
+#include "celix_framework.h"
#include "celix_properties.h"
#include "celix_array_list.h"
diff --git a/libs/framework/include_deprecated/bundle_context.h b/libs/framework/include_deprecated/bundle_context.h
index 1ee6bfe3..3c12de46 100644
--- a/libs/framework/include_deprecated/bundle_context.h
+++ b/libs/framework/include_deprecated/bundle_context.h
@@ -35,7 +35,6 @@
#include "bundle_listener.h"
#include "framework_listener.h"
#include "properties.h"
-#include "array_list.h"
#include "celix_service_listener.h"
#include "dm_dependency_manager.h"
diff --git a/libs/framework/include_deprecated/bundle_revision.h b/libs/framework/include_deprecated/bundle_revision.h
index 6b39ca4f..372b9f9e 100644
--- a/libs/framework/include_deprecated/bundle_revision.h
+++ b/libs/framework/include_deprecated/bundle_revision.h
@@ -27,7 +27,7 @@
#include "celix_errno.h"
#include "manifest.h"
#include "celix_log.h"
-#include "array_list.h"
+#include "celix_array_list.h"
#include "celix_framework_export.h"
#ifdef __cplusplus
diff --git a/libs/framework/include_deprecated/dm_component.h b/libs/framework/include_deprecated/dm_component.h
index abe1e42e..b2d27cf5 100644
--- a/libs/framework/include_deprecated/dm_component.h
+++ b/libs/framework/include_deprecated/dm_component.h
@@ -32,7 +32,7 @@
#include "celix_types.h"
#include "celix_errno.h"
#include "properties.h"
-#include "array_list.h"
+#include "celix_array_list.h"
#include "celix_dm_info.h"
#include "celix_dm_component.h"
#include "celix_framework_export.h"
diff --git a/libs/framework/include_deprecated/dm_dependency_manager.h b/libs/framework/include_deprecated/dm_dependency_manager.h
index ce322a3f..cab5030f 100644
--- a/libs/framework/include_deprecated/dm_dependency_manager.h
+++ b/libs/framework/include_deprecated/dm_dependency_manager.h
@@ -30,7 +30,6 @@
#include "celix_types.h"
#include "celix_errno.h"
-#include "array_list.h"
#include "celix_dm_info.h"
#include "celix_framework_export.h"
diff --git a/libs/framework/include_deprecated/module.h b/libs/framework/include_deprecated/module.h
index c17b0791..0aeabb64 100644
--- a/libs/framework/include_deprecated/module.h
+++ b/libs/framework/include_deprecated/module.h
@@ -34,7 +34,6 @@ typedef struct module celix_module_t;
#include "manifest.h"
#include "version.h"
-#include "array_list.h"
#include "bundle.h"
#include "celix_framework_export.h"
diff --git a/libs/framework/include_deprecated/service_reference.h b/libs/framework/include_deprecated/service_reference.h
index 184c686d..35068cca 100644
--- a/libs/framework/include_deprecated/service_reference.h
+++ b/libs/framework/include_deprecated/service_reference.h
@@ -23,7 +23,6 @@
#include <stdbool.h>
#include "celix_types.h"
-#include "array_list.h"
#include "service_registration.h"
#include "bundle.h"
#include "celix_framework_export.h"
diff --git a/libs/framework/include_deprecated/service_registration.h b/libs/framework/include_deprecated/service_registration.h
index 7bef89bd..256d7db0 100644
--- a/libs/framework/include_deprecated/service_registration.h
+++ b/libs/framework/include_deprecated/service_registration.h
@@ -23,7 +23,6 @@
#include <stdbool.h>
#include "celix_types.h"
-#include "array_list.h"
#include "bundle.h"
#include "celix_framework_export.h"
diff --git a/libs/framework/include_deprecated/service_registry.h b/libs/framework/include_deprecated/service_registry.h
index 40e568cc..d7ce53dc 100644
--- a/libs/framework/include_deprecated/service_registry.h
+++ b/libs/framework/include_deprecated/service_registry.h
@@ -24,7 +24,7 @@
#include "filter.h"
#include "service_factory.h"
#include "celix_service_event.h"
-#include "array_list.h"
+#include "celix_array_list.h"
#include "service_registration.h"
#include "celix_service_factory.h"
#include "celix_framework_export.h"
diff --git a/libs/framework/include_deprecated/service_tracker.h b/libs/framework/include_deprecated/service_tracker.h
index d65834f3..5f75c8ab 100644
--- a/libs/framework/include_deprecated/service_tracker.h
+++ b/libs/framework/include_deprecated/service_tracker.h
@@ -21,7 +21,6 @@
#define SERVICE_TRACKER_H_
#include "celix_service_listener.h"
-#include "array_list.h"
#include "service_tracker_customizer.h"
#include "bundle_context.h"
#include "celix_bundle_context.h"
diff --git a/libs/framework/src/bundle.c b/libs/framework/src/bundle.c
index 731441b5..6a687696 100644
--- a/libs/framework/src/bundle.c
+++ b/libs/framework/src/bundle.c
@@ -83,21 +83,19 @@ celix_status_t celix_bundle_createFromArchive(celix_framework_t *framework, bund
}
celix_status_t bundle_destroy(bundle_pt bundle) {
- array_list_iterator_pt iter = arrayListIterator_create(bundle->modules);
- while (arrayListIterator_hasNext(iter)) {
- module_pt module = arrayListIterator_next(iter);
- module_destroy(module);
- }
- arrayListIterator_destroy(iter);
- arrayList_destroy(bundle->modules);
+ for (int i = 0; i < celix_arrayList_size(bundle->modules); ++i) {
+ module_pt module = celix_arrayList_get(bundle->modules, i);
+ module_destroy(module);
+ }
+ celix_arrayList_destroy(bundle->modules);
- free(bundle->symbolicName);
+ free(bundle->symbolicName);
free(bundle->name);
free(bundle->group);
free(bundle->description);
- free(bundle);
+ free(bundle);
- return CELIX_SUCCESS;
+ return CELIX_SUCCESS;
}
celix_status_t bundle_getArchive(const_bundle_pt bundle, bundle_archive_pt *archive) {
@@ -113,16 +111,16 @@ celix_status_t bundle_getArchive(const_bundle_pt bundle, bundle_archive_pt *arch
celix_status_t bundle_getCurrentModule(const_bundle_pt bundle, module_pt *module) {
celix_status_t status = CELIX_SUCCESS;
- if (bundle == NULL || arrayList_size(bundle->modules)==0 ) {
+ if (bundle == NULL || celix_arrayList_size(bundle->modules)==0 ) {
status = CELIX_ILLEGAL_ARGUMENT;
} else {
- *module = arrayList_get(bundle->modules, arrayList_size(bundle->modules) - 1);
+ *module = celix_arrayList_get(bundle->modules, celix_arrayList_size(bundle->modules) - 1);
}
return status;
}
-array_list_pt bundle_getModules(const_bundle_pt bundle) {
+celix_array_list_t* bundle_getModules(const_bundle_pt bundle) {
return bundle->modules;
}
@@ -345,7 +343,7 @@ celix_status_t bundle_closeRevisions(const_bundle_pt bundle) {
celix_status_t bundle_refresh(bundle_pt bundle) {
module_pt module;
- arrayList_clear(bundle->modules);
+ celix_arrayList_clear(bundle->modules);
celix_status_t status = bundle_createModule(bundle, &module);
if (status == CELIX_SUCCESS) {
status = bundle_addModule(bundle, module);
@@ -370,7 +368,7 @@ celix_status_t bundle_getBundleId(const bundle_t *bundle, long *bndId) {
return status;
}
-celix_status_t bundle_getRegisteredServices(bundle_pt bundle, array_list_pt *list) {
+celix_status_t bundle_getRegisteredServices(bundle_pt bundle, celix_array_list_t** list) {
celix_status_t status;
status = fw_getBundleRegisteredServices(bundle->framework, bundle, list);
@@ -380,7 +378,7 @@ celix_status_t bundle_getRegisteredServices(bundle_pt bundle, array_list_pt *lis
return status;
}
-celix_status_t bundle_getServicesInUse(bundle_pt bundle, array_list_pt *list) {
+celix_status_t bundle_getServicesInUse(bundle_pt bundle, celix_array_list_t** list) {
celix_status_t status;
status = fw_getBundleServicesInUse(bundle->framework, bundle, list);
diff --git a/libs/framework/src/bundle_context.c b/libs/framework/src/bundle_context.c
index d8b2c95c..9785b06e 100644
--- a/libs/framework/src/bundle_context.c
+++ b/libs/framework/src/bundle_context.c
@@ -178,7 +178,7 @@ celix_status_t bundleContext_registerServiceFactory(bundle_context_pt context, c
return fw_registerServiceFactory(context->framework, service_registration, bndId, serviceName, factory, properties);
}
-celix_status_t bundleContext_getServiceReferences(bundle_context_pt context, const char * serviceName, const char * filter, array_list_pt *service_references) {
+celix_status_t bundleContext_getServiceReferences(bundle_context_pt context, const char * serviceName, const char * filter, celix_array_list_t** service_references) {
if (context == NULL || service_references == NULL) {
return CELIX_ILLEGAL_ARGUMENT;
}
@@ -187,20 +187,20 @@ celix_status_t bundleContext_getServiceReferences(bundle_context_pt context, con
celix_status_t bundleContext_getServiceReference(bundle_context_pt context, const char * serviceName, service_reference_pt *service_reference) {
service_reference_pt reference = NULL;
- array_list_pt services = NULL;
+ celix_array_list_t* services = NULL;
celix_status_t status = CELIX_SUCCESS;
if (serviceName != NULL) {
if (bundleContext_getServiceReferences(context, serviceName, NULL, &services) == CELIX_SUCCESS) {
- unsigned int size = arrayList_size(services);
+ unsigned int size = celix_arrayList_size(services);
for(unsigned int i = 0; i < size; i++) {
if(i == 0) {
- reference = arrayList_get(services, 0);
+ reference = celix_arrayList_get(services, 0);
} else {
- bundleContext_ungetServiceReference(context, arrayList_get(services, i));
+ bundleContext_ungetServiceReference(context, celix_arrayList_get(services, i));
}
}
- arrayList_destroy(services);
+ celix_arrayList_destroy(services);
*service_reference = reference;
} else {
status = CELIX_ILLEGAL_ARGUMENT;
@@ -251,7 +251,7 @@ celix_status_t bundleContext_ungetService(bundle_context_pt context, service_ref
return serviceReference_ungetService(reference, result);
}
-celix_status_t bundleContext_getBundles(bundle_context_pt context, array_list_pt *bundles) {
+celix_status_t bundleContext_getBundles(bundle_context_pt context, celix_array_list_t** bundles) {
if (context == NULL || bundles == NULL) {
return CELIX_ILLEGAL_ARGUMENT;
}
@@ -1387,7 +1387,7 @@ static celix_status_t bundleContext_callServicedTrackerTrackerCallback(void *han
if (entry != NULL) {
size_t size = celix_arrayList_size(listeners);
for (unsigned int i = 0; i < size; ++i) {
- listener_hook_info_pt info = arrayList_get(listeners, i);
+ listener_hook_info_pt info = celix_arrayList_get(listeners, i);
celix_bundle_t *bnd = NULL;
bundleContext_getBundle(info->context, &bnd);
diff --git a/libs/framework/src/bundle_context_private.h b/libs/framework/src/bundle_context_private.h
index fa2c2c9c..38482d1d 100644
--- a/libs/framework/src/bundle_context_private.h
+++ b/libs/framework/src/bundle_context_private.h
@@ -80,7 +80,7 @@ struct celix_bundle_context {
celix_bundle_t *bundle;
celix_thread_mutex_t mutex; //protects fields below (NOTE/FIXME also used by bundle.c for listing service tracker usage)
- array_list_t *svcRegistrations; //serviceIds
+ celix_array_list_t *svcRegistrations; //serviceIds
celix_dependency_manager_t *mng;
long nextTrackerId;
hash_map_t *bundleTrackers; //key = trackerId, value = celix_bundle_context_bundle_tracker_entry_t*
diff --git a/libs/framework/src/bundle_private.h b/libs/framework/src/bundle_private.h
index 1b3471cf..f061a901 100644
--- a/libs/framework/src/bundle_private.h
+++ b/libs/framework/src/bundle_private.h
@@ -37,7 +37,7 @@ struct celix_bundle {
bundle_state_e state;
void *handle;
bundle_archive_pt archive;
- array_list_pt modules;
+ celix_array_list_t* modules;
celix_framework_t *framework;
};
diff --git a/libs/framework/src/dm_component_impl.c b/libs/framework/src/dm_component_impl.c
index 8ba8def3..2d20ff5a 100644
--- a/libs/framework/src/dm_component_impl.c
+++ b/libs/framework/src/dm_component_impl.c
@@ -281,7 +281,7 @@ celix_status_t celix_dmComponent_addServiceDependency(celix_dm_component_t *comp
celix_dmServiceDependency_setComponent(dep, component);
celixThreadMutex_lock(&component->mutex);
- arrayList_add(component->dependencies, dep);
+ celix_arrayList_add(component->dependencies, dep);
bool startDep = celix_dmComponent_currentState(component) != CELIX_DM_CMP_STATE_INACTIVE;
if (startDep) {
celix_dmServiceDependency_enable(dep);
@@ -678,7 +678,7 @@ static celix_status_t celix_dmComponent_handleSet(celix_dm_component_t *componen
*/
static celix_status_t celix_dmComponent_enableDependencies(celix_dm_component_t *component) {
for (int i = 0; i < celix_arrayList_size(component->dependencies); i++) {
- celix_dm_service_dependency_t *dependency = arrayList_get(component->dependencies, i);
+ celix_dm_service_dependency_t *dependency = celix_arrayList_get(component->dependencies, i);
celix_dmServiceDependency_enable(dependency);
}
return CELIX_SUCCESS;
@@ -689,7 +689,7 @@ static celix_status_t celix_dmComponent_enableDependencies(celix_dm_component_t
*/
static celix_status_t celix_dmComponent_disableDependencies(celix_dm_component_t *component) {
for (int i = 0; i < celix_arrayList_size(component->dependencies); i++) {
- celix_dm_service_dependency_t *dependency = arrayList_get(component->dependencies, i);
+ celix_dm_service_dependency_t *dependency = celix_arrayList_get(component->dependencies, i);
celix_dmServiceDependency_disable(dependency);
}
return CELIX_SUCCESS;
@@ -899,7 +899,7 @@ static celix_status_t celix_dmComponent_registerServices(celix_dm_component_t *c
celixThreadMutex_lock(&component->mutex);
}
for (int i = 0; i < celix_arrayList_size(component->providedInterfaces); i++) {
- dm_interface_t *interface = arrayList_get(component->providedInterfaces, i);
+ dm_interface_t *interface = celix_arrayList_get(component->providedInterfaces, i);
if (interface->svcId == -1L) {
celix_properties_t *regProps = celix_properties_copy(interface->properties);
celix_service_registration_options_t opts = CELIX_EMPTY_SERVICE_REGISTRATION_OPTIONS;
@@ -934,7 +934,7 @@ static celix_status_t celix_dmComponent_unregisterServices(celix_dm_component_t
}
celix_array_list_t* ids = NULL;
for (int i = 0; i < celix_arrayList_size(component->providedInterfaces); ++i) {
- dm_interface_t *interface = arrayList_get(component->providedInterfaces, i);
+ dm_interface_t *interface = celix_arrayList_get(component->providedInterfaces, i);
if (interface->svcId == -1) {
continue;
}
diff --git a/libs/framework/src/dm_dependency_manager_impl.c b/libs/framework/src/dm_dependency_manager_impl.c
index 2b5aee9a..8c574428 100644
--- a/libs/framework/src/dm_dependency_manager_impl.c
+++ b/libs/framework/src/dm_dependency_manager_impl.c
@@ -367,13 +367,13 @@ celix_status_t dependencyManager_getInfo(celix_dependency_manager_t *manager, dm
celixThreadMutex_lock(&manager->mutex);
if (info != NULL) {
- arrayList_create(&info->components);
- size = arrayList_size(manager->components);
+ celix_arrayList_create(&info->components);
+ size = celix_arrayList_size(manager->components);
for (i = 0; i < size; i += 1) {
- celix_dm_component_t *cmp = arrayList_get(manager->components, i);
+ celix_dm_component_t *cmp = celix_arrayList_get(manager->components, i);
cmpInfo = NULL;
component_getComponentInfo(cmp, &cmpInfo);
- arrayList_add(info->components, cmpInfo);
+ celix_arrayList_add(info->components, cmpInfo);
}
} else {
status = CELIX_ENOMEM;
diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c
index bdfd0ee6..ddef1e15 100644
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@ -348,10 +348,10 @@ celix_status_t framework_destroy(framework_pt framework) {
hashMap_destroy(framework->installRequestMap, false, false);
if (framework->bundleListeners) {
- arrayList_destroy(framework->bundleListeners);
+ celix_arrayList_destroy(framework->bundleListeners);
}
if (framework->frameworkListeners) {
- arrayList_destroy(framework->frameworkListeners);
+ celix_arrayList_destroy(framework->frameworkListeners);
}
assert(celix_arrayList_size(framework->dispatcher.dynamicEventQueue) == 0);
@@ -706,55 +706,55 @@ bool celix_framework_isBundleAlreadyInstalled(celix_framework_t* fw, const char*
return alreadyExists;
}
-celix_status_t fw_getDependentBundles(framework_pt framework, bundle_pt exporter, array_list_pt *list) {
+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;
- }
-
- array_list_pt modules;
- unsigned int modIdx = 0;
- arrayList_create(list);
-
- modules = bundle_getModules(exporter);
- for (modIdx = 0; modIdx < arrayList_size(modules); modIdx++) {
- module_pt module = (module_pt) arrayList_get(modules, modIdx);
- array_list_pt dependents = module_getDependents(module);
- if(dependents!=NULL){
- unsigned int depIdx = 0;
- for (depIdx = 0; depIdx < arrayList_size(dependents); depIdx++) {
- module_pt dependent = (module_pt) arrayList_get(dependents, depIdx);
- arrayList_add(*list, module_getBundle(dependent));
- }
- arrayList_destroy(dependents);
- }
- }
+ 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 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;
+ if (framework == NULL || exporter == NULL) {
+ return CELIX_ILLEGAL_ARGUMENT;
}
- array_list_pt dependents = NULL;
+ 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 < arrayList_size(dependents); depIdx++) {
- if (!hashMap_containsKey(*map, arrayList_get(dependents, depIdx))) {
- hashMap_put(*map, arrayList_get(dependents, depIdx), arrayList_get(dependents, depIdx));
- fw_populateDependentGraph(framework, (bundle_pt) arrayList_get(dependents, depIdx), map);
- }
- }
- arrayList_destroy(dependents);
- }
+ 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");
@@ -798,11 +798,11 @@ celix_status_t fw_registerServiceFactory(framework_pt framework, service_registr
return status;
}
-celix_status_t fw_getServiceReferences(framework_pt framework, array_list_pt *references, bundle_pt bundle, const char * serviceName, const char * sfilter) {
+celix_status_t fw_getServiceReferences(framework_pt framework, celix_array_list_t** references, bundle_pt bundle, const char * serviceName, const char * sfilter) {
celix_status_t status = CELIX_SUCCESS;
celix_autoptr(celix_filter_t) filter = NULL;
- unsigned int refIdx = 0;
+ int refIdx = 0;
if (sfilter != NULL) {
filter = celix_filter_create(sfilter);
@@ -812,8 +812,8 @@ celix_status_t fw_getServiceReferences(framework_pt framework, array_list_pt *re
if (status == CELIX_SUCCESS) {
- for (refIdx = 0; (*references != NULL) && refIdx < arrayList_size(*references); refIdx++) {
- service_reference_pt ref = (service_reference_pt) arrayList_get(*references, refIdx);
+ for (refIdx = 0; (*references != NULL) && refIdx < celix_arrayList_size(*references); refIdx++) {
+ service_reference_pt ref = (service_reference_pt) celix_arrayList_get(*references, refIdx);
service_registration_pt reg = NULL;
const char* serviceNameObjectClass;
properties_pt props = NULL;
@@ -823,7 +823,7 @@ celix_status_t fw_getServiceReferences(framework_pt framework, array_list_pt *re
serviceNameObjectClass = properties_get(props, CELIX_FRAMEWORK_SERVICE_NAME);
if (!serviceReference_isAssignableTo(ref, bundle, serviceNameObjectClass)) {
serviceReference_release(ref, NULL);
- arrayList_remove(*references, refIdx);
+ celix_arrayList_removeAt(*references, refIdx);
refIdx--;
}
}
@@ -835,11 +835,11 @@ celix_status_t fw_getServiceReferences(framework_pt framework, array_list_pt *re
return status;
}
-celix_status_t fw_getBundleRegisteredServices(framework_pt framework, bundle_pt bundle, array_list_pt *services) {
+celix_status_t fw_getBundleRegisteredServices(framework_pt framework, bundle_pt bundle, celix_array_list_t** services) {
return serviceRegistry_getRegisteredServices(framework->registry, bundle, services);
}
-celix_status_t fw_getBundleServicesInUse(framework_pt framework, bundle_pt bundle, array_list_pt *services) {
+celix_status_t fw_getBundleServicesInUse(framework_pt framework, bundle_pt bundle, celix_array_list_t* *services) {
celix_status_t status = CELIX_SUCCESS;
status = serviceRegistry_getServicesInUse(framework->registry, bundle, services);
return status;
@@ -922,7 +922,7 @@ celix_status_t fw_removeBundleListener(framework_pt framework, bundle_pt bundle,
fw_bundle_listener_pt bundleListener = NULL;
celixThreadMutex_lock(&framework->bundleListenerLock);
- for (int i = 0; i < arrayList_size(framework->bundleListeners); i++) {
+ for (int i = 0; i < celix_arrayList_size(framework->bundleListeners); i++) {
bundleListener = celix_arrayList_get(framework->bundleListeners, i);
if (bundleListener->listener == listener && bundleListener->bundle == bundle) {
celix_arrayList_removeAt(framework->bundleListeners, i);
@@ -953,7 +953,7 @@ celix_status_t fw_addFrameworkListener(framework_pt framework, bundle_pt bundle,
frameworkListener->bundle = bundle;
celixThreadMutex_lock(&framework->frameworkListenersLock);
- arrayList_add(framework->frameworkListeners, frameworkListener);
+ celix_arrayList_add(framework->frameworkListeners, frameworkListener);
celixThreadMutex_unlock(&framework->frameworkListenersLock);
}
@@ -963,14 +963,14 @@ celix_status_t fw_addFrameworkListener(framework_pt framework, bundle_pt bundle,
}
celix_status_t fw_removeFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener) {
- unsigned int i;
+ int i;
fw_framework_listener_pt frameworkListener;
celixThreadMutex_lock(&framework->frameworkListenersLock);
- for (i = 0; i < arrayList_size(framework->frameworkListeners); i++) {
- frameworkListener = (fw_framework_listener_pt) arrayList_get(framework->frameworkListeners, i);
+ for (i = 0; i < celix_arrayList_size(framework->frameworkListeners); i++) {
+ frameworkListener = (fw_framework_listener_pt) celix_arrayList_get(framework->frameworkListeners, i);
if (frameworkListener->listener == listener && frameworkListener->bundle == bundle) {
- arrayList_remove(framework->frameworkListeners, i);
+ celix_arrayList_removeAt(framework->frameworkListeners, i);
free(frameworkListener);
@@ -1029,11 +1029,10 @@ static celix_status_t framework_markBundleResolved(framework_pt framework, modul
return status;
}
-array_list_pt framework_getBundles(framework_pt framework) {
+celix_array_list_t* framework_getBundles(framework_pt framework) {
//FIXME Note that this does not increase the use count of the bundle, which can lead to race conditions.
//promote to use the celix_bundleContext_useBundle(s) functions and deprecated this one
- array_list_pt bundles = NULL;
- arrayList_create(&bundles);
+ celix_array_list_t* bundles = celix_arrayList_create();
celixThreadMutex_lock(&framework->installedBundles.mutex);
int size = celix_arrayList_size(framework->installedBundles.entries);
@@ -1233,13 +1232,13 @@ static void fw_handleEventRequest(celix_framework_t *framework, celix_framework_
celix_array_list_t *localListeners = celix_arrayList_create();
celixThreadMutex_lock(&framework->bundleListenerLock);
for (int i = 0; i < celix_arrayList_size(framework->bundleListeners); ++i) {
- fw_bundle_listener_pt listener = arrayList_get(framework->bundleListeners, i);
+ fw_bundle_listener_pt listener = celix_arrayList_get(framework->bundleListeners, i);
fw_bundleListener_increaseUseCount(listener);
celix_arrayList_add(localListeners, listener);
}
celixThreadMutex_unlock(&framework->bundleListenerLock);
for (int i = 0; i < celix_arrayList_size(localListeners); ++i) {
- fw_bundle_listener_pt listener = arrayList_get(localListeners, i);
+ fw_bundle_listener_pt listener = celix_arrayList_get(localListeners, i);
bundle_event_t bEvent;
memset(&bEvent, 0, sizeof(bEvent));
diff --git a/libs/framework/src/framework_private.h b/libs/framework/src/framework_private.h
index a5b299ff..e903fa72 100644
--- a/libs/framework/src/framework_private.h
+++ b/libs/framework/src/framework_private.h
@@ -26,7 +26,7 @@
#include "framework.h"
#include "manifest.h"
#include "hash_map.h"
-#include "array_list.h"
+#include "celix_array_list.h"
#include "celix_errno.h"
#include "service_factory.h"
#include "bundle_archive.h"
@@ -135,10 +135,10 @@ struct celix_framework {
long bundleId; //the bundle id of the framework (normally 0)
hash_map_pt installRequestMap;
- array_list_pt frameworkListeners;
+ celix_array_list_t* frameworkListeners;
celix_thread_mutex_t frameworkListenersLock;
- array_list_pt bundleListeners;
+ celix_array_list_t* bundleListeners;
celix_thread_mutex_t bundleListenerLock;
long currentBundleId; //atomic
@@ -267,9 +267,9 @@ celix_status_t celix_framework_installBundleInternal(celix_framework_t* framewor
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_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);
-celix_status_t fw_getBundleServicesInUse(framework_pt framework, bundle_pt bundle, array_list_pt *services);
+celix_status_t fw_getServiceReferences(framework_pt framework, celix_array_list_t** references, bundle_pt bundle, const char* serviceName, const char* filter);
+celix_status_t fw_getBundleRegisteredServices(framework_pt framework, bundle_pt bundle, celix_array_list_t** services);
+celix_status_t fw_getBundleServicesInUse(framework_pt framework, bundle_pt bundle, celix_array_list_t** services);
void fw_addServiceListener(framework_pt framework, bundle_pt bundle, celix_service_listener_t *listener, const char* filter);
void fw_removeServiceListener(framework_pt framework, bundle_pt bundle, celix_service_listener_t *listener);
@@ -280,7 +280,7 @@ celix_status_t fw_removeBundleListener(framework_pt framework, bundle_pt bundle,
celix_status_t fw_addFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener);
celix_status_t fw_removeFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener);
-array_list_pt framework_getBundles(framework_pt framework) __attribute__((deprecated("not thread safe, use celix_framework_useBundles instead")));
+celix_array_list_t* framework_getBundles(framework_pt framework) __attribute__((deprecated("not thread safe, use celix_framework_useBundles instead")));
long framework_getBundle(framework_pt framework, const char* location);
bundle_pt framework_getBundleById(framework_pt framework, long id);
diff --git a/libs/framework/src/module.c b/libs/framework/src/module.c
index ed68c45a..2d2dcc9c 100644
--- a/libs/framework/src/module.c
+++ b/libs/framework/src/module.c
@@ -198,7 +198,7 @@ bundle_pt module_getBundle(module_pt module) {
return module->bundle;
}
-array_list_pt module_getDependentImporters(module_pt module) {
+celix_array_list_t* module_getDependentImporters(module_pt module) {
return NULL;
}
@@ -210,7 +210,7 @@ void module_removeDependentImporter(module_pt module, module_pt importer) {
//----------------------------------------------------
//TODO add implementation (functions not implemented but already exported)
-array_list_pt module_getDependentRequirers(module_pt module) {
+celix_array_list_t* module_getDependentRequirers(module_pt module) {
return NULL;
}
@@ -221,7 +221,7 @@ void module_removeDependentRequirer(module_pt module, module_pt requirer) {
}
//----------------------------------------------------
-array_list_pt module_getDependents(module_pt module) {
+celix_array_list_t* module_getDependents(module_pt module) {
return NULL;
}
diff --git a/libs/framework/src/registry_callback_private.h b/libs/framework/src/registry_callback_private.h
index 90185217..3c96dbbd 100644
--- a/libs/framework/src/registry_callback_private.h
+++ b/libs/framework/src/registry_callback_private.h
@@ -35,7 +35,7 @@
typedef struct registry_callback_struct {
void *handle;
- celix_status_t (*getUsingBundles)(void *handle, service_registration_pt reg, array_list_pt *bundles);
+ celix_status_t (*getUsingBundles)(void *handle, service_registration_pt reg, celix_array_list_t** bundles);
celix_status_t (*unregister)(void *handle, bundle_pt bundle, service_registration_pt reg);
bool (*tryRemoveServiceReference)(void *handle, service_reference_pt ref);
} registry_callback_t;
diff --git a/libs/framework/src/service_reference.c b/libs/framework/src/service_reference.c
index 21d1a282..2d6460ec 100644
--- a/libs/framework/src/service_reference.c
+++ b/libs/framework/src/service_reference.c
@@ -313,7 +313,7 @@ unsigned int serviceReference_hashCode(const void *referenceP) {
}
-celix_status_t serviceReference_getUsingBundles(service_reference_pt ref, array_list_pt *out) {
+celix_status_t serviceReference_getUsingBundles(service_reference_pt ref, celix_array_list_t** out) {
celix_status_t status = CELIX_SUCCESS;
registry_callback_t callback;
diff --git a/libs/framework/src/service_registry.c b/libs/framework/src/service_registry.c
index 0dd6eaca..e1d45c8b 100644
--- a/libs/framework/src/service_registry.c
+++ b/libs/framework/src/service_registry.c
@@ -38,7 +38,7 @@ static bool serviceRegistry_tryRemoveServiceReference(service_registry_pt regist
static celix_status_t serviceRegistry_addHooks(service_registry_pt registry, const char* serviceName, const void *serviceObject, service_registration_pt registration);
static celix_status_t serviceRegistry_removeHook(service_registry_pt registry, service_registration_pt registration);
static void serviceRegistry_logWarningServiceReferenceUsageCount(service_registry_pt registry, bundle_pt bundle, service_reference_pt ref, size_t usageCount, size_t refCount);
-static celix_status_t serviceRegistry_getUsingBundles(service_registry_pt registry, service_registration_pt reg, array_list_pt *bundles);
+static celix_status_t serviceRegistry_getUsingBundles(service_registry_pt registry, service_registration_pt reg, celix_array_list_t** bundles);
static celix_status_t serviceRegistry_getServiceReference_internal(service_registry_pt registry, bundle_pt owner, service_registration_pt registration, service_reference_pt *out);
static void celix_serviceRegistry_serviceChanged(celix_service_registry_t *registry, celix_service_event_type_t eventType, service_registration_pt registration);
static void serviceRegistry_callHooksForListenerFilter(service_registry_pt registry, celix_bundle_t *owner, const celix_filter_t *filter, bool removed);
@@ -94,7 +94,7 @@ void celix_serviceRegistry_destroy(celix_service_registry_t* registry) {
celix_decreaseCountServiceListener(entry);
celix_waitAndDestroyServiceListener(entry);
}
- arrayList_destroy(registry->serviceListeners);
+ celix_arrayList_destroy(registry->serviceListeners);
//destroy service registration map
size = hashMap_size(registry->serviceRegistrations);
@@ -141,23 +141,23 @@ void celix_serviceRegistry_destroy(celix_service_registry_t* registry) {
free(registry);
}
-celix_status_t serviceRegistry_getRegisteredServices(service_registry_pt registry, bundle_pt bundle, array_list_pt *services) {
+celix_status_t serviceRegistry_getRegisteredServices(service_registry_pt registry, bundle_pt bundle, celix_array_list_t** services) {
celix_status_t status = CELIX_SUCCESS;
celixThreadRwlock_writeLock(®istry->lock);
- array_list_pt regs = (array_list_pt) hashMap_get(registry->serviceRegistrations, bundle);
+ celix_array_list_t* regs = (celix_array_list_t*) hashMap_get(registry->serviceRegistrations, bundle);
if (regs != NULL) {
unsigned int i;
- arrayList_create(services);
+ *services = celix_arrayList_create();
- for (i = 0; i < arrayList_size(regs); i++) {
- service_registration_pt reg = arrayList_get(regs, i);
+ for (i = 0; i < celix_arrayList_size(regs); i++) {
+ service_registration_pt reg = celix_arrayList_get(regs, i);
service_reference_pt reference = NULL;
//assert(serviceRegistration_isValid(reg));
status = serviceRegistry_getServiceReference_internal(registry, bundle, reg, &reference);
if (status == CELIX_SUCCESS) {
- arrayList_add(*services, reference);
+ celix_arrayList_add(*services, reference);
}
}
}
@@ -178,7 +178,7 @@ celix_status_t serviceRegistry_registerServiceFactory(service_registry_pt regist
}
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) {
- array_list_pt regs;
+ celix_array_list_t* regs;
long svcId = reservedId > 0 ? reservedId : celix_serviceRegistry_nextSvcId(registry);
celix_properties_setLong(dictionary, CELIX_FRAMEWORK_SERVICE_BUNDLE_ID, celix_bundle_getId(bundle));
@@ -201,13 +201,12 @@ static celix_status_t serviceRegistry_registerServiceInternal(service_registry_p
}
celixThreadRwlock_writeLock(®istry->lock);
- regs = (array_list_pt) hashMap_get(registry->serviceRegistrations, bundle);
+ regs = (celix_array_list_t*) hashMap_get(registry->serviceRegistrations, bundle);
if (regs == NULL) {
- regs = NULL;
- arrayList_create(®s);
+ regs = celix_arrayList_create();
hashMap_put(registry->serviceRegistrations, bundle, regs);
}
- arrayList_add(regs, *registration);
+ celix_arrayList_add(regs, *registration);
//update pending register event
celix_increasePendingRegisteredEvent(registry, svcId);
@@ -226,56 +225,56 @@ static celix_status_t serviceRegistry_registerServiceInternal(service_registry_p
return CELIX_SUCCESS;
}
-static celix_status_t serviceRegistry_unregisterService(service_registry_pt registry, bundle_pt bundle, service_registration_pt registration) {
- // array_list_t clients;
- celix_array_list_t *regs;
+static celix_status_t serviceRegistry_unregisterService(service_registry_pt registry,
+ bundle_pt bundle,
+ service_registration_pt registration) {
+ // array_list_t clients;
+ celix_array_list_t* regs;
- //fprintf(stderr, "REG: Unregistering service registration with pointer %p\n", registration);
+ // fprintf(stderr, "REG: Unregistering service registration with pointer %p\n", registration);
long svcId = serviceRegistration_getServiceId(registration);
- const char *svcName = NULL;
+ const char* svcName = NULL;
serviceRegistration_getServiceName(registration, &svcName);
- //printf("Unregistering service %li with name %s\n", svcId, svcName);
+ // printf("Unregistering service %li with name %s\n", svcId, svcName);
if (strcmp(OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, svcName) == 0) {
serviceRegistry_removeHook(registry, registration);
}
- celixThreadRwlock_writeLock(®istry->lock);
- regs = (celix_array_list_t*) hashMap_get(registry->serviceRegistrations, bundle);
- if (regs != NULL) {
- arrayList_removeElement(regs, registration);
- int size = arrayList_size(regs);
+ celixThreadRwlock_writeLock(®istry->lock);
+ regs = (celix_array_list_t*)hashMap_get(registry->serviceRegistrations, bundle);
+ if (regs != NULL) {
+ celix_arrayList_remove(regs, registration);
+ int size = celix_arrayList_size(regs);
if (size == 0) {
celix_arrayList_destroy(regs);
hashMap_remove(registry->serviceRegistrations, bundle);
}
- }
- celixThreadRwlock_unlock(®istry->lock);
-
+ }
+ celixThreadRwlock_unlock(®istry->lock);
- //check and wait for pending register events
+ // check and wait for pending register events
celix_waitForPendingRegisteredEvents(registry, svcId);
celix_serviceRegistry_serviceChanged(registry, OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING, registration);
celixThreadRwlock_readLock(®istry->lock);
- //invalidate service references
+ // invalidate service references
hash_map_iterator_pt iter = hashMapIterator_create(registry->serviceReferences);
while (hashMapIterator_hasNext(iter)) {
hash_map_pt refsMap = hashMapIterator_nextValue(iter);
- service_reference_pt ref = refsMap != NULL ?
- hashMap_get(refsMap, (void*)registration->serviceId) : NULL;
+ service_reference_pt ref = refsMap != NULL ? hashMap_get(refsMap, (void*)registration->serviceId) : NULL;
if (ref != NULL) {
serviceReference_invalidateCache(ref);
}
}
hashMapIterator_destroy(iter);
serviceRegistration_invalidate(registration);
- celixThreadRwlock_unlock(®istry->lock);
+ celixThreadRwlock_unlock(®istry->lock);
serviceRegistration_release(registration);
- return CELIX_SUCCESS;
+ return CELIX_SUCCESS;
}
celix_status_t serviceRegistry_getServiceReference(service_registry_pt registry, bundle_pt owner,
@@ -324,66 +323,70 @@ static celix_status_t serviceRegistry_getServiceReference_internal(service_regis
return status;
}
-celix_status_t serviceRegistry_getServiceReferences(service_registry_pt registry, bundle_pt owner, const char *serviceName, filter_pt filter, array_list_pt *out) {
- celix_status_t status;
- hash_map_iterator_pt iterator;
- array_list_pt references = NULL;
- array_list_pt matchingRegistrations = NULL;
+celix_status_t serviceRegistry_getServiceReferences(service_registry_pt registry,
+ bundle_pt owner,
+ const char* serviceName,
+ filter_pt filter,
+ celix_array_list_t** out) {
bool matchResult;
+ celix_autoptr(celix_array_list_t) references = celix_arrayList_create();
+ celix_autoptr(celix_array_list_t) matchingRegistrations = celix_arrayList_create();
- status = arrayList_create(&references);
- status = CELIX_DO_IF(status, arrayList_create(&matchingRegistrations));
+ if (!references || !matchingRegistrations) {
+ fw_log(registry->framework->logger, CELIX_LOG_LEVEL_ERROR, "Cannot create service references, out of memory");
+ return CELIX_ENOMEM;
+ }
+ celix_status_t status = CELIX_SUCCESS;
celixThreadRwlock_readLock(®istry->lock);
- iterator = hashMapIterator_create(registry->serviceRegistrations);
- while (status == CELIX_SUCCESS && hashMapIterator_hasNext(iterator)) {
- array_list_pt regs = (array_list_pt) hashMapIterator_nextValue(iterator);
- 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;
-
- status = serviceRegistration_getProperties(registration, &props);
- if (status == CELIX_SUCCESS) {
- bool matched = false;
- matchResult = false;
- if (filter != NULL) {
- filter_match(filter, props, &matchResult);
- }
- if ((serviceName == NULL) && ((filter == NULL) || matchResult)) {
- matched = true;
- } else if (serviceName != NULL) {
- const char *className = NULL;
- matchResult = false;
- serviceRegistration_getServiceName(registration, &className);
- if (filter != NULL) {
- filter_match(filter, props, &matchResult);
- }
- if ((strcmp(className, serviceName) == 0) && ((filter == NULL) || matchResult)) {
- matched = true;
- }
- }
- if (matched) {
+ hash_map_iterator_t iterator = hashMapIterator_construct(registry->serviceRegistrations);
+ while (status == CELIX_SUCCESS && hashMapIterator_hasNext(&iterator)) {
+ celix_array_list_t* regs = hashMapIterator_nextValue(&iterator);
+ unsigned int regIdx;
+ for (regIdx = 0; (regs != NULL) && regIdx < celix_arrayList_size(regs); regIdx++) {
+ service_registration_pt registration = celix_arrayList_get(regs, regIdx);
+ properties_pt props = NULL;
+
+ status = serviceRegistration_getProperties(registration, &props);
+ if (status == CELIX_SUCCESS) {
+ bool matched = false;
+ matchResult = false;
+ if (filter != NULL) {
+ filter_match(filter, props, &matchResult);
+ }
+ if ((serviceName == NULL) && ((filter == NULL) || matchResult)) {
+ matched = true;
+ } else if (serviceName != NULL) {
+ const char* className = NULL;
+ matchResult = false;
+ serviceRegistration_getServiceName(registration, &className);
+ if (filter != NULL) {
+ filter_match(filter, props, &matchResult);
+ }
+ if ((strcmp(className, serviceName) == 0) && ((filter == NULL) || matchResult)) {
+ matched = true;
+ }
+ }
+ if (matched) {
// assert(serviceRegistration_isValid(registration));
serviceRegistration_retain(registration);
- arrayList_add(matchingRegistrations, registration);
- }
- }
- }
- }
+ celix_arrayList_add(matchingRegistrations, registration);
+ }
+ }
+ }
+ }
celixThreadRwlock_unlock(®istry->lock);
- hashMapIterator_destroy(iterator);
if (status == CELIX_SUCCESS) {
unsigned int i;
- unsigned int size = arrayList_size(matchingRegistrations);
+ unsigned int size = celix_arrayList_size(matchingRegistrations);
for (i = 0; i < size; i += 1) {
- service_registration_pt reg = arrayList_get(matchingRegistrations, i);
+ service_registration_pt reg = celix_arrayList_get(matchingRegistrations, i);
service_reference_pt reference = NULL;
celix_status_t subStatus = serviceRegistry_getServiceReference(registry, owner, reg, &reference);
if (subStatus == CELIX_SUCCESS) {
- arrayList_add(references, reference);
+ celix_arrayList_add(references, reference);
} else {
status = CELIX_BUNDLE_EXCEPTION;
}
@@ -391,23 +394,18 @@ celix_status_t serviceRegistry_getServiceReferences(service_registry_pt registry
}
}
- if(matchingRegistrations != NULL){
- arrayList_destroy(matchingRegistrations);
- }
-
if (status == CELIX_SUCCESS) {
- *out = references;
+ *out = celix_steal_ptr(references);
} else {
- //TODO: test this branch using malloc mock
- unsigned int size = arrayList_size(references);
- for(unsigned int i = 0; i < size; i++) {
- serviceReference_release(arrayList_get(references, i), NULL);
+ // TODO: test this branch using malloc mock
+ unsigned int size = celix_arrayList_size(references);
+ for (unsigned int i = 0; i < size; i++) {
+ serviceReference_release(celix_arrayList_get(references, i), NULL);
}
- arrayList_destroy(references);
framework_logIfError(registry->framework->logger, status, NULL, "Cannot get service references");
}
- return status;
+ return status;
}
static bool serviceRegistry_tryRemoveServiceReference(service_registry_pt registry, service_reference_pt reference) {
@@ -518,32 +516,30 @@ celix_status_t serviceRegistry_clearReferencesFor(service_registry_pt registry,
return status;
}
+celix_status_t
+serviceRegistry_getServicesInUse(service_registry_pt registry, bundle_pt bundle, celix_array_list_t** out) {
+ celix_array_list_t* result = celix_arrayList_create();
-celix_status_t serviceRegistry_getServicesInUse(service_registry_pt registry, bundle_pt bundle, array_list_pt *out) {
-
- array_list_pt result = NULL;
- arrayList_create(&result);
-
- //LOCK
+ // LOCK
celixThreadRwlock_readLock(®istry->lock);
hash_map_pt refsMap = hashMap_get(registry->serviceReferences, bundle);
- if(refsMap) {
+ if (refsMap) {
hash_map_iterator_pt iter = hashMapIterator_create(refsMap);
while (hashMapIterator_hasNext(iter)) {
service_reference_pt ref = hashMapIterator_nextValue(iter);
- arrayList_add(result, ref);
+ celix_arrayList_add(result, ref);
}
hashMapIterator_destroy(iter);
}
- //UNLOCK
+ // UNLOCK
celixThreadRwlock_unlock(®istry->lock);
*out = result;
- return CELIX_SUCCESS;
+ return CELIX_SUCCESS;
}
static celix_status_t serviceRegistry_addHooks(service_registry_pt registry, const char* serviceName, const void* serviceObject, service_registration_pt registration) {
@@ -563,7 +559,7 @@ static celix_status_t serviceRegistry_addHooks(service_registry_pt registry, con
long svcId = serviceRegistration_getServiceId(registration);
entry = celix_createHookEntry(svcId, (celix_listener_hook_service_t*)serviceObject);
celix_increaseCountHook(entry);
- arrayList_add(registry->listenerHooks, entry);
+ celix_arrayList_add(registry->listenerHooks, entry);
for (int i = 0; i < celix_arrayList_size(registry->serviceListeners); ++i) {
celix_service_registry_service_listener_entry_t *listenerEntry = celix_arrayList_get(registry->serviceListeners, i);
@@ -572,7 +568,7 @@ static celix_status_t serviceRegistry_addHooks(service_registry_pt registry, con
}
celixThreadRwlock_unlock(®istry->lock);
- for (int i = 0; i < arrayList_size(listeners); ++i) {
+ for (int i = 0; i < celix_arrayList_size(listeners); ++i) {
celix_service_registry_service_listener_entry_t *listenerEntry = celix_arrayList_get(listeners, i);
bundle_getContext(listenerEntry->bundle, &info.context);
info.filter = celix_filter_getFilterString(listenerEntry->filter);
@@ -619,7 +615,7 @@ static celix_status_t serviceRegistry_removeHook(service_registry_pt registry, s
celixThreadRwlock_unlock(®istry->lock);
if (removedEntry != NULL) {
- for (int i = 0; i < arrayList_size(listeners); ++i) {
+ for (int i = 0; i < celix_arrayList_size(listeners); ++i) {
celix_service_registry_service_listener_entry_t *listenerEntry = celix_arrayList_get(listeners, i);
bundle_getContext(listenerEntry->bundle, &info.context);
info.filter = celix_filter_getFilterString(listenerEntry->filter);
@@ -650,9 +646,9 @@ static void serviceRegistry_callHooksForListenerFilter(service_registry_pt regis
celix_array_list_t *hookRegistrations = celix_arrayList_create();
celixThreadRwlock_readLock(®istry->lock);
- unsigned size = arrayList_size(registry->listenerHooks);
+ unsigned size = celix_arrayList_size(registry->listenerHooks);
for (int i = 0; i < size; ++i) {
- celix_service_registry_listener_hook_entry_t* entry = arrayList_get(registry->listenerHooks, i);
+ celix_service_registry_listener_hook_entry_t* entry = celix_arrayList_get(registry->listenerHooks, i);
if (entry != NULL) {
celix_increaseCountHook(entry); //increate use count to ensure the hook cannot be removed, untill used
celix_arrayList_add(hookRegistrations, entry);
@@ -660,7 +656,7 @@ static void serviceRegistry_callHooksForListenerFilter(service_registry_pt regis
}
celixThreadRwlock_unlock(®istry->lock);
- for (int i = 0; i < arrayList_size(hookRegistrations); ++i) {
+ for (int i = 0; i < celix_arrayList_size(hookRegistrations); ++i) {
celix_service_registry_listener_hook_entry_t* entry = celix_arrayList_get(hookRegistrations, i);
if (removed) {
entry->hook->removed(entry->hook->handle, infos);
@@ -675,18 +671,18 @@ static void serviceRegistry_callHooksForListenerFilter(service_registry_pt regis
size_t serviceRegistry_nrOfHooks(service_registry_pt registry) {
celixThreadRwlock_readLock(®istry->lock);
- unsigned size = arrayList_size(registry->listenerHooks);
+ unsigned size = celix_arrayList_size(registry->listenerHooks);
celixThreadRwlock_unlock(®istry->lock);
return (size_t) size;
}
-static celix_status_t serviceRegistry_getUsingBundles(service_registry_pt registry, service_registration_pt registration, array_list_pt *out) {
+static celix_status_t serviceRegistry_getUsingBundles(service_registry_pt registry, service_registration_pt registration, celix_array_list_t** out) {
celix_status_t status;
- array_list_pt bundles = NULL;
+ celix_array_list_t* bundles = NULL;
hash_map_iterator_pt iter;
- status = arrayList_create(&bundles);
- if (status == CELIX_SUCCESS) {
+ bundles = celix_arrayList_create();
+ if (bundles) {
celixThreadRwlock_readLock(®istry->lock);
iter = hashMapIterator_create(registry->serviceReferences);
while (hashMapIterator_hasNext(iter)) {
@@ -694,18 +690,20 @@ static celix_status_t serviceRegistry_getUsingBundles(service_registry_pt regist
bundle_pt registrationUser = hashMapEntry_getKey(entry);
hash_map_pt regMap = hashMapEntry_getValue(entry);
if (hashMap_containsKey(regMap, (void*)registration->serviceId)) {
- arrayList_add(bundles, registrationUser);
+ celix_arrayList_add(bundles, registrationUser);
}
}
hashMapIterator_destroy(iter);
celixThreadRwlock_unlock(®istry->lock);
+ } else {
+ status = CELIX_ENOMEM;
}
if (status == CELIX_SUCCESS) {
*out = bundles;
} else {
if (bundles != NULL) {
- arrayList_destroy(bundles);
+ celix_arrayList_destroy(bundles);
}
}
@@ -830,7 +828,7 @@ char* celix_serviceRegistry_createFilterFor(celix_service_registry_t* registry,
"Error incorrect version range.");
return NULL;
}
- versionRange = versionRange_createLDAPFilter(range, CELIX_FRAMEWORK_SERVICE_VERSION);
+ versionRange = celix_versionRange_createLDAPFilter(range, CELIX_FRAMEWORK_SERVICE_VERSION);
if (versionRange == NULL) {
celix_framework_log(registry->framework->logger, CELIX_LOG_LEVEL_ERROR, __FUNCTION__, __BASE_FILE__, __LINE__,
"Error creating LDAP filter.");
@@ -996,7 +994,7 @@ celix_status_t celix_serviceRegistry_addServiceListener(celix_service_registry_t
//find already registered services
hash_map_iterator_t iter = hashMapIterator_construct(registry->serviceRegistrations);
while (hashMapIterator_hasNext(&iter)) {
- celix_array_list_t *regs = (array_list_pt) hashMapIterator_nextValue(&iter);
+ celix_array_list_t *regs = (celix_array_list_t*) 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;
diff --git a/libs/framework/src/service_tracker.c b/libs/framework/src/service_tracker.c
index 18d07cd4..8d21a9ea 100644
--- a/libs/framework/src/service_tracker.c
+++ b/libs/framework/src/service_tracker.c
@@ -267,15 +267,14 @@ service_reference_pt serviceTracker_getServiceReference(service_tracker_t* track
return result;
}
-array_list_pt serviceTracker_getServiceReferences(service_tracker_t* tracker) {
+celix_array_list_t* serviceTracker_getServiceReferences(service_tracker_t* tracker) {
//TODO deprecated warning -> not locked
- array_list_pt references = NULL;
- arrayList_create(&references);
+ celix_array_list_t* references = celix_arrayList_create();
celixThreadMutex_lock(&tracker->mutex);
for (int i = 0; i < celix_arrayList_size(tracker->trackedServices); i++) {
celix_tracked_entry_t *tracked = celix_arrayList_get(tracker->trackedServices, i);
- arrayList_add(references, tracked->reference);
+ celix_arrayList_add(references, tracked->reference);
}
celixThreadMutex_unlock(&tracker->mutex);
@@ -296,15 +295,14 @@ void *serviceTracker_getService(service_tracker_t* tracker) {
return service;
}
-array_list_pt serviceTracker_getServices(service_tracker_t* tracker) {
+celix_array_list_t* serviceTracker_getServices(service_tracker_t* tracker) {
//TODO deprecated warning -> not locked, also make locked variant
- array_list_pt references = NULL;
- arrayList_create(&references);
+ celix_array_list_t* references = celix_arrayList_create();
celixThreadMutex_lock(&tracker->mutex);
for (int i = 0; i < celix_arrayList_size(tracker->trackedServices); i++) {
celix_tracked_entry_t *tracked = celix_arrayList_get(tracker->trackedServices, i);
- arrayList_add(references, tracked->service);
+ celix_arrayList_add(references, tracked->service);
}
celixThreadMutex_unlock(&tracker->mutex);
@@ -367,7 +365,7 @@ static void serviceTracker_serviceChanged(void *handle, celix_service_event_t *e
size_t serviceTracker_nrOfTrackedServices(service_tracker_t *tracker) {
celixThreadMutex_lock(&tracker->mutex);
- size_t result = (size_t) arrayList_size(tracker->trackedServices);
+ size_t result = (size_t) celix_arrayList_size(tracker->trackedServices);
celixThreadMutex_unlock(&tracker->mutex);
return result;
}
@@ -382,7 +380,7 @@ static celix_status_t serviceTracker_track(service_tracker_t* tracker, service_r
celixThreadMutex_lock(&tracker->mutex);
for (int i = 0; i < celix_arrayList_size(tracker->trackedServices); i++) {
bool equals = false;
- celix_tracked_entry_t *visit = (celix_tracked_entry_t*) arrayList_get(tracker->trackedServices, i);
+ celix_tracked_entry_t *visit = (celix_tracked_entry_t*) celix_arrayList_get(tracker->trackedServices, i);
serviceReference_equals(reference, visit->reference, &equals);
if (equals) {
//NOTE it is possible to get two REGISTERED events, second one can be ignored.
@@ -412,7 +410,7 @@ static celix_status_t serviceTracker_track(service_tracker_t* tracker, service_r
celix_tracked_entry_t *tracked = tracked_create(reference, service, props, bnd); //use count 1
celixThreadMutex_lock(&tracker->mutex);
- arrayList_add(tracker->trackedServices, tracked);
+ celix_arrayList_add(tracker->trackedServices, tracked);
celixThreadCondition_broadcast(&tracker->condTracked);
celixThreadMutex_unlock(&tracker->mutex);
@@ -521,7 +519,7 @@ static celix_status_t serviceTracker_untrack(service_tracker_t* tracker, service
celixThreadMutex_lock(&tracker->mutex);
for (int i = 0; i < celix_arrayList_size(tracker->trackedServices); i++) {
bool equals;
- celix_tracked_entry_t *tracked = (celix_tracked_entry_t*) arrayList_get(tracker->trackedServices, i);
+ celix_tracked_entry_t *tracked = celix_arrayList_get(tracker->trackedServices, i);
serviceReference_equals(reference, tracked->reference, &equals);
if (equals) {
remove = tracked;
@@ -718,7 +716,7 @@ static celix_tracked_entry_t* celix_serviceTracker_findHighestRankingService(ser
//precondition tracker->mutex locked
celix_tracked_entry_t* highest = NULL;
for (int i = 0; i < celix_arrayList_size(tracker->trackedServices); ++i) {
- celix_tracked_entry_t* tracked = (celix_tracked_entry_t *) arrayList_get(tracker->trackedServices, i);
+ celix_tracked_entry_t* tracked = celix_arrayList_get(tracker->trackedServices, i);
if (serviceName == NULL || (serviceName != NULL && tracked->serviceName != NULL &&
celix_utils_stringEquals(tracked->serviceName, serviceName))) {
if (highest == NULL) {
@@ -795,7 +793,7 @@ size_t celix_serviceTracker_useServices(
count = (size_t)size;
celix_tracked_entry_t *entries[size];
for (int i = 0; i < size; i++) {
- celix_tracked_entry_t *tracked = (celix_tracked_entry_t *) arrayList_get(tracker->trackedServices, i);
+ celix_tracked_entry_t *tracked = celix_arrayList_get(tracker->trackedServices, i);
tracked_retain(tracked);
entries[i] = tracked;
}
diff --git a/libs/utils/benchmark/src/StringHashmapBenchmark.cc b/libs/utils/benchmark/src/StringHashmapBenchmark.cc
index 134a77da..4552dd04 100644
--- a/libs/utils/benchmark/src/StringHashmapBenchmark.cc
+++ b/libs/utils/benchmark/src/StringHashmapBenchmark.cc
@@ -18,7 +18,6 @@
*/
#include <benchmark/benchmark.h>
-#include <celix_utils_api.h>
#include <unordered_map>
#include <random>
#include <iostream>
@@ -29,6 +28,7 @@
#include "celix_string_hash_map.h"
#include "celix_hash_map_internal.h"
#include "celix_properties_internal.h"
+#include "utils.h"
class StringHashmapBenchmark {
public:
diff --git a/libs/utils/include_deprecated/array_list.h b/libs/utils/include_deprecated/array_list.h
deleted file mode 100644
index b42a4836..00000000
--- a/libs/utils/include_deprecated/array_list.h
+++ /dev/null
@@ -1,97 +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.
- */
-
-#ifndef ARRAY_LIST_H_
-#define ARRAY_LIST_H_
-
-#include "exports.h"
-#include "celix_errno.h"
-#include "stdbool.h"
-#include "celix_array_list.h"
-
-#include <stdbool.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct celix_array_list *array_list_pt __attribute__((deprecated("array_list is deprecated use celix_array_list instead")));
-typedef struct celix_array_list array_list_t __attribute__((deprecated("array_list is deprecated use celix_array_list instead")));
-
-typedef struct celix_array_list_iterator *array_list_iterator_pt;
-typedef struct celix_array_list_iterator array_list_iterator_t;
-
-typedef celix_status_t (*array_list_element_equals_pt)(const void *, const void *, bool *equals);
-
-CELIX_UTILS_DEPRECATED_EXPORT celix_status_t arrayList_create(celix_array_list_t **list);
-
-CELIX_UTILS_DEPRECATED_EXPORT celix_status_t arrayList_createWithEquals(array_list_element_equals_pt equals, celix_array_list_t **list);
-
-CELIX_UTILS_DEPRECATED_EXPORT void arrayList_destroy(celix_array_list_t *list);
-
-CELIX_UTILS_DEPRECATED_EXPORT void arrayList_trimToSize(celix_array_list_t *list);
-
-CELIX_UTILS_DEPRECATED_EXPORT celix_status_t arrayList_ensureCapacity(celix_array_list_t *list, int capacity);
-
-CELIX_UTILS_DEPRECATED_EXPORT unsigned int arrayList_size(celix_array_list_t *list);
-
-CELIX_UTILS_DEPRECATED_EXPORT bool arrayList_isEmpty(celix_array_list_t *list);
-
-CELIX_UTILS_DEPRECATED_EXPORT bool arrayList_contains(celix_array_list_t *list, void *element);
-
-CELIX_UTILS_DEPRECATED_EXPORT int arrayList_indexOf(celix_array_list_t *list, void *element);
-
-CELIX_UTILS_DEPRECATED_EXPORT int arrayList_lastIndexOf(celix_array_list_t *list, void *element);
-
-CELIX_UTILS_DEPRECATED_EXPORT void *arrayList_get(celix_array_list_t *list, unsigned int index);
-
-CELIX_UTILS_DEPRECATED_EXPORT void *arrayList_set(celix_array_list_t *list, unsigned int index, void *element);
-
-CELIX_UTILS_DEPRECATED_EXPORT bool arrayList_add(celix_array_list_t *list, void *element);
-
-CELIX_UTILS_DEPRECATED_EXPORT int arrayList_addIndex(celix_array_list_t *list, unsigned int index, void *element);
-
-CELIX_UTILS_DEPRECATED_EXPORT bool arrayList_addAll(celix_array_list_t *list, celix_array_list_t *toAdd);
-
-CELIX_UTILS_DEPRECATED_EXPORT void *arrayList_remove(celix_array_list_t *list, unsigned int index);
-
-CELIX_UTILS_DEPRECATED_EXPORT bool arrayList_removeElement(celix_array_list_t *list, void *element);
-
-CELIX_UTILS_DEPRECATED_EXPORT void arrayList_clear(celix_array_list_t *list);
-
-CELIX_UTILS_DEPRECATED_EXPORT celix_array_list_t *arrayList_clone(celix_array_list_t *list);
-
-CELIX_UTILS_DEPRECATED_EXPORT array_list_iterator_pt arrayListIterator_create(celix_array_list_t *list);
-
-CELIX_UTILS_DEPRECATED_EXPORT void arrayListIterator_destroy(array_list_iterator_pt iterator);
-
-CELIX_UTILS_DEPRECATED_EXPORT bool arrayListIterator_hasNext(array_list_iterator_pt iterator);
-
-CELIX_UTILS_DEPRECATED_EXPORT void *arrayListIterator_next(array_list_iterator_pt iterator);
-
-CELIX_UTILS_DEPRECATED_EXPORT bool arrayListIterator_hasPrevious(array_list_iterator_pt iterator);
-
-CELIX_UTILS_DEPRECATED_EXPORT void *arrayListIterator_previous(array_list_iterator_pt iterator);
-
-CELIX_UTILS_DEPRECATED_EXPORT void arrayListIterator_remove(array_list_iterator_pt iterator);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* ARRAY_LIST_H_ */
diff --git a/libs/utils/include_deprecated/celix_utils_api.h b/libs/utils/include_deprecated/celix_utils_api.h
index ef315306..f82e2f66 100644
--- a/libs/utils/include_deprecated/celix_utils_api.h
+++ b/libs/utils/include_deprecated/celix_utils_api.h
@@ -24,13 +24,11 @@
#include "celix_errno.h"
#include "celix_threads.h"
-#include "array_list.h"
+#include "celix_array_list.h"
#include "hash_map.h"
-#include "properties.h"
-#include "utils.h"
+#include "celix_properties.h"
#include "celix_utils.h"
-#include "version.h"
-#include "version_range.h"
+#include "celix_version.h"
#if defined(NO_MEMSTREAM_AVAILABLE)
#include "memstream/open_memstream.h"
diff --git a/libs/utils/src/array_list.c b/libs/utils/src/array_list.c
index f6234827..5b7a16e2 100644
--- a/libs/utils/src/array_list.c
+++ b/libs/utils/src/array_list.c
@@ -28,16 +28,10 @@
#include <stdio.h>
#include <string.h>
-#include "array_list.h"
#include "celix_array_list.h"
#include "array_list_private.h"
#include "celix_build_assert.h"
-static celix_status_t arrayList_elementEquals(const void *a, const void *b, bool *equals) {
- *equals = (a == b);
- return CELIX_SUCCESS;
-}
-
static bool celix_arrayList_defaultEquals(celix_array_list_entry_t a, celix_array_list_entry_t b) {
return memcmp(&a, &b, sizeof(a)) == 0;
}
@@ -45,9 +39,7 @@ static bool celix_arrayList_defaultEquals(celix_array_list_entry_t a, celix_arra
static bool celix_arrayList_equalsForElement(celix_array_list_t *list, celix_array_list_entry_t a, celix_array_list_entry_t b) {
bool equals = false;
if (list != NULL) {
- if (list->equalsDeprecated != NULL) {
- list->equalsDeprecated(a.voidPtrVal, b.voidPtrVal, &equals);
- } else if (list->equals != NULL) {
+ if (list->equals != NULL) {
equals = list->equals(a, b);
}
}
@@ -63,34 +55,7 @@ static void celix_arrayList_callRemovedCallback(celix_array_list_t *list, int in
}
}
-celix_status_t arrayList_create(array_list_pt *list) {
- return arrayList_createWithEquals(arrayList_elementEquals, list);
-}
-
-celix_status_t arrayList_createWithEquals(array_list_element_equals_pt equals, array_list_pt *list) {
- *list = celix_arrayList_create();
- if (*list != NULL) {
- (*list)->equalsDeprecated = equals;
-
- }
- return CELIX_SUCCESS;
-}
-
-void arrayList_destroy(array_list_pt list) {
- celix_arrayList_destroy(list);
-}
-
-void arrayList_trimToSize(array_list_pt list) {
- list->modCount++;
- size_t oldCapacity = list->capacity;
- if (list->size < oldCapacity) {
- celix_array_list_entry_t * newList = realloc(list->elementData, sizeof(celix_array_list_entry_t) * list->size);
- list->capacity = list->size;
- list->elementData = newList;
- }
-}
-
-celix_status_t arrayList_ensureCapacity(array_list_pt list, int capacity) {
+static celix_status_t celix_arrayList_ensureCapacity(celix_array_list_t* list, int capacity) {
celix_status_t status = CELIX_SUCCESS;
celix_array_list_entry_t *newList;
list->modCount++;
@@ -110,265 +75,8 @@ celix_status_t arrayList_ensureCapacity(array_list_pt list, int capacity) {
return status;
}
-unsigned int arrayList_size(array_list_pt list) {
- return (int)list->size;
-}
-
-bool arrayList_isEmpty(array_list_pt list) {
- return list->size == 0;
-}
-
-bool arrayList_contains(array_list_pt list, void * element) {
- int index = arrayList_indexOf(list, element);
- return index >= 0;
-}
-
-int arrayList_indexOf(array_list_pt list, void * element) {
- if (element == NULL) {
- unsigned int i = 0;
- for (i = 0; i < list->size; i++) {
- if (list->elementData[i].voidPtrVal == NULL) {
- return i;
- }
- }
- } else {
- unsigned int i = 0;
- for (i = 0; i < list->size; i++) {
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
- entry.voidPtrVal = element;
- bool equals = celix_arrayList_equalsForElement(list, entry, list->elementData[i]);
- if (equals) {
- return i;
- }
- }
- }
- return -1;
-}
-
-int arrayList_lastIndexOf(array_list_pt list, void * element) {
- if (element == NULL) {
- int i = 0;
- int size = (int)list->size;
- for (i = size - 1; i >= 0; i--) {
- if (list->elementData[i].voidPtrVal == NULL) {
- return (int)i;
- }
- }
- } else {
- int i = 0;
- int size = (int)list->size;
- for (i = size - 1; i >= 0; i--) {
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
- entry.voidPtrVal = element;
- bool equals = celix_arrayList_equalsForElement(list, entry, list->elementData[i]);
- if (equals) {
- return (int)i;
- }
- }
- }
- return -1;
-}
-
-void * arrayList_get(array_list_pt list, unsigned int index) {
- if (index >= list->size) {
- return NULL;
- }
-
- return list->elementData[index].voidPtrVal;
-}
-
-void * arrayList_set(array_list_pt list, unsigned int index, void * element) {
- void * oldElement;
- if (index >= list->size) {
- return NULL;
- }
-
- oldElement = list->elementData[index].voidPtrVal;
- memset(&list->elementData[index], 0, sizeof(celix_array_list_entry_t));
- list->elementData[index].voidPtrVal = element;
- return oldElement;
-}
-
-bool arrayList_add(array_list_pt list, void * element) {
- arrayList_ensureCapacity(list, (int)list->size + 1);
- memset(&list->elementData[list->size], 0, sizeof(celix_array_list_entry_t));
- list->elementData[list->size++].voidPtrVal = element;
- return true;
-}
-
-int arrayList_addIndex(array_list_pt list, unsigned int index, void * element) {
- size_t numMoved;
- if (index > list->size) {
- return -1;
- }
- arrayList_ensureCapacity(list, (int)list->size+1);
- numMoved = list->size - index;
- memmove(list->elementData+(index+1), list->elementData+index, sizeof(celix_array_list_entry_t) * numMoved);
-
- list->elementData[index].voidPtrVal = element;
- list->size++;
- return 0;
-}
-
-void * arrayList_remove(array_list_pt list, unsigned int index) {
- void * oldElement;
- size_t numMoved;
- if (index >= list->size) {
- return NULL;
- }
-
- list->modCount++;
- oldElement = list->elementData[index].voidPtrVal;
- numMoved = list->size - index - 1;
- memmove(list->elementData+index, list->elementData+index+1, sizeof(celix_array_list_entry_t) * numMoved);
- memset(&list->elementData[--list->size], 0, sizeof(celix_array_list_entry_t));
-
- return oldElement;
-}
-
-void arrayList_fastRemove(array_list_pt list, unsigned int index) {
- size_t numMoved;
- list->modCount++;
-
- numMoved = list->size - index - 1;
- memmove(list->elementData+index, list->elementData+index+1, sizeof(celix_array_list_entry_t) * numMoved);
- memset(&list->elementData[--list->size], 0, sizeof(celix_array_list_entry_t));
-}
-
-bool arrayList_removeElement(array_list_pt list, void * element) {
- if (element == NULL) {
- unsigned int i = 0;
- for (i = 0; i < list->size; i++) {
- if (list->elementData[i].voidPtrVal == NULL) {
- arrayList_fastRemove(list, i);
- return true;
- }
- }
- } else {
- unsigned int i = 0;
- for (i = 0; i < list->size; i++) {
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
- entry.voidPtrVal = element;
- bool equals = celix_arrayList_equalsForElement(list, entry, list->elementData[i]);
- if (equals) {
- arrayList_fastRemove(list, i);
- return true;
- }
- }
- }
- return false;
-}
-
-void arrayList_clear(array_list_pt list) {
- celix_arrayList_clear(list);
-}
-
-bool arrayList_addAll(array_list_pt list, array_list_pt toAdd) {
- unsigned int i;
- unsigned int size = arrayList_size(toAdd);
- arrayList_ensureCapacity(list, list->size + size);
-// memcpy(list->elementData+list->size, *toAdd->elementData, size);
-// list->size += size;
- for (i = 0; i < arrayList_size(toAdd); i++) {
- arrayList_add(list, arrayList_get(toAdd, i));
- }
- return size != 0;
-}
-
-array_list_pt arrayList_clone(array_list_pt list) {
- unsigned int i;
- array_list_pt new = NULL;
- arrayList_create(&new);
-// arrayList_ensureCapacity(new, list->size);
-// memcpy(new->elementData, list->elementData, list->size);
-// new->size = list->size;
-
- for (i = 0; i < arrayList_size(list); i++) {
- arrayList_add(new, arrayList_get(list, i));
- }
- new->modCount = 0;
- return new;
-}
-
-array_list_iterator_pt arrayListIterator_create(array_list_pt list) {
- array_list_iterator_pt iterator = (array_list_iterator_pt) malloc(sizeof(*iterator));
-
- iterator->lastReturned = -1;
- iterator->cursor = 0;
- iterator->list = list;
- iterator->expectedModificationCount = list->modCount;
-
- return iterator;
-}
-
-void arrayListIterator_destroy(array_list_iterator_pt iterator) {
- iterator->lastReturned = -1;
- iterator->cursor = 0;
- iterator->expectedModificationCount = 0;
- iterator->list = NULL;
- free(iterator);
-}
-
-bool arrayListIterator_hasNext(array_list_iterator_pt iterator) {
- return iterator->cursor != iterator->list->size;
-}
-
-void * arrayListIterator_next(array_list_iterator_pt iterator) {
- void * next;
- if (iterator->expectedModificationCount != iterator->list->modCount) {
- return NULL;
- }
- next = arrayList_get(iterator->list, iterator->cursor);
- iterator->lastReturned = iterator->cursor++;
- return next;
-}
-
-bool arrayListIterator_hasPrevious(array_list_iterator_pt iterator) {
- return iterator->cursor != 0;
-}
-
-void * arrayListIterator_previous(array_list_iterator_pt iterator) {
- int i;
- void * previous;
- if (iterator->expectedModificationCount != iterator->list->modCount) {
- return NULL;
- }
- i = iterator->cursor - 1;
- previous = arrayList_get(iterator->list, i);
- iterator->lastReturned = iterator->cursor = i;
- return previous;
-}
-
-void arrayListIterator_remove(array_list_iterator_pt iterator) {
- if (iterator->lastReturned == -1) {
- return;
- }
- if (iterator->expectedModificationCount != iterator->list->modCount) {
- return;
- }
- if (arrayList_remove(iterator->list, iterator->lastReturned) != NULL) {
- if (iterator->lastReturned < iterator->cursor) {
- iterator->cursor--;
- }
- iterator->lastReturned = -1;
- iterator->expectedModificationCount = iterator->list->modCount;
- }
-}
-
-
-
-
-/**********************************************************************************************************************
- **********************************************************************************************************************
- * Updated API
- **********************************************************************************************************************
- **********************************************************************************************************************/
-
celix_array_list_t* celix_arrayList_createWithOptions(const celix_array_list_create_options_t* opts) {
- array_list_t *list = calloc(1, sizeof(*list));
+ celix_array_list_t *list = calloc(1, sizeof(*list));
if (list != NULL) {
list->capacity = 10;
list->elementData = malloc(sizeof(celix_array_list_entry_t) * list->capacity);
@@ -416,17 +124,38 @@ void* celix_arrayList_get(const celix_array_list_t *list, int index) {
return arrayList_getEntry(list, index).voidPtrVal;
}
-int celix_arrayList_getInt(const celix_array_list_t *list, int index) { return arrayList_getEntry(list, index).intVal; }
-long int celix_arrayList_getLong(const celix_array_list_t *list, int index) { return arrayList_getEntry(list, index).longVal; }
-unsigned int celix_arrayList_getUInt(const celix_array_list_t *list, int index) { return arrayList_getEntry(list, index).uintVal; }
-unsigned long int celix_arrayList_getULong(const celix_array_list_t *list, int index) { return arrayList_getEntry(list, index).ulongVal; }
-float celix_arrayList_getFloat(const celix_array_list_t *list, int index) { return arrayList_getEntry(list, index).floatVal; }
-double celix_arrayList_getDouble(const celix_array_list_t *list, int index) { return arrayList_getEntry(list, index).doubleVal; }
-bool celix_arrayList_getBool(const celix_array_list_t *list, int index) { return arrayList_getEntry(list, index).boolVal; }
-size_t celix_arrayList_getSize(const celix_array_list_t *list, int index) { return arrayList_getEntry(list, index).sizeVal; }
+int celix_arrayList_getInt(const celix_array_list_t* list, int index) { return arrayList_getEntry(list, index).intVal; }
+
+long int celix_arrayList_getLong(const celix_array_list_t* list, int index) {
+ return arrayList_getEntry(list, index).longVal;
+}
+
+unsigned int celix_arrayList_getUInt(const celix_array_list_t* list, int index) {
+ return arrayList_getEntry(list, index).uintVal;
+}
+
+unsigned long int celix_arrayList_getULong(const celix_array_list_t* list, int index) {
+ return arrayList_getEntry(list, index).ulongVal;
+}
+
+float celix_arrayList_getFloat(const celix_array_list_t* list, int index) {
+ return arrayList_getEntry(list, index).floatVal;
+}
+
+double celix_arrayList_getDouble(const celix_array_list_t* list, int index) {
+ return arrayList_getEntry(list, index).doubleVal;
+}
+
+bool celix_arrayList_getBool(const celix_array_list_t* list, int index) {
+ return arrayList_getEntry(list, index).boolVal;
+}
+
+size_t celix_arrayList_getSize(const celix_array_list_t* list, int index) {
+ return arrayList_getEntry(list, index).sizeVal;
+}
static celix_status_t celix_arrayList_addEntry(celix_array_list_t *list, celix_array_list_entry_t entry) {
- celix_status_t status = arrayList_ensureCapacity(list, (int)list->size + 1);
+ celix_status_t status = celix_arrayList_ensureCapacity(list, (int)list->size + 1);
if (status == CELIX_SUCCESS) {
list->elementData[list->size++] = entry;
}
diff --git a/libs/utils/src/array_list_private.h b/libs/utils/src/array_list_private.h
index 9a761433..1746202d 100644
--- a/libs/utils/src/array_list_private.h
+++ b/libs/utils/src/array_list_private.h
@@ -27,29 +27,15 @@
#ifndef array_list_t_PRIVATE_H_
#define array_list_t_PRIVATE_H_
-#include "array_list.h"
-
struct celix_array_list {
celix_array_list_entry_t* elementData;
size_t size;
size_t capacity;
-
unsigned int modCount;
-
- array_list_element_equals_pt equalsDeprecated;
celix_arrayList_equals_fp equals;
-
void (*simpleRemovedCallback)(void* value);
void* removedCallbackData;
void (*removedCallback)(void* data, celix_array_list_entry_t entry);
};
-struct celix_array_list_iterator {
- array_list_pt list;
- unsigned int cursor;
- int lastReturned;
- unsigned int expectedModificationCount;
-};
-
-
#endif /* array_list_t_PRIVATE_H_ */