void test_arrayList_remove(void) { char * entry = "entry"; char * entry2 = "entry2"; char * entry3 = "entry3"; char * get; char * removed; arrayList_clear(list); arrayList_add(list, entry); arrayList_add(list, entry2); get = arrayList_get(list, 1); CU_ASSERT_EQUAL(entry2, get); // Remove first entry removed = arrayList_remove(list, 0); CU_ASSERT_EQUAL(entry, removed); // Check the new first element get = arrayList_get(list, 0); CU_ASSERT_EQUAL(entry2, get); // Add a new element arrayList_add(list, entry3); get = arrayList_get(list, 1); CU_ASSERT_EQUAL(entry3, get); }
int main() { endpoint_descriptor_writer_pt writer = NULL; endpointDescriptorWriter_create(&writer); array_list_pt list = NULL; arrayList_create(&list); properties_pt props = properties_create(); properties_set(props, "objectClass", "com.acme.Foo"); properties_set(props, "endpoint.service.id", "3"); properties_set(props, "endpoint.id", "abcdefghijklmnopqrstuvwxyz"); properties_set(props, "endpoint.framework.uuid", "2983D849-93B1-4C2C-AC6D-5BCDA93ACB96"); endpoint_description_pt epd = NULL; endpointDescription_create(props, &epd); arrayList_add(list, epd); properties_pt props2 = properties_create(); properties_set(props2, "objectClass", "com.acme.Bar"); properties_set(props, "endpoint.service.id", "4"); properties_set(props, "endpoint.id", "abcdefghijklmnopqrstuvwxyz"); properties_set(props, "endpoint.framework.uuid", "2983D849-93B1-4C2C-AC6D-5BCDA93ACB96"); endpoint_description_pt epd2 = NULL; endpointDescription_create(props2, &epd2); arrayList_add(list, epd2); char *buffer = NULL; endpointDescriptorWriter_writeDocument(writer, list, &buffer); arrayList_destroy(list); endpointDescription_destroy(epd); endpointDescription_destroy(epd2); endpointDescriptorWriter_destroy(writer); printf("%s\n", buffer); }
void test_arrayList_addAll(void) { char * entry = "entry"; char * entry2 = "entry2"; char * entry3 = "entry3"; char * get; array_list_pt toAdd; bool changed; arrayList_clear(list); arrayList_create(&toAdd); arrayList_add(toAdd, entry); arrayList_add(toAdd, entry2); arrayList_add(list, entry3); get = arrayList_get(list, 0); CU_ASSERT_EQUAL(entry3, get); changed = arrayList_addAll(list, toAdd); CU_ASSERT_TRUE(changed); CU_ASSERT_EQUAL(arrayList_size(list), 3); get = arrayList_get(list, 1); CU_ASSERT_EQUAL(entry, get); get = arrayList_get(list, 2); CU_ASSERT_EQUAL(entry2, get); }
void test_arrayList_get(void) { char * entry = "entry"; char * entry2 = "entry2"; char * entry3 = NULL; char * get; arrayList_clear(list); arrayList_add(list, entry); arrayList_add(list, entry2); get = arrayList_get(list, 0); CU_ASSERT_EQUAL(entry, get); get = arrayList_get(list, 1); CU_ASSERT_EQUAL(entry2, get); arrayList_add(list, entry3); get = arrayList_get(list, 2); CU_ASSERT_PTR_NULL(get); get = arrayList_get(list, 42); CU_ASSERT_PTR_NULL(get); }
void test_arrayList_clear(void) { char * entry = "entry"; char * entry2 = "entry2"; arrayList_clear(list); arrayList_add(list, entry); arrayList_add(list, entry2); CU_ASSERT_EQUAL(arrayList_size(list), 2); arrayList_clear(list); CU_ASSERT_EQUAL(arrayList_size(list), 0); }
celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt *out) { celix_status_t status = CELIX_SUCCESS; int i; int size; dm_component_info_pt cmpInfo = NULL; dm_dependency_manager_info_pt info = calloc(1, sizeof(*info)); celixThreadMutex_lock(&manager->mutex); if (info != NULL) { arrayList_create(&info->components); size = arrayList_size(manager->components); for (i = 0; i < size; i += 1) { dm_component_pt cmp = arrayList_get(manager->components, i); cmpInfo = NULL; component_getComponentInfo(cmp, &cmpInfo); arrayList_add(info->components, cmpInfo); } } else { status = CELIX_ENOMEM; } celixThreadMutex_unlock(&manager->mutex); if (status == CELIX_SUCCESS) { *out = info; } return status; }
/* Service's functions implementation */ celix_status_t pubsub_discovery_announcePublisher(void *handle, pubsub_endpoint_pt pubEP) { celix_status_t status = CELIX_SUCCESS; printf("pubsub_discovery_announcePublisher : %s / %s\n", pubEP->topic, pubEP->endpoint); pubsub_discovery_pt pubsub_discovery = (pubsub_discovery_pt) handle; celixThreadMutex_lock(&pubsub_discovery->discoveredPubsMutex); char *pub_key = createScopeTopicKey(pubEP->scope,pubEP->topic); array_list_pt pubEP_list = (array_list_pt)hashMap_get(pubsub_discovery->discoveredPubs,pub_key); if(pubEP_list==NULL){ arrayList_create(&pubEP_list); hashMap_put(pubsub_discovery->discoveredPubs,strdup(pub_key),pubEP_list); } free(pub_key); pubsub_endpoint_pt p = NULL; pubsubEndpoint_clone(pubEP, &p); arrayList_add(pubEP_list,p); status = etcdWriter_addPublisherEndpoint(pubsub_discovery->writer,p,true); celixThreadMutex_unlock(&pubsub_discovery->discoveredPubsMutex); return status; }
celix_status_t serviceRegistry_getRegisteredServices(service_registry_pt registry, bundle_pt bundle, array_list_pt *services) { celix_status_t status = CELIX_SUCCESS; celixThreadMutex_lock(®istry->mutex); array_list_pt regs = (array_list_pt) hashMap_get(registry->serviceRegistrations, bundle); if (regs != NULL) { unsigned int i; arrayList_create(services); for (i = 0; i < arrayList_size(regs); i++) { service_registration_pt reg = arrayList_get(regs, i); if (serviceRegistration_isValid(reg)) { service_reference_pt reference = NULL; status = serviceRegistry_createServiceReference(registry, bundle, reg, &reference); if (status == CELIX_SUCCESS) { arrayList_add(*services, reference); } } } } celixThreadMutex_unlock(®istry->mutex); framework_logIfError(logger, status, NULL, "Cannot get registered services"); return status; }
static void testProxyRemoval(void) { celix_status_t status; bundle_pt bundle = NULL; array_list_pt bundleNames = NULL; array_list_pt proxyBundle = NULL; service_reference_pt ref = NULL; arrayList_create(&bundleNames); arrayList_create(&proxyBundle); arrayList_add(bundleNames, (void*) CALCULATOR_PROXY); status = getSpecifiedBundles(clientContext, bundleNames, proxyBundle); CHECK_EQUAL(CELIX_SUCCESS, status); CHECK_EQUAL(arrayList_size(proxyBundle), arrayList_size(bundleNames)); status = bundleContext_getBundleById(clientContext, (long) arrayList_get(proxyBundle, 0), &bundle); CHECK_EQUAL(CELIX_SUCCESS, status); status = bundle_stop(bundle); CHECK_EQUAL(CELIX_SUCCESS, status); status = bundleContext_getServiceReference(clientContext, (char *) CALCULATOR_SERVICE, &ref); CHECK_EQUAL(CELIX_SUCCESS, status); CHECK(ref == NULL); arrayList_destroy(bundleNames); arrayList_destroy(proxyBundle); }
celix_status_t serviceRegistry_registerServiceInternal(service_registry_pt registry, bundle_pt bundle, char * serviceName, void * serviceObject, properties_pt dictionary, bool isFactory, service_registration_pt *registration) { array_list_pt regs; celixThreadMutex_lock(®istry->mutex); if (isFactory) { *registration = serviceRegistration_createServiceFactory(registry, bundle, serviceName, ++registry->currentServiceId, serviceObject, dictionary); } else { *registration = serviceRegistration_create(registry, bundle, serviceName, ++registry->currentServiceId, serviceObject, dictionary); } serviceRegistry_addHooks(registry, serviceName, serviceObject, *registration); regs = (array_list_pt) hashMap_get(registry->serviceRegistrations, bundle); if (regs == NULL) { regs = NULL; arrayList_create(®s); } arrayList_add(regs, *registration); hashMap_put(registry->serviceRegistrations, bundle, regs); celixThreadMutex_unlock(®istry->mutex); if (registry->serviceChanged != NULL) { // service_event_pt event = (service_event_pt) malloc(sizeof(*event)); // event->type = REGISTERED; // event->reference = (*registration)->reference; registry->serviceChanged(registry->framework, OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED, *registration, NULL); // free(event); // event = NULL; } return CELIX_SUCCESS; }
celix_status_t shell_getCommands(shell_pt shell_ptr, array_list_pt *commands_ptr) { celix_status_t status = CELIX_SUCCESS; hash_map_iterator_pt iter = NULL; if (!shell_ptr || !commands_ptr) { status = CELIX_ILLEGAL_ARGUMENT; } if (status == CELIX_SUCCESS) { iter = hashMapIterator_create(shell_ptr->command_name_map_ptr); if (!iter) { status = CELIX_BUNDLE_EXCEPTION; } } if (status == CELIX_SUCCESS) { arrayList_create(commands_ptr); while (hashMapIterator_hasNext(iter)) { char *name_str = hashMapIterator_nextKey(iter); arrayList_add(*commands_ptr, name_str); } hashMapIterator_destroy(iter); } return status; }
celix_status_t deviceManager_getIdleDevices(device_manager_pt manager, array_list_pt *idleDevices) { celix_status_t status = CELIX_SUCCESS; status = arrayList_create(idleDevices); if (status == CELIX_SUCCESS) { hash_map_iterator_pt iter = hashMapIterator_create(manager->devices); while (hashMapIterator_hasNext(iter)) { celix_status_t substatus = CELIX_SUCCESS; service_reference_pt ref = hashMapIterator_nextKey(iter); const char *bsn = NULL; module_pt module = NULL; bundle_pt bundle = NULL; substatus = serviceReference_getBundle(ref, &bundle); if (substatus == CELIX_SUCCESS) { substatus = bundle_getCurrentModule(bundle, &module); if (substatus == CELIX_SUCCESS) { substatus = module_getSymbolicName(module, &bsn); if (substatus == CELIX_SUCCESS) { logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Check idle device: %s", bsn); array_list_pt bundles = NULL; substatus = serviceReference_getUsingBundles(ref, &bundles); if (substatus == CELIX_SUCCESS) { bool inUse = false; int i; for (i = 0; i < arrayList_size(bundles); i++) { bundle_pt bundle = arrayList_get(bundles, i); bool isDriver; celix_status_t sstatus = deviceManager_isDriverBundle(manager, bundle, &isDriver); if (sstatus == CELIX_SUCCESS) { if (isDriver) { const char *bsn = NULL; module_pt module = NULL; bundle_getCurrentModule(bundle, &module); module_getSymbolicName(module, &bsn); logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Not idle, used by driver: %s", bsn); inUse = true; break; } } } if (!inUse) { arrayList_add(*idleDevices, ref); } } if(bundles!=NULL){ arrayList_destroy(bundles); } } } } } hashMapIterator_destroy(iter); } return status; }
celix_status_t serviceRegistry_getServiceReferencesForRegistration(service_registry_pt registry, service_registration_pt registration, array_list_pt *references) { celix_status_t status = CELIX_SUCCESS; hash_map_values_pt referenceValues = NULL; hash_map_iterator_pt iterator = NULL; arrayList_create(references); celixThreadMutex_lock(®istry->referencesMapMutex); referenceValues = hashMapValues_create(registry->serviceReferences); iterator = hashMapValues_iterator(referenceValues); while (hashMapIterator_hasNext(iterator)) { array_list_pt refs = (array_list_pt) hashMapIterator_nextValue(iterator); unsigned int refIdx; for (refIdx = 0; (refs != NULL) && refIdx < arrayList_size(refs); refIdx++) { service_registration_pt reg = NULL; service_reference_pt reference = (service_reference_pt) arrayList_get(refs, refIdx); bool valid = false; serviceRefernce_isValid(reference, &valid); if (valid) { serviceReference_getServiceRegistration(reference, ®); if (reg == registration) { arrayList_add(*references, reference); } } } } hashMapIterator_destroy(iterator); hashMapValues_destroy(referenceValues); celixThreadMutex_unlock(®istry->referencesMapMutex); return status; }
array_list_pt serviceRegistry_getUsingBundles(service_registry_pt registry, service_reference_pt reference) { array_list_pt bundles = NULL; hash_map_iterator_pt iter; arrayList_create(&bundles); celixThreadMutex_lock(®istry->mutex); iter = hashMapIterator_create(registry->inUseMap); while (hashMapIterator_hasNext(iter)) { hash_map_entry_pt entry = hashMapIterator_nextEntry(iter); bundle_pt bundle = hashMapEntry_getKey(entry); array_list_pt usages = hashMapEntry_getValue(entry); unsigned int i; for (i = 0; i < arrayList_size(usages); i++) { usage_count_pt usage = arrayList_get(usages, i); bool equals = false; serviceReference_equals(usage->reference, reference, &equals); if (equals) { arrayList_add(bundles, bundle); } } } hashMapIterator_destroy(iter); celixThreadMutex_unlock(®istry->mutex); return bundles; }
celix_status_t deploymentAdmin_readVersions(deployment_admin_pt admin, array_list_pt *versions) { celix_status_t status = CELIX_SUCCESS; arrayList_create(versions); CURL *curl; CURLcode res; curl = curl_easy_init(); struct MemoryStruct chunk; chunk.memory = calloc(1, sizeof(char)); chunk.size = 0; if (curl) { curl_easy_setopt(curl, CURLOPT_URL, admin->pollUrl); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, deploymentAdmin_parseVersions); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &chunk); curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); res = curl_easy_perform(curl); if (res != CURLE_OK) { status = CELIX_BUNDLE_EXCEPTION; } /* always cleanup */ curl_easy_cleanup(curl); char *last; char *token = apr_strtok(chunk.memory, "\n", &last); while (token != NULL) { arrayList_add(*versions, apr_pstrdup(admin->pool, token)); token = apr_strtok(NULL, "\n", &last); } } return status; }
static celix_status_t getPermutations(array_list_pt bundleIds, int from, int to, array_list_pt permutations) { celix_status_t status = CELIX_SUCCESS; int i = 0; if (from == to) { long* permutation = (long*) calloc(to + 1, sizeof(*permutation)); if (!permutation) { status = CELIX_ENOMEM; } else { for (; i <= to; i++) { permutation[i] = (long) arrayList_get(bundleIds, i); } arrayList_add(permutations, permutation); } } else { for (i = from; i <= to; i++) { long fromOrg = (long) arrayList_get(bundleIds, from); long iOrg = (long) arrayList_get(bundleIds, i); arrayList_set(bundleIds, from, (void*) iOrg); arrayList_set(bundleIds, i, (void*) fromOrg); status = getPermutations(bundleIds, from + 1, to, permutations); arrayList_set(bundleIds, from, (void*) fromOrg); arrayList_set(bundleIds, i, (void*) iOrg); } } return status; }
static void testExport(void) { celix_status_t status; array_list_pt bundleNames = NULL; array_list_pt bundlePermutations = NULL; array_list_pt rsaBundles = NULL; unsigned int i, size; arrayList_create(&bundleNames); arrayList_create(&bundlePermutations); arrayList_create(&rsaBundles); arrayList_add(bundleNames, (void*) DISCOVERY_CFG_NAME); arrayList_add(bundleNames, (void*) RSA_HTTP_NAME); arrayList_add(bundleNames, (void*) TOPOLOGY_MANAGER_NAME); status = getSpecifiedBundles(serverContext, bundleNames, rsaBundles); CHECK_EQUAL(CELIX_SUCCESS, status); CHECK_EQUAL(arrayList_size(rsaBundles), arrayList_size(bundleNames)); status = getPermutations(rsaBundles, 0, arrayList_size(rsaBundles) - 1, bundlePermutations); CHECK_EQUAL(CELIX_SUCCESS, status); size = arrayList_size(bundlePermutations); for (i = 0; i < size; ++i) { long* singlePermutation = (long*) arrayList_get(bundlePermutations, i); status = stopStartPermutation(serverContext, singlePermutation, arrayList_size(rsaBundles)); CHECK_EQUAL(CELIX_SUCCESS, status); /* we need to sleep here for a bit to ensure * that the client has flushed the old discovery * values */ sleep(2); // check whether calc service is available test1(); free(singlePermutation); } arrayList_destroy(bundlePermutations); arrayList_destroy(bundleNames); arrayList_destroy(rsaBundles); }
static celix_status_t getSpecifiedBundles(bundle_context_pt context, array_list_pt bundleNames, array_list_pt retrievedBundles) { celix_status_t status; array_list_pt bundles = NULL; status = bundleContext_getBundles(context, &bundles); if (status == CELIX_SUCCESS) { unsigned int size = arrayList_size(bundles); unsigned int i; for (i = 0; i < size; i++) { module_pt module = NULL; const char *name = NULL; bundle_pt bundle = (bundle_pt) arrayList_get(bundles, i); status = bundle_getCurrentModule(bundle, &module); if (status == CELIX_SUCCESS) { status = module_getSymbolicName(module, &name); } if (status == CELIX_SUCCESS) { printf("FOUND %s\n", name); array_list_iterator_pt iter = arrayListIterator_create(bundleNames); while(arrayListIterator_hasNext(iter)) { char* bundleName = (char*) arrayListIterator_next(iter); if ((strcmp(name, bundleName) == 0)) { bundle_archive_pt bundleArchive = NULL; long bundleId = -1; status = bundle_getArchive(bundle, &bundleArchive); if (status == CELIX_SUCCESS) { status = bundleArchive_getId(bundleArchive, &bundleId); } if (status == CELIX_SUCCESS) { arrayList_add(retrievedBundles, (void*) bundleId); break; } } } arrayListIterator_destroy(iter); } } arrayList_destroy(bundles); } return status; }
int sampleQueue_putAll(sample_queue_type *sampleQueue, struct sample *samples, uint32_t size, uint32_t *samplesTaken) { celix_status_t status = CELIX_SUCCESS; uint32_t i = 0; uint32_t samples_added = 0; pthread_mutex_lock(&sampleQueue->lock); if (sampleQueue->queue != NULL) { msg(3, "SAMPLE_QUEUE: Adding a burst of %u samples\n", size); for (; (i < size) && ((MAX_QUEUE_SIZE == 0) || (arrayList_size(sampleQueue->queue) < MAX_QUEUE_SIZE)); i++) { struct sample* s = calloc(1, sizeof(struct sample)); if (s != NULL) { memcpy(s, &samples[i], sizeof(struct sample)); if (arrayList_add(sampleQueue->queue, s)) { msg(3, "\tSAMPLE_QUEUE: Added sample {%llu | %f | %f } to queue\n", s->time, s->value1, s->value2); samples_added++; sampleQueue->currentQueueSize += 1; pthread_cond_signal(&sampleQueue->listEmpty); } else { free(s); } } else { status = CELIX_ENOMEM; break; } } msg(3, "SAMPLE_QUEUE: End burst\n"); *samplesTaken = samples_added; sampleQueue->putCnt += samples_added; if (*samplesTaken != size) { msg(2, "SAMPLE_QUEUE: Could not add all the requested samples (requested:%u, added%u)\n", size, *samplesTaken); if (status == CELIX_SUCCESS) //Don't mask the ENOMEM status = CELIX_BUNDLE_EXCEPTION; } } else { msg(0, "SAMPLE_QUEUE: putAll denied because service is removed"); status = CELIX_ILLEGAL_STATE; } pthread_mutex_unlock(&sampleQueue->lock); return (int) status; }
celix_status_t dependencyManager_add(dm_dependency_manager_pt manager, dm_component_pt component) { celix_status_t status; arrayList_add(manager->components, component); status = component_start(component); return status; }
celix_status_t pubsub_topicSubscriptionAddDisconnectPublisherToPendingList(topic_subscription_pt ts, char* pubURL) { celix_status_t status = CELIX_SUCCESS; char *url = strdup(pubURL); celixThreadMutex_lock(&ts->pendingDisconnections_lock); arrayList_add(ts->pendingDisconnections, url); celixThreadMutex_unlock(&ts->pendingDisconnections_lock); return status; }
celix_status_t wiringTopologyManager_waRemoved(void * handle, service_reference_pt reference, void * service) { celix_status_t status = CELIX_SUCCESS; wiring_topology_manager_pt manager = handle; wiring_admin_service_pt wiringAdminService = (wiring_admin_service_pt) service; /* check whether one of the exported Wires can be exported here via the newly available wiringAdmin*/ celixThreadMutex_lock(&manager->exportedWiringEndpointsLock); hash_map_iterator_pt iter = hashMapIterator_create(manager->exportedWiringEndpoints); while (hashMapIterator_hasNext(iter)) { hash_map_entry_pt entry = hashMapIterator_nextEntry(iter); hash_map_pt wiringAdminMap = hashMapEntry_getValue(entry); if (hashMap_containsKey(wiringAdminMap, wiringAdminService)) { wiring_endpoint_description_pt wEndpoint = (wiring_endpoint_description_pt) hashMap_remove(wiringAdminMap, wiringAdminService); status = wiringTopologyManager_notifyListenersWiringEndpointRemoved(manager, wEndpoint); if (status == CELIX_SUCCESS) { status = wiringAdminService->removeExportedWiringEndpoint(wiringAdminService->admin, wEndpoint); } else { printf("WTM: failed while removing WiringAdmin.\n"); } } } hashMapIterator_destroy(iter); celixThreadMutex_unlock(&manager->exportedWiringEndpointsLock); /* Check if the added WA can match one of the imported WiringEndpoints */ celixThreadMutex_lock(&manager->importedWiringEndpointsLock); iter = hashMapIterator_create(manager->importedWiringEndpoints); while (hashMapIterator_hasNext(iter)) { hash_map_entry_pt entry = hashMapIterator_nextEntry(iter); wiring_endpoint_description_pt importedWiringEndpointDesc = hashMapEntry_getKey(entry); array_list_pt wiringAdminList = hashMapEntry_getValue(entry); if (arrayList_contains(wiringAdminList, wiringAdminService)) { status = wiringAdminService->removeImportedWiringEndpoint(wiringAdminService->admin, importedWiringEndpointDesc); arrayList_removeElement(wiringAdminList, wiringAdminService); } if (status == CELIX_SUCCESS) { arrayList_add(wiringAdminList, wiringAdminService); } } hashMapIterator_destroy(iter); celixThreadMutex_unlock(&manager->importedWiringEndpointsLock); celixThreadMutex_lock(&manager->waListLock); arrayList_removeElement(manager->waList, wiringAdminService); celixThreadMutex_unlock(&manager->waListLock); printf("WTM: Removed WA\n"); return status; }
void test_arrayList_indexOf(void) { char * entry = "entry"; char * entry2 = "entry2"; arrayList_clear(list); arrayList_add(list, entry); arrayList_add(list, entry2); arrayList_add(list, entry2); arrayList_add(list, entry2); arrayList_add(list, entry2); CU_ASSERT_EQUAL(arrayList_indexOf(list, entry), 0); CU_ASSERT_EQUAL(arrayList_indexOf(list, entry2), 1); CU_ASSERT_EQUAL(arrayList_lastIndexOf(list, entry), 0); CU_ASSERT_EQUAL(arrayList_lastIndexOf(list, entry2), 4); }
celix_status_t discovery_endpointAdded(void *handle, endpoint_description_pt endpoint, char *matchedFilter) { celix_status_t status = CELIX_SUCCESS; struct disc_mock_activator *act = handle; printf("%s\n", __func__); arrayList_add(act->endpointList, endpoint); return status; }
celix_status_t deploymentAdmin_startDeploymentPackageCustomizerBundles(deployment_admin_pt admin, deployment_package_pt source, deployment_package_pt target) { celix_status_t status = CELIX_SUCCESS; array_list_pt bundles = NULL; array_list_pt sourceInfos = NULL; arrayList_create(&bundles); deploymentPackage_getBundleInfos(source, &sourceInfos); int i; for (i = 0; i < arrayList_size(sourceInfos); i++) { bundle_info_pt sourceInfo = arrayList_get(sourceInfos, i); if (sourceInfo->customizer) { bundle_pt bundle = NULL; deploymentPackage_getBundle(source, sourceInfo->symbolicName, &bundle); if (bundle != NULL) { arrayList_add(bundles, bundle); } } } if (target != NULL) { array_list_pt targetInfos = NULL; deploymentPackage_getBundleInfos(target, &targetInfos); for (i = 0; i < arrayList_size(targetInfos); i++) { bundle_info_pt targetInfo = arrayList_get(targetInfos, i); if (targetInfo->customizer) { bundle_pt bundle = NULL; deploymentPackage_getBundle(target, targetInfo->symbolicName, &bundle); if (bundle != NULL) { arrayList_add(bundles, bundle); } } } } for (i = 0; i < arrayList_size(bundles); i++) { bundle_pt bundle = arrayList_get(bundles, i); bundle_start(bundle); } return status; }
array_list_pt pubsub_getTopicsFromString(char* string){ array_list_pt topic_list = NULL; arrayList_create(&topic_list); char* topics = strdup(string); char* topic = strtok(topics,",;|# "); arrayList_add(topic_list,strdup(topic)); while( (topic = strtok(NULL,",;|# ")) !=NULL){ arrayList_add(topic_list,strdup(topic)); } free(topics); return topic_list; }
celix_status_t pubsub_topicSubscriptionAddSubscriber(topic_subscription_pt ts, pubsub_endpoint_pt subEP){ celix_status_t status = CELIX_SUCCESS; celixThreadMutex_lock(&ts->ts_lock); arrayList_add(ts->sub_ep_list,subEP); celixThreadMutex_unlock(&ts->ts_lock); return status; }
void test_arrayList_size(void) { char * entry; char * entry2; char * entry3; arrayList_clear(list); CU_ASSERT_EQUAL(list->size, 0); entry = "entry"; arrayList_add(list, entry); CU_ASSERT_EQUAL(list->size, 1); entry2 = "entry"; arrayList_add(list, entry2); CU_ASSERT_EQUAL(list->size, 2); entry3 = "entry"; arrayList_add(list, entry3); CU_ASSERT_EQUAL(list->size, 3); }
static celix_status_t serviceTracker_track(service_tracker_pt tracker, service_reference_pt reference, service_event_pt event) { celix_status_t status = CELIX_SUCCESS; tracked_pt tracked = NULL; int found = -1; unsigned int i; for (i = 0; i < arrayList_size(tracker->tracked); i++) { bool equals; tracked = (tracked_pt) arrayList_get(tracker->tracked, i); serviceReference_equals(reference, tracked->reference, &equals); if (equals) { found = 0; break; } } if (found) { void * service = NULL; status = serviceTracker_addingService(tracker, reference, &service); if (status == CELIX_SUCCESS) { if (service != NULL) { tracked = (tracked_pt) malloc(sizeof(*tracked)); tracked->reference = reference; tracked->service = service; arrayList_add(tracker->tracked, tracked); if (tracker->customizer != NULL) { void *handle = NULL; added_callback_pt function = NULL; serviceTrackerCustomizer_getHandle(tracker->customizer, &handle); serviceTrackerCustomizer_getAddedFunction(tracker->customizer, &function); if (function != NULL) { function(handle, reference, service); } } } } } else { if (tracker->customizer != NULL) { void *handle = NULL; modified_callback_pt function = NULL; serviceTrackerCustomizer_getHandle(tracker->customizer, &handle); serviceTrackerCustomizer_getModifiedFunction(tracker->customizer, &function); if (function != NULL) { function(handle, reference, tracked->service); } } } framework_logIfError(logger, status, NULL, "Cannot track reference"); return status; }
celix_status_t serviceRegistry_addHooks(service_registry_pt registry, char *serviceName, void *serviceObject, service_registration_pt registration) { celix_status_t status = CELIX_SUCCESS; if (strcmp(OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, serviceName) == 0) { celixThreadMutex_lock(®istry->mutex); arrayList_add(registry->listenerHooks, registration); celixThreadMutex_unlock(®istry->mutex); } return status; }