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 2018/11/26 19:59:26 UTC
[1/4] celix git commit: CELIX-438: Add a dependency manager API with
the celix prefix. Also add a compile options to enable deprecated compiler
warning for the 'old' api.
Repository: celix
Updated Branches:
refs/heads/develop 352610019 -> 2492416e3
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/src/dm_service_dependency.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/dm_service_dependency.c b/libs/framework/src/dm_service_dependency.c
index 65a0593..583916d 100644
--- a/libs/framework/src/dm_service_dependency.c
+++ b/libs/framework/src/dm_service_dependency.c
@@ -41,78 +41,55 @@
static celix_status_t serviceDependency_addedService(void *_ptr, service_reference_pt reference, void *service);
static celix_status_t serviceDependency_modifiedService(void *_ptr, service_reference_pt reference, void *service);
static celix_status_t serviceDependency_removedService(void *_ptr, service_reference_pt reference, void *service);
-static void* serviceDependency_getCallbackHandle(dm_service_dependency_pt dep);
+static void* serviceDependency_getCallbackHandle(celix_dm_service_dependency_t *dep);
-celix_status_t serviceDependency_create(dm_service_dependency_pt *dependency_ptr) {
- celix_status_t status = CELIX_SUCCESS;
-
- *dependency_ptr = calloc(1, sizeof(**dependency_ptr));
- if (!*dependency_ptr) {
- status = CELIX_ENOMEM;
- } else {
- (*dependency_ptr)->component = NULL;
- (*dependency_ptr)->available = false;
- (*dependency_ptr)->instanceBound = false;
- (*dependency_ptr)->required = false;
- (*dependency_ptr)->strategy = DM_SERVICE_DEPENDENCY_DEFAULT_STRATEGY;
-
- (*dependency_ptr)->callbackHandle = NULL;
- (*dependency_ptr)->set = NULL;
- (*dependency_ptr)->add = NULL;
- (*dependency_ptr)->change = NULL;
- (*dependency_ptr)->remove = NULL;
- (*dependency_ptr)->swap = NULL;
-
- (*dependency_ptr)->add_with_ref = NULL;
- (*dependency_ptr)->change_with_ref = NULL;
- (*dependency_ptr)->remove_with_ref = NULL;
- (*dependency_ptr)->swap_with_ref = NULL;
-
- (*dependency_ptr)->autoConfigure = NULL;
-
- (*dependency_ptr)->isStarted = false;
-
- (*dependency_ptr)->addCLanguageFilter = false;
- (*dependency_ptr)->tracked_service = NULL;
- (*dependency_ptr)->tracked_filter_unmodified = NULL;
- (*dependency_ptr)->tracked_filter = NULL;
-
- (*dependency_ptr)->tracker = NULL;
- (*dependency_ptr)->tracker_customizer = NULL;
- }
-
- return status;
+celix_status_t serviceDependency_create(celix_dm_service_dependency_t **dependency_ptr) {
+ celix_dm_service_dependency_t *dep = celix_dmServiceDependency_create();
+ if (dep != NULL) {
+ *dependency_ptr = dep;
+ return CELIX_SUCCESS;
+ } else {
+ return CELIX_BUNDLE_EXCEPTION;
+ }
}
-celix_status_t serviceDependency_destroy(dm_service_dependency_pt *dependency_ptr) {
- celix_status_t status = CELIX_SUCCESS;
+celix_dm_service_dependency_t* celix_dmServiceDependency_create() {
+ celix_dm_service_dependency_t *dep = calloc(1, sizeof(*dep));
+ dep->strategy = DM_SERVICE_DEPENDENCY_DEFAULT_STRATEGY;
+ return dep;
+}
- if (!*dependency_ptr) {
- status = CELIX_ENOMEM;
+celix_status_t serviceDependency_destroy(celix_dm_service_dependency_t **dependency_ptr) {
+ if (dependency_ptr != NULL) {
+ celix_dmServiceDependency_destroy(*dependency_ptr);
}
+ return CELIX_SUCCESS;
+}
- if (status == CELIX_SUCCESS) {
- free((*dependency_ptr)->tracked_service);
- free((*dependency_ptr)->tracked_filter);
- free((*dependency_ptr)->tracked_filter_unmodified);
- free(*dependency_ptr);
- *dependency_ptr = NULL;
+void celix_dmServiceDependency_destroy(celix_dm_service_dependency_t *dep) {
+ if (dep != NULL) {
+ free(dep->tracked_service);
+ free(dep->tracked_filter);
+ free(dep->tracked_filter_unmodified);
+ free(dep);
}
-
- return status;
}
-celix_status_t serviceDependency_lock(dm_service_dependency_pt dependency) {
+celix_status_t serviceDependency_lock(celix_dm_service_dependency_t *dependency) {
celixThreadMutex_lock(&dependency->lock);
return CELIX_SUCCESS;
}
-celix_status_t serviceDependency_unlock(dm_service_dependency_pt dependency) {
+celix_status_t serviceDependency_unlock(celix_dm_service_dependency_t *dependency) {
celixThreadMutex_unlock(&dependency->lock);
return CELIX_SUCCESS;
}
-celix_status_t serviceDependency_setRequired(dm_service_dependency_pt dependency, bool required) {
+celix_status_t serviceDependency_setRequired(celix_dm_service_dependency_t *dependency, bool required) {
+ return celix_dmServiceDependency_setRequired(dependency, required);
+}
+
+celix_status_t celix_dmServiceDependency_setRequired(celix_dm_service_dependency_t *dependency, bool required) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency) {
@@ -126,12 +103,20 @@ celix_status_t serviceDependency_setRequired(dm_service_dependency_pt dependency
return status;
}
-celix_status_t serviceDependency_setAddCLanguageFilter(dm_service_dependency_pt dependency, bool addCLangFilter) {
+celix_status_t serviceDependency_setAddCLanguageFilter(celix_dm_service_dependency_t *dependency, bool addCLangFilter) {
+ return celix_dmServiceDependency_setAddCLanguageFilter(dependency, addCLangFilter);
+}
+
+celix_status_t celix_dmServiceDependency_setAddCLanguageFilter(celix_dm_service_dependency_t *dependency, bool addCLangFilter) {
dependency->addCLanguageFilter = addCLangFilter;
return CELIX_SUCCESS;
}
-celix_status_t serviceDependency_setStrategy(dm_service_dependency_pt dependency, dm_service_dependency_strategy_t strategy) {
+celix_status_t serviceDependency_setStrategy(celix_dm_service_dependency_t *dependency, dm_service_dependency_strategy_t strategy) {
+ return celix_dmServiceDependency_setStrategy(dependency, strategy);
+}
+
+celix_status_t celix_dmServiceDependency_setStrategy(celix_dm_service_dependency_t *dependency, dm_service_dependency_strategy_t strategy) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency) {
@@ -143,20 +128,23 @@ celix_status_t serviceDependency_setStrategy(dm_service_dependency_pt dependency
return status;
}
-celix_status_t serviceDependency_getStrategy(dm_service_dependency_pt dependency, dm_service_dependency_strategy_t* strategy) {
- celix_status_t status = CELIX_SUCCESS;
-
- if (!dependency) {
- status = CELIX_ILLEGAL_ARGUMENT;
- } else {
- *strategy = dependency->strategy;
+celix_status_t serviceDependency_getStrategy(celix_dm_service_dependency_t *dependency, dm_service_dependency_strategy_t* strategy) {
+ celix_dm_service_dependency_strategy_t str = celix_dmServiceDependency_getStrategy(dependency);
+ if (strategy != NULL) {
+ *strategy = str;
}
+ return CELIX_SUCCESS;
+}
- return status;
+celix_dm_service_dependency_strategy_t celix_dmServiceDependency_getStrategy(celix_dm_service_dependency_t *dependency) {
+ return dependency->strategy;
+}
+celix_status_t serviceDependency_setService(celix_dm_service_dependency_t *dependency, const char* serviceName, const char* serviceVersionRange, const char* filter) {
+ return celix_dmServiceDependency_setService(dependency, serviceName, serviceVersionRange, filter);
}
-celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency, const char* serviceName, const char* serviceVersionRange, const char* filter) {
+celix_status_t celix_dmServiceDependency_setService(celix_dm_service_dependency_t *dependency, const char* serviceName, const char* serviceVersionRange, const char* filter) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency || !serviceName) {
status = CELIX_ILLEGAL_ARGUMENT;
@@ -282,13 +270,19 @@ celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency,
return status;
}
-
-celix_status_t serviceDependency_getFilter(dm_service_dependency_pt dependency, const char** filter) {
- *filter = (const char*)dependency->tracked_filter;
+celix_status_t serviceDependency_getFilter(celix_dm_service_dependency_t *dependency, const char** filter) {
+ const char *f = celix_dmServiceDependency_getFilter(dependency);
+ if (filter != NULL) {
+ *filter = f;
+ }
return CELIX_SUCCESS;
}
-celix_status_t serviceDependency_setCallbacks(dm_service_dependency_pt dependency, service_set_fpt set, service_add_fpt add, service_change_fpt change, service_remove_fpt remove, service_swap_fpt swap) {
+const char* celix_dmServiceDependency_getFilter(celix_dm_service_dependency_t *dependency) {
+ return (const char*)dependency->tracked_filter;
+}
+
+celix_status_t serviceDependency_setCallbacks(celix_dm_service_dependency_t *dependency, service_set_fpt set, service_add_fpt add, service_change_fpt change, service_remove_fpt remove, service_swap_fpt swap) {
celix_status_t status = CELIX_SUCCESS;
//printf("Setting callbacks set %p, add %p, change %p, remove %p and swap %p\n", set, add, change, remove, swap);
@@ -298,17 +292,17 @@ celix_status_t serviceDependency_setCallbacks(dm_service_dependency_pt dependenc
}
if (status == CELIX_SUCCESS) {
- dependency->set = set;
- dependency->add = add;
- dependency->change = change;
- dependency->remove = remove;
- dependency->swap = swap;
+ dependency->set = (celix_dm_service_update_fp)set;
+ dependency->add = (celix_dm_service_update_fp)add;
+ dependency->change = (celix_dm_service_update_fp)change;
+ dependency->remove = (celix_dm_service_update_fp)remove;
+ dependency->swap = (celix_dm_service_swap_fp)swap;
}
return status;
}
-celix_status_t serviceDependency_setCallbacksWithServiceReference(dm_service_dependency_pt dependency, service_set_with_ref_fpt set, service_add_with_ref_fpt add, service_change_with_ref_fpt change, service_remove_with_ref_fpt remove,
+celix_status_t serviceDependency_setCallbacksWithServiceReference(celix_dm_service_dependency_t *dependency, service_set_with_ref_fpt set, service_add_with_ref_fpt add, service_change_with_ref_fpt change, service_remove_with_ref_fpt remove,
service_swap_with_ref_fpt swap) {
celix_status_t status = CELIX_SUCCESS;
@@ -327,7 +321,32 @@ celix_status_t serviceDependency_setCallbacksWithServiceReference(dm_service_dep
return status;
}
-celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_pt dependency, celix_thread_mutex_t *service_lock, const void **field) {
+celix_status_t celix_dmServiceDependency_setCallback(celix_dm_service_dependency_t *dependency, celix_dm_service_update_fp set) {
+ dependency->set = set;
+ return CELIX_SUCCESS;
+}
+
+
+celix_status_t celix_dmServiceDependency_setCallbackWithProperties(celix_dm_service_dependency_t *dependency, celix_dm_service_update_with_props_fp set) {
+ dependency->set_with_props = set;
+ return CELIX_SUCCESS;
+}
+
+
+celix_status_t celix_dmServiceDependency_setCallbacksWithOptions(celix_dm_service_dependency_t *dependency, const celix_dm_service_dependency_callback_options_t *opts) {
+ dependency->set = opts->set;
+ dependency->add = opts->add;
+ dependency->remove = opts->remove;
+ dependency->swap = opts->swap;
+
+ dependency->set_with_props = opts->setWithProps;
+ dependency->add_with_props = opts->addWithProps;
+ dependency->rem_with_props = opts->removeWithProps;
+ dependency->swap_with_props = opts->swapWithProps;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t serviceDependency_setAutoConfigure(celix_dm_service_dependency_t *dependency, celix_thread_mutex_t *service_lock, const void **field) {
celix_status_t status = CELIX_SUCCESS;
celix_thread_mutex_t lock;
@@ -346,7 +365,7 @@ celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_pt depen
return status;
}
-celix_status_t serviceDependency_setComponent(dm_service_dependency_pt dependency, dm_component_pt component) {
+celix_status_t serviceDependency_setComponent(celix_dm_service_dependency_t *dependency, celix_dm_component_t *component) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency) {
@@ -360,7 +379,7 @@ celix_status_t serviceDependency_setComponent(dm_service_dependency_pt dependenc
return status;
}
-celix_status_t serviceDependency_start(dm_service_dependency_pt dependency) {
+celix_status_t serviceDependency_start(celix_dm_service_dependency_t *dependency) {
celix_status_t status = CELIX_SUCCESS;
bundle_context_pt context = NULL;
@@ -396,7 +415,7 @@ celix_status_t serviceDependency_start(dm_service_dependency_pt dependency) {
return status;
}
-celix_status_t serviceDependency_stop(dm_service_dependency_pt dependency) {
+celix_status_t serviceDependency_stop(celix_dm_service_dependency_t *dependency) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency) {
@@ -418,7 +437,7 @@ celix_status_t serviceDependency_stop(dm_service_dependency_pt dependency) {
return status;
}
-celix_status_t serviceDependency_setInstanceBound(dm_service_dependency_pt dependency, bool instanceBound) {
+celix_status_t serviceDependency_setInstanceBound(celix_dm_service_dependency_t *dependency, bool instanceBound) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency) {
@@ -432,7 +451,7 @@ celix_status_t serviceDependency_setInstanceBound(dm_service_dependency_pt depen
return status;
}
-celix_status_t serviceDependency_setAvailable(dm_service_dependency_pt dependency, bool available) {
+celix_status_t serviceDependency_setAvailable(celix_dm_service_dependency_t *dependency, bool available) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency) {
@@ -446,7 +465,7 @@ celix_status_t serviceDependency_setAvailable(dm_service_dependency_pt dependenc
return status;
}
-celix_status_t serviceDependency_invokeSet(dm_service_dependency_pt dependency, dm_event_pt event) {
+celix_status_t serviceDependency_invokeSet(celix_dm_service_dependency_t *dependency, dm_event_pt event) {
celix_status_t status = CELIX_SUCCESS;
assert(dependency->isStarted == true);
array_list_pt serviceReferences = NULL;
@@ -501,6 +520,15 @@ celix_status_t serviceDependency_invokeSet(dm_service_dependency_pt dependency,
if (dependency->set_with_ref) {
dependency->set_with_ref(serviceDependency_getCallbackHandle(dependency), curServRef, service);
}
+ if (dependency->set_with_props) {
+ service_registration_pt reg = NULL;
+ celix_properties_t *props = NULL;
+ serviceReference_getServiceRegistration(curServRef, ®);
+ if (reg != NULL) {
+ serviceRegistration_getProperties(reg, &props);
+ }
+ dependency->set_with_props(serviceDependency_getCallbackHandle(dependency), service, props);
+ }
if (curServRef) {
bundleContext_ungetService(event->context, curServRef, NULL);
@@ -510,7 +538,7 @@ celix_status_t serviceDependency_invokeSet(dm_service_dependency_pt dependency,
return status;
}
-celix_status_t serviceDependency_invokeAdd(dm_service_dependency_pt dependency, dm_event_pt event) {
+celix_status_t serviceDependency_invokeAdd(celix_dm_service_dependency_t *dependency, dm_event_pt event) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency) {
@@ -519,17 +547,26 @@ celix_status_t serviceDependency_invokeAdd(dm_service_dependency_pt dependency,
if (status == CELIX_SUCCESS) {
if (dependency->add) {
- dependency->add(serviceDependency_getCallbackHandle(dependency), event->service);
+ dependency->add(serviceDependency_getCallbackHandle(dependency), (void*)event->service);
}
if (dependency->add_with_ref) {
- dependency->add_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service);
+ dependency->add_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, (void*)event->service);
+ }
+ if (dependency->add_with_props) {
+ service_registration_pt reg = NULL;
+ celix_properties_t *props = NULL;
+ serviceReference_getServiceRegistration(event->reference, ®);
+ if (reg != NULL) {
+ serviceRegistration_getProperties(reg, &props);
+ }
+ dependency->add_with_props(serviceDependency_getCallbackHandle(dependency), (void*)event->service, props);
}
}
return status;
}
-celix_status_t serviceDependency_invokeChange(dm_service_dependency_pt dependency, dm_event_pt event) {
+celix_status_t serviceDependency_invokeChange(celix_dm_service_dependency_t *dependency, dm_event_pt event) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency) {
@@ -538,7 +575,7 @@ celix_status_t serviceDependency_invokeChange(dm_service_dependency_pt dependenc
if (status == CELIX_SUCCESS) {
if (dependency->change) {
- dependency->change(serviceDependency_getCallbackHandle(dependency), event->service);
+ dependency->change(serviceDependency_getCallbackHandle(dependency), (void*)event->service);
}
if (dependency->change_with_ref) {
dependency->change_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service);
@@ -548,7 +585,7 @@ celix_status_t serviceDependency_invokeChange(dm_service_dependency_pt dependenc
return status;
}
-celix_status_t serviceDependency_invokeRemove(dm_service_dependency_pt dependency, dm_event_pt event) {
+celix_status_t serviceDependency_invokeRemove(celix_dm_service_dependency_t *dependency, dm_event_pt event) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency) {
@@ -557,17 +594,26 @@ celix_status_t serviceDependency_invokeRemove(dm_service_dependency_pt dependenc
if (status == CELIX_SUCCESS) {
if (dependency->remove) {
- dependency->remove(serviceDependency_getCallbackHandle(dependency), event->service);
+ dependency->remove(serviceDependency_getCallbackHandle(dependency), (void*)event->service);
}
if (dependency->remove_with_ref) {
dependency->remove_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service);
}
+ if (dependency->rem_with_props) {
+ service_registration_pt reg = NULL;
+ celix_properties_t *props = NULL;
+ serviceReference_getServiceRegistration(event->reference, ®);
+ if (reg != NULL) {
+ serviceRegistration_getProperties(reg, &props);
+ }
+ dependency->rem_with_props(serviceDependency_getCallbackHandle(dependency), (void*)event->service, props);
+ }
}
return status;
}
-celix_status_t serviceDependency_invokeSwap(dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent) {
+celix_status_t serviceDependency_invokeSwap(celix_dm_service_dependency_t *dependency, dm_event_pt event, dm_event_pt newEvent) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency) {
@@ -576,17 +622,26 @@ celix_status_t serviceDependency_invokeSwap(dm_service_dependency_pt dependency,
if (status == CELIX_SUCCESS) {
if (dependency->swap) {
- dependency->swap(serviceDependency_getCallbackHandle(dependency), event->service, newEvent->service);
+ dependency->swap(serviceDependency_getCallbackHandle(dependency), (void*)event->service, (void*)newEvent->service);
}
if (dependency->swap_with_ref) {
dependency->swap_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service, newEvent->reference, newEvent->service);
}
+ if (dependency->swap_with_props) {
+ service_registration_pt reg = NULL;
+ celix_properties_t *props = NULL;
+ serviceReference_getServiceRegistration(newEvent->reference, ®);
+ if (reg != NULL) {
+ serviceRegistration_getProperties(reg, &props);
+ }
+ dependency->swap_with_props(serviceDependency_getCallbackHandle(dependency),(void*) event->service, (void*)newEvent->service, props);
+ }
}
return status;
}
-celix_status_t serviceDependency_isAvailable(dm_service_dependency_pt dependency, bool *available) {
+celix_status_t serviceDependency_isAvailable(celix_dm_service_dependency_t *dependency, bool *available) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency) {
@@ -600,7 +655,7 @@ celix_status_t serviceDependency_isAvailable(dm_service_dependency_pt dependency
return status;
}
-celix_status_t serviceDependency_isRequired(dm_service_dependency_pt dependency, bool *required) {
+celix_status_t serviceDependency_isRequired(celix_dm_service_dependency_t *dependency, bool *required) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency) {
@@ -614,7 +669,7 @@ celix_status_t serviceDependency_isRequired(dm_service_dependency_pt dependency,
return status;
}
-celix_status_t serviceDependency_isInstanceBound(dm_service_dependency_pt dependency, bool *instanceBound) {
+celix_status_t serviceDependency_isInstanceBound(celix_dm_service_dependency_t *dependency, bool *instanceBound) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency) {
@@ -628,7 +683,7 @@ celix_status_t serviceDependency_isInstanceBound(dm_service_dependency_pt depend
return status;
}
-celix_status_t serviceDependency_isAutoConfig(dm_service_dependency_pt dependency, bool *autoConfig) {
+celix_status_t serviceDependency_isAutoConfig(celix_dm_service_dependency_t *dependency, bool *autoConfig) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency) {
@@ -642,7 +697,7 @@ celix_status_t serviceDependency_isAutoConfig(dm_service_dependency_pt dependenc
return status;
}
-celix_status_t serviceDependency_getAutoConfig(dm_service_dependency_pt dependency, const void*** autoConfigure) {
+celix_status_t serviceDependency_getAutoConfig(celix_dm_service_dependency_t *dependency, const void*** autoConfigure) {
celix_status_t status = CELIX_SUCCESS;
if (!dependency) {
@@ -656,12 +711,12 @@ celix_status_t serviceDependency_getAutoConfig(dm_service_dependency_pt dependen
return status;
}
-celix_status_t serviceDependency_addedService(void *_ptr, service_reference_pt reference, void *service) {
+static celix_status_t serviceDependency_addedService(void *_ptr, service_reference_pt reference, void *service) {
celix_status_t status = CELIX_SUCCESS;
bundle_context_pt context = NULL;
bundle_pt bundle = NULL;
dm_event_pt event = NULL;
- dm_service_dependency_pt dependency = _ptr;
+ celix_dm_service_dependency_t *dependency = _ptr;
if (!dependency || !reference || !service) {
status = CELIX_ILLEGAL_ARGUMENT;
@@ -686,18 +741,18 @@ celix_status_t serviceDependency_addedService(void *_ptr, service_reference_pt r
}
if (status == CELIX_SUCCESS) {
- component_handleEvent(dependency->component, dependency, event);
+ celix_private_dmComponent_handleEvent(dependency->component, dependency, event);
}
return status;
}
-celix_status_t serviceDependency_modifiedService(void *_ptr, service_reference_pt reference, void *service) {
+static celix_status_t serviceDependency_modifiedService(void *_ptr, service_reference_pt reference, void *service) {
celix_status_t status = CELIX_SUCCESS;
bundle_context_pt context = NULL;
bundle_pt bundle = NULL;
dm_event_pt event = NULL;
- dm_service_dependency_pt dependency = _ptr;
+ celix_dm_service_dependency_t *dependency = _ptr;
if (!dependency || !reference || !service) {
status = CELIX_ILLEGAL_ARGUMENT;
@@ -722,18 +777,18 @@ celix_status_t serviceDependency_modifiedService(void *_ptr, service_reference_p
}
if (status == CELIX_SUCCESS) {
- component_handleEvent(dependency->component, dependency, event);
+ celix_private_dmComponent_handleEvent(dependency->component, dependency, event);
}
return status;
}
-celix_status_t serviceDependency_removedService(void *_ptr, service_reference_pt reference, void *service) {
+static celix_status_t serviceDependency_removedService(void *_ptr, service_reference_pt reference, void *service) {
celix_status_t status = CELIX_SUCCESS;
bundle_context_pt context = NULL;
bundle_pt bundle = NULL;
dm_event_pt event = NULL;
- dm_service_dependency_pt dependency = _ptr;
+ celix_dm_service_dependency_t *dependency = _ptr;
if (!dependency || !reference || !service) {
status = CELIX_ILLEGAL_ARGUMENT;
@@ -758,15 +813,21 @@ celix_status_t serviceDependency_removedService(void *_ptr, service_reference_pt
}
if (status == CELIX_SUCCESS) {
- component_handleEvent(dependency->component, dependency, event);
+ celix_private_dmComponent_handleEvent(dependency->component, dependency, event);
}
return status;
}
-celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_pt dep, dm_service_dependency_info_pt *out) {
- celix_status_t status = CELIX_SUCCESS;
- dm_service_dependency_info_pt info = calloc(1, sizeof(*info));
+celix_status_t serviceDependency_getServiceDependencyInfo(celix_dm_service_dependency_t *dep, dm_service_dependency_info_t **out) {
+ if (out != NULL) {
+ *out = celix_dmServiceDependency_createInfo(dep);
+ }
+ return CELIX_SUCCESS;
+}
+
+dm_service_dependency_info_t* celix_dmServiceDependency_createInfo(celix_dm_service_dependency_t* dep) {
+ celix_dm_service_dependency_info_t *info = calloc(1, sizeof(*info));
if (info != NULL) {
celixThreadMutex_lock(&dep->lock);
info->available = dep->available;
@@ -783,29 +844,31 @@ celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_
arrayList_destroy(refs);
celixThreadMutex_unlock(&dep->lock);
- } else {
- status = CELIX_ENOMEM;
}
+ return info;
+}
- if (status == CELIX_SUCCESS) {
- *out = info;
- }
- return status;
+void dependency_destroyDependencyInfo(dm_service_dependency_info_pt info) {
+ celix_dmServiceDependency_destroyInfo(NULL, info);
}
-void dependency_destroyDependencyInfo(dm_service_dependency_info_pt info) {
+void celix_dmServiceDependency_destroyInfo(celix_dm_service_dependency_t *dep __attribute__((unused)), dm_service_dependency_info_t *info) {
if (info != NULL) {
free(info->filter);
}
free(info);
}
-celix_status_t serviceDependency_setCallbackHandle(dm_service_dependency_pt dependency, void* handle) {
+celix_status_t serviceDependency_setCallbackHandle(celix_dm_service_dependency_t *dependency, void* handle) {
+ return celix_dmServiceDependency_setCallbackHandle(dependency, handle);
+}
+
+celix_status_t celix_dmServiceDependency_setCallbackHandle(celix_dm_service_dependency_t *dependency, void* handle) {
dependency->callbackHandle = handle;
return CELIX_SUCCESS;
}
-static void* serviceDependency_getCallbackHandle(dm_service_dependency_pt dependency) {
+static void* serviceDependency_getCallbackHandle(celix_dm_service_dependency_t *dependency) {
return dependency->callbackHandle == NULL ? component_getImplementation(dependency->component) : dependency->callbackHandle;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/src/dm_service_dependency_impl.h
----------------------------------------------------------------------
diff --git a/libs/framework/src/dm_service_dependency_impl.h b/libs/framework/src/dm_service_dependency_impl.h
index 7026ebf..3b408fb 100644
--- a/libs/framework/src/dm_service_dependency_impl.h
+++ b/libs/framework/src/dm_service_dependency_impl.h
@@ -40,19 +40,19 @@ extern "C" {
#include "dm_service_dependency.h"
#include "dm_component.h"
-struct dm_service_dependency {
- dm_component_pt component;
+struct celix_dm_service_dependency {
+ celix_dm_component_t *component;
bool available;
bool instanceBound;
bool required;
dm_service_dependency_strategy_t strategy;
void* callbackHandle; //This handle can be set to be used instead of the component implementation
- service_set_fpt set;
- service_add_fpt add;
- service_change_fpt change;
- service_remove_fpt remove;
- service_swap_fpt swap;
+ celix_dm_service_update_fp set;
+ celix_dm_service_update_fp add;
+ celix_dm_service_update_fp change;
+ celix_dm_service_update_fp remove;
+ celix_dm_service_swap_fp swap;
service_set_with_ref_fpt set_with_ref;
service_add_with_ref_fpt add_with_ref;
@@ -60,6 +60,11 @@ struct dm_service_dependency {
service_remove_with_ref_fpt remove_with_ref;
service_swap_with_ref_fpt swap_with_ref;
+ celix_dm_service_update_with_props_fp set_with_props;
+ celix_dm_service_update_with_props_fp add_with_props;
+ celix_dm_service_update_with_props_fp rem_with_props;
+ celix_dm_service_swap_with_props_fp swap_with_props;
+
const void **autoConfigure;
celix_thread_mutex_t lock;
@@ -74,28 +79,28 @@ struct dm_service_dependency {
service_tracker_customizer_pt tracker_customizer;
};
-celix_status_t serviceDependency_start(dm_service_dependency_pt dependency);
-celix_status_t serviceDependency_stop(dm_service_dependency_pt dependency);
-celix_status_t serviceDependency_setInstanceBound(dm_service_dependency_pt dependency, bool instanceBound);
-celix_status_t serviceDependency_setAutoConfig(dm_service_dependency_pt dependency, void **autoConfigure);
-celix_status_t serviceDependency_setAvailable(dm_service_dependency_pt dependency, bool available);
-
-celix_status_t serviceDependency_setComponent(dm_service_dependency_pt dependency, dm_component_pt component);
-//celix_status_t serviceDependency_removeComponent(dm_service_dependency_pt dependency, dm_component_pt component);
-
-celix_status_t serviceDependency_invokeSet(dm_service_dependency_pt dependency, dm_event_pt event);
-celix_status_t serviceDependency_invokeAdd(dm_service_dependency_pt dependency, dm_event_pt event);
-celix_status_t serviceDependency_invokeChange(dm_service_dependency_pt dependency, dm_event_pt event);
-celix_status_t serviceDependency_invokeRemove(dm_service_dependency_pt dependency, dm_event_pt event);
-celix_status_t serviceDependency_invokeSwap(dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent);
-celix_status_t serviceDependency_isAvailable(dm_service_dependency_pt dependency, bool *available);
-celix_status_t serviceDependency_isRequired(dm_service_dependency_pt dependency, bool *required);
-celix_status_t serviceDependency_isInstanceBound(dm_service_dependency_pt dependency, bool *instanceBound);
-celix_status_t serviceDependency_isAutoConfig(dm_service_dependency_pt dependency, bool *autoConfig);
-
-celix_status_t serviceDependency_getAutoConfig(dm_service_dependency_pt dependency, const void*** autoConfigure);
-celix_status_t serviceDependency_unlock(dm_service_dependency_pt dependency);
-celix_status_t serviceDependency_lock(dm_service_dependency_pt dependency);
+celix_status_t serviceDependency_start(celix_dm_service_dependency_t *dependency);
+celix_status_t serviceDependency_stop(celix_dm_service_dependency_t *dependency);
+celix_status_t serviceDependency_setInstanceBound(celix_dm_service_dependency_t *dependency, bool instanceBound);
+celix_status_t serviceDependency_setAutoConfig(celix_dm_service_dependency_t *dependency, void **autoConfigure);
+celix_status_t serviceDependency_setAvailable(celix_dm_service_dependency_t *dependency, bool available);
+
+celix_status_t serviceDependency_setComponent(celix_dm_service_dependency_t *dependency, celix_dm_component_t *component);
+//celix_status_t serviceDependency_removeComponent(celix_dm_service_dependency_t *dependency, celix_dm_component_t *component);
+
+celix_status_t serviceDependency_invokeSet(celix_dm_service_dependency_t *dependency, dm_event_pt event);
+celix_status_t serviceDependency_invokeAdd(celix_dm_service_dependency_t *dependency, dm_event_pt event);
+celix_status_t serviceDependency_invokeChange(celix_dm_service_dependency_t *dependency, dm_event_pt event);
+celix_status_t serviceDependency_invokeRemove(celix_dm_service_dependency_t *dependency, dm_event_pt event);
+celix_status_t serviceDependency_invokeSwap(celix_dm_service_dependency_t *dependency, dm_event_pt event, dm_event_pt newEvent);
+celix_status_t serviceDependency_isAvailable(celix_dm_service_dependency_t *dependency, bool *available);
+celix_status_t serviceDependency_isRequired(celix_dm_service_dependency_t *dependency, bool *required);
+celix_status_t serviceDependency_isInstanceBound(celix_dm_service_dependency_t *dependency, bool *instanceBound);
+celix_status_t serviceDependency_isAutoConfig(celix_dm_service_dependency_t *dependency, bool *autoConfig);
+
+celix_status_t serviceDependency_getAutoConfig(celix_dm_service_dependency_t *dependency, const void*** autoConfigure);
+celix_status_t serviceDependency_unlock(celix_dm_service_dependency_t *dependency);
+celix_status_t serviceDependency_lock(celix_dm_service_dependency_t *dependency);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/src/framework.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c
index 4ed4187..de14161 100644
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@ -33,6 +33,7 @@
#include <uuid/uuid.h>
#include <assert.h>
+#include "celix_dependency_manager.h"
#include "framework_private.h"
#include "constants.h"
#include "resolver.h"
@@ -1176,8 +1177,8 @@ celix_status_t fw_stopBundle(framework_pt framework, bundle_pt bundle, bool reco
if (activator->stop != NULL) {
status = CELIX_DO_IF(status, activator->stop(activator->userData, context));
if (status == CELIX_SUCCESS) {
- dm_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(context);
- dependencyManager_removeAllComponents(mng);
+ celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(context);
+ celix_dependencyManager_removeAllComponents(mng);
}
}
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/src/framework_private.h
----------------------------------------------------------------------
diff --git a/libs/framework/src/framework_private.h b/libs/framework/src/framework_private.h
index 10bb26f..edd9c7d 100644
--- a/libs/framework/src/framework_private.h
+++ b/libs/framework/src/framework_private.h
@@ -41,11 +41,11 @@
#include "celix_threads.h"
#include "service_registry.h"
-struct framework {
+struct celix_framework {
#ifdef WITH_APR
apr_pool_t *pool;
#endif
- struct bundle * bundle;
+ celix_bundle_t *bundle;
long bundleId; //the bundle id of the framework (normally 0)
hash_map_pt installRequestMap;
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/src/module.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/module.c b/libs/framework/src/module.c
index 748bb46..8569f44 100644
--- a/libs/framework/src/module.c
+++ b/libs/framework/src/module.c
@@ -39,7 +39,7 @@ struct module {
manifest_pt headerMap;
char * id;
- struct bundle * bundle;
+ celix_bundle_t *bundle;
};
module_pt module_create(manifest_pt headerMap, const char * moduleId, bundle_pt bundle) {
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/utils/include/array_list.h
----------------------------------------------------------------------
diff --git a/libs/utils/include/array_list.h b/libs/utils/include/array_list.h
index bdf9547..9262984 100644
--- a/libs/utils/include/array_list.h
+++ b/libs/utils/include/array_list.h
@@ -31,72 +31,65 @@
#include "exports.h"
#include "celix_errno.h"
#include "stdbool.h"
+#include "celix_array_list.h"
#ifdef __cplusplus
extern "C" {
#endif
-typedef union celix_array_list_entry {
- void *voidPtrVal;
- int intVal;
- long int longVal;
- unsigned int uintVal;
- unsigned long ulongVal;
- double doubleVal;
- float floatVal;
- bool boolVal;
- size_t sizeVal;
-} celix_array_list_entry_t;
+#ifdef ADD_CELIX_DEPRECATED_WARNING
+#define CELIX_DEPRECATED_ATTR __attribute__ ((deprecated))
+#else
+#define CELIX_DEPRECATED_ATTR
+#endif
-typedef struct celix_arrayList *array_list_pt;
-typedef struct celix_arrayList array_list_t;
+typedef struct celix_array_list *array_list_pt CELIX_DEPRECATED_ATTR;
+typedef struct celix_array_list array_list_t CELIX_DEPRECATED_ATTR;
-typedef struct arrayListIterator *array_list_iterator_pt;
-typedef struct arrayListIterator array_list_iterator_t;
+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);
-typedef bool (*celix_arrayList_equals_fp)(celix_array_list_entry_t, celix_array_list_entry_t);
-
-UTILS_EXPORT celix_status_t arrayList_create(array_list_pt *list);
+UTILS_EXPORT celix_status_t arrayList_create(celix_array_list_t **list);
-UTILS_EXPORT celix_status_t arrayList_createWithEquals(array_list_element_equals_pt equals, array_list_pt *list);
+UTILS_EXPORT celix_status_t arrayList_createWithEquals(array_list_element_equals_pt equals, celix_array_list_t **list);
-UTILS_EXPORT void arrayList_destroy(array_list_pt list);
+UTILS_EXPORT void arrayList_destroy(celix_array_list_t *list);
-UTILS_EXPORT void arrayList_trimToSize(array_list_pt list);
+UTILS_EXPORT void arrayList_trimToSize(celix_array_list_t *list);
-UTILS_EXPORT void arrayList_ensureCapacity(array_list_pt list, int capacity);
+UTILS_EXPORT void arrayList_ensureCapacity(celix_array_list_t *list, int capacity);
-UTILS_EXPORT unsigned int arrayList_size(array_list_pt list);
+UTILS_EXPORT unsigned int arrayList_size(celix_array_list_t *list);
-UTILS_EXPORT bool arrayList_isEmpty(array_list_pt list);
+UTILS_EXPORT bool arrayList_isEmpty(celix_array_list_t *list);
-UTILS_EXPORT bool arrayList_contains(array_list_pt list, void *element);
+UTILS_EXPORT bool arrayList_contains(celix_array_list_t *list, void *element);
-UTILS_EXPORT int arrayList_indexOf(array_list_pt list, void *element);
+UTILS_EXPORT int arrayList_indexOf(celix_array_list_t *list, void *element);
-UTILS_EXPORT int arrayList_lastIndexOf(array_list_pt list, void *element);
+UTILS_EXPORT int arrayList_lastIndexOf(celix_array_list_t *list, void *element);
-UTILS_EXPORT void *arrayList_get(array_list_pt list, unsigned int index);
+UTILS_EXPORT void *arrayList_get(celix_array_list_t *list, unsigned int index);
-UTILS_EXPORT void *arrayList_set(array_list_pt list, unsigned int index, void *element);
+UTILS_EXPORT void *arrayList_set(celix_array_list_t *list, unsigned int index, void *element);
-UTILS_EXPORT bool arrayList_add(array_list_pt list, void *element);
+UTILS_EXPORT bool arrayList_add(celix_array_list_t *list, void *element);
-UTILS_EXPORT int arrayList_addIndex(array_list_pt list, unsigned int index, void *element);
+UTILS_EXPORT int arrayList_addIndex(celix_array_list_t *list, unsigned int index, void *element);
-UTILS_EXPORT bool arrayList_addAll(array_list_pt list, array_list_pt toAdd);
+UTILS_EXPORT bool arrayList_addAll(celix_array_list_t *list, celix_array_list_t *toAdd);
-UTILS_EXPORT void *arrayList_remove(array_list_pt list, unsigned int index);
+UTILS_EXPORT void *arrayList_remove(celix_array_list_t *list, unsigned int index);
-UTILS_EXPORT bool arrayList_removeElement(array_list_pt list, void *element);
+UTILS_EXPORT bool arrayList_removeElement(celix_array_list_t *list, void *element);
-UTILS_EXPORT void arrayList_clear(array_list_pt list);
+UTILS_EXPORT void arrayList_clear(celix_array_list_t *list);
-UTILS_EXPORT array_list_pt arrayList_clone(array_list_pt list);
+UTILS_EXPORT celix_array_list_t *arrayList_clone(celix_array_list_t *list);
-UTILS_EXPORT array_list_iterator_pt arrayListIterator_create(array_list_pt list);
+UTILS_EXPORT array_list_iterator_pt arrayListIterator_create(celix_array_list_t *list);
UTILS_EXPORT void arrayListIterator_destroy(array_list_iterator_pt iterator);
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/utils/include/celix_array_list.h
----------------------------------------------------------------------
diff --git a/libs/utils/include/celix_array_list.h b/libs/utils/include/celix_array_list.h
index b4b5742..4bb3e7b 100644
--- a/libs/utils/include/celix_array_list.h
+++ b/libs/utils/include/celix_array_list.h
@@ -17,7 +17,6 @@
*under the License.
*/
-#include "array_list.h"
#include "celixbool.h"
#include "exports.h"
#include "celix_errno.h"
@@ -30,8 +29,22 @@
extern "C" {
#endif
+typedef union celix_array_list_entry {
+ void *voidPtrVal;
+ int intVal;
+ long int longVal;
+ unsigned int uintVal;
+ unsigned long ulongVal;
+ double doubleVal;
+ float floatVal;
+ bool boolVal;
+ size_t sizeVal;
+} celix_array_list_entry_t;
+
+typedef struct celix_array_list celix_array_list_t;
+
+typedef bool (*celix_arrayList_equals_fp)(celix_array_list_entry_t, celix_array_list_entry_t);
-typedef struct celix_arrayList celix_array_list_t;
celix_array_list_t* celix_arrayList_create();
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/utils/include/filter.h
----------------------------------------------------------------------
diff --git a/libs/utils/include/filter.h b/libs/utils/include/filter.h
index 1fc194a..105925c 100644
--- a/libs/utils/include/filter.h
+++ b/libs/utils/include/filter.h
@@ -37,7 +37,7 @@ celix_filter_t* filter_create(const char *filterString);
void filter_destroy(celix_filter_t *filter);
-celix_status_t filter_match(celix_filter_t *filter, properties_t *properties, bool *result);
+celix_status_t filter_match(celix_filter_t *filter, celix_properties_t *properties, bool *result);
celix_status_t filter_match_filter(celix_filter_t *src, filter_t *dest, bool *result);
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/utils/include/properties.h
----------------------------------------------------------------------
diff --git a/libs/utils/include/properties.h b/libs/utils/include/properties.h
index 0efe0c4..f0070bd 100644
--- a/libs/utils/include/properties.h
+++ b/libs/utils/include/properties.h
@@ -29,36 +29,45 @@
#include <stdio.h>
+#include "celix_properties.h"
#include "hash_map.h"
#include "exports.h"
#include "celix_errno.h"
#ifdef __cplusplus
extern "C" {
#endif
-typedef hash_map_pt properties_pt;
-typedef hash_map_t properties_t;
-UTILS_EXPORT properties_pt properties_create(void);
-UTILS_EXPORT void properties_destroy(properties_pt properties);
+#ifdef ADD_CELIX_DEPRECATED_WARNING
+#define CELIX_DEPRECATED_ATTR __attribute__ ((deprecated))
+#else
+#define CELIX_DEPRECATED_ATTR
+#endif
+
+typedef hash_map_pt properties_pt CELIX_DEPRECATED_ATTR;
+typedef hash_map_t properties_t CELIX_DEPRECATED_ATTR;
+
+UTILS_EXPORT celix_properties_t* properties_create(void);
+
+UTILS_EXPORT void properties_destroy(celix_properties_t *properties);
-UTILS_EXPORT properties_pt properties_load(const char *filename);
+UTILS_EXPORT celix_properties_t* properties_load(const char *filename);
-UTILS_EXPORT properties_pt properties_loadWithStream(FILE *stream);
+UTILS_EXPORT celix_properties_t* properties_loadWithStream(FILE *stream);
-UTILS_EXPORT properties_pt properties_loadFromString(const char *input);
+UTILS_EXPORT celix_properties_t* properties_loadFromString(const char *input);
-UTILS_EXPORT void properties_store(properties_pt properties, const char *file, const char *header);
+UTILS_EXPORT void properties_store(celix_properties_t *properties, const char *file, const char *header);
-UTILS_EXPORT const char *properties_get(properties_pt properties, const char *key);
+UTILS_EXPORT const char* properties_get(celix_properties_t *properties, const char *key);
-UTILS_EXPORT const char *properties_getWithDefault(properties_pt properties, const char *key, const char *defaultValue);
+UTILS_EXPORT const char* properties_getWithDefault(celix_properties_t *properties, const char *key, const char *defaultValue);
-UTILS_EXPORT void properties_set(properties_pt properties, const char *key, const char *value);
+UTILS_EXPORT void properties_set(celix_properties_t *properties, const char *key, const char *value);
-UTILS_EXPORT void properties_unset(properties_pt properties, const char *key);
+UTILS_EXPORT void properties_unset(celix_properties_t *properties, const char *key);
-UTILS_EXPORT celix_status_t properties_copy(properties_pt properties, properties_pt *copy);
+UTILS_EXPORT celix_status_t properties_copy(celix_properties_t *properties, celix_properties_t **copy);
#define PROPERTIES_FOR_EACH(props, key) \
for(hash_map_iterator_t iter = hashMapIterator_construct(props); \
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/utils/private/test/filter_test.cpp
----------------------------------------------------------------------
diff --git a/libs/utils/private/test/filter_test.cpp b/libs/utils/private/test/filter_test.cpp
index 0dbe61f..c42c8f1 100644
--- a/libs/utils/private/test/filter_test.cpp
+++ b/libs/utils/private/test/filter_test.cpp
@@ -155,7 +155,7 @@ TEST(filter, create_misc){
get_filter = filter_create(filter_str3);
CHECK(get_filter != NULL);
LONGS_EQUAL(CELIX_FILTER_OPERAND_SUBSTRING, get_filter->operand)
- LONGS_EQUAL(2, arrayList_size((array_list_pt) get_filter->children));
+ LONGS_EQUAL(2, celix_arrayList_size((celix_array_list_t*) get_filter->children));
filter_destroy(get_filter);
//test parsing a attribute of 0 length
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/utils/src/array_list_private.h
----------------------------------------------------------------------
diff --git a/libs/utils/src/array_list_private.h b/libs/utils/src/array_list_private.h
index 5f83605..df37354 100644
--- a/libs/utils/src/array_list_private.h
+++ b/libs/utils/src/array_list_private.h
@@ -29,7 +29,7 @@
#include "array_list.h"
-struct celix_arrayList {
+struct celix_array_list {
celix_array_list_entry_t* elementData;
size_t size;
size_t capacity;
@@ -40,7 +40,7 @@ struct celix_arrayList {
celix_arrayList_equals_fp equals;
};
-struct arrayListIterator {
+struct celix_array_list_iterator {
array_list_pt list;
unsigned int cursor;
int lastReturned;
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/utils/src/filter.c
----------------------------------------------------------------------
diff --git a/libs/utils/src/filter.c b/libs/utils/src/filter.c
index 1218f31..db92d70 100644
--- a/libs/utils/src/filter.c
+++ b/libs/utils/src/filter.c
@@ -36,7 +36,7 @@ static celix_filter_t * filter_parseNot(char* filterString, int* pos);
static celix_filter_t * filter_parseItem(char* filterString, int* pos);
static char * filter_parseAttr(char* filterString, int* pos);
static char * filter_parseValue(char* filterString, int* pos);
-static array_list_pt filter_parseSubstring(char* filterString, int* pos);
+static celix_array_list_t* filter_parseSubstring(char* filterString, int* pos);
static celix_status_t filter_compare(const celix_filter_t* filter, const char *propertyValue, bool *result);
@@ -106,7 +106,6 @@ static celix_filter_t * filter_parseFilterComp(char * filterString, int * pos) {
static celix_filter_t * filter_parseAndOrOr(char * filterString, celix_filter_operand_t andOrOr, int * pos) {
- array_list_pt children = NULL;
filter_skipWhiteSpace(filterString, pos);
bool failure = false;
@@ -115,23 +114,23 @@ static celix_filter_t * filter_parseAndOrOr(char * filterString, celix_filter_op
return NULL;
}
- arrayList_create(&children);
+ celix_array_list_t *children = celix_arrayList_create();
while(filterString[*pos] == '(') {
celix_filter_t * child = filter_parseFilter(filterString, pos);
if(child == NULL) {
failure = true;
break;
}
- arrayList_add(children, child);
+ celix_arrayList_add(children, child);
}
if(failure == true){
int i;
- for (i = 0; i < arrayList_size(children); ++i) {
- celix_filter_t * f = arrayList_get(children, i);
+ for (i = 0; i < celix_arrayList_size(children); ++i) {
+ celix_filter_t * f = celix_arrayList_get(children, i);
filter_destroy(f);
}
- arrayList_destroy(children);
+ celix_arrayList_destroy(children);
children = NULL;
}
@@ -153,9 +152,8 @@ static celix_filter_t * filter_parseNot(char * filterString, int * pos) {
child = filter_parseFilter(filterString, pos);
- array_list_t* children = NULL;
- arrayList_create(&children);
- arrayList_add(children, child);
+ celix_array_list_t* children = celix_arrayList_create();
+ celix_arrayList_add(children, child);
celix_filter_t * filter = (celix_filter_t *) calloc(1, sizeof(*filter));
filter->operand = CELIX_FILTER_OPERAND_NOT;
@@ -223,7 +221,7 @@ static celix_filter_t * filter_parseItem(char * filterString, int * pos) {
}
case '=': {
celix_filter_t * filter = NULL;
- array_list_pt subs;
+ celix_array_list_t *subs;
if (filterString[*pos + 1] == '*') {
int oldPos = *pos;
*pos += 2;
@@ -241,15 +239,15 @@ static celix_filter_t * filter_parseItem(char * filterString, int * pos) {
(*pos)++;
subs = filter_parseSubstring(filterString, pos);
if(subs!=NULL){
- if (arrayList_size(subs) == 1) {
- char * string = (char *) arrayList_get(subs, 0);
+ if (celix_arrayList_size(subs) == 1) {
+ char * string = (char *) celix_arrayList_get(subs, 0);
if (string != NULL) {
filter->operand = CELIX_FILTER_OPERAND_EQUAL;
filter->attribute = attr;
filter->value = string;
- arrayList_clear(subs);
- arrayList_destroy(subs);
+ celix_arrayList_clear(subs);
+ celix_arrayList_destroy(subs);
return filter;
}
@@ -344,12 +342,11 @@ static char * filter_parseValue(char * filterString, int * pos) {
return value;
}
-static array_list_pt filter_parseSubstring(char * filterString, int * pos) {
+static celix_array_list_t* filter_parseSubstring(char * filterString, int * pos) {
char *sub = calloc(strlen(filterString) + 1, sizeof(*sub));
- array_list_pt operands = NULL;
+ celix_array_list_t* operands = celix_arrayList_create();
int keepRunning = 1;
- arrayList_create(&operands);
while (keepRunning) {
char c = filterString[*pos];
@@ -357,7 +354,7 @@ static array_list_pt filter_parseSubstring(char * filterString, int * pos) {
switch (c) {
case ')': {
if (strlen(sub) > 0) {
- arrayList_add(operands, strdup(sub));
+ celix_arrayList_add(operands, strdup(sub));
}
keepRunning = 0;
break;
@@ -374,10 +371,10 @@ static array_list_pt filter_parseSubstring(char * filterString, int * pos) {
}
case '*': {
if (strlen(sub) > 0) {
- arrayList_add(operands, strdup(sub));
+ celix_arrayList_add(operands, strdup(sub));
}
sub[0] = '\0';
- arrayList_add(operands, NULL);
+ celix_arrayList_add(operands, NULL);
(*pos)++;
break;
}
@@ -398,9 +395,9 @@ static array_list_pt filter_parseSubstring(char * filterString, int * pos) {
}
free(sub);
- if (arrayList_size(operands) == 0) {
+ if (celix_arrayList_size(operands) == 0) {
fprintf(stderr, "Filter Error: Missing value.");
- arrayList_destroy(operands);
+ celix_arrayList_destroy(operands);
return NULL;
}
@@ -428,14 +425,14 @@ static celix_status_t filter_compare(const celix_filter_t* filter, const char *p
case CELIX_FILTER_OPERAND_SUBSTRING: {
int pos = 0;
unsigned int i;
- int size = arrayList_size(filter->children);
+ int size = celix_arrayList_size(filter->children);
for (i = 0; i < size; i++) {
- char * substr = (char *) arrayList_get(filter->children, i);
+ char * substr = (char *) celix_arrayList_get(filter->children, i);
if (i + 1 < size) {
if (substr == NULL) {
unsigned int index;
- char * substr2 = (char *) arrayList_get(filter->children, i + 1);
+ char * substr2 = (char *) celix_arrayList_get(filter->children, i + 1);
if (substr2 == NULL) {
continue;
}
@@ -564,22 +561,22 @@ void celix_filter_destroy(celix_filter_t *filter) {
if (filter != NULL) {
if(filter->children != NULL){
if (filter->operand == CELIX_FILTER_OPERAND_SUBSTRING) {
- int size = arrayList_size(filter->children);
+ int size = celix_arrayList_size(filter->children);
int i = 0;
for (i = 0; i < size; i++) {
- char *operand = arrayList_get(filter->children, i);
+ char *operand = celix_arrayList_get(filter->children, i);
free(operand);
}
- arrayList_destroy(filter->children);
+ celix_arrayList_destroy(filter->children);
filter->children = NULL;
} else if (filter->operand == CELIX_FILTER_OPERAND_OR || filter->operand == CELIX_FILTER_OPERAND_AND || filter->operand == CELIX_FILTER_OPERAND_NOT) {
- int size = arrayList_size(filter->children);
+ int size = celix_arrayList_size(filter->children);
int i = 0;
for (i = 0; i < size; i++) {
- celix_filter_t *f = arrayList_get(filter->children, i);
+ celix_filter_t *f = celix_arrayList_get(filter->children, i);
filter_destroy(f);
}
- arrayList_destroy(filter->children);
+ celix_arrayList_destroy(filter->children);
filter->children = NULL;
} else {
fprintf(stderr, "Filter Error: Corrupt filter. children has a value, but not an expected operand");
@@ -599,10 +596,10 @@ bool celix_filter_match(const celix_filter_t *filter, const celix_properties_t*
bool result = false;
switch (filter->operand) {
case CELIX_FILTER_OPERAND_AND: {
- array_list_pt children = filter->children;
+ celix_array_list_t* children = filter->children;
unsigned int i;
- for (i = 0; i < arrayList_size(children); i++) {
- celix_filter_t * sfilter = (celix_filter_t *) arrayList_get(children, i);
+ for (i = 0; i < celix_arrayList_size(children); i++) {
+ celix_filter_t * sfilter = (celix_filter_t *) celix_arrayList_get(children, i);
bool mresult = celix_filter_match(sfilter, properties);
if (!mresult) {
return false;
@@ -611,10 +608,10 @@ bool celix_filter_match(const celix_filter_t *filter, const celix_properties_t*
return true;
}
case CELIX_FILTER_OPERAND_OR: {
- array_list_pt children = filter->children;
+ celix_array_list_t* children = filter->children;
unsigned int i;
- for (i = 0; i < arrayList_size(children); i++) {
- celix_filter_t * sfilter = (celix_filter_t *) arrayList_get(children, i);
+ for (i = 0; i < celix_arrayList_size(children); i++) {
+ celix_filter_t * sfilter = (celix_filter_t *) celix_arrayList_get(children, i);
bool mresult = celix_filter_match(sfilter, properties);
if (mresult) {
return true;
@@ -623,7 +620,7 @@ bool celix_filter_match(const celix_filter_t *filter, const celix_properties_t*
return false;
}
case CELIX_FILTER_OPERAND_NOT: {
- celix_filter_t * sfilter = arrayList_get(filter->children, 0);
+ celix_filter_t * sfilter = celix_arrayList_get(filter->children, 0);
bool mresult = celix_filter_match(sfilter, properties);
return !mresult;
}
@@ -662,9 +659,9 @@ bool celix_filter_matchFilter(const celix_filter_t *filter1, const celix_filter_
int sameCount = 0;
for (i =0; i < sizeSrc; ++i) {
bool same = false;
- celix_filter_t *srcPart = arrayList_get(filter1->children, i);
+ celix_filter_t *srcPart = celix_arrayList_get(filter1->children, i);
for (k = 0; k < sizeDest; ++k) {
- celix_filter_t *destPart = arrayList_get(filter2->children, k);
+ celix_filter_t *destPart = celix_arrayList_get(filter2->children, k);
filter_match_filter(srcPart, destPart, &same);
if (same) {
sameCount += 1;
[4/4] celix git commit: CELIX-438: Add a dependency manager API with
the celix prefix. Also add a compile options to enable deprecated compiler
warning for the 'old' api.
Posted by pn...@apache.org.
CELIX-438: Add a dependency manager API with the celix prefix. Also add a compile options to enable deprecated compiler warning for the 'old' api.
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/2492416e
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/2492416e
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/2492416e
Branch: refs/heads/develop
Commit: 2492416e3d61d97d73e0673722ce6bc7ed39d0b7
Parents: 3526100
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Mon Nov 26 20:57:46 2018 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Mon Nov 26 20:57:46 2018 +0100
----------------------------------------------------------------------
.../log_service/loghelper_include/log_helper.h | 2 +-
.../discovery_common/src/discovery_activator.c | 2 +-
bundles/shell/shell/include/shell.h | 2 +-
bundles/shell/shell/src/dm_shell_list_command.c | 115 +++---
cmake/cmake_celix/DockerPackaging.cmake | 2 +-
examples/celix-examples/CMakeLists.txt | 2 +
.../bar/private/src/bar_activator.c | 13 +-
.../foo1/private/src/foo1_activator.c | 28 +-
.../foo2/private/src/foo2.c | 2 +-
.../foo2/private/src/foo2_activator.c | 30 +-
.../civetweb/src/bundle_activator.c | 2 +-
.../celix-examples/dm_example/CMakeLists.txt | 1 -
.../dm_example/phase1/src/phase1_activator.c | 47 +--
.../dm_example/phase1/src/phase1_cmp.c | 6 +-
.../dm_example/phase1/src/phase1_cmp.h | 2 +-
.../dm_example/phase2a/src/phase2a_activator.c | 59 ++-
.../dm_example/phase2b/src/phase2b_activator.c | 60 ++-
.../dm_example/phase3/src/phase3_activator.c | 62 ++--
.../dm_example/phase3/src/phase3_cmp.c | 2 +-
.../phase1/src/Phase1Activator.cc | 8 +-
.../dm_example_cxx/phase1/src/Phase1Activator.h | 1 -
.../celix-examples/embedding/private/src/main.c | 8 +-
.../hello_world/private/src/activator.c | 8 +-
.../hello_world_test/private/src/activator.c | 8 +-
.../log_service_example/src/activator.c | 8 +-
.../service_hook_example/src/activator.c | 12 +-
.../src/dynamic_provider_example.c | 2 +-
libs/dependency_manager_cxx/src/dm_activator.cc | 18 +-
libs/framework/include/bundle.h | 76 ++--
libs/framework/include/bundle_activator.h | 16 +-
libs/framework/include/bundle_context.h | 54 +--
libs/framework/include/bundle_revision.h | 4 +-
libs/framework/include/celix/dm/Component.h | 20 +-
.../framework/include/celix/dm/Component_Impl.h | 26 +-
.../include/celix/dm/DependencyManager.h | 16 +-
libs/framework/include/celix/dm/DmActivator.h | 14 +-
.../include/celix/dm/ServiceDependency.h | 16 +-
.../include/celix/dm/ServiceDependency_Impl.h | 83 ++---
libs/framework/include/celix_api.h | 3 +-
libs/framework/include/celix_bundle_context.h | 2 +-
.../include/celix_dependency_manager.h | 86 +++++
libs/framework/include/celix_dm_component.h | 154 ++++++++
libs/framework/include/celix_dm_info.h | 76 ++++
.../include/celix_dm_service_dependency.h | 169 +++++++++
libs/framework/include/celix_framework.h | 2 -
.../framework/include/celix_framework_factory.h | 2 +-
libs/framework/include/celix_launcher.h | 14 +-
libs/framework/include/celix_types.h | 50 ++-
libs/framework/include/dm_activator.h | 12 +-
libs/framework/include/dm_component.h | 52 ++-
libs/framework/include/dm_dependency_manager.h | 18 +-
libs/framework/include/dm_info.h | 76 ----
libs/framework/include/dm_service_dependency.h | 36 +-
libs/framework/include/framework.h | 17 +-
libs/framework/include/listener_hook_service.h | 6 +-
libs/framework/include/manifest.h | 4 +-
libs/framework/include/module.h | 12 +-
libs/framework/include/service_reference.h | 6 +-
libs/framework/include/service_registration.h | 4 +-
libs/framework/include/service_registry.h | 40 +-
libs/framework/include/service_tracker.h | 12 +-
.../private/mock/dm_dependency_manager_mock.c | 24 +-
libs/framework/src/bundle_context.c | 13 +-
libs/framework/src/bundle_context_private.h | 8 +-
libs/framework/src/bundle_private.h | 4 +-
libs/framework/src/dm_component_impl.c | 361 +++++++++++--------
libs/framework/src/dm_component_impl.h | 6 +-
libs/framework/src/dm_dependency_manager_impl.c | 204 ++++++++---
libs/framework/src/dm_dependency_manager_impl.h | 21 +-
libs/framework/src/dm_service_dependency.c | 299 +++++++++------
libs/framework/src/dm_service_dependency_impl.h | 63 ++--
libs/framework/src/framework.c | 5 +-
libs/framework/src/framework_private.h | 4 +-
libs/framework/src/module.c | 2 +-
libs/utils/include/array_list.h | 67 ++--
libs/utils/include/celix_array_list.h | 17 +-
libs/utils/include/filter.h | 2 +-
libs/utils/include/properties.h | 35 +-
libs/utils/private/test/filter_test.cpp | 2 +-
libs/utils/src/array_list_private.h | 4 +-
libs/utils/src/filter.c | 79 ++--
81 files changed, 1744 insertions(+), 1166 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/bundles/log_service/loghelper_include/log_helper.h
----------------------------------------------------------------------
diff --git a/bundles/log_service/loghelper_include/log_helper.h b/bundles/log_service/loghelper_include/log_helper.h
index 2ae9d83..5af5d77 100644
--- a/bundles/log_service/loghelper_include/log_helper.h
+++ b/bundles/log_service/loghelper_include/log_helper.h
@@ -27,7 +27,7 @@
typedef struct log_helper log_helper_t;
typedef struct log_helper* log_helper_pt;
-celix_status_t logHelper_create(bundle_context_pt context, log_helper_pt* log_helper);
+celix_status_t logHelper_create(celix_bundle_context_t *context, log_helper_pt* log_helper);
celix_status_t logHelper_start(log_helper_pt loghelper);
celix_status_t logHelper_stop(log_helper_pt loghelper);
celix_status_t logHelper_destroy(log_helper_pt* loghelper);
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/bundles/remote_services/discovery_common/src/discovery_activator.c
----------------------------------------------------------------------
diff --git a/bundles/remote_services/discovery_common/src/discovery_activator.c b/bundles/remote_services/discovery_common/src/discovery_activator.c
index 3267d25..30a40b3 100644
--- a/bundles/remote_services/discovery_common/src/discovery_activator.c
+++ b/bundles/remote_services/discovery_common/src/discovery_activator.c
@@ -62,7 +62,7 @@ celix_status_t bundleActivator_createEPLTracker(struct activator *activator, ser
return status;
}
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+celix_status_t bundleActivator_create(celix_bundle_context_t *context, void **userData) {
celix_status_t status;
struct activator* activator = calloc(1,sizeof(struct activator));
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/bundles/shell/shell/include/shell.h
----------------------------------------------------------------------
diff --git a/bundles/shell/shell/include/shell.h b/bundles/shell/shell/include/shell.h
index c8e7d60..42c2cdb 100644
--- a/bundles/shell/shell/include/shell.h
+++ b/bundles/shell/shell/include/shell.h
@@ -38,7 +38,7 @@ typedef shell_t* shell_pt;
struct shellService {
shell_pt shell;
- celix_status_t (*getCommands)(shell_pt shell_ptr, array_list_pt *commands_ptr);
+ celix_status_t (*getCommands)(shell_pt shell_ptr, celix_array_list_t **commands_ptr);
celix_status_t (*getCommandUsage)(shell_pt shell_ptr, char *command_name_str, char **usage_str);
celix_status_t (*getCommandDescription)(shell_pt shell_ptr, char *command_name_str, char **command_description_str);
celix_status_t (*getCommandReference)(shell_pt shell_ptr, char *command_name_str, service_reference_pt *command_reference_ptr);
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/bundles/shell/shell/src/dm_shell_list_command.c
----------------------------------------------------------------------
diff --git a/bundles/shell/shell/src/dm_shell_list_command.c b/bundles/shell/shell/src/dm_shell_list_command.c
index aeb7afd..192f875 100644
--- a/bundles/shell/shell/src/dm_shell_list_command.c
+++ b/bundles/shell/shell/src/dm_shell_list_command.c
@@ -21,7 +21,7 @@
#include <string.h>
#include <shell_constants.h>
#include "celix_bundle_context.h"
-#include "dm_dependency_manager.h"
+#include "celix_dependency_manager.h"
static const char * const OK_COLOR = "\033[92m";
@@ -29,21 +29,19 @@ static const char * const WARNING_COLOR = "\033[93m";
static const char * const NOK_COLOR = "\033[91m";
static const char * const END_COLOR = "\033[m";
-static void parseCommandLine(const char*line, array_list_pt *requestedBundleIds, bool *fullInfo, FILE *err) {
+static void parseCommandLine(const char*line, celix_array_list_t **requestedBundleIds, bool *fullInfo, FILE *err) {
*fullInfo = false;
char *str = strdup(line);
// skip first argument since this is the command
strtok(str," ");
char* tok = strtok(NULL," ");
- *requestedBundleIds = NULL;
- arrayList_create(requestedBundleIds);
+ *requestedBundleIds = celix_arrayList_create();
while (tok) {
if (tok[0] == 'f') { // f or full argument => show full info
*fullInfo = true;
} else if ( (tok[0] >= '0') && (tok[0] <= '9')) { // bundle id
- long *id = malloc(sizeof(*id));
- *id = strtol(tok, NULL, 10);
- arrayList_add(*requestedBundleIds, id);
+ long id = strtol(tok, NULL, 10);
+ celix_arrayList_addLong(*requestedBundleIds, id);
} else {
fprintf (err, "DM: Skipping unknown argument: %s", tok );
}
@@ -52,34 +50,6 @@ static void parseCommandLine(const char*line, array_list_pt *requestedBundleIds,
free (str);
}
-static void destroyBundleIdList(array_list_pt ids) {
- unsigned int size = arrayList_size(ids);
- for (unsigned int i = 0; i < size; i++) {
- free(arrayList_get(ids, i));
- }
- arrayList_destroy(ids);
-}
-
-/*
- * Check if the ID is in the array list. If arrayist is empty also true is returned so that all
- * bundles are shown
- */
-static bool is_bundleId_in_list(array_list_pt ids, long id) {
- unsigned int size = arrayList_size(ids);
- bool result = false;
- if (size == 0) {
- result = true;
- }
- for(unsigned int i = 0; i < size; ++i) {
- if (*((long*)arrayList_get(ids, i)) == id) {
- result = true;
- break;
- }
- }
- return result;
-}
-
-
static void printFullInfo(FILE *out, bool colors, dm_component_info_pt compInfo) {
const char *startColors = "";
const char *endColors = "";
@@ -136,58 +106,55 @@ static void printBasicInfo(FILE *out, bool colors, dm_component_info_pt compInfo
}
-celix_status_t dmListCommand_execute(void* handle, char * line, FILE *out, FILE *err) {
- bundle_context_t *ctx = handle;
+static void dm_printInfo(FILE *out, bool useColors, bool fullInfo, celix_dependency_manager_info_t *info) {
+ if (info != NULL) {
+ int size = celix_arrayList_size(info->components);
+ if (size > 0) {
+ fprintf(out, "[Bundle: %ld]\n", info->bndId);
+ for (unsigned int cmpCnt = 0; cmpCnt < size; cmpCnt++) {
+ dm_component_info_pt compInfo = celix_arrayList_get(info->components, cmpCnt);
+ if (fullInfo) {
+ printFullInfo(out, useColors, compInfo);
+ } else {
+ printBasicInfo(out, useColors, compInfo);
+ }
+ }
+ fprintf(out, "\n");
+ }
+ }
+}
- array_list_t *bundles = NULL;
- bundleContext_getBundles(ctx, &bundles);
+celix_status_t dmListCommand_execute(void* handle, char * line, FILE *out, FILE *err) {
+ celix_bundle_context_t *ctx = handle;
+ celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx);
const char *config = NULL;
bundleContext_getPropertyWithDefault(ctx, SHELL_USE_ANSI_COLORS, SHELL_USE_ANSI_COLORS_DEFAULT_VALUE, &config);
bool useColors = config != NULL && strncmp("true", config, 5) == 0;
- array_list_pt bundleIds = NULL;
+ celix_array_list_t *bundleIds = NULL;
bool fullInfo = false;
parseCommandLine(line, &bundleIds, &fullInfo, err);
- if (bundles != NULL) {
- unsigned int size = arrayList_size(bundles);
- for (unsigned int i = 0; i < size; ++i) {
- long bndId = -1;
- bundle_t *bnd = arrayList_get(bundles, i);
- bundle_getBundleId(bnd, &bndId);
- if (!is_bundleId_in_list(bundleIds, bndId)) {
- continue;
- }
- bundle_context_t *bndCtx = NULL;
- bundle_getContext(bnd, &bndCtx);
- if (bndCtx != NULL) {
- dm_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(bndCtx);
- dm_dependency_manager_info_t *info = NULL;
- dependencyManager_getInfo(mng, &info);
- if (info != NULL) {
- size_t size = celix_arrayList_size(info->components);
- if (size > 0) {
- fprintf(out, "[Bundle: %ld]\n", bndId);
- for (unsigned int cmpCnt = 0; cmpCnt < size; cmpCnt++) {
- dm_component_info_pt compInfo = celix_arrayList_get(info->components, cmpCnt);
- if (fullInfo) {
- printFullInfo(out, useColors, compInfo);
- } else {
- printBasicInfo(out, useColors, compInfo);
- }
- }
- fprintf(out, "\n");
- }
- dependencyManager_destroyInfo(mng, info);
- }
-
+ if (celix_arrayList_size(bundleIds) == 0) {
+ celix_array_list_t *infos = celix_dependencyManager_createInfos(mng);
+ for (int i = 0; i < celix_arrayList_size(infos); ++i) {
+ celix_dependency_manager_info_t *info = celix_arrayList_get(infos, i);
+ dm_printInfo(out, useColors, fullInfo, info);
+ }
+ celix_dependencyManager_destroyInfos(mng, infos);
+ } else {
+ for (int i = 0; i < celix_arrayList_size(bundleIds); ++i) {
+ long bndId = celix_arrayList_getLong(bundleIds, i);
+ celix_dependency_manager_info_t *info = celix_dependencyManager_createInfo(mng, bndId);
+ if (info != NULL) {
+ dm_printInfo(out, useColors, fullInfo, info);
+ celix_dependencyManager_destroyInfo(mng, info);
}
}
- arrayList_destroy(bundles);
}
- destroyBundleIdList(bundleIds);
+ celix_arrayList_destroy(bundleIds);
return CELIX_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/cmake/cmake_celix/DockerPackaging.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/DockerPackaging.cmake b/cmake/cmake_celix/DockerPackaging.cmake
index cdc46c9..8556917 100644
--- a/cmake/cmake_celix/DockerPackaging.cmake
+++ b/cmake/cmake_celix/DockerPackaging.cmake
@@ -111,7 +111,7 @@ int main(int argc, char *argv[]) {
$<JOIN:$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_EMBEDDED_PROPERTIES>,\\n\\
>\";
- properties_pt packedConfig = properties_loadFromString(config);
+ celix_properties_t *packedConfig = properties_loadFromString(config);
return celixLauncher_launchAndWaitForShutdown(argc, argv, packedConfig);
}
"
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/CMakeLists.txt b/examples/celix-examples/CMakeLists.txt
index 86ed757..e7ce308 100644
--- a/examples/celix-examples/CMakeLists.txt
+++ b/examples/celix-examples/CMakeLists.txt
@@ -21,6 +21,8 @@ else ()
set(EXAMPLES true) #celix_subproject is only available in the celix project -> using examples dir in other project is also supported
endif ()
if (EXAMPLES)
+ add_compile_definitions(ADD_CELIX_DEPRECATED_WARNING) #ensure that no deprecated api is used in the examples
+
add_subdirectory(bundle_example_c)
add_subdirectory(hello_world)
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/best_practice_example_c/bar/private/src/bar_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/best_practice_example_c/bar/private/src/bar_activator.c b/examples/celix-examples/best_practice_example_c/bar/private/src/bar_activator.c
index 39d0164..25e82b0 100644
--- a/examples/celix-examples/best_practice_example_c/bar/private/src/bar_activator.c
+++ b/examples/celix-examples/best_practice_example_c/bar/private/src/bar_activator.c
@@ -17,7 +17,7 @@
*under the License.
*/
-#include "dm_activator.h"
+#include "celix_api.h"
#include "bar.h"
#include <stdlib.h>
@@ -35,17 +35,16 @@ static celix_status_t activator_start(activator_t *act, celix_bundle_context_t *
if (act->bar == NULL) {
status = CELIX_ENOMEM;
} else {
- dm_component_pt cmp = NULL;
- component_create(ctx, "BAR", &cmp);
- component_setImplementation(cmp, act->bar);
- component_addInterface(cmp, EXAMPLE_NAME, EXAMPLE_VERSION, &act->exampleService, NULL);
- dependencyManager_add(celix_bundleContext_getDependencyManager(ctx), cmp);
+ celix_dm_component_t *cmp = celix_dmComponent_create(ctx, "BAR");
+ celix_dmComponent_setImplementation(cmp, act->bar);
+ celix_dmComponent_addInterface(cmp, EXAMPLE_NAME, EXAMPLE_VERSION, &act->exampleService, NULL);
+ celix_dependencyManager_add(celix_bundleContext_getDependencyManager(ctx), cmp);
}
return status;
}
static celix_status_t activator_stop(activator_t *act, celix_bundle_context_t *ctx) {
- dependencyManager_removeAllComponents(celix_bundleContext_getDependencyManager(ctx));
+ celix_dependencyManager_removeAllComponents(celix_bundleContext_getDependencyManager(ctx));
bar_destroy(act->bar);
return CELIX_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c b/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
index 61783ef..4098117 100644
--- a/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
+++ b/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
@@ -17,7 +17,7 @@
*under the License.
*/
-#include "dm_activator.h"
+#include "celix_api.h"
#include "foo1.h"
#include <stdlib.h>
@@ -32,21 +32,19 @@ static celix_status_t activator_start(activator_t *act, celix_bundle_context_t *
if (act->foo == NULL) {
status = CELIX_ENOMEM;
} else {
- dm_component_pt cmp = NULL;
- component_create(ctx, "FOO1", &cmp);
- component_setImplementation(cmp, act->foo);
+ celix_dm_component_t *cmp = celix_dmComponent_create(ctx, "FOO1");
+ celix_dmComponent_setImplementation(cmp, act->foo);
/*
With the component_setCallbacksSafe we register callbacks when a component is started / stopped using a component
with type foo1_t*
*/
- component_setCallbacksSafe(cmp, foo1_t*, NULL, foo1_start, foo1_stop, NULL);
+ CELIX_DMCOMPONENT_SETCALLBACKS(cmp, foo1_t*, NULL, foo1_start, foo1_stop, NULL);
- dm_service_dependency_pt dep = NULL;
- serviceDependency_create(&dep);
- serviceDependency_setRequired(dep, true);
- serviceDependency_setService(dep, EXAMPLE_NAME, EXAMPLE_CONSUMER_RANGE, NULL);
- serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING);
+ celix_dm_service_dependency_t *dep = celix_dmServiceDependency_create();
+ celix_dmServiceDependency_setRequired(dep, true);
+ celix_dmServiceDependency_setService(dep, EXAMPLE_NAME, EXAMPLE_CONSUMER_RANGE, NULL);
+ celix_dmServiceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING);
/*
With the serviceDependency_setCallbacksSafe we register callbacks when a service
@@ -56,17 +54,19 @@ static celix_status_t activator_start(activator_t *act, celix_bundle_context_t *
service because after removal of the service the memory location of that service
could be freed
*/
- serviceDependency_setCallbacksSafe(dep, foo1_t*, const example_t*, foo1_setExample, NULL, NULL, NULL, NULL);
- component_addServiceDependency(cmp, dep);
+ celix_dm_service_dependency_callback_options_t opts = CELIX_EMPTY_DM_SERVICE_DEPENDENCY_CALLBACK_OPTIONS;
+ opts.set = (void*)foo1_setExample;
+ celix_dmServiceDependency_setCallbacksWithOptions(dep, &opts);
+ celix_dmComponent_addServiceDependency(cmp, dep);
- dependencyManager_add(celix_bundleContext_getDependencyManager(ctx), cmp);
+ celix_dependencyManager_add(celix_bundleContext_getDependencyManager(ctx), cmp);
}
return status;
}
static celix_status_t activator_stop(activator_t *act, celix_bundle_context_t *ctx) {
- dependencyManager_removeAllComponents(celix_bundleContext_getDependencyManager(ctx));
+ celix_dependencyManager_removeAllComponents(celix_bundleContext_getDependencyManager(ctx));
foo1_destroy(act->foo);
return CELIX_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2.c b/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2.c
index b98e20b..4a1482c 100644
--- a/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2.c
+++ b/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2.c
@@ -37,7 +37,7 @@
static void* foo2_thread(void*);
struct foo2_struct {
- array_list_pt examples;
+ celix_array_list_t *examples;
pthread_t thread;
bool running;
};
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2_activator.c b/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2_activator.c
index 309b8c1..9765e35 100644
--- a/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2_activator.c
+++ b/examples/celix-examples/best_practice_example_c/foo2/private/src/foo2_activator.c
@@ -17,7 +17,7 @@
*under the License.
*/
-#include "dm_activator.h"
+#include "celix_api.h"
#include "foo2.h"
#include <stdlib.h>
@@ -33,21 +33,19 @@ static celix_status_t activator_start(struct activator *act, celix_bundle_contex
status = CELIX_ENOMEM;
} else {
- dm_component_pt cmp = NULL;
- component_create(ctx, "FOO2", &cmp);
- component_setImplementation(cmp, act->foo);
+ celix_dm_component_t *cmp = celix_dmComponent_create(ctx, "FOO2");
+ celix_dmComponent_setImplementation(cmp, act->foo);
/*
With the component_setCallbacksSafe we register callbacks when a component is started / stopped using a component
with type foo1_t*
*/
- component_setCallbacksSafe(cmp, foo2_t*, NULL, foo2_start, foo2_stop, NULL);
+ CELIX_DMCOMPONENT_SETCALLBACKS(cmp, foo2_t*, NULL, foo2_start, foo2_stop, NULL);
- dm_service_dependency_pt dep = NULL;
- serviceDependency_create(&dep);
- serviceDependency_setRequired(dep, false);
- serviceDependency_setService(dep, EXAMPLE_NAME, EXAMPLE_CONSUMER_RANGE, NULL);
- serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND);
+ celix_dm_service_dependency_t *dep = celix_dmServiceDependency_create();
+ celix_dmServiceDependency_setRequired(dep, false);
+ celix_dmServiceDependency_setService(dep, EXAMPLE_NAME, EXAMPLE_CONSUMER_RANGE, NULL);
+ celix_dmServiceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND);
/*
With the serviceDependency_setCallbacksSafe we register callbacks when a service
@@ -57,18 +55,20 @@ static celix_status_t activator_start(struct activator *act, celix_bundle_contex
service because after removal of the service the memory location of that service
could be freed
*/
- serviceDependency_setCallbacksSafe(dep, foo2_t*, const example_t*, NULL, foo2_addExample, NULL,
- foo2_removeExample, NULL);
- component_addServiceDependency(cmp, dep);
+ celix_dm_service_dependency_callback_options_t opts = CELIX_EMPTY_DM_SERVICE_DEPENDENCY_CALLBACK_OPTIONS;
+ opts.add = (void*)foo2_addExample;
+ opts.remove = (void*)foo2_removeExample;
+ celix_dmServiceDependency_setCallbacksWithOptions(dep, &opts);
+ celix_dmComponent_addServiceDependency(cmp, dep);
- dependencyManager_add(celix_bundleContext_getDependencyManager(ctx), cmp);
+ celix_dependencyManager_add(celix_bundleContext_getDependencyManager(ctx), cmp);
}
return status;
}
static celix_status_t activator_stop(struct activator *act, celix_bundle_context_t *ctx) {
- dependencyManager_removeAllComponents(celix_bundleContext_getDependencyManager(ctx));
+ celix_dependencyManager_removeAllComponents(celix_bundleContext_getDependencyManager(ctx));
foo2_destroy(act->foo);
return CELIX_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/civetweb/src/bundle_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/civetweb/src/bundle_activator.c b/examples/celix-examples/civetweb/src/bundle_activator.c
index 17892fb..3dcd490 100644
--- a/examples/celix-examples/civetweb/src/bundle_activator.c
+++ b/examples/celix-examples/civetweb/src/bundle_activator.c
@@ -74,7 +74,7 @@ static int websocket_data_handler(struct mg_connection *conn, int bits, char *da
static celix_status_t activator_start(activator_data_t *data, celix_bundle_context_t *ctx) {
data->ctx = ctx;
- bundle_t *bnd = celix_bundleContext_getBundle(ctx);
+ celix_bundle_t *bnd = celix_bundleContext_getBundle(ctx);
data->root = celix_bundle_getEntry(bnd, "resources");
const char *options[] = {
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/dm_example/CMakeLists.txt b/examples/celix-examples/dm_example/CMakeLists.txt
index 581a17c..a3986f8 100644
--- a/examples/celix-examples/dm_example/CMakeLists.txt
+++ b/examples/celix-examples/dm_example/CMakeLists.txt
@@ -22,7 +22,6 @@ add_subdirectory(phase2a)
add_subdirectory(phase2b)
add_subdirectory(phase3)
-
add_celix_container(dm_example
COPY
BUNDLES
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/phase1/src/phase1_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/dm_example/phase1/src/phase1_activator.c b/examples/celix-examples/dm_example/phase1/src/phase1_activator.c
index 31dcb16..985002a 100644
--- a/examples/celix-examples/dm_example/phase1/src/phase1_activator.c
+++ b/examples/celix-examples/dm_example/phase1/src/phase1_activator.c
@@ -26,8 +26,7 @@
#include <stdlib.h>
#include <phase1_cmp.h>
-#include "bundle_activator.h"
-#include "dm_activator.h"
+#include "celix_api.h"
#include "phase1.h"
@@ -36,51 +35,41 @@ struct phase1_activator_struct {
phase1_t phase1Serv;
};
-celix_status_t dm_create(bundle_context_pt context, void **userData) {
- printf("PHASE1: dm_create\n");
- *userData = calloc(1, sizeof(struct phase1_activator_struct));
- return *userData != NULL ? CELIX_SUCCESS : CELIX_ENOMEM;
-}
-
-celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
- printf("PHASE1: dm_init\n");
- celix_status_t status = CELIX_SUCCESS;
-
-
- struct phase1_activator_struct *act = (struct phase1_activator_struct *)userData;
-
+static celix_status_t start(struct phase1_activator_struct *act, celix_bundle_context_t *ctx) {
+ celix_status_t status = CELIX_SUCCESS;
+ printf("PHASE1: start\n");
act->phase1Cmp = phase1_create();
if (act->phase1Cmp != NULL) {
act->phase1Serv.handle = act->phase1Cmp;
act->phase1Serv.getData = (void *)phase1_getData;
- properties_pt props = properties_create();
+ celix_properties_t *props = properties_create();
properties_set(props, "id", "phase1");
- dm_component_pt cmp;
- component_create(context, "PHASE1_PROCESSING_COMPONENT", &cmp);
- component_setImplementation(cmp, act->phase1Cmp);
- component_setCallbacksSafe(cmp, phase1_cmp_t *, phase1_init, phase1_start, phase1_stop, phase1_deinit);
+ celix_dm_component_t *cmp= celix_dmComponent_create(ctx, "PHASE1_PROCESSING_COMPONENT");
+ celix_dmComponent_setImplementation(cmp, act->phase1Cmp);
+ CELIX_DMCOMPONENT_SETCALLBACKS(cmp, phase1_cmp_t *, phase1_init, phase1_start, phase1_stop, phase1_deinit);
phase1_setComp(act->phase1Cmp, cmp);
- component_addInterface(cmp, PHASE1_NAME, PHASE1_VERSION, &act->phase1Serv, props);
+ celix_dmComponent_addInterface(cmp, PHASE1_NAME, PHASE1_VERSION, &act->phase1Serv, props);
- dependencyManager_add(manager, cmp);
+ celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx);
+ celix_dependencyManager_add(mng, cmp);
} else {
status = CELIX_ENOMEM;
}
-
- return status;
+ return status;
}
-celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
- printf("PHASE1: dm-destroy\n");
-
- struct phase1_activator_struct *act = (struct phase1_activator_struct *)userData;
+static celix_status_t stop(struct phase1_activator_struct *act, celix_bundle_context_t *ctx) {
+ printf("PHASE1: stop\n");
+ celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx);
+ celix_dependencyManager_removeAllComponents(mng);
if (act->phase1Cmp != NULL) {
phase1_destroy(act->phase1Cmp);
}
- free(act);
return CELIX_SUCCESS;
}
+
+CELIX_GEN_BUNDLE_ACTIVATOR(struct phase1_activator_struct, start, stop);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/phase1/src/phase1_cmp.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/dm_example/phase1/src/phase1_cmp.c b/examples/celix-examples/dm_example/phase1/src/phase1_cmp.c
index 40da821..e27dcb7 100644
--- a/examples/celix-examples/dm_example/phase1/src/phase1_cmp.c
+++ b/examples/celix-examples/dm_example/phase1/src/phase1_cmp.c
@@ -39,7 +39,7 @@ struct phase1_cmp_struct {
celix_thread_t thread;
bool running;
unsigned int counter;
- dm_component_pt component;
+ celix_dm_component_t *component;
};
@@ -54,7 +54,7 @@ phase1_cmp_t *phase1_create(void) {
return cmp;
}
-void phase1_setComp(phase1_cmp_t *cmp, dm_component_pt dmCmp) {
+void phase1_setComp(phase1_cmp_t *cmp, celix_dm_component_t *dmCmp) {
cmp->component = dmCmp;
}
@@ -95,7 +95,7 @@ static void *phase1_thread(void *data) {
cmp->counter += 1;
if (cmp->counter == 2) {
static char *runtime_interface = "DUMMY INTERFACE: DO NOT USE\n";
- component_addInterface(cmp->component, "RUNTIME_ADDED_INTERFACE", "1.0.0", runtime_interface, NULL);
+ celix_dmComponent_addInterface(cmp->component, "RUNTIME_ADDED_INTERFACE", "1.0.0", runtime_interface, NULL);
}
usleep(SLEEPTIME);
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/phase1/src/phase1_cmp.h
----------------------------------------------------------------------
diff --git a/examples/celix-examples/dm_example/phase1/src/phase1_cmp.h b/examples/celix-examples/dm_example/phase1/src/phase1_cmp.h
index 153eed1..002ece8 100644
--- a/examples/celix-examples/dm_example/phase1/src/phase1_cmp.h
+++ b/examples/celix-examples/dm_example/phase1/src/phase1_cmp.h
@@ -31,7 +31,7 @@
typedef struct phase1_cmp_struct phase1_cmp_t;
phase1_cmp_t *phase1_create(void);
-void phase1_setComp(phase1_cmp_t *cmp, dm_component_pt dmCmp);
+void phase1_setComp(phase1_cmp_t *cmp, celix_dm_component_t *dmCmp);
int phase1_init(phase1_cmp_t *cmp);
int phase1_start(phase1_cmp_t *cmp);
int phase1_stop(phase1_cmp_t *cmp);
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/phase2a/src/phase2a_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/dm_example/phase2a/src/phase2a_activator.c b/examples/celix-examples/dm_example/phase2a/src/phase2a_activator.c
index 6fa6919..04c0512 100644
--- a/examples/celix-examples/dm_example/phase2a/src/phase2a_activator.c
+++ b/examples/celix-examples/dm_example/phase2a/src/phase2a_activator.c
@@ -20,8 +20,7 @@
#include <stdlib.h>
#include <phase2a_cmp.h>
-#include "bundle_activator.h"
-#include "dm_activator.h"
+#include "celix_api.h"
#include "phase1.h"
#include "phase2.h"
@@ -32,58 +31,48 @@ struct phase2a_activator_struct {
phase2_t phase2Serv;
};
-celix_status_t dm_create(bundle_context_pt context, void **userData) {
- printf("phase2a: dm_create\n");
- *userData = calloc(1, sizeof(struct phase2a_activator_struct));
- return *userData != NULL ? CELIX_SUCCESS : CELIX_ENOMEM;
-}
-
-celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
- printf("phase2a: dm_init\n");
- celix_status_t status = CELIX_SUCCESS;
-
- struct phase2a_activator_struct *act = (struct phase2a_activator_struct *)userData;
-
+static celix_status_t start(struct phase2a_activator_struct *act, celix_bundle_context_t *ctx) {
+ printf("phase2a: start\n");
+ celix_status_t status = CELIX_SUCCESS;
act->phase2aCmp = phase2a_create();
if (act->phase2aCmp != NULL) {
act->phase2Serv.handle = act->phase2aCmp;
act->phase2Serv.getData = (void *)phase2a_getData;
- properties_pt props = properties_create();
+ celix_properties_t *props = properties_create();
properties_set(props, "id", "phase2a");
- dm_component_pt cmp;
- component_create(context, "PHASE2A_PROCESSING_COMPONENT", &cmp);
- component_setImplementation(cmp, act->phase2aCmp);
- component_setCallbacksSafe(cmp, phase2a_cmp_t *, phase2a_init, phase2a_start, phase2a_stop, phase2a_deinit);
- component_addInterface(cmp, PHASE2_NAME, PHASE2_VERSION, &act->phase2Serv, props);
+ celix_dm_component_t *cmp = celix_dmComponent_create(ctx, "PHASE2A_PROCESSING_COMPONENT");
+ celix_dmComponent_setImplementation(cmp, act->phase2aCmp);
+ CELIX_DMCOMPONENT_SETCALLBACKS(cmp, phase2a_cmp_t *, phase2a_init, phase2a_start, phase2a_stop, phase2a_deinit);
+ celix_dmComponent_addInterface(cmp, PHASE2_NAME, PHASE2_VERSION, &act->phase2Serv, props);
- dm_service_dependency_pt dep;
- serviceDependency_create(&dep);
- serviceDependency_setService(dep, PHASE1_NAME, PHASE1_RANGE_ALL, NULL);
- serviceDependency_setCallbacksSafe(dep, phase2a_cmp_t*, const phase1_t*, phase2a_setPhase1, NULL, NULL, NULL, NULL);
- serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING);
- serviceDependency_setRequired(dep, true);
- component_addServiceDependency(cmp, dep);
+ celix_dm_service_dependency_t *dep = celix_dmServiceDependency_create();
+ celix_dmServiceDependency_setService(dep, PHASE1_NAME, PHASE1_RANGE_ALL, NULL);
+ celix_dmServiceDependency_setCallback(dep, (void*)phase2a_setPhase1);
+ celix_dmServiceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING);
+ celix_dmServiceDependency_setRequired(dep, true);
+ celix_dmComponent_addServiceDependency(cmp, dep);
- dependencyManager_add(manager, cmp);
+ celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx);
+ celix_dependencyManager_add(mng, cmp);
} else {
status = CELIX_ENOMEM;
}
- return status;
+ return status;
}
-celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
- printf("phase2a: dm-destroy\n");
-
- struct phase2a_activator_struct *act = (struct phase2a_activator_struct *)userData;
+static celix_status_t stop(struct phase2a_activator_struct *act, celix_bundle_context_t *ctx) {
+ printf("phase2a: stop\n");
+ celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx);
+ celix_dependencyManager_removeAllComponents(mng);
if (act->phase2aCmp != NULL) {
phase2a_destroy(act->phase2aCmp);
}
- free(act);
-
return CELIX_SUCCESS;
}
+
+CELIX_GEN_BUNDLE_ACTIVATOR(struct phase2a_activator_struct, start, stop)
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/phase2b/src/phase2b_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/dm_example/phase2b/src/phase2b_activator.c b/examples/celix-examples/dm_example/phase2b/src/phase2b_activator.c
index c7692d4..328b48a 100644
--- a/examples/celix-examples/dm_example/phase2b/src/phase2b_activator.c
+++ b/examples/celix-examples/dm_example/phase2b/src/phase2b_activator.c
@@ -26,8 +26,7 @@
#include <stdlib.h>
#include <phase2b_cmp.h>
-#include "bundle_activator.h"
-#include "dm_activator.h"
+#include "celix_api.h"
#include "phase1.h"
#include "phase2.h"
@@ -38,58 +37,49 @@ struct phase2b_activator_struct {
phase2_t phase2Serv;
};
-celix_status_t dm_create(bundle_context_pt context, void **userData) {
- printf("phase2b: dm_create\n");
- *userData = calloc(1, sizeof(struct phase2b_activator_struct));
- return *userData != NULL ? CELIX_SUCCESS : CELIX_ENOMEM;
-}
-
-celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
- printf("phase2b: dm_init\n");
- celix_status_t status = CELIX_SUCCESS;
-
- struct phase2b_activator_struct *act = (struct phase2b_activator_struct *)userData;
-
+static celix_status_t start(struct phase2b_activator_struct *act, celix_bundle_context_t *ctx) {
+ printf("phase2b: start\n");
+ celix_status_t status = CELIX_SUCCESS;
act->phase2bCmp = phase2b_create();
if (act->phase2bCmp != NULL) {
act->phase2Serv.handle = act->phase2bCmp;
act->phase2Serv.getData = (void *)phase2b_getData;
- properties_pt props = properties_create();
+ celix_properties_t *props = properties_create();
properties_set(props, "id", "phase2b");
- dm_component_pt cmp;
- component_create(context, "PHASE2B_PROCESSING_COMPONENT", &cmp);
- component_setImplementation(cmp, act->phase2bCmp);
- component_setCallbacksSafe(cmp, phase2b_cmp_t *, phase2b_init, phase2b_start, phase2b_stop, phase2b_deinit);
- component_addInterface(cmp, PHASE2_NAME, PHASE2_VERSION, &act->phase2Serv, props);
+ celix_dm_component_t *cmp = celix_dmComponent_create(ctx, "PHASE2B_PROCESSING_COMPONENT");
+ celix_dmComponent_setImplementation(cmp, act->phase2bCmp);
+ CELIX_DMCOMPONENT_SETCALLBACKS(cmp, phase2b_cmp_t *, phase2b_init, phase2b_start, phase2b_stop, phase2b_deinit);
+ celix_dmComponent_addInterface(cmp, PHASE2_NAME, PHASE2_VERSION, &act->phase2Serv, props);
- dm_service_dependency_pt dep;
- serviceDependency_create(&dep);
- serviceDependency_setService(dep, PHASE1_NAME, PHASE1_RANGE_EXACT, NULL);
- serviceDependency_setCallbacksSafe(dep, phase2b_cmp_t*, const phase1_t*, phase2b_setPhase1, NULL, NULL, NULL, NULL);
- serviceDependency_setRequired(dep, true);
- serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING);
- component_addServiceDependency(cmp, dep);
+ celix_dm_service_dependency_t *dep = celix_dmServiceDependency_create();
+ celix_dmServiceDependency_setService(dep, PHASE1_NAME, PHASE1_RANGE_EXACT, NULL);
+ celix_dmServiceDependency_setCallback(dep, (void*)phase2b_setPhase1);
+ celix_dmServiceDependency_setRequired(dep, true);
+ celix_dmServiceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING);
+ celix_dmComponent_addServiceDependency(cmp, dep);
- dependencyManager_add(manager, cmp);
+ celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx);
+ celix_dependencyManager_add(mng, cmp);
} else {
status = CELIX_ENOMEM;
}
- return status;
+ return status;
}
-celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
- printf("phase2b: dm-destroy\n");
-
- struct phase2b_activator_struct *act = (struct phase2b_activator_struct *)userData;
+static celix_status_t stop(struct phase2b_activator_struct *act, celix_bundle_context_t *ctx) {
+ printf("phase2b: stop\n");
+ celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx);
+ celix_dependencyManager_removeAllComponents(mng);
if (act->phase2bCmp != NULL) {
phase2b_destroy(act->phase2bCmp);
}
- free(act);
-
return CELIX_SUCCESS;
}
+
+
+CELIX_GEN_BUNDLE_ACTIVATOR(struct phase2b_activator_struct, start, stop)
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/phase3/src/phase3_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/dm_example/phase3/src/phase3_activator.c b/examples/celix-examples/dm_example/phase3/src/phase3_activator.c
index 64b7a0b..7401776 100644
--- a/examples/celix-examples/dm_example/phase3/src/phase3_activator.c
+++ b/examples/celix-examples/dm_example/phase3/src/phase3_activator.c
@@ -25,8 +25,7 @@
*/
#include <stdlib.h>
-#include "bundle_activator.h"
-#include "dm_activator.h"
+#include "celix_api.h"
#include "phase2.h"
#include "phase3_cmp.h"
@@ -35,50 +34,45 @@ struct phase3_activator_struct {
phase3_cmp_t *phase3Cmp;
};
-celix_status_t dm_create(bundle_context_pt context, void **userData) {
- printf("phase3: dm_create\n");
- *userData = calloc(1, sizeof(struct phase3_activator_struct));
- return *userData != NULL ? CELIX_SUCCESS : CELIX_ENOMEM;
-}
-
-celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
- printf("phase3: dm_init\n");
- celix_status_t status = CELIX_SUCCESS;
-
- struct phase3_activator_struct *act = (struct phase3_activator_struct *)userData;
-
+static celix_status_t start(struct phase3_activator_struct *act, celix_bundle_context_t *ctx) {
+ celix_status_t status = CELIX_SUCCESS;
+ printf("phase3: start\n");
act->phase3Cmp = phase3_create();
if (act->phase3Cmp != NULL) {
- dm_component_pt cmp;
- component_create(context, "PHASE3_PROCESSING_COMPONENT", &cmp);
- component_setImplementation(cmp, act->phase3Cmp);
- component_setCallbacksSafe(cmp, phase3_cmp_t *, phase3_init, phase3_start, phase3_stop, phase3_deinit);
+ celix_dm_component_t *cmp = celix_dmComponent_create(ctx, "PHASE3_PROCESSING_COMPONENT");
+ celix_dmComponent_setImplementation(cmp, act->phase3Cmp);
+ CELIX_DMCOMPONENT_SETCALLBACKS(cmp, phase3_cmp_t *, phase3_init, phase3_start, phase3_stop, phase3_deinit);
- dm_service_dependency_pt dep;
- serviceDependency_create(&dep);
- serviceDependency_setService(dep, PHASE2_NAME, NULL, NULL);
- serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND); //SUSPEND Strategy is default
- serviceDependency_setCallbacksSafe(dep, phase3_cmp_t*, const phase2_t*, NULL, phase3_addPhase2, NULL, phase3_removePhase2, NULL);
- serviceDependency_setRequired(dep, true);
- component_addServiceDependency(cmp, dep);
+ celix_dm_service_dependency_t *dep = celix_dmServiceDependency_create();
+ celix_dmServiceDependency_setService(dep, PHASE2_NAME, NULL, NULL);
+ celix_dmServiceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND); //SUSPEND Strategy is default
+ celix_dm_service_dependency_callback_options_t opts = CELIX_EMPTY_DM_SERVICE_DEPENDENCY_CALLBACK_OPTIONS;
+ opts.add = (void*)phase3_addPhase2;
+ opts.remove = (void*)phase3_removePhase2;
+ celix_dmServiceDependency_setCallbacksWithOptions(dep, &opts);
+ celix_dmServiceDependency_setRequired(dep, true);
+ celix_dmComponent_addServiceDependency(cmp, dep);
- dependencyManager_add(manager, cmp);
+ celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx);
+ celix_dependencyManager_add(mng, cmp);
} else {
status = CELIX_ENOMEM;
}
+ return status;
- return status;
}
-celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
- printf("phase3: dm-destroy\n");
-
- struct phase3_activator_struct *act = (struct phase3_activator_struct *)userData;
+static celix_status_t stop(struct phase3_activator_struct *act, celix_bundle_context_t *ctx) {
+ celix_status_t status = CELIX_SUCCESS;
+ printf("phase3: stop\n");
+ celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx);
+ celix_dependencyManager_removeAllComponents(mng);
if (act->phase3Cmp != NULL) {
phase3_destroy(act->phase3Cmp);
}
- free(act);
-
- return CELIX_SUCCESS;
+ return status;
}
+
+
+CELIX_GEN_BUNDLE_ACTIVATOR(struct phase3_activator_struct, start, stop);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example/phase3/src/phase3_cmp.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/dm_example/phase3/src/phase3_cmp.c b/examples/celix-examples/dm_example/phase3/src/phase3_cmp.c
index 47cb720..e4e6902 100644
--- a/examples/celix-examples/dm_example/phase3/src/phase3_cmp.c
+++ b/examples/celix-examples/dm_example/phase3/src/phase3_cmp.c
@@ -38,7 +38,7 @@ struct phase3_cmp_struct {
celix_thread_t thread;
bool running;
double currentValue;
- array_list_pt phase2Services; //phase2_t *
+ celix_array_list_t *phase2Services; //phase2_t *
};
static void *phase3_thread(void *data);
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
----------------------------------------------------------------------
diff --git a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
index 61443dd..c4895e4 100644
--- a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
+++ b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
@@ -41,7 +41,7 @@ struct InvalidCServ {
};
void Phase1Activator::init() {
- auto cmp = std::unique_ptr<Phase1Cmp>(new Phase1Cmp());
+ auto cmp = std::shared_ptr<Phase1Cmp>(new Phase1Cmp());
Properties cmdProps;
cmdProps[OSGI_SHELL_COMMAND_NAME] = "phase1_info";
@@ -87,7 +87,7 @@ void Phase1Activator::init() {
tst->handle = cmp.get();
- phase1cmp = &mng.createComponent(std::move(cmp)) //using a pointer a instance. Also supported is lazy initialization (default constructor needed) or a rvalue reference (move)
+ phase1cmp = &mng.createComponent(cmp) //using a pointer a instance. Also supported is lazy initialization (default constructor needed) or a rvalue reference (move)
.addInterface<IPhase1>(IPHASE1_VERSION)
//.addInterface<IPhase2>() -> Compile error (static assert), because Phase1Cmp does not implement IPhase2
.addCInterface(&cmd, OSGI_SHELL_COMMAND_SERVICE_NAME, "", cmdProps)
@@ -96,8 +96,4 @@ void Phase1Activator::init() {
//.addCInterface(tst.get(), "TEST_SRV") -> Compile error (static assert), because InvalidCServ is not a pod
.addInterface<srv::info::IName>(INAME_VERSION)
.setCallbacks(&Phase1Cmp::init, &Phase1Cmp::start, &Phase1Cmp::stop, &Phase1Cmp::deinit);
-}
-
-void Phase1Activator::deinit() {
- phase1cmp->removeCallbacks();
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h
----------------------------------------------------------------------
diff --git a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h
index a3b062b..76ba839 100644
--- a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h
+++ b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h
@@ -39,7 +39,6 @@ class Phase1Activator : public DmActivator {
Phase1Activator(const Phase1Activator&) = delete;
Phase1Activator& operator=(const Phase1Activator&) = delete;
virtual void init();
- virtual void deinit();
};
#endif //CELIX_PHASE1ACTIVATOR_H
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/embedding/private/src/main.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/embedding/private/src/main.c b/examples/celix-examples/embedding/private/src/main.c
index b77cb22..d1ef0d6 100644
--- a/examples/celix-examples/embedding/private/src/main.c
+++ b/examples/celix-examples/embedding/private/src/main.c
@@ -43,18 +43,18 @@ celix_status_t embedded_foo();
int main(void) {
- framework_pt framework = NULL;
+ celix_framework_t *framework = NULL;
- properties_pt config = properties_create();
+ celix_properties_t *config = properties_create();
int rc = celixLauncher_launchWithProperties(config, &framework);
if (rc == 0) {
- bundle_pt fwBundle = NULL;
+ celix_bundle_t *fwBundle = NULL;
if(framework_getFrameworkBundle(framework, &fwBundle) == CELIX_SUCCESS){
if(bundle_start(fwBundle) == CELIX_SUCCESS){
- bundle_context_pt context = NULL;
+ celix_bundle_context_t *context = NULL;
bundle_getContext(fwBundle, &context);
struct foo *f = calloc(1, sizeof(*f));
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/hello_world/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/hello_world/private/src/activator.c b/examples/celix-examples/hello_world/private/src/activator.c
index 37cf782..f19118b 100644
--- a/examples/celix-examples/hello_world/private/src/activator.c
+++ b/examples/celix-examples/hello_world/private/src/activator.c
@@ -35,7 +35,7 @@ struct userData {
char * word;
};
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+celix_status_t bundleActivator_create(celix_bundle_context_t *context, void **userData) {
celix_status_t status = CELIX_SUCCESS;
*userData = malloc(sizeof(struct userData));
if (*userData != NULL) {
@@ -46,7 +46,7 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
return status;
}
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+celix_status_t bundleActivator_start(void * userData, celix_bundle_context_t *context) {
struct userData * data = (struct userData *) userData;
printf("Hello %s\n", data->word);
@@ -56,13 +56,13 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
return CELIX_SUCCESS;
}
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+celix_status_t bundleActivator_stop(void * userData, celix_bundle_context_t *context) {
struct userData * data = (struct userData *) userData;
printf("Goodbye %s\n", data->word);
return CELIX_SUCCESS;
}
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+celix_status_t bundleActivator_destroy(void * userData, celix_bundle_context_t *context) {
free(userData);
return CELIX_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/hello_world_test/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/hello_world_test/private/src/activator.c b/examples/celix-examples/hello_world_test/private/src/activator.c
index 2185e16..8ec3546 100644
--- a/examples/celix-examples/hello_world_test/private/src/activator.c
+++ b/examples/celix-examples/hello_world_test/private/src/activator.c
@@ -33,7 +33,7 @@ struct userData {
char * word;
};
-celix_status_t bundleActivator_create(bundle_context_pt __attribute__((unused)) context, void **userData) {
+celix_status_t bundleActivator_create(celix_bundle_context_t __attribute__((unused)) *context, void **userData) {
celix_status_t status = CELIX_SUCCESS;
*userData = malloc(sizeof(struct userData));
if (*userData != NULL) {
@@ -44,20 +44,20 @@ celix_status_t bundleActivator_create(bundle_context_pt __attribute__((unused))
return status;
}
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt __attribute__((unused)) context) {
+celix_status_t bundleActivator_start(void * userData, celix_bundle_context_t __attribute__((unused)) *context) {
struct userData * data = (struct userData *) userData;
printf("Hello %s\n", data->word);
return CELIX_SUCCESS;
}
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt __attribute__((unused)) context) {
+celix_status_t bundleActivator_stop(void * userData, celix_bundle_context_t __attribute__((unused)) *context) {
struct userData * data = (struct userData *) userData;
printf("Goodbye %s\n", data->word);
return CELIX_SUCCESS;
}
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt __attribute__((unused)) context) {
+celix_status_t bundleActivator_destroy(void * userData, celix_bundle_context_t __attribute__((unused)) *context) {
free(userData);
return CELIX_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/log_service_example/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/log_service_example/src/activator.c b/examples/celix-examples/log_service_example/src/activator.c
index 75eaf59..ac7e707 100644
--- a/examples/celix-examples/log_service_example/src/activator.c
+++ b/examples/celix-examples/log_service_example/src/activator.c
@@ -37,7 +37,7 @@ struct userData {
static void *loggerThread(void *userData);
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+celix_status_t bundleActivator_create(celix_bundle_context_t *context, void **userData) {
celix_status_t status = CELIX_SUCCESS;
*userData = calloc(1, sizeof(struct userData));
if (*userData != NULL) {
@@ -50,7 +50,7 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
}
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+celix_status_t bundleActivator_start(void * userData, celix_bundle_context_t *context) {
struct userData * data = (struct userData *) userData;
printf("Started log example\n");
logHelper_start(data->log_helper);
@@ -59,7 +59,7 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
return CELIX_SUCCESS;
}
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+celix_status_t bundleActivator_stop(void * userData, celix_bundle_context_t *context) {
struct userData * data = (struct userData *) userData;
printf("Stopping logger example\n");
data->running = false;
@@ -68,7 +68,7 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context)
return CELIX_SUCCESS;
}
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+celix_status_t bundleActivator_destroy(void * userData, celix_bundle_context_t *context) {
struct userData * data = (struct userData *) userData;
logHelper_destroy(&data->log_helper);
free(userData);
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/service_hook_example/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/service_hook_example/src/activator.c b/examples/celix-examples/service_hook_example/src/activator.c
index f2d2a15..8fe56f2 100644
--- a/examples/celix-examples/service_hook_example/src/activator.c
+++ b/examples/celix-examples/service_hook_example/src/activator.c
@@ -42,7 +42,7 @@ struct userData {
};
-celix_status_t tracker_added(void*hook, array_list_pt listeners) {
+celix_status_t tracker_added(void*hook, celix_array_list_t *listeners) {
for(unsigned int i = 0; i < arrayList_size(listeners); i++) {
listener_hook_info_pt info = arrayList_get(listeners, i);
printf("Added tracker for service %s\n", info->filter);
@@ -51,7 +51,7 @@ celix_status_t tracker_added(void*hook, array_list_pt listeners) {
return CELIX_SUCCESS;
}
-celix_status_t tracker_removed(void*hook, array_list_pt listeners) {
+celix_status_t tracker_removed(void*hook, celix_array_list_t *listeners) {
for(unsigned int i = 0; i < arrayList_size(listeners); i++) {
listener_hook_info_pt info = arrayList_get(listeners, i);
printf("Removed tracker for service %s\n", info->filter);
@@ -60,7 +60,7 @@ celix_status_t tracker_removed(void*hook, array_list_pt listeners) {
return CELIX_SUCCESS;
}
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+celix_status_t bundleActivator_create(celix_bundle_context_t *context, void **userData) {
celix_status_t status = CELIX_SUCCESS;
*userData = malloc(sizeof(struct userData));
if (*userData != NULL) {
@@ -71,7 +71,7 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
return status;
}
-celix_status_t bundleActivator_start(void * handle, bundle_context_pt context) {
+celix_status_t bundleActivator_start(void * handle, celix_bundle_context_t *context) {
printf("Starting hook example bundle\n");
struct userData *userData = (struct userData*)handle;
@@ -116,7 +116,7 @@ celix_status_t bundleActivator_start(void * handle, bundle_context_pt context) {
return CELIX_SUCCESS;
}
-celix_status_t bundleActivator_stop(void * handle, bundle_context_pt context) {
+celix_status_t bundleActivator_stop(void * handle, celix_bundle_context_t *context) {
printf("Stopping hook example bundle\n");
struct userData *userData = (struct userData*)handle;
@@ -131,7 +131,7 @@ celix_status_t bundleActivator_stop(void * handle, bundle_context_pt context) {
return CELIX_SUCCESS;
}
-celix_status_t bundleActivator_destroy(void * handle, bundle_context_pt context) {
+celix_status_t bundleActivator_destroy(void * handle, celix_bundle_context_t *context) {
free(handle);
return CELIX_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/examples/celix-examples/services_example_c/src/dynamic_provider_example.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/src/dynamic_provider_example.c b/examples/celix-examples/services_example_c/src/dynamic_provider_example.c
index 1b09ab9..1c3a289 100644
--- a/examples/celix-examples/services_example_c/src/dynamic_provider_example.c
+++ b/examples/celix-examples/services_example_c/src/dynamic_provider_example.c
@@ -63,7 +63,7 @@ void * run(void *handle) {
bool up = true;
while (isRunning(data)) {
if (up) {
- properties_t *props = properties_create();
+ celix_properties_t *props = properties_create();
celix_properties_setLong(props, OSGI_FRAMEWORK_SERVICE_RANKING, rand());
data->svcIds[i++] = celix_bundleContext_registerService(data->ctx, &data->svc, EXAMPLE_CALC_NAME, props);
} else { //down
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/dependency_manager_cxx/src/dm_activator.cc
----------------------------------------------------------------------
diff --git a/libs/dependency_manager_cxx/src/dm_activator.cc b/libs/dependency_manager_cxx/src/dm_activator.cc
index b7669e3..6ac02c5 100644
--- a/libs/dependency_manager_cxx/src/dm_activator.cc
+++ b/libs/dependency_manager_cxx/src/dm_activator.cc
@@ -30,7 +30,7 @@ struct BundleActivatorData {
std::unique_ptr<celix::dm::DmActivator> act;
};
-extern "C" celix_status_t bundleActivator_create(bundle_context_pt context, void** userData) {
+extern "C" celix_status_t bundleActivator_create(celix_bundle_context_t *context, void** userData) {
int status = CELIX_SUCCESS;
BundleActivatorData* data = nullptr;
@@ -52,9 +52,8 @@ extern "C" celix_status_t bundleActivator_create(bundle_context_pt context, void
if (data == nullptr || data->act == nullptr) {
status = CELIX_ENOMEM;
if (data != nullptr) {
- data->act = nullptr;
+ delete data;
}
- delete data;
*userData = nullptr;
} else {
*userData = data;
@@ -62,7 +61,7 @@ extern "C" celix_status_t bundleActivator_create(bundle_context_pt context, void
return status;
}
-extern "C" celix_status_t bundleActivator_start(void* userData, [[gnu::unused]] bundle_context_pt context) {
+extern "C" celix_status_t bundleActivator_start(void* userData, celix_bundle_context_t *) {
int status = CELIX_SUCCESS;
auto* data = static_cast<BundleActivatorData*>(userData);
if (data != nullptr) {
@@ -71,21 +70,20 @@ extern "C" celix_status_t bundleActivator_start(void* userData, [[gnu::unused]]
return status;
}
-extern "C" celix_status_t bundleActivator_stop(void* userData, [[gnu::unused]] bundle_context_pt context) {
+extern "C" celix_status_t bundleActivator_stop(void* userData, celix_bundle_context_t *) {
int status = CELIX_SUCCESS;
auto* data = static_cast<BundleActivatorData*>(userData);
if (data != nullptr) {
status = data->act->stop();
+ data->act = nullptr;
}
return status;
}
-extern "C" celix_status_t bundleActivator_destroy([[gnu::unused]] void* userData,[[gnu::unused]] bundle_context_pt context ) {
- int status = CELIX_SUCCESS;
+extern "C" celix_status_t bundleActivator_destroy(void *userData, celix_bundle_context_t* ) {
auto* data = static_cast<BundleActivatorData*>(userData);
if (data != nullptr) {
- data->act = nullptr;
+ delete data;
}
- delete data;
- return status;
+ return CELIX_SUCCESS;
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/bundle.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/bundle.h b/libs/framework/include/bundle.h
index 676c8b4..7ea0d1e 100644
--- a/libs/framework/include/bundle.h
+++ b/libs/framework/include/bundle.h
@@ -40,85 +40,85 @@ extern "C" {
struct celix_bundle_activator;
typedef struct celix_bundle_activator celix_bundle_activator_t;
-FRAMEWORK_EXPORT celix_status_t bundle_create(bundle_pt *bundle);
+FRAMEWORK_EXPORT celix_status_t bundle_create(celix_bundle_t **bundle);
FRAMEWORK_EXPORT celix_status_t
-bundle_createFromArchive(bundle_pt *bundle, framework_pt framework, bundle_archive_pt archive);
+bundle_createFromArchive(celix_bundle_t **bundle, celix_framework_t *framework, bundle_archive_pt archive);
-FRAMEWORK_EXPORT celix_status_t bundle_destroy(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_status_t bundle_destroy(celix_bundle_t *bundle);
-FRAMEWORK_EXPORT celix_status_t bundle_isSystemBundle(bundle_pt bundle, bool *systemBundle);
+FRAMEWORK_EXPORT celix_status_t bundle_isSystemBundle(celix_bundle_t *bundle, bool *systemBundle);
-FRAMEWORK_EXPORT celix_status_t bundle_getArchive(bundle_pt bundle, bundle_archive_pt *archive);
+FRAMEWORK_EXPORT celix_status_t bundle_getArchive(celix_bundle_t *bundle, bundle_archive_pt *archive);
-FRAMEWORK_EXPORT celix_status_t bundle_getCurrentModule(bundle_pt bundle, module_pt *module);
+FRAMEWORK_EXPORT celix_status_t bundle_getCurrentModule(celix_bundle_t *bundle, module_pt *module);
-FRAMEWORK_EXPORT array_list_pt bundle_getModules(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_array_list_t *bundle_getModules(celix_bundle_t *bundle);
-FRAMEWORK_EXPORT void *bundle_getHandle(bundle_pt bundle);
+FRAMEWORK_EXPORT void *bundle_getHandle(celix_bundle_t *bundle);
-FRAMEWORK_EXPORT void bundle_setHandle(bundle_pt bundle, void *handle);
+FRAMEWORK_EXPORT void bundle_setHandle(celix_bundle_t *bundle, void *handle);
-FRAMEWORK_EXPORT celix_bundle_activator_t *bundle_getActivator(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_bundle_activator_t *bundle_getActivator(celix_bundle_t *bundle);
-FRAMEWORK_EXPORT celix_status_t bundle_setActivator(bundle_pt bundle, celix_bundle_activator_t *activator);
+FRAMEWORK_EXPORT celix_status_t bundle_setActivator(celix_bundle_t *bundle, celix_bundle_activator_t *activator);
-FRAMEWORK_EXPORT celix_status_t bundle_getContext(bundle_pt bundle, bundle_context_pt *context);
+FRAMEWORK_EXPORT celix_status_t bundle_getContext(celix_bundle_t *bundle, celix_bundle_context_t **context);
-FRAMEWORK_EXPORT celix_status_t bundle_setContext(bundle_pt bundle, bundle_context_pt context);
+FRAMEWORK_EXPORT celix_status_t bundle_setContext(celix_bundle_t *bundle, celix_bundle_context_t *context);
-FRAMEWORK_EXPORT celix_status_t bundle_getEntry(bundle_pt bundle, const char *name, char **entry);
+FRAMEWORK_EXPORT celix_status_t bundle_getEntry(celix_bundle_t *bundle, const char *name, char **entry);
-FRAMEWORK_EXPORT celix_status_t bundle_start(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_status_t bundle_start(celix_bundle_t *bundle);
-FRAMEWORK_EXPORT celix_status_t bundle_startWithOptions(bundle_pt bundle, int options);
+FRAMEWORK_EXPORT celix_status_t bundle_startWithOptions(celix_bundle_t *bundle, int options);
-FRAMEWORK_EXPORT celix_status_t bundle_update(bundle_pt bundle, const char *inputFile);
+FRAMEWORK_EXPORT celix_status_t bundle_update(celix_bundle_t *bundle, const char *inputFile);
-FRAMEWORK_EXPORT celix_status_t bundle_stop(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_status_t bundle_stop(celix_bundle_t *bundle);
-FRAMEWORK_EXPORT celix_status_t bundle_stopWithOptions(bundle_pt bundle, int options);
+FRAMEWORK_EXPORT celix_status_t bundle_stopWithOptions(celix_bundle_t *bundle, int options);
-FRAMEWORK_EXPORT celix_status_t bundle_uninstall(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_status_t bundle_uninstall(celix_bundle_t *bundle);
-FRAMEWORK_EXPORT celix_status_t bundle_setState(bundle_pt bundle, bundle_state_e state);
+FRAMEWORK_EXPORT celix_status_t bundle_setState(celix_bundle_t *bundle, bundle_state_e state);
-FRAMEWORK_EXPORT celix_status_t bundle_setPersistentStateInactive(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_status_t bundle_setPersistentStateInactive(celix_bundle_t *bundle);
-FRAMEWORK_EXPORT celix_status_t bundle_setPersistentStateUninstalled(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_status_t bundle_setPersistentStateUninstalled(celix_bundle_t *bundle);
-FRAMEWORK_EXPORT void uninstallBundle(bundle_pt bundle);
+FRAMEWORK_EXPORT void uninstallBundle(celix_bundle_t *bundle);
-FRAMEWORK_EXPORT celix_status_t bundle_revise(bundle_pt bundle, const char *location, const char *inputFile);
+FRAMEWORK_EXPORT celix_status_t bundle_revise(celix_bundle_t *bundle, const char *location, const char *inputFile);
-FRAMEWORK_EXPORT celix_status_t bundle_addModule(bundle_pt bundle, module_pt module);
+FRAMEWORK_EXPORT celix_status_t bundle_addModule(celix_bundle_t *bundle, module_pt module);
-FRAMEWORK_EXPORT celix_status_t bundle_closeModules(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_status_t bundle_closeModules(celix_bundle_t *bundle);
// Service Reference Functions
-FRAMEWORK_EXPORT array_list_pt getUsingBundles(service_reference_pt reference);
+FRAMEWORK_EXPORT celix_array_list_t *getUsingBundles(service_reference_pt reference);
FRAMEWORK_EXPORT int compareTo(service_reference_pt a, service_reference_pt b);
-FRAMEWORK_EXPORT celix_status_t bundle_getState(bundle_pt bundle, bundle_state_e *state);
+FRAMEWORK_EXPORT celix_status_t bundle_getState(celix_bundle_t *bundle, bundle_state_e *state);
-FRAMEWORK_EXPORT celix_status_t bundle_closeAndDelete(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_status_t bundle_closeAndDelete(celix_bundle_t *bundle);
-FRAMEWORK_EXPORT celix_status_t bundle_close(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_status_t bundle_close(celix_bundle_t *bundle);
-FRAMEWORK_EXPORT celix_status_t bundle_refresh(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_status_t bundle_refresh(celix_bundle_t *bundle);
-FRAMEWORK_EXPORT celix_status_t bundle_getBundleId(bundle_pt bundle, long *id);
+FRAMEWORK_EXPORT celix_status_t bundle_getBundleId(celix_bundle_t *bundle, long *id);
-FRAMEWORK_EXPORT celix_status_t bundle_getRegisteredServices(bundle_pt bundle, array_list_pt *list);
+FRAMEWORK_EXPORT celix_status_t bundle_getRegisteredServices(celix_bundle_t *bundle, celix_array_list_t **list);
-FRAMEWORK_EXPORT celix_status_t bundle_getServicesInUse(bundle_pt bundle, array_list_pt *list);
+FRAMEWORK_EXPORT celix_status_t bundle_getServicesInUse(celix_bundle_t *bundle, celix_array_list_t **list);
-FRAMEWORK_EXPORT celix_status_t bundle_setFramework(bundle_pt bundle, framework_pt framework);
+FRAMEWORK_EXPORT celix_status_t bundle_setFramework(celix_bundle_t *bundle, celix_framework_t *framework);
-FRAMEWORK_EXPORT celix_status_t bundle_getFramework(bundle_pt bundle, framework_pt *framework);
+FRAMEWORK_EXPORT celix_status_t bundle_getFramework(celix_bundle_t *bundle, celix_framework_t **framework);
-FRAMEWORK_EXPORT celix_status_t bundle_getBundleLocation(bundle_pt bundle, const char **location);
+FRAMEWORK_EXPORT celix_status_t bundle_getBundleLocation(celix_bundle_t *bundle, const char **location);
#ifdef __cplusplus
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/bundle_activator.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/bundle_activator.h b/libs/framework/include/bundle_activator.h
index 99ef6bc..ce0e33c 100644
--- a/libs/framework/include/bundle_activator.h
+++ b/libs/framework/include/bundle_activator.h
@@ -36,7 +36,7 @@ extern "C" {
* The activator instance is handle as a void pointer by the framework, the implementation must cast it to the
* implementation specific type.
*
- * @param context The execution context of the bundle being started.
+ * @param ctx The execution context of the bundle being started.
* @param[out] userData A pointer to the specific activator instance used by this bundle.
*
* @return Status code indication failure or success:
@@ -44,7 +44,7 @@ extern "C" {
* - Any other status code will mark the bundle as stopped and the framework will remove this
* bundle's listeners, unregister all services, and release all services used by this bundle.
*/
-ACTIVATOR_EXPORT celix_status_t bundleActivator_create(bundle_context_t *context_ptr, void **userData);
+ACTIVATOR_EXPORT celix_status_t bundleActivator_create(celix_bundle_context_t *ctx, void **userData);
/**
* Called when this bundle is started so the Framework can perform the bundle-specific activities necessary
@@ -55,14 +55,14 @@ ACTIVATOR_EXPORT celix_status_t bundleActivator_create(bundle_context_t *context
* This method must complete and return to its caller in a timely manner.
*
* @param userData The activator instance to be used.
- * @param context The execution context of the bundle being started.
+ * @param ctx The execution context of the bundle being started.
*
* @return Status code indication failure or success:
* - CELIX_SUCCESS when no errors are encountered.
* - Any other status code will mark the bundle as stopped and the framework will remove this
* bundle's listeners, unregister all services, and release all services used by this bundle.
*/
-ACTIVATOR_EXPORT celix_status_t bundleActivator_start(void *userData, bundle_context_t *context);
+ACTIVATOR_EXPORT celix_status_t bundleActivator_start(void *userData, celix_bundle_context_t *ctx);
/**
* Called when this bundle is stopped so the Framework can perform the bundle-specific activities necessary
@@ -74,14 +74,14 @@ ACTIVATOR_EXPORT celix_status_t bundleActivator_start(void *userData, bundle_con
* This method must complete and return to its caller in a timely manner.
*
* @param userData The activator instance to be used.
- * @param context The execution context of the bundle being stopped.
+ * @param ctx The execution context of the bundle being stopped.
*
* @return Status code indication failure or success:
* - CELIX_SUCCESS when no errors are encountered.
* - Any other status code will mark the bundle as stopped and the framework will remove this
* bundle's listeners, unregister all services, and release all services used by this bundle.
*/
-ACTIVATOR_EXPORT celix_status_t bundleActivator_stop(void *userData, bundle_context_t *context);
+ACTIVATOR_EXPORT celix_status_t bundleActivator_stop(void *userData, celix_bundle_context_t *ctx);
/**
* Called when this bundle is stopped so the bundle can destroy the instance of its activator. In general, this
@@ -91,7 +91,7 @@ ACTIVATOR_EXPORT celix_status_t bundleActivator_stop(void *userData, bundle_cont
* This method must complete and return to its caller in a timely manner.
*
* @param userData The activator instance to be used.
- * @param context The execution context of the bundle being stopped.
+ * @param ctx The execution context of the bundle being stopped.
*
* @return Status code indication failure or success:
* - CELIX_SUCCESS when no errors are encountered.
@@ -99,7 +99,7 @@ ACTIVATOR_EXPORT celix_status_t bundleActivator_stop(void *userData, bundle_cont
* bundle's listeners, unregister all services, and release all services used by this bundle.
*/
ACTIVATOR_EXPORT celix_status_t
-bundleActivator_destroy(void *userData, bundle_context_t* context);
+bundleActivator_destroy(void *userData, celix_bundle_context_t* ctx);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/bundle_context.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/bundle_context.h b/libs/framework/include/bundle_context.h
index 97a264b..8c2e3aa 100644
--- a/libs/framework/include/bundle_context.h
+++ b/libs/framework/include/bundle_context.h
@@ -44,27 +44,27 @@ extern "C" {
#endif
celix_status_t
-bundleContext_create(framework_pt framework, framework_logger_pt, bundle_pt bundle, bundle_context_pt *bundle_context);
+bundleContext_create(celix_framework_t *framework, framework_logger_pt, celix_bundle_t *bundle, celix_bundle_context_t **bundle_context);
-celix_status_t bundleContext_destroy(bundle_context_pt context);
+celix_status_t bundleContext_destroy(celix_bundle_context_t *context);
-FRAMEWORK_EXPORT celix_status_t bundleContext_getBundle(bundle_context_pt context, bundle_pt *bundle);
+FRAMEWORK_EXPORT celix_status_t bundleContext_getBundle(celix_bundle_context_t *context, celix_bundle_t **bundle);
-FRAMEWORK_EXPORT celix_status_t bundleContext_getFramework(bundle_context_pt context, framework_pt *framework);
+FRAMEWORK_EXPORT celix_status_t bundleContext_getFramework(celix_bundle_context_t *context, celix_framework_t **framework);
FRAMEWORK_EXPORT celix_status_t
-bundleContext_installBundle(bundle_context_pt context, const char *location, bundle_pt *bundle);
+bundleContext_installBundle(celix_bundle_context_t *context, const char *location, celix_bundle_t **bundle);
FRAMEWORK_EXPORT celix_status_t
-bundleContext_installBundle2(bundle_context_pt context, const char *location, const char *inputFile, bundle_pt *bundle);
+bundleContext_installBundle2(celix_bundle_context_t *context, const char *location, const char *inputFile, celix_bundle_t **bundle);
FRAMEWORK_EXPORT celix_status_t
-bundleContext_registerService(bundle_context_pt context, const char *serviceName, const void *svcObj,
- properties_pt properties, service_registration_pt *service_registration);
+bundleContext_registerService(celix_bundle_context_t *context, const char *serviceName, const void *svcObj,
+ celix_properties_t *properties, service_registration_pt *service_registration);
FRAMEWORK_EXPORT celix_status_t
-bundleContext_registerServiceFactory(bundle_context_pt context, const char *serviceName, service_factory_pt factory,
- properties_pt properties, service_registration_pt *service_registration);
+bundleContext_registerServiceFactory(celix_bundle_context_t *context, const char *serviceName, service_factory_pt factory,
+ celix_properties_t *properties, service_registration_pt *service_registration);
/**
* Get a service reference for the bundle context. When the service reference is no longer needed use bundleContext_ungetServiceReference.
@@ -75,7 +75,7 @@ bundleContext_registerServiceFactory(bundle_context_pt context, const char *serv
* @param service_reference _output_ The found service reference, or NULL when no service is found.
* @return CELIX_SUCCESS on success
*/
-FRAMEWORK_EXPORT celix_status_t bundleContext_getServiceReference(bundle_context_pt context, const char *serviceName,
+FRAMEWORK_EXPORT celix_status_t bundleContext_getServiceReference(celix_bundle_context_t *context, const char *serviceName,
service_reference_pt *service_reference);
/** Same as bundleContext_getServiceReference, but than for a optional serviceName combined with a optional filter.
@@ -88,8 +88,8 @@ FRAMEWORK_EXPORT celix_status_t bundleContext_getServiceReference(bundle_context
* @return CELIX_SUCCESS on success
*/
FRAMEWORK_EXPORT celix_status_t
-bundleContext_getServiceReferences(bundle_context_pt context, const char *serviceName, const char *filter,
- array_list_pt *service_references);
+bundleContext_getServiceReferences(celix_bundle_context_t *context, const char *serviceName, const char *filter,
+ celix_array_list_t **service_references);
/**
* Retains (increases the ref count) the provided service reference. Can be used to retain a service reference.
@@ -100,7 +100,7 @@ bundleContext_getServiceReferences(bundle_context_pt context, const char *servic
* @return CELIX_SUCCES on success
*/
FRAMEWORK_EXPORT celix_status_t
-bundleContext_retainServiceReference(bundle_context_pt context, service_reference_pt reference);
+bundleContext_retainServiceReference(celix_bundle_context_t *context, service_reference_pt reference);
/**
* Ungets the service references. If the ref counter of the service refernce goes to 0, the reference will be destroyed.
@@ -112,34 +112,34 @@ bundleContext_retainServiceReference(bundle_context_pt context, service_referenc
* @return CELIX_SUCCESS on success.
*/
FRAMEWORK_EXPORT celix_status_t
-bundleContext_ungetServiceReference(bundle_context_pt context, service_reference_pt reference);
+bundleContext_ungetServiceReference(celix_bundle_context_t *context, service_reference_pt reference);
FRAMEWORK_EXPORT celix_status_t
-bundleContext_getService(bundle_context_pt context, service_reference_pt reference, void **service_instance);
+bundleContext_getService(celix_bundle_context_t *context, service_reference_pt reference, void **service_instance);
FRAMEWORK_EXPORT celix_status_t
-bundleContext_ungetService(bundle_context_pt context, service_reference_pt reference, bool *result);
+bundleContext_ungetService(celix_bundle_context_t *context, service_reference_pt reference, bool *result);
-FRAMEWORK_EXPORT celix_status_t bundleContext_getBundles(bundle_context_pt context, array_list_pt *bundles);
+FRAMEWORK_EXPORT celix_status_t bundleContext_getBundles(celix_bundle_context_t *context, celix_array_list_t **bundles);
-FRAMEWORK_EXPORT celix_status_t bundleContext_getBundleById(bundle_context_pt context, long id, bundle_pt *bundle);
+FRAMEWORK_EXPORT celix_status_t bundleContext_getBundleById(celix_bundle_context_t *context, long id, celix_bundle_t **bundle);
FRAMEWORK_EXPORT celix_status_t
-bundleContext_addServiceListener(bundle_context_pt context, celix_service_listener_t *listener, const char *filter);
+bundleContext_addServiceListener(celix_bundle_context_t *context, celix_service_listener_t *listener, const char *filter);
FRAMEWORK_EXPORT celix_status_t
-bundleContext_removeServiceListener(bundle_context_pt context, celix_service_listener_t *listener);
+bundleContext_removeServiceListener(celix_bundle_context_t *context, celix_service_listener_t *listener);
-FRAMEWORK_EXPORT celix_status_t bundleContext_addBundleListener(bundle_context_pt context, bundle_listener_pt listener);
+FRAMEWORK_EXPORT celix_status_t bundleContext_addBundleListener(celix_bundle_context_t *context, bundle_listener_pt listener);
FRAMEWORK_EXPORT celix_status_t
-bundleContext_removeBundleListener(bundle_context_pt context, bundle_listener_pt listener);
+bundleContext_removeBundleListener(celix_bundle_context_t *context, bundle_listener_pt listener);
FRAMEWORK_EXPORT celix_status_t
-bundleContext_addFrameworkListener(bundle_context_pt context, framework_listener_pt listener);
+bundleContext_addFrameworkListener(celix_bundle_context_t *context, framework_listener_pt listener);
FRAMEWORK_EXPORT celix_status_t
-bundleContext_removeFrameworkListener(bundle_context_pt context, framework_listener_pt listener);
+bundleContext_removeFrameworkListener(celix_bundle_context_t *context, framework_listener_pt listener);
/**
* Gets the config property - or environment variable if the config property does not exist - for the provided name.
@@ -150,7 +150,7 @@ bundleContext_removeFrameworkListener(bundle_context_pt context, framework_liste
* @return 0 if successful.
*/
FRAMEWORK_EXPORT celix_status_t
-bundleContext_getProperty(bundle_context_pt context, const char *name, const char **value);
+bundleContext_getProperty(celix_bundle_context_t *context, const char *name, const char **value);
/**
* Gets the config property - or environment variable if the config property does not exist - for the provided name.
@@ -162,7 +162,7 @@ bundleContext_getProperty(bundle_context_pt context, const char *name, const cha
* @return 0 if successful.
*/
FRAMEWORK_EXPORT celix_status_t
-bundleContext_getPropertyWithDefault(bundle_context_pt context, const char *name, const char *defaultValue, const char **value);
+bundleContext_getPropertyWithDefault(celix_bundle_context_t *context, const char *name, const char *defaultValue, const char **value);
#ifdef __cplusplus
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/bundle_revision.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/bundle_revision.h b/libs/framework/include/bundle_revision.h
index 7c67a94..b18eb45 100644
--- a/libs/framework/include/bundle_revision.h
+++ b/libs/framework/include/bundle_revision.h
@@ -123,13 +123,13 @@ celix_status_t bundleRevision_getManifest(bundle_revision_pt revision, manifest_
* Retrieves the handles of the installed libraries for this revision.
*
* @param revision The revision to get the manifest for.
- * @param[out] handles array_list_pt containing the handles.
+ * @param[out] handles celix_array_list_t *containing the handles.
*
* @return Status code indication failure or success:
* - CELIX_SUCCESS when no errors are encountered.
* - CELIX_ILLEGAL_ARGUMENT If <code>revision</code> is illegal.
*/
-celix_status_t bundleRevision_getHandles(bundle_revision_pt revision, array_list_pt *handles);
+celix_status_t bundleRevision_getHandles(bundle_revision_pt revision, celix_array_list_t **handles);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix/dm/Component.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix/dm/Component.h b/libs/framework/include/celix/dm/Component.h
index 85723f9..d5df319 100644
--- a/libs/framework/include/celix/dm/Component.h
+++ b/libs/framework/include/celix/dm/Component.h
@@ -31,12 +31,12 @@ namespace celix { namespace dm {
class BaseComponent {
private:
- bundle_context_pt context {nullptr};
- dm_component_pt cCmp {nullptr};
+ celix_bundle_context_t *context {nullptr};
+ celix_dm_component_t *cCmp {nullptr};
public:
- BaseComponent(const bundle_context_pt con, std::string name) : context{con}, cCmp{nullptr} {
- component_create(this->context, name.c_str(), &this->cCmp);
- component_setImplementation(this->cCmp, this);
+ BaseComponent(celix_bundle_context_t *con, std::string name) : context{con}, cCmp{nullptr} {
+ this->cCmp = celix_dmComponent_create(this->context, name.c_str());
+ celix_dmComponent_setImplementation(this->cCmp, this);
}
virtual ~BaseComponent() {}
@@ -46,12 +46,12 @@ namespace celix { namespace dm {
/**
* Returns the C DM Component
*/
- dm_component_pt cComponent() const { return this->cCmp; }
+ celix_dm_component_t* cComponent() const { return this->cCmp; }
/**
* Returns the C bundle context
*/
- bundle_context_pt bundleContext() const { return this->context; }
+ celix_bundle_context_t* bundleContext() const { return this->context; }
};
@@ -74,7 +74,7 @@ namespace celix { namespace dm {
int (T::*stopFpNoExc)() = {};
int (T::*deinitFpNoExc)() = {};
public:
- Component(const bundle_context_pt context, std::string name);
+ Component(celix_bundle_context_t *context, std::string name);
virtual ~Component();
/**
@@ -83,14 +83,14 @@ namespace celix { namespace dm {
* Will use new(nothrow) if exceptions are disabled.
* @return newly created DM Component or nullptr
*/
- static Component<T>* create(bundle_context_pt, std::string name);
+ static Component<T>* create(celix_bundle_context_t*, std::string name);
/**
* Creates a Component using the provided bundle context.
* Will use new(nothrow) if exceptions are disabled.
* @return newly created DM Component or nullptr
*/
- static Component<T>* create(bundle_context_pt);
+ static Component<T>* create(celix_bundle_context_t*);
/**
* Wether the component is valid. Invalid component can occurs when no new components can be created and
[2/4] celix git commit: CELIX-438: Add a dependency manager API with
the celix prefix. Also add a compile options to enable deprecated compiler
warning for the 'old' api.
Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/service_registry.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/service_registry.h b/libs/framework/include/service_registry.h
index 5a3c790..81bbe3c 100644
--- a/libs/framework/include/service_registry.h
+++ b/libs/framework/include/service_registry.h
@@ -42,62 +42,62 @@ typedef struct celix_serviceRegistry celix_service_registry_t;
extern "C" {
#endif
-typedef void (*serviceChanged_function_pt)(framework_pt, celix_service_event_type_t, service_registration_pt, properties_pt);
+typedef void (*serviceChanged_function_pt)(celix_framework_t*, celix_service_event_type_t, service_registration_pt, celix_properties_t*);
-celix_status_t serviceRegistry_create(framework_pt framework, serviceChanged_function_pt serviceChanged,
+celix_status_t serviceRegistry_create(celix_framework_t *framework, serviceChanged_function_pt serviceChanged,
service_registry_pt *registry);
celix_status_t serviceRegistry_destroy(service_registry_pt registry);
celix_status_t
-serviceRegistry_getRegisteredServices(service_registry_pt registry, bundle_pt bundle, array_list_pt *services);
+serviceRegistry_getRegisteredServices(service_registry_pt registry, celix_bundle_t *bundle, celix_array_list_t **services);
celix_status_t
-serviceRegistry_getServicesInUse(service_registry_pt registry, bundle_pt bundle, array_list_pt *services);
+serviceRegistry_getServicesInUse(service_registry_pt registry, celix_bundle_t *bundle, celix_array_list_t **services);
-celix_status_t serviceRegistry_registerService(service_registry_pt registry, bundle_pt bundle, const char *serviceName,
- const void *serviceObject, properties_pt dictionary,
+celix_status_t serviceRegistry_registerService(service_registry_pt registry, celix_bundle_t *bundle, const char *serviceName,
+ const void *serviceObject, celix_properties_t *dictionary,
service_registration_pt *registration);
celix_status_t
-serviceRegistry_registerServiceFactory(service_registry_pt registry, bundle_pt bundle, const char *serviceName,
- service_factory_pt factory, properties_pt dictionary,
+serviceRegistry_registerServiceFactory(service_registry_pt registry, celix_bundle_t *bundle, const char *serviceName,
+ service_factory_pt factory, celix_properties_t *dictionary,
service_registration_pt *registration);
celix_status_t
-serviceRegistry_unregisterService(service_registry_pt registry, bundle_pt bundle, service_registration_pt registration);
+serviceRegistry_unregisterService(service_registry_pt registry, celix_bundle_t *bundle, service_registration_pt registration);
-celix_status_t serviceRegistry_clearServiceRegistrations(service_registry_pt registry, bundle_pt bundle);
+celix_status_t serviceRegistry_clearServiceRegistrations(service_registry_pt registry, celix_bundle_t *bundle);
-celix_status_t serviceRegistry_getServiceReference(service_registry_pt registry, bundle_pt bundle,
+celix_status_t serviceRegistry_getServiceReference(service_registry_pt registry, celix_bundle_t *bundle,
service_registration_pt registration,
service_reference_pt *reference);
celix_status_t
-serviceRegistry_getServiceReferences(service_registry_pt registry, bundle_pt bundle, const char *serviceName,
- filter_pt filter, array_list_pt *references);
+serviceRegistry_getServiceReferences(service_registry_pt registry, celix_bundle_t *bundle, const char *serviceName,
+ filter_pt filter, celix_array_list_t **references);
celix_status_t
-serviceRegistry_retainServiceReference(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference);
+serviceRegistry_retainServiceReference(service_registry_pt registry, celix_bundle_t *bundle, service_reference_pt reference);
celix_status_t
-serviceRegistry_ungetServiceReference(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference);
+serviceRegistry_ungetServiceReference(service_registry_pt registry, celix_bundle_t *bundle, service_reference_pt reference);
celix_status_t
-serviceRegistry_getService(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference,
+serviceRegistry_getService(service_registry_pt registry, celix_bundle_t *bundle, service_reference_pt reference,
const void **service);
celix_status_t
-serviceRegistry_ungetService(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference,
+serviceRegistry_ungetService(service_registry_pt registry, celix_bundle_t *bundle, service_reference_pt reference,
bool *result);
-celix_status_t serviceRegistry_clearReferencesFor(service_registry_pt registry, bundle_pt bundle);
+celix_status_t serviceRegistry_clearReferencesFor(service_registry_pt registry, celix_bundle_t *bundle);
-celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry, bundle_pt bundle, array_list_pt *hooks);
+celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry, celix_bundle_t *bundle, celix_array_list_t **hooks);
celix_status_t
serviceRegistry_servicePropertiesModified(service_registry_pt registry, service_registration_pt registration,
- properties_pt oldprops);
+ celix_properties_t *oldprops);
celix_status_t
celix_serviceRegistry_registerServiceFactory(
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/service_tracker.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/service_tracker.h b/libs/framework/include/service_tracker.h
index 40559db..09278b1 100644
--- a/libs/framework/include/service_tracker.h
+++ b/libs/framework/include/service_tracker.h
@@ -45,11 +45,11 @@ typedef struct celix_serviceTracker *service_tracker_pt;
typedef struct celix_serviceTracker service_tracker_t;
FRAMEWORK_EXPORT celix_status_t
-serviceTracker_create(bundle_context_t *ctx, const char *service, service_tracker_customizer_pt customizer,
+serviceTracker_create(celix_bundle_context_t *ctx, const char *service, service_tracker_customizer_pt customizer,
service_tracker_t **tracker);
FRAMEWORK_EXPORT celix_status_t
-serviceTracker_createWithFilter(bundle_context_t *ctx, const char *filter, service_tracker_customizer_pt customizer,
+serviceTracker_createWithFilter(celix_bundle_context_t *ctx, const char *filter, service_tracker_customizer_pt customizer,
service_tracker_t **tracker);
FRAMEWORK_EXPORT celix_status_t serviceTracker_open(service_tracker_t *tracker);
@@ -60,11 +60,11 @@ FRAMEWORK_EXPORT celix_status_t serviceTracker_destroy(service_tracker_t *tracke
FRAMEWORK_EXPORT service_reference_pt serviceTracker_getServiceReference(service_tracker_t *tracker);
-FRAMEWORK_EXPORT array_list_pt serviceTracker_getServiceReferences(service_tracker_t *tracker);
+FRAMEWORK_EXPORT celix_array_list_t *serviceTracker_getServiceReferences(service_tracker_t *tracker);
FRAMEWORK_EXPORT void *serviceTracker_getService(service_tracker_t *tracker);
-FRAMEWORK_EXPORT array_list_pt serviceTracker_getServices(service_tracker_t *tracker);
+FRAMEWORK_EXPORT celix_array_list_t *serviceTracker_getServices(service_tracker_t *tracker);
FRAMEWORK_EXPORT void *serviceTracker_getServiceByReference(service_tracker_t *tracker, service_reference_pt reference);
@@ -83,7 +83,7 @@ FRAMEWORK_EXPORT void serviceTracker_serviceChanged(celix_service_listener_t *li
* Note that is different from the serviceTracker_create function, because is also starts the service tracker
*/
celix_service_tracker_t* celix_serviceTracker_create(
- bundle_context_t *ctx,
+ celix_bundle_context_t *ctx,
const char *serviceName,
const char *versionRange,
const char *filter
@@ -95,7 +95,7 @@ celix_service_tracker_t* celix_serviceTracker_create(
* Note that is different from the serviceTracker_create function, because is also starts the service tracker
*/
celix_service_tracker_t* celix_serviceTracker_createWithOptions(
- bundle_context_t *ctx,
+ celix_bundle_context_t *ctx,
const celix_service_tracking_options_t *opts
);
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/private/mock/dm_dependency_manager_mock.c
----------------------------------------------------------------------
diff --git a/libs/framework/private/mock/dm_dependency_manager_mock.c b/libs/framework/private/mock/dm_dependency_manager_mock.c
index 8f87c8c..2f56396 100644
--- a/libs/framework/private/mock/dm_dependency_manager_mock.c
+++ b/libs/framework/private/mock/dm_dependency_manager_mock.c
@@ -22,20 +22,20 @@
#include "dm_dependency_manager.h"
-celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_t *manager) {
- mock_c()->actualCall("dependencyManager_removeAllComponents")
- ->withPointerParameters("manager", manager);
- return mock_c()->returnValue().value.intValue;
-}
-celix_status_t dependencyManager_create(bundle_context_t *context, dm_dependency_manager_t **manager) {
- mock_c()->actualCall("dependencyManager_create")
- ->withPointerParameters("context", context)
- ->withOutputParameter("manager", (void **) manager);
- return mock_c()->returnValue().value.intValue;
+celix_dependency_manager_t* celix_private_dependencyManager_create(celix_bundle_context_t *context) {
+ mock_c()->actualCall("celix_private_dependencyManager_create")
+ ->withPointerParameters("context", context);
+ return mock_c()->returnValue().value.pointerValue;
}
-void dependencyManager_destroy(dm_dependency_manager_t *manager) {
- mock_c()->actualCall("dependencyManager_destroy")
+void celix_private_dependencyManager_destroy(celix_dependency_manager_t *manager) {
+ mock_c()->actualCall("celix_private_dependencyManager_destroy")
->withPointerParameters("manager", manager);
}
+
+celix_status_t celix_dependencyManager_removeAllComponents(celix_dependency_manager_t *manager) {
+ mock_c()->actualCall("celix_dependencyManager_removeAllComponents")
+ ->withPointerParameters("manager", manager);
+ return mock_c()->returnValue().value.intValue;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/src/bundle_context.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/bundle_context.c b/libs/framework/src/bundle_context.c
index 83503a5..ced4382 100644
--- a/libs/framework/src/bundle_context.c
+++ b/libs/framework/src/bundle_context.c
@@ -30,7 +30,8 @@
#include "celix_bundle.h"
#include "celix_log.h"
#include "service_tracker.h"
-#include "dm_dependency_manager.h"
+#include "celix_dependency_manager.h"
+#include "dm_dependency_manager_impl.h"
#include "celix_array_list.h"
static celix_status_t bundleContext_bundleChanged(void *handle, bundle_event_t *event);
@@ -91,8 +92,8 @@ celix_status_t bundleContext_destroy(bundle_context_pt context) {
arrayList_destroy(context->svcRegistrations);
if (context->mng != NULL) {
- dependencyManager_removeAllComponents(context->mng);
- dependencyManager_destroy(context->mng);
+ celix_dependencyManager_removeAllComponents(context->mng);
+ celix_private_dependencyManager_destroy(context->mng);
context->mng = NULL;
}
@@ -506,12 +507,12 @@ void celix_bundleContext_unregisterService(bundle_context_t *ctx, long serviceId
}
}
-dm_dependency_manager_t* celix_bundleContext_getDependencyManager(bundle_context_t *ctx) {
- dm_dependency_manager_t* result = NULL;
+celix_dependency_manager_t* celix_bundleContext_getDependencyManager(bundle_context_t *ctx) {
+ celix_dependency_manager_t* result = NULL;
if (ctx != NULL) {
celixThreadMutex_lock(&ctx->mutex);
if (ctx->mng == NULL) {
- dependencyManager_create(ctx, &ctx->mng);
+ ctx->mng = celix_private_dependencyManager_create(ctx);
}
if (ctx->mng == NULL) {
framework_logIfError(logger, CELIX_BUNDLE_EXCEPTION, NULL, "Cannot create dependency manager");
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/src/bundle_context_private.h
----------------------------------------------------------------------
diff --git a/libs/framework/src/bundle_context_private.h b/libs/framework/src/bundle_context_private.h
index f32a347..4f6baf8 100644
--- a/libs/framework/src/bundle_context_private.h
+++ b/libs/framework/src/bundle_context_private.h
@@ -53,13 +53,13 @@ typedef struct celix_bundle_context_service_tracker_tracker_entry {
void (*remove)(void *handle, const celix_service_tracker_info_t *info);
} celix_bundle_context_service_tracker_tracker_entry_t;
-struct bundleContext {
- struct framework * framework;
- struct bundle * bundle;
+struct celix_bundle_context {
+ celix_framework_t *framework;
+ celix_bundle_t *bundle;
celix_thread_mutex_t mutex; //protects fields below
array_list_t *svcRegistrations;
- dm_dependency_manager_t *mng;
+ celix_dependency_manager_t *mng;
long nextTrackerId;
hash_map_t *bundleTrackers; //key = trackerId, value = celix_bundle_context_bundle_tracker_entry_t*
hash_map_t *serviceTrackers; //key = trackerId, value = celix_service_tracker_t*
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/src/bundle_private.h
----------------------------------------------------------------------
diff --git a/libs/framework/src/bundle_private.h b/libs/framework/src/bundle_private.h
index 82bf391..bb55d5e 100644
--- a/libs/framework/src/bundle_private.h
+++ b/libs/framework/src/bundle_private.h
@@ -26,7 +26,7 @@
-struct bundle {
+struct celix_bundle {
bundle_context_pt context;
struct celix_bundle_activator *activator;
bundle_state_e state;
@@ -35,7 +35,7 @@ struct bundle {
array_list_pt modules;
manifest_pt manifest;
- struct framework * framework;
+ celix_framework_t *framework;
};
#endif /* BUNDLE_PRIVATE_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/src/dm_component_impl.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/dm_component_impl.c b/libs/framework/src/dm_component_impl.c
index e853a60..f6ec79e 100644
--- a/libs/framework/src/dm_component_impl.c
+++ b/libs/framework/src/dm_component_impl.c
@@ -35,7 +35,7 @@
typedef struct dm_executor_struct * dm_executor_pt;
-struct dm_component_struct {
+struct celix_dm_component_struct {
char id[DM_COMPONENT_MAX_ID_LENGTH];
char name[DM_COMPONENT_MAX_NAME_LENGTH];
bundle_context_pt context;
@@ -43,15 +43,15 @@ struct dm_component_struct {
void* implementation;
- init_fpt callbackInit;
- start_fpt callbackStart;
- stop_fpt callbackStop;
- deinit_fpt callbackDeinit;
+ celix_dm_cmp_lifecycle_fpt callbackInit;
+ celix_dm_cmp_lifecycle_fpt callbackStart;
+ celix_dm_cmp_lifecycle_fpt callbackStop;
+ celix_dm_cmp_lifecycle_fpt callbackDeinit;
array_list_pt dependencies; //protected by mutex
pthread_mutex_t mutex;
- dm_component_state_t state;
+ celix_dm_component_state_t state;
bool isStarted;
bool active;
@@ -77,102 +77,105 @@ struct dm_executor_struct {
};
typedef struct dm_executor_task_struct {
- dm_component_pt component;
+ celix_dm_component_t *component;
void (*command)(void *command_ptr, void *data);
void *data;
} dm_executor_task_t;
typedef struct dm_handle_event_type_struct {
- dm_service_dependency_pt dependency;
+ celix_dm_service_dependency_t *dependency;
dm_event_pt event;
dm_event_pt newEvent;
} *dm_handle_event_type_pt;
static celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t currentThread __attribute__((unused)));
static celix_status_t executor_execute(dm_executor_pt executor);
-static celix_status_t executor_executeTask(dm_executor_pt executor, dm_component_pt component, void (*command), void *data);
-static celix_status_t executor_schedule(dm_executor_pt executor, dm_component_pt component, void (*command), void *data);
-static celix_status_t executor_create(dm_component_pt component __attribute__((unused)), dm_executor_pt *executor);
+static celix_status_t executor_executeTask(dm_executor_pt executor, celix_dm_component_t *component, void (*command), void *data);
+static celix_status_t executor_schedule(dm_executor_pt executor, celix_dm_component_t *component, void (*command), void *data);
+static celix_status_t executor_create(celix_dm_component_t *component __attribute__((unused)), dm_executor_pt *executor);
static void executor_destroy(dm_executor_pt executor);
-static celix_status_t component_invokeRemoveRequiredDependencies(dm_component_pt component);
-static celix_status_t component_invokeRemoveInstanceBoundDependencies(dm_component_pt component);
-static celix_status_t component_invokeRemoveOptionalDependencies(dm_component_pt component);
-static celix_status_t component_registerServices(dm_component_pt component);
-static celix_status_t component_unregisterServices(dm_component_pt component);
-static celix_status_t component_invokeAddOptionalDependencies(dm_component_pt component);
-static celix_status_t component_invokeAddRequiredInstanceBoundDependencies(dm_component_pt component);
-static celix_status_t component_invokeAddRequiredDependencies(dm_component_pt component);
-static celix_status_t component_invokeAutoConfigInstanceBoundDependencies(dm_component_pt component);
-static celix_status_t component_invokeAutoConfigDependencies(dm_component_pt component);
-static celix_status_t component_configureImplementation(dm_component_pt component, dm_service_dependency_pt dependency);
-static celix_status_t component_allInstanceBoundAvailable(dm_component_pt component, bool *available);
-static celix_status_t component_allRequiredAvailable(dm_component_pt component, bool *available);
-static celix_status_t component_performTransition(dm_component_pt component, dm_component_state_t oldState, dm_component_state_t newState, bool *transition);
-static celix_status_t component_calculateNewState(dm_component_pt component, dm_component_state_t currentState, dm_component_state_t *newState);
-static celix_status_t component_handleChange(dm_component_pt component);
-static celix_status_t component_startDependencies(dm_component_pt component __attribute__((unused)), array_list_pt dependencies);
-static celix_status_t component_getDependencyEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt *event_pptr);
-static celix_status_t component_updateInstance(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, bool update, bool add);
-
-static celix_status_t component_addTask(dm_component_pt component, dm_service_dependency_pt dep);
-static celix_status_t component_startTask(dm_component_pt component, void * data __attribute__((unused)));
-static celix_status_t component_stopTask(dm_component_pt component, void * data __attribute__((unused)));
-static celix_status_t component_removeTask(dm_component_pt component, dm_service_dependency_pt dependency);
-static celix_status_t component_handleEventTask(dm_component_pt component, dm_handle_event_type_pt data);
-
-static celix_status_t component_handleAdded(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
-static celix_status_t component_handleChanged(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
-static celix_status_t component_handleRemoved(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
-static celix_status_t component_handleSwapped(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent);
-
-static celix_status_t component_suspend(dm_component_pt component, dm_service_dependency_pt dependency);
-static celix_status_t component_resume(dm_component_pt component, dm_service_dependency_pt dependency);
-
-celix_status_t component_create(bundle_context_pt context, const char *name, dm_component_pt *out) {
- celix_status_t status = CELIX_SUCCESS;
-
- dm_component_pt component = calloc(1, sizeof(*component));
-
- if (!component) {
- status = CELIX_ENOMEM;
- } else {
- snprintf(component->id, DM_COMPONENT_MAX_ID_LENGTH, "%p", component);
- snprintf(component->name, DM_COMPONENT_MAX_NAME_LENGTH, "%s", name == NULL ? "n/a" : name);
-
- component->context = context;
-
- arrayList_create(&component->dm_interfaces);
- arrayList_create(&(component)->dependencies);
- pthread_mutex_init(&(component)->mutex, NULL);
-
- component->implementation = NULL;
-
- component->callbackInit = NULL;
- component->callbackStart = NULL;
- component->callbackStop = NULL;
- component->callbackDeinit = NULL;
-
- component->state = DM_CMP_STATE_INACTIVE;
- component->isStarted = false;
- component->active = false;
+static celix_status_t component_invokeRemoveRequiredDependencies(celix_dm_component_t *component);
+static celix_status_t component_invokeRemoveInstanceBoundDependencies(celix_dm_component_t *component);
+static celix_status_t component_invokeRemoveOptionalDependencies(celix_dm_component_t *component);
+static celix_status_t component_registerServices(celix_dm_component_t *component);
+static celix_status_t component_unregisterServices(celix_dm_component_t *component);
+static celix_status_t component_invokeAddOptionalDependencies(celix_dm_component_t *component);
+static celix_status_t component_invokeAddRequiredInstanceBoundDependencies(celix_dm_component_t *component);
+static celix_status_t component_invokeAddRequiredDependencies(celix_dm_component_t *component);
+static celix_status_t component_invokeAutoConfigInstanceBoundDependencies(celix_dm_component_t *component);
+static celix_status_t component_invokeAutoConfigDependencies(celix_dm_component_t *component);
+static celix_status_t component_configureImplementation(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency);
+static celix_status_t component_allInstanceBoundAvailable(celix_dm_component_t *component, bool *available);
+static celix_status_t component_allRequiredAvailable(celix_dm_component_t *component, bool *available);
+static celix_status_t component_performTransition(celix_dm_component_t *component, celix_dm_component_state_t oldState, celix_dm_component_state_t newState, bool *transition);
+static celix_status_t component_calculateNewState(celix_dm_component_t *component, celix_dm_component_state_t currentState, celix_dm_component_state_t *newState);
+static celix_status_t component_handleChange(celix_dm_component_t *component);
+static celix_status_t component_startDependencies(celix_dm_component_t *component __attribute__((unused)), array_list_pt dependencies);
+static celix_status_t component_getDependencyEvent(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency, dm_event_pt *event_pptr);
+static celix_status_t component_updateInstance(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency, dm_event_pt event, bool update, bool add);
+
+static celix_status_t component_addTask(celix_dm_component_t *component, celix_dm_service_dependency_t *dep);
+static celix_status_t component_startTask(celix_dm_component_t *component, void * data __attribute__((unused)));
+static celix_status_t component_stopTask(celix_dm_component_t *component, void * data __attribute__((unused)));
+static celix_status_t component_removeTask(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency);
+static celix_status_t component_handleEventTask(celix_dm_component_t *component, dm_handle_event_type_pt data);
+
+static celix_status_t component_handleAdded(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency, dm_event_pt event);
+static celix_status_t component_handleChanged(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency, dm_event_pt event);
+static celix_status_t component_handleRemoved(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency, dm_event_pt event);
+static celix_status_t component_handleSwapped(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency, dm_event_pt event, dm_event_pt newEvent);
+
+static celix_status_t component_suspend(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency);
+static celix_status_t component_resume(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency);
+
+celix_dm_component_t* celix_dmComponent_create(bundle_context_t *context, const char* name) {
+ celix_dm_component_t *component = calloc(1, sizeof(*component));
+ snprintf(component->id, DM_COMPONENT_MAX_ID_LENGTH, "%p", component);
+ snprintf(component->name, DM_COMPONENT_MAX_NAME_LENGTH, "%s", name == NULL ? "n/a" : name);
+
+ component->context = context;
+
+ arrayList_create(&component->dm_interfaces);
+ arrayList_create(&(component)->dependencies);
+ pthread_mutex_init(&(component)->mutex, NULL);
+
+ component->implementation = NULL;
+
+ component->callbackInit = NULL;
+ component->callbackStart = NULL;
+ component->callbackStop = NULL;
+ component->callbackDeinit = NULL;
+
+ component->state = DM_CMP_STATE_INACTIVE;
+ component->isStarted = false;
+ component->active = false;
- component->setCLanguageProperty = false;
+ component->setCLanguageProperty = false;
- component->dependencyEvents = hashMap_create(NULL, NULL, NULL, NULL);
+ component->dependencyEvents = hashMap_create(NULL, NULL, NULL, NULL);
- component->executor = NULL;
- executor_create(component, &component->executor);
- }
+ component->executor = NULL;
+ executor_create(component, &component->executor);
+ return component;
+}
- if (status == CELIX_SUCCESS) {
- *out = component;
+celix_status_t component_create(bundle_context_pt context, const char *name, celix_dm_component_t **out) {
+ celix_status_t status = CELIX_SUCCESS;
+ celix_dm_component_t *cmp = celix_dmComponent_create(context, name);
+ if (cmp == NULL) {
+ status = CELIX_BUNDLE_EXCEPTION;
+ } else {
+ *out = cmp;
}
-
return status;
}
-void component_destroy(dm_component_pt component) {
+void component_destroy(celix_dm_component_t *component) {
+ celix_dmComponent_destroy(component);
+}
+
+void celix_dmComponent_destroy(celix_dm_component_t *component) {
if (component) {
unsigned int i;
@@ -192,7 +195,7 @@ void component_destroy(dm_component_pt component) {
hash_map_iterator_pt iter = hashMapIterator_create(component->dependencyEvents);
while(hashMapIterator_hasNext(iter)){
hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
- dm_service_dependency_pt sdep = (dm_service_dependency_pt)hashMapEntry_getKey(entry);
+ celix_dm_service_dependency_t *sdep = (celix_dm_service_dependency_t*)hashMapEntry_getKey(entry);
array_list_pt eventList = (array_list_pt)hashMapEntry_getValue(entry);
serviceDependency_destroy(&sdep);
arrayList_destroy(eventList);
@@ -208,7 +211,12 @@ void component_destroy(dm_component_pt component) {
}
}
-celix_status_t component_addServiceDependency(dm_component_pt component, dm_service_dependency_pt dep) {
+celix_status_t component_addServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dep) {
+ return celix_dmComponent_addServiceDependency(component, dep);
+}
+
+celix_status_t celix_dmComponent_addServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dep) {
+
celix_status_t status = CELIX_SUCCESS;
executor_executeTask(component->executor, component, component_addTask, dep);
@@ -217,7 +225,7 @@ celix_status_t component_addServiceDependency(dm_component_pt component, dm_serv
}
-static celix_status_t component_addTask(dm_component_pt component, dm_service_dependency_pt dep) {
+static celix_status_t component_addTask(celix_dm_component_t *component, celix_dm_service_dependency_t *dep) {
celix_status_t status = CELIX_SUCCESS;
array_list_pt bounds = NULL;
@@ -245,19 +253,35 @@ static celix_status_t component_addTask(dm_component_pt component, dm_service_de
return status;
}
-dm_component_state_t component_currentState(dm_component_pt cmp) {
+celix_dm_component_state_t component_currentState(celix_dm_component_t *cmp) {
+ return celix_dmComponent_currentState(cmp);
+}
+
+celix_dm_component_state_t celix_dmComponent_currentState(celix_dm_component_t *cmp) {
return cmp->state;
}
-void * component_getImplementation(dm_component_pt cmp) {
+void* component_getImplementation(celix_dm_component_t *cmp) {
+ return celix_dmComponent_getImplementation(cmp);
+}
+
+void* celix_dmComponent_getImplementation(celix_dm_component_t *cmp) {
return cmp->implementation;
}
-const char * component_getName(dm_component_pt cmp) {
+const char* component_getName(celix_dm_component_t *cmp) {
+ return celix_dmComponent_getName(cmp);
+}
+
+const char * celix_dmComponent_getName(celix_dm_component_t *cmp) {
return cmp->name;
}
-celix_status_t component_removeServiceDependency(dm_component_pt component, dm_service_dependency_pt dependency) {
+celix_status_t component_removeServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency) {
+ return celix_dmComponent_removeServiceDependency(component, dependency);
+}
+
+celix_status_t celix_dmComponent_removeServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency) {
celix_status_t status = CELIX_SUCCESS;
executor_executeTask(component->executor, component, component_removeTask, dependency);
@@ -265,7 +289,7 @@ celix_status_t component_removeServiceDependency(dm_component_pt component, dm_s
return status;
}
-celix_status_t component_removeTask(dm_component_pt component, dm_service_dependency_pt dependency) {
+static celix_status_t component_removeTask(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
@@ -293,7 +317,7 @@ celix_status_t component_removeTask(dm_component_pt component, dm_service_depend
return status;
}
-celix_status_t component_start(dm_component_pt component) {
+celix_status_t celix_private_dmComponent_start(celix_dm_component_t *component) {
celix_status_t status = CELIX_SUCCESS;
component->active = true;
@@ -302,7 +326,7 @@ celix_status_t component_start(dm_component_pt component) {
return status;
}
-celix_status_t component_startTask(dm_component_pt component, void *data __attribute__((unused))) {
+celix_status_t component_startTask(celix_dm_component_t *component, void *data __attribute__((unused))) {
celix_status_t status = CELIX_SUCCESS;
component->isStarted = true;
@@ -311,7 +335,7 @@ celix_status_t component_startTask(dm_component_pt component, void *data __attr
return status;
}
-celix_status_t component_stop(dm_component_pt component) {
+celix_status_t celix_private_dmComponent_stop(celix_dm_component_t *component) {
celix_status_t status = CELIX_SUCCESS;
component->active = false;
@@ -320,7 +344,7 @@ celix_status_t component_stop(dm_component_pt component) {
return status;
}
-celix_status_t component_stopTask(dm_component_pt component, void *data __attribute__((unused))) {
+static celix_status_t component_stopTask(celix_dm_component_t *component, void *data __attribute__((unused))) {
celix_status_t status = CELIX_SUCCESS;
component->isStarted = false;
@@ -330,12 +354,20 @@ celix_status_t component_stopTask(dm_component_pt component, void *data __attrib
return status;
}
-celix_status_t component_setCLanguageProperty(dm_component_pt component, bool setCLangProp) {
+celix_status_t component_setCLanguageProperty(celix_dm_component_t *component, bool setCLangProp) {
+ return celix_dmComponent_setCLanguageProperty(component, setCLangProp);
+}
+
+celix_status_t celix_dmComponent_setCLanguageProperty(celix_dm_component_t *component, bool setCLangProp) {
component->setCLanguageProperty = setCLangProp;
return CELIX_SUCCESS;
}
-celix_status_t component_addInterface(dm_component_pt component, const char* serviceName, const char* serviceVersion, const void* service, properties_pt properties) {
+celix_status_t component_addInterface(celix_dm_component_t *component, const char* serviceName, const char* serviceVersion, const void* service, properties_pt properties) {
+ return celix_dmComponent_addInterface(component, serviceName, serviceVersion, service, properties);
+}
+
+celix_status_t celix_dmComponent_addInterface(celix_dm_component_t *component, const char* serviceName, const char* serviceVersion, const void* service, properties_pt properties) {
celix_status_t status = CELIX_SUCCESS;
dm_interface_t *interface = (dm_interface_t *) calloc(1, sizeof(*interface));
@@ -373,7 +405,11 @@ celix_status_t component_addInterface(dm_component_pt component, const char* ser
return status;
}
-celix_status_t component_removeInterface(dm_component_pt component, const void* service) {
+celix_status_t component_removeInterface(celix_dm_component_t *component, const void* service) {
+ return celix_dmComponent_removeInterface(component, service);
+}
+
+celix_status_t celix_dmComponent_removeInterface(celix_dm_component_t *component, const void* service) {
celix_status_t status = CELIX_ILLEGAL_ARGUMENT;
celixThreadMutex_lock(&component->mutex);
@@ -397,7 +433,11 @@ celix_status_t component_removeInterface(dm_component_pt component, const void*
return status;
}
-celix_status_t component_getInterfaces(dm_component_pt component, array_list_pt *out) {
+celix_status_t component_getInterfaces(celix_dm_component_t *component, array_list_pt *out) {
+ return celix_dmComponent_getInterfaces(component, out);
+}
+
+celix_status_t celix_dmComponent_getInterfaces(celix_dm_component_t *component, array_list_pt *out) {
celix_status_t status = CELIX_SUCCESS;
array_list_pt names = NULL;
arrayList_create(&names);
@@ -420,7 +460,7 @@ celix_status_t component_getInterfaces(dm_component_pt component, array_list_pt
return status;
}
-celix_status_t component_handleEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
+celix_status_t celix_private_dmComponent_handleEvent(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency, dm_event_pt event) {
celix_status_t status = CELIX_SUCCESS;
dm_handle_event_type_pt data = calloc(1, sizeof(*data));
@@ -434,7 +474,7 @@ celix_status_t component_handleEvent(dm_component_pt component, dm_service_depen
return status;
}
-celix_status_t component_handleEventTask(dm_component_pt component, dm_handle_event_type_pt data) {
+static celix_status_t component_handleEventTask(celix_dm_component_t *component, dm_handle_event_type_pt data) {
celix_status_t status = CELIX_SUCCESS;
switch (data->event->event_type) {
@@ -459,7 +499,7 @@ celix_status_t component_handleEventTask(dm_component_pt component, dm_handle_ev
return status;
}
-static celix_status_t component_suspend(dm_component_pt component, dm_service_dependency_pt dependency) {
+static celix_status_t component_suspend(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency) {
celix_status_t status = CELIX_SUCCESS;
dm_service_dependency_strategy_t strategy;
@@ -471,7 +511,7 @@ static celix_status_t component_suspend(dm_component_pt component, dm_service_de
return status;
}
-static celix_status_t component_resume(dm_component_pt component, dm_service_dependency_pt dependency) {
+static celix_status_t component_resume(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency) {
celix_status_t status = CELIX_SUCCESS;
dm_service_dependency_strategy_t strategy;
@@ -483,7 +523,7 @@ static celix_status_t component_resume(dm_component_pt component, dm_service_dep
return status;
}
-celix_status_t component_handleAdded(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
+static celix_status_t component_handleAdded(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency, dm_event_pt event) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
@@ -539,7 +579,7 @@ celix_status_t component_handleAdded(dm_component_pt component, dm_service_depen
return status;
}
-celix_status_t component_handleChanged(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
+static celix_status_t component_handleChanged(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency, dm_event_pt event) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
@@ -584,7 +624,7 @@ celix_status_t component_handleChanged(dm_component_pt component, dm_service_dep
return status;
}
-celix_status_t component_handleRemoved(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
+static celix_status_t component_handleRemoved(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency, dm_event_pt event) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
@@ -646,7 +686,7 @@ celix_status_t component_handleRemoved(dm_component_pt component, dm_service_dep
return status;
}
-celix_status_t component_handleSwapped(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent) {
+static celix_status_t component_handleSwapped(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency, dm_event_pt event, dm_event_pt newEvent) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
@@ -695,7 +735,7 @@ celix_status_t component_handleSwapped(dm_component_pt component, dm_service_dep
return status;
}
-celix_status_t component_updateInstance(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, bool update, bool add) {
+static celix_status_t component_updateInstance(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency, dm_event_pt event, bool update, bool add) {
celix_status_t status = CELIX_SUCCESS;
bool autoConfig = false;
@@ -718,13 +758,13 @@ celix_status_t component_updateInstance(dm_component_pt component, dm_service_de
return status;
}
-celix_status_t component_startDependencies(dm_component_pt component __attribute__((unused)), array_list_pt dependencies) {
+static celix_status_t component_startDependencies(celix_dm_component_t *component __attribute__((unused)), array_list_pt dependencies) {
celix_status_t status = CELIX_SUCCESS;
array_list_pt required_dependencies = NULL;
arrayList_create(&required_dependencies);
for (unsigned int i = 0; i < arrayList_size(dependencies); i++) {
- dm_service_dependency_pt dependency = arrayList_get(dependencies, i);
+ celix_dm_service_dependency_t *dependency = arrayList_get(dependencies, i);
bool required = false;
serviceDependency_isRequired(dependency, &required);
if (required) {
@@ -736,7 +776,7 @@ celix_status_t component_startDependencies(dm_component_pt component __attribute
}
for (unsigned int i = 0; i < arrayList_size(required_dependencies); i++) {
- dm_service_dependency_pt dependency = arrayList_get(required_dependencies, i);
+ celix_dm_service_dependency_t *dependency = arrayList_get(required_dependencies, i);
serviceDependency_start(dependency);
}
@@ -745,12 +785,12 @@ celix_status_t component_startDependencies(dm_component_pt component __attribute
return status;
}
-celix_status_t component_stopDependencies(dm_component_pt component) {
+static celix_status_t component_stopDependencies(celix_dm_component_t *component) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
- dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+ celix_dm_service_dependency_t *dependency = arrayList_get(component->dependencies, i);
pthread_mutex_unlock(&component->mutex);
serviceDependency_stop(dependency);
pthread_mutex_lock(&component->mutex);
@@ -760,11 +800,11 @@ celix_status_t component_stopDependencies(dm_component_pt component) {
return status;
}
-celix_status_t component_handleChange(dm_component_pt component) {
+static celix_status_t component_handleChange(celix_dm_component_t *component) {
celix_status_t status = CELIX_SUCCESS;
- dm_component_state_t oldState;
- dm_component_state_t newState;
+ celix_dm_component_state_t oldState;
+ celix_dm_component_state_t newState;
bool transition = false;
do {
@@ -783,7 +823,7 @@ celix_status_t component_handleChange(dm_component_pt component) {
return status;
}
-celix_status_t component_calculateNewState(dm_component_pt component, dm_component_state_t currentState, dm_component_state_t *newState) {
+static celix_status_t component_calculateNewState(celix_dm_component_t *component, celix_dm_component_state_t currentState, celix_dm_component_state_t *newState) {
celix_status_t status = CELIX_SUCCESS;
if (currentState == DM_CMP_STATE_INACTIVE) {
@@ -846,7 +886,7 @@ celix_status_t component_calculateNewState(dm_component_pt component, dm_compone
return status;
}
-celix_status_t component_performTransition(dm_component_pt component, dm_component_state_t oldState, dm_component_state_t newState, bool *transition) {
+static celix_status_t component_performTransition(celix_dm_component_t *component, celix_dm_component_state_t oldState, celix_dm_component_state_t newState, bool *transition) {
celix_status_t status = CELIX_SUCCESS;
//printf("performing transition for %s in thread %i from %i to %i\n", component->name, (int) pthread_self(), oldState, newState);
@@ -893,13 +933,13 @@ celix_status_t component_performTransition(dm_component_pt component, dm_compone
return status;
}
-celix_status_t component_allRequiredAvailable(dm_component_pt component, bool *available) {
+static celix_status_t component_allRequiredAvailable(celix_dm_component_t *component, bool *available) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
*available = true;
for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
- dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+ celix_dm_service_dependency_t *dependency = arrayList_get(component->dependencies, i);
bool required = false;
bool instanceBound = false;
@@ -920,13 +960,13 @@ celix_status_t component_allRequiredAvailable(dm_component_pt component, bool *a
return status;
}
-celix_status_t component_allInstanceBoundAvailable(dm_component_pt component, bool *available) {
+static celix_status_t component_allInstanceBoundAvailable(celix_dm_component_t *component, bool *available) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
*available = true;
for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
- dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+ celix_dm_service_dependency_t *dependency = arrayList_get(component->dependencies, i);
bool required = false;
bool instanceBound = false;
@@ -947,12 +987,12 @@ celix_status_t component_allInstanceBoundAvailable(dm_component_pt component, bo
return status;
}
-celix_status_t component_invokeAddRequiredDependencies(dm_component_pt component) {
+static celix_status_t component_invokeAddRequiredDependencies(celix_dm_component_t *component) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
- dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+ celix_dm_service_dependency_t *dependency = arrayList_get(component->dependencies, i);
bool required = false;
bool instanceBound = false;
@@ -975,12 +1015,12 @@ celix_status_t component_invokeAddRequiredDependencies(dm_component_pt component
return status;
}
-celix_status_t component_invokeAutoConfigDependencies(dm_component_pt component) {
+static celix_status_t component_invokeAutoConfigDependencies(celix_dm_component_t *component) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
- dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+ celix_dm_service_dependency_t *dependency = arrayList_get(component->dependencies, i);
bool autoConfig = false;
bool instanceBound = false;
@@ -997,12 +1037,12 @@ celix_status_t component_invokeAutoConfigDependencies(dm_component_pt component)
return status;
}
-celix_status_t component_invokeAutoConfigInstanceBoundDependencies(dm_component_pt component) {
+static celix_status_t component_invokeAutoConfigInstanceBoundDependencies(celix_dm_component_t *component) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
- dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+ celix_dm_service_dependency_t *dependency = arrayList_get(component->dependencies, i);
bool autoConfig = false;
bool instanceBound = false;
@@ -1019,12 +1059,12 @@ celix_status_t component_invokeAutoConfigInstanceBoundDependencies(dm_component_
return status;
}
-celix_status_t component_invokeAddRequiredInstanceBoundDependencies(dm_component_pt component) {
+static celix_status_t component_invokeAddRequiredInstanceBoundDependencies(celix_dm_component_t *component) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
- dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+ celix_dm_service_dependency_t *dependency = arrayList_get(component->dependencies, i);
bool required = false;
bool instanceBound = false;
@@ -1047,12 +1087,12 @@ celix_status_t component_invokeAddRequiredInstanceBoundDependencies(dm_component
return status;
}
-celix_status_t component_invokeAddOptionalDependencies(dm_component_pt component) {
+static celix_status_t component_invokeAddOptionalDependencies(celix_dm_component_t *component) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
- dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+ celix_dm_service_dependency_t *dependency = arrayList_get(component->dependencies, i);
bool required = false;
@@ -1073,12 +1113,12 @@ celix_status_t component_invokeAddOptionalDependencies(dm_component_pt component
return status;
}
-celix_status_t component_invokeRemoveOptionalDependencies(dm_component_pt component) {
+static celix_status_t component_invokeRemoveOptionalDependencies(celix_dm_component_t *component) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
- dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+ celix_dm_service_dependency_t *dependency = arrayList_get(component->dependencies, i);
bool required = false;
@@ -1099,12 +1139,12 @@ celix_status_t component_invokeRemoveOptionalDependencies(dm_component_pt compon
return status;
}
-celix_status_t component_invokeRemoveInstanceBoundDependencies(dm_component_pt component) {
+static celix_status_t component_invokeRemoveInstanceBoundDependencies(celix_dm_component_t *component) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
- dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+ celix_dm_service_dependency_t *dependency = arrayList_get(component->dependencies, i);
bool instanceBound = false;
@@ -1125,12 +1165,12 @@ celix_status_t component_invokeRemoveInstanceBoundDependencies(dm_component_pt c
return status;
}
-celix_status_t component_invokeRemoveRequiredDependencies(dm_component_pt component) {
+static celix_status_t component_invokeRemoveRequiredDependencies(celix_dm_component_t *component) {
celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(&component->mutex);
for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
- dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
+ celix_dm_service_dependency_t *dependency = arrayList_get(component->dependencies, i);
bool required = false;
bool instanceBound = false;
@@ -1153,7 +1193,7 @@ celix_status_t component_invokeRemoveRequiredDependencies(dm_component_pt compon
return status;
}
-celix_status_t component_getDependencyEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt *event_pptr) {
+static celix_status_t component_getDependencyEvent(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency, dm_event_pt *event_pptr) {
celix_status_t status = CELIX_SUCCESS;
array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
@@ -1177,7 +1217,7 @@ celix_status_t component_getDependencyEvent(dm_component_pt component, dm_servic
return status;
}
-celix_status_t component_configureImplementation(dm_component_pt component, dm_service_dependency_pt dependency) {
+static celix_status_t component_configureImplementation(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency) {
celix_status_t status = CELIX_SUCCESS;
const void **field = NULL;
@@ -1199,7 +1239,7 @@ celix_status_t component_configureImplementation(dm_component_pt component, dm_s
return status;
}
-celix_status_t component_registerServices(dm_component_pt component) {
+static celix_status_t component_registerServices(celix_dm_component_t *component) {
celix_status_t status = CELIX_SUCCESS;
if (component->context != NULL) {
@@ -1220,7 +1260,7 @@ celix_status_t component_registerServices(dm_component_pt component) {
return status;
}
-celix_status_t component_unregisterServices(dm_component_pt component) {
+static celix_status_t component_unregisterServices(celix_dm_component_t *component) {
celix_status_t status = CELIX_SUCCESS;
unsigned int i;
@@ -1237,7 +1277,11 @@ celix_status_t component_unregisterServices(dm_component_pt component) {
return status;
}
-celix_status_t component_setCallbacks(dm_component_pt component, init_fpt init, start_fpt start, stop_fpt stop, deinit_fpt deinit) {
+celix_status_t component_setCallbacks(celix_dm_component_t *component, celix_dm_cmp_lifecycle_fpt init, celix_dm_cmp_lifecycle_fpt start, celix_dm_cmp_lifecycle_fpt stop, celix_dm_cmp_lifecycle_fpt deinit) {
+ return celix_dmComponent_setCallbacks(component, init, start, stop, deinit);
+}
+
+celix_status_t celix_dmComponent_setCallbacks(celix_dm_component_t *component, celix_dm_cmp_lifecycle_fpt init, celix_dm_cmp_lifecycle_fpt start, celix_dm_cmp_lifecycle_fpt stop, celix_dm_cmp_lifecycle_fpt deinit) {
if (component->active) {
return CELIX_ILLEGAL_STATE;
}
@@ -1248,17 +1292,27 @@ celix_status_t component_setCallbacks(dm_component_pt component, init_fpt init,
return CELIX_SUCCESS;
}
-celix_status_t component_isAvailable(dm_component_pt component, bool *available) {
+
+/*
+celix_status_t component_isAvailable(celix_dm_component_t *component, bool *available) {
*available = component->state == DM_CMP_STATE_TRACKING_OPTIONAL;
return CELIX_SUCCESS;
+}*/
+
+celix_status_t component_setImplementation(celix_dm_component_t *component, void *implementation) {
+ return celix_dmComponent_setImplementation(component, implementation);
}
-celix_status_t component_setImplementation(dm_component_pt component, void *implementation) {
+celix_status_t celix_dmComponent_setImplementation(celix_dm_component_t *component, void *implementation) {
component->implementation = implementation;
return CELIX_SUCCESS;
}
-celix_status_t component_getBundleContext(dm_component_pt component, bundle_context_pt *context) {
+celix_status_t component_getBundleContext(celix_dm_component_t *component, bundle_context_pt *context) {
+ return celix_dmComponent_getBundleContext(component, context);
+}
+
+celix_status_t celix_dmComponent_getBundleContext(celix_dm_component_t *component, bundle_context_pt *context) {
celix_status_t status = CELIX_SUCCESS;
if (!component) {
@@ -1273,7 +1327,7 @@ celix_status_t component_getBundleContext(dm_component_pt component, bundle_cont
}
-static celix_status_t executor_create(dm_component_pt component __attribute__((unused)), dm_executor_pt *executor) {
+static celix_status_t executor_create(celix_dm_component_t *component __attribute__((unused)), dm_executor_pt *executor) {
celix_status_t status = CELIX_SUCCESS;
*executor = malloc(sizeof(**executor));
@@ -1298,7 +1352,7 @@ static void executor_destroy(dm_executor_pt executor) {
}
}
-static celix_status_t executor_schedule(dm_executor_pt executor, dm_component_pt component, void (*command), void *data) {
+static celix_status_t executor_schedule(dm_executor_pt executor, celix_dm_component_t *component, void (*command), void *data) {
celix_status_t status = CELIX_SUCCESS;
dm_executor_task_t *task = NULL;
@@ -1318,7 +1372,7 @@ static celix_status_t executor_schedule(dm_executor_pt executor, dm_component_pt
return status;
}
-static celix_status_t executor_executeTask(dm_executor_pt executor, dm_component_pt component, void (*command), void *data) {
+static celix_status_t executor_executeTask(dm_executor_pt executor, celix_dm_component_t *component, void (*command), void *data) {
celix_status_t status = CELIX_SUCCESS;
// Check thread and executor thread, if the same, execute immediately.
@@ -1386,7 +1440,11 @@ static celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t curre
return status;
}
-celix_status_t component_getComponentInfo(dm_component_pt component, dm_component_info_pt *out) {
+celix_status_t component_getComponentInfo(celix_dm_component_t *component, dm_component_info_pt *out) {
+ return celix_dmComponent_getComponentInfo(component, out);
+}
+
+celix_status_t celix_dmComponent_getComponentInfo(celix_dm_component_t *component, dm_component_info_pt *out) {
celix_status_t status = CELIX_SUCCESS;
int i;
int size;
@@ -1425,7 +1483,7 @@ celix_status_t component_getComponentInfo(dm_component_pt component, dm_componen
celixThreadMutex_lock(&component->mutex);
size = arrayList_size(component->dependencies);
for (i = 0; i < size; i += 1) {
- dm_service_dependency_pt dep = arrayList_get(component->dependencies, i);
+ celix_dm_service_dependency_t *dep = arrayList_get(component->dependencies, i);
dm_service_dependency_info_pt depInfo = NULL;
status = serviceDependency_getServiceDependencyInfo(dep, &depInfo);
if (status == CELIX_SUCCESS) {
@@ -1444,8 +1502,11 @@ celix_status_t component_getComponentInfo(dm_component_pt component, dm_componen
return status;
}
-
void component_destroyComponentInfo(dm_component_info_pt info) {
+ return celix_dmComponent_destroyComponentInfo(info);
+}
+
+void celix_dmComponent_destroyComponentInfo(dm_component_info_pt info) {
int i;
int size;
if (info != NULL) {
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/src/dm_component_impl.h
----------------------------------------------------------------------
diff --git a/libs/framework/src/dm_component_impl.h b/libs/framework/src/dm_component_impl.h
index 495197c..bd72614 100644
--- a/libs/framework/src/dm_component_impl.h
+++ b/libs/framework/src/dm_component_impl.h
@@ -35,11 +35,11 @@ extern "C" {
#include "dm_service_dependency_impl.h"
#include "dm_event.h"
-celix_status_t component_start(dm_component_pt component);
+celix_status_t celix_private_dmComponent_start(celix_dm_component_t *component);
-celix_status_t component_stop(dm_component_pt component);
+celix_status_t celix_private_dmComponent_stop(celix_dm_component_t *component);
-celix_status_t component_handleEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
+celix_status_t celix_private_dmComponent_handleEvent(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency, dm_event_pt event);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/src/dm_dependency_manager_impl.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/dm_dependency_manager_impl.c b/libs/framework/src/dm_dependency_manager_impl.c
index 14c02f6..fec76d4 100644
--- a/libs/framework/src/dm_dependency_manager_impl.c
+++ b/libs/framework/src/dm_dependency_manager_impl.c
@@ -17,87 +17,194 @@
* under the License.
*/
-/*
- * dm_dependency_manager_impl.c
- *
- * \date 26 Jul 2014
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
#include <pthread.h>
#include <stdlib.h>
#include <dm_dependency_manager.h>
+#include <memory.h>
#include "bundle_context.h"
#include "dm_component_impl.h"
#include "dm_dependency_manager_impl.h"
+#include "celix_dependency_manager.h"
+#include "celix_bundle.h"
-celix_status_t dependencyManager_create(bundle_context_pt context __attribute__((unused)), dm_dependency_manager_pt *manager) {
- celix_status_t status = CELIX_ENOMEM;
-
- (*manager) = calloc(1, sizeof(**manager));
-
- if (*manager) {
- arrayList_create(&(*manager)->components);
-
- status = CELIX_SUCCESS;
+celix_dependency_manager_t* celix_private_dependencyManager_create(celix_bundle_context_t *context) {
+ celix_dependency_manager_t *manager = calloc(1, sizeof(*manager));
+ if (manager != NULL) {
+ manager->ctx = context;
+ manager->components = celix_arrayList_create();
+ pthread_mutex_init(&manager->mutex, NULL);
}
-
- return status;
-
+ return manager;
}
-void dependencyManager_destroy(dm_dependency_manager_pt manager) {
+void celix_private_dependencyManager_destroy(celix_dependency_manager_t *manager) {
if (manager != NULL) {
- arrayList_destroy(manager->components);
+ celix_arrayList_destroy(manager->components);
+ pthread_mutex_destroy(&manager->mutex);
free(manager);
}
}
-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);
+celix_status_t celix_dependencyManager_add(celix_dependency_manager_t *manager, celix_dm_component_t *component) {
+ celix_status_t status;
+ celix_arrayList_add(manager->components, component);
+ status = celix_private_dmComponent_start(component);
return status;
}
-celix_status_t dependencyManager_remove(dm_dependency_manager_pt manager, dm_component_pt component) {
- celix_status_t status;
- arrayList_removeElement(manager->components, component);
- status = component_stop(component);
- component_destroy(component);
+celix_status_t celix_dependencyManager_remove(celix_dependency_manager_t *manager, celix_dm_component_t *component) {
+ celix_status_t status;
+
+ celix_arrayList_remove(manager->components, component);
+ status = celix_private_dmComponent_stop(component);
+ component_destroy(component);
- return status;
+ return status;
}
-celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_pt manager) {
+
+celix_status_t celix_dependencyManager_removeAllComponents(celix_dependency_manager_t *manager) {
celix_status_t status = CELIX_SUCCESS;
- unsigned int i=0;
- unsigned int size = arrayList_size(manager->components);
+ int i=0;
+ int size = celix_arrayList_size(manager->components);
for(;i<size;i++){
- dm_component_pt cmp = arrayList_get(manager->components, i);
+ celix_dm_component_t *cmp = celix_arrayList_get(manager->components, i);
// printf("Stopping comp %s\n", component_getName(cmp));
- component_stop(cmp);
+ celix_private_dmComponent_stop(cmp);
}
while (!arrayList_isEmpty(manager->components)) {
- dm_component_pt cmp = arrayList_remove(manager->components, 0);
+ celix_dm_component_t *cmp = celix_arrayList_get(manager->components, 0);
+ celix_arrayList_removeAt(manager->components, 0);
// printf("Removing comp %s\n", component_getName(cmp));
- component_destroy(cmp);
+ component_destroy(cmp);
+ }
+
+ return status;
+}
+
+
+static void celix_dm_getInfoCallback(void *handle, const celix_bundle_t *bnd) {
+ celix_dependency_manager_info_t **out = handle;
+
+ celix_bundle_context_t *context = NULL;
+ bundle_getContext((celix_bundle_t*)bnd, &context);
+ celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(context);
+
+ celix_dependency_manager_info_t *info = calloc(1, sizeof(*info));
+ celixThreadMutex_lock(&mng->mutex);
+ if (info != NULL) {
+ info->components = celix_arrayList_create();
+ int size = celix_arrayList_size(mng->components);
+ for (int i = 0; i < size; i += 1) {
+ celix_dm_component_t *cmp = celix_arrayList_get(mng->components, i);
+ celix_dm_component_info_t *cmpInfo = NULL;
+ component_getComponentInfo(cmp, &cmpInfo);
+ celix_arrayList_add(info->components, cmpInfo);
+ }
+ }
+ celixThreadMutex_unlock(&mng->mutex);
+
+ *out = info;
+}
+
+celix_dependency_manager_info_t* celix_dependencyManager_createInfo(celix_dependency_manager_t *manager, long bndId) {
+ celix_dependency_manager_info_t *info = NULL;
+ celix_bundleContext_useBundle(manager->ctx, bndId, &info, celix_dm_getInfoCallback);
+ return info;
+}
+
+
+static void celix_dm_getInfosCallback(void *handle, const celix_bundle_t *bnd) {
+ celix_array_list_t *infos = handle;
+
+ celix_bundle_context_t *context = NULL;
+ bundle_getContext((celix_bundle_t*)bnd, &context);
+ celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(context);
+
+ celix_dependency_manager_info_t *info = calloc(1, sizeof(*info));
+ celixThreadMutex_lock(&mng->mutex);
+ if (info != NULL) {
+ info->bndId = celix_bundle_getId(bnd);
+ info->components = celix_arrayList_create();
+ int size = celix_arrayList_size(mng->components);
+ for (int i = 0; i < size; i += 1) {
+ celix_dm_component_t *cmp = celix_arrayList_get(mng->components, i);
+ celix_dm_component_info_t *cmpInfo = NULL;
+ component_getComponentInfo(cmp, &cmpInfo);
+ celix_arrayList_add(info->components, cmpInfo);
+ }
+
+ celix_arrayList_add(infos, info);
+ }
+ celixThreadMutex_unlock(&mng->mutex);
+}
+
+celix_array_list_t * celix_dependencyManager_createInfos(celix_dependency_manager_t *manager) {
+ celix_array_list_t *infos = celix_arrayList_create();
+ celix_bundleContext_useBundles(manager->ctx, infos, celix_dm_getInfosCallback);
+ return infos;
+}
+
+
+void celix_dependencyManager_destroyInfo(celix_dependency_manager_t *manager __attribute__((unused)), celix_dependency_manager_info_t *info) {
+ for (int i = 0; i < celix_arrayList_size(info->components); i += 1) {
+ celix_dm_component_info_t *cmpinfo = (dm_component_info_pt)arrayList_get(info->components, i);
+ component_destroyComponentInfo(cmpinfo);
}
+ arrayList_destroy(info->components);
+ free(info);
+}
+
+
+void celix_dependencyManager_destroyInfos(celix_dependency_manager_t *manager, celix_array_list_t * infos /*entries celix_dm_dependency_manager_info_t*/) {
+ for (int i = 0; i < celix_arrayList_size(infos); ++i) {
+ celix_dependencyManager_destroyInfo(manager, celix_arrayList_get(infos, i));
+ }
+ celix_arrayList_destroy(infos);
+}
+
+
+
+/************************ DEPRECATED API ************************************************/
+
+
+celix_status_t dependencyManager_create(bundle_context_pt context, celix_dependency_manager_t **out) {
+ celix_status_t status = CELIX_SUCCESS;
+ celix_dependency_manager_t *manager = celix_private_dependencyManager_create(context);
+ if (manager != NULL) {
+ *out = manager;
+ } else {
+ status = CELIX_BUNDLE_EXCEPTION;
+ }
return status;
}
-celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt *out) {
+void dependencyManager_destroy(celix_dependency_manager_t *manager) {
+ celix_private_dependencyManager_destroy(manager);
+}
+
+celix_status_t dependencyManager_add(celix_dependency_manager_t *manager, celix_dm_component_t *component) {
+ return celix_dependencyManager_add(manager, component);
+}
+
+celix_status_t dependencyManager_remove(celix_dependency_manager_t *manager, celix_dm_component_t *component) {
+ return celix_dependencyManager_remove(manager, component);
+}
+
+celix_status_t dependencyManager_removeAllComponents(celix_dependency_manager_t *manager) {
+ return celix_dependencyManager_removeAllComponents(manager);
+}
+
+celix_status_t dependencyManager_getInfo(celix_dependency_manager_t *manager, dm_dependency_manager_info_pt *out) {
celix_status_t status = CELIX_SUCCESS;
unsigned int i;
int size;
@@ -110,7 +217,7 @@ celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager, dm_de
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);
+ celix_dm_component_t *cmp = arrayList_get(manager->components, i);
cmpInfo = NULL;
component_getComponentInfo(cmp, &cmpInfo);
arrayList_add(info->components, cmpInfo);
@@ -128,12 +235,7 @@ celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager, dm_de
return status;
}
-void dependencyManager_destroyInfo(dm_dependency_manager_pt __attribute__((__unused__)) manager, dm_dependency_manager_info_pt info) {
- unsigned int i = 0;
- for (; i < arrayList_size(info->components); i += 1) {
- dm_component_info_pt cmpinfo = (dm_component_info_pt)arrayList_get(info->components, i);
- component_destroyComponentInfo(cmpinfo);
- }
- arrayList_destroy(info->components);
- free(info);
-}
+
+void dependencyManager_destroyInfo(celix_dependency_manager_t *manager, celix_dependency_manager_info_t *info) {
+ celix_dependencyManager_destroyInfo(manager, info);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/src/dm_dependency_manager_impl.h
----------------------------------------------------------------------
diff --git a/libs/framework/src/dm_dependency_manager_impl.h b/libs/framework/src/dm_dependency_manager_impl.h
index c673605..34e75cf 100644
--- a/libs/framework/src/dm_dependency_manager_impl.h
+++ b/libs/framework/src/dm_dependency_manager_impl.h
@@ -16,28 +16,27 @@
*specific language governing permissions and limitations
*under the License.
*/
-/*
- * dm_dependency_manager_impl.h
- *
- * \date 15 Oct 2015
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
#ifndef CELIX_DM_DEPENDENCY_MANAGER_IMPL_H
#define CELIX_DM_DEPENDENCY_MANAGER_IMPL_H
+#include "celix_array_list.h"
+#include "celix_bundle_context.h"
+#include <pthread.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-
-struct dm_dependency_manager {
- array_list_pt components;
-
+struct celix_dependency_manager {
+ celix_bundle_context_t *ctx;
+ celix_array_list_t *components;
pthread_mutex_t mutex;
};
+celix_dependency_manager_t* celix_private_dependencyManager_create(celix_bundle_context_t *context);
+void celix_private_dependencyManager_destroy(celix_dependency_manager_t *manager);
+
#ifdef __cplusplus
}
#endif
[3/4] celix git commit: CELIX-438: Add a dependency manager API with
the celix prefix. Also add a compile options to enable deprecated compiler
warning for the 'old' api.
Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix/dm/Component_Impl.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix/dm/Component_Impl.h b/libs/framework/include/celix/dm/Component_Impl.h
index 7848c6a..54914be 100644
--- a/libs/framework/include/celix/dm/Component_Impl.h
+++ b/libs/framework/include/celix/dm/Component_Impl.h
@@ -30,7 +30,7 @@
using namespace celix::dm;
template<class T>
-Component<T>::Component(const bundle_context_pt context, std::string name) : BaseComponent(context, name) {}
+Component<T>::Component(celix_bundle_context_t *context, std::string name) : BaseComponent(context, name) {}
template<class T>
Component<T>::~Component() {
@@ -42,7 +42,7 @@ template<class I>
Component<T>& Component<T>::addInterfaceWithName(const std::string serviceName, const std::string version, const Properties properties) {
if (!serviceName.empty()) {
//setup c properties
- properties_pt cProperties = properties_create();
+ celix_properties_t *cProperties = properties_create();
properties_set(cProperties, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_CXX_LANGUAGE);
for (const auto& pair : properties) {
properties_set(cProperties, (char *) pair.first.c_str(), (char *) pair.second.c_str());
@@ -52,7 +52,7 @@ Component<T>& Component<T>::addInterfaceWithName(const std::string serviceName,
I* intfPtr = static_cast<I*>(cmpPtr); //NOTE T should implement I
const char *cVersion = version.empty() ? nullptr : version.c_str();
- component_addInterface(this->cComponent(), (char *) serviceName.c_str(), (char *) cVersion,
+ celix_dmComponent_addInterface(this->cComponent(), (char *) serviceName.c_str(), (char *) cVersion,
intfPtr, cProperties);
} else {
std::cerr << "Cannot add interface with a empty name\n";
@@ -78,14 +78,14 @@ template<class T>
template<class I>
Component<T>& Component<T>::addCInterface(const I* svc, const std::string serviceName, const std::string version, const Properties properties) {
static_assert(std::is_pod<I>::value, "Service I must be a 'Plain Old Data' object");
- properties_pt cProperties = properties_create();
+ celix_properties_t *cProperties = properties_create();
properties_set(cProperties, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
for (const auto& pair : properties) {
properties_set(cProperties, (char*)pair.first.c_str(), (char*)pair.second.c_str());
}
const char *cVersion = version.empty() ? nullptr : version.c_str();
- component_addInterface(this->cComponent(), (char*)serviceName.c_str(), (char*)cVersion, svc, cProperties);
+ celix_dmComponent_addInterface(this->cComponent(), (char*)serviceName.c_str(), (char*)cVersion, svc, cProperties);
return *this;
};
@@ -94,7 +94,7 @@ template<class T>
template<class I>
Component<T>& Component<T>::removeCInterface(const I* svc){
static_assert(std::is_pod<I>::value, "Service I must be a 'Plain Old Data' object");
- component_removeInterface(this->cComponent(), svc);
+ celix_dmComponent_removeInterface(this->cComponent(), svc);
return *this;
};
@@ -111,7 +111,7 @@ ServiceDependency<T,I>& Component<T>::createServiceDependency(const std::string
}
#endif
this->dependencies.push_back(dep);
- component_addServiceDependency(cComponent(), dep->cServiceDependency());
+ celix_dmComponent_addServiceDependency(cComponent(), dep->cServiceDependency());
dep->setComponentInstance(&getInstance());
return *dep;
}
@@ -137,7 +137,7 @@ CServiceDependency<T,I>& Component<T>::createCServiceDependency(const std::strin
}
#endif
this->dependencies.push_back(dep);
- component_addServiceDependency(cComponent(), dep->cServiceDependency());
+ celix_dmComponent_addServiceDependency(cComponent(), dep->cServiceDependency());
dep->setComponentInstance(&getInstance());
return *dep;
}
@@ -151,13 +151,13 @@ Component<T>& Component<T>::remove(CServiceDependency<T,I>& dep) {
}
template<class T>
-Component<T>* Component<T>::create(bundle_context_pt context) {
+Component<T>* Component<T>::create(celix_bundle_context_t *context) {
std::string name = typeName<T>();
return Component<T>::create(context, name);
}
template<class T>
-Component<T>* Component<T>::create(bundle_context_pt context, std::string name) {
+Component<T>* Component<T>::create(celix_bundle_context_t *context, std::string name) {
#ifdef __EXCEPTIONS
Component<T>* cmp = new Component<T>{context, name};
#else
@@ -268,7 +268,7 @@ Component<T>& Component<T>::setCallbacks(
return 0;
};
- component_setCallbacks(this->cComponent(), cInit, cStart, cStop, cDeinit);
+ celix_dmComponent_setCallbacks(this->cComponent(), cInit, cStart, cStop, cDeinit);
return *this;
}
@@ -322,7 +322,7 @@ Component<T>& Component<T>::setCallbacks(
return 0;
};
- component_setCallbacks(this->cComponent(), cInit, cStart, cStop, cDeinit);
+ celix_dmComponent_setCallbacks(this->cComponent(), cInit, cStart, cStop, cDeinit);
return *this;
}
@@ -330,7 +330,7 @@ Component<T>& Component<T>::setCallbacks(
template<class T>
Component<T>& Component<T>::removeCallbacks() {
- component_setCallbacks(this->cComponent(), nullptr, nullptr, nullptr, nullptr);
+ celix_dmComponent_setCallbacks(this->cComponent(), nullptr, nullptr, nullptr, nullptr);
return *this;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix/dm/DependencyManager.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix/dm/DependencyManager.h b/libs/framework/include/celix/dm/DependencyManager.h
index f90a03c..0f77da7 100644
--- a/libs/framework/include/celix/dm/DependencyManager.h
+++ b/libs/framework/include/celix/dm/DependencyManager.h
@@ -24,7 +24,7 @@
#include "bundle_context.h"
#include "celix_bundle_context.h"
-#include "dm_dependency_manager.h"
+#include "celix_dependency_manager.h"
#include <vector>
#include <mutex>
@@ -36,7 +36,7 @@ namespace celix { namespace dm {
class DependencyManager {
public:
- DependencyManager(bundle_context_pt ctx) : context(ctx) {
+ DependencyManager(celix_bundle_context_t *ctx) : context(ctx) {
this->cDepMan = celix_bundleContext_getDependencyManager(ctx);
}
@@ -58,8 +58,8 @@ namespace celix { namespace dm {
DependencyManager(const DependencyManager&) = delete;
DependencyManager& operator=(const DependencyManager&) = delete;
- bundle_context_pt bundleContext() const { return context; }
- dm_dependency_manager_pt cDependencyManager() const { return cDepMan; }
+ celix_bundle_context_t* bundleContext() const { return context; }
+ celix_dependency_manager_t *cDependencyManager() const { return cDepMan; }
/**
@@ -111,7 +111,7 @@ namespace celix { namespace dm {
}
for (auto it = toBeStartedComponents.begin(); it != toBeStartedComponents.end(); ++it) {
- dependencyManager_add(cDepMan, (*it)->cComponent());
+ celix_dependencyManager_add(cDepMan, (*it)->cComponent());
{
std::lock_guard<std::recursive_mutex> lock(componentsMutex);
startedComponents.push_back(std::move(*it));
@@ -131,15 +131,15 @@ namespace celix { namespace dm {
* Stops the Dependency Manager
*/
void stop() {
- dependencyManager_removeAllComponents(cDepMan);
+ celix_dependencyManager_removeAllComponents(cDepMan);
queuedComponents.clear();
startedComponents.clear();
}
private:
- bundle_context_pt context {nullptr};
+ celix_bundle_context_t *context {nullptr};
std::vector<std::unique_ptr<BaseComponent>> queuedComponents {};
std::vector<std::unique_ptr<BaseComponent>> startedComponents {};
- dm_dependency_manager_pt cDepMan {nullptr};
+ celix_dependency_manager_t* cDepMan {nullptr};
std::recursive_mutex componentsMutex{};
};
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix/dm/DmActivator.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix/dm/DmActivator.h b/libs/framework/include/celix/dm/DmActivator.h
index d7aac3c..55a7573 100644
--- a/libs/framework/include/celix/dm/DmActivator.h
+++ b/libs/framework/include/celix/dm/DmActivator.h
@@ -38,7 +38,7 @@ namespace celix { namespace dm {
DependencyManager& manager() const { return this->mng; }
- bundle_context_pt context() const { return this->ctx; }
+ celix_bundle_context_t* context() const { return this->ctx; }
/**
* The init of the DM Activator. Should be overridden by the bundle specific DM activator.
@@ -66,7 +66,7 @@ namespace celix { namespace dm {
protected:
DependencyManager& mng;
- bundle_context_pt ctx;
+ celix_bundle_context_t *ctx;
private:
int start() {
celix_status_t status = CELIX_SUCCESS;
@@ -82,15 +82,15 @@ namespace celix { namespace dm {
this->deinit();
// Remove all components
- dependencyManager_removeAllComponents(this->mng.cDependencyManager());
+ celix_dependencyManager_removeAllComponents(this->mng.cDependencyManager());
return status;
}
- friend int ::bundleActivator_create(::bundle_context_pt, void**);
- friend int ::bundleActivator_start(void*, ::bundle_context_pt);
- friend int ::bundleActivator_stop(void*, ::bundle_context_pt);
- friend int ::bundleActivator_destroy(void*, ::bundle_context_pt);
+ friend int ::bundleActivator_create(::celix_bundle_context_t*, void**);
+ friend int ::bundleActivator_start(void*, ::celix_bundle_context_t*);
+ friend int ::bundleActivator_stop(void*, ::celix_bundle_context_t*);
+ friend int ::bundleActivator_destroy(void*, ::celix_bundle_context_t*);
};
}}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix/dm/ServiceDependency.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix/dm/ServiceDependency.h b/libs/framework/include/celix/dm/ServiceDependency.h
index f439b82..59d43f0 100644
--- a/libs/framework/include/celix/dm/ServiceDependency.h
+++ b/libs/framework/include/celix/dm/ServiceDependency.h
@@ -43,16 +43,16 @@ namespace celix { namespace dm {
class BaseServiceDependency {
protected:
const bool valid;
- dm_service_dependency_pt cServiceDep {nullptr};
+ celix_dm_service_dependency_t *cServiceDep {nullptr};
void setDepStrategy(DependencyUpdateStrategy strategy) {
if (!valid) {
return;
}
if (strategy == DependencyUpdateStrategy::locking) {
- serviceDependency_setStrategy(this->cServiceDependency(), DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING);
+ celix_dmServiceDependency_setStrategy(this->cServiceDependency(), DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING);
} else if (strategy == DependencyUpdateStrategy::suspend) {
- serviceDependency_setStrategy(this->cServiceDependency(), DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND);
+ celix_dmServiceDependency_setStrategy(this->cServiceDependency(), DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND);
} else {
std::cerr << "Unexpected dependency update strategy. Cannot convert for dm_depdendency\n";
}
@@ -60,9 +60,9 @@ namespace celix { namespace dm {
public:
BaseServiceDependency(bool v) : valid{v} {
if (this->valid) {
- serviceDependency_create(&this->cServiceDep);
+ this->cServiceDep = celix_dmServiceDependency_create();
//NOTE using suspend as default strategy
- serviceDependency_setStrategy(this->cServiceDep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND);
+ celix_dmServiceDependency_setStrategy(this->cServiceDep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND);
}
}
@@ -79,7 +79,7 @@ namespace celix { namespace dm {
/**
* Returns the C DM service dependency
*/
- dm_service_dependency_pt cServiceDependency() const { return cServiceDep; }
+ celix_dm_service_dependency_t *cServiceDependency() const { return cServiceDep; }
};
template<class T>
@@ -202,7 +202,7 @@ namespace celix { namespace dm {
std::function<void(const I* service, Properties&& properties)> removeFp{nullptr};
void setupCallbacks();
- int invokeCallback(std::function<void(const I*, Properties&&)> fp, service_reference_pt ref, const void* service);
+ int invokeCallback(std::function<void(const I*, Properties&&)> fp, const celix_properties_t *props, const void* service);
void setupService();
};
@@ -316,7 +316,7 @@ namespace celix { namespace dm {
void setupService();
void setupCallbacks();
- int invokeCallback(std::function<void(I*, Properties&&)> fp, service_reference_pt ref, const void* service);
+ int invokeCallback(std::function<void(I*, Properties&&)> fp, const celix_properties_t *props, const void* service);
};
}}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix/dm/ServiceDependency_Impl.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix/dm/ServiceDependency_Impl.h b/libs/framework/include/celix/dm/ServiceDependency_Impl.h
index 0f0dc26..5254728 100644
--- a/libs/framework/include/celix/dm/ServiceDependency_Impl.h
+++ b/libs/framework/include/celix/dm/ServiceDependency_Impl.h
@@ -20,6 +20,7 @@
#include <vector>
#include <iostream>
#include "constants.h"
+#include "celix_properties.h"
using namespace celix::dm;
@@ -50,7 +51,7 @@ void CServiceDependency<T,I>::setupService() {
}
const char* cversion = this->versionRange.empty() ? nullptr : versionRange.c_str();
const char* cfilter = filter.empty() ? nullptr : filter.c_str();
- serviceDependency_setService(this->cServiceDependency(), this->name.c_str(), cversion, cfilter);
+ celix_dmServiceDependency_setService(this->cServiceDependency(), this->name.c_str(), cversion, cfilter);
};
template<class T, typename I>
@@ -68,7 +69,7 @@ CServiceDependency<T,I>& CServiceDependency<T,I>::setRequired(bool req) {
if (!this->valid) {
return *this;
}
- serviceDependency_setRequired(this->cServiceDependency(), req);
+ celix_dmServiceDependency_setRequired(this->cServiceDependency(), req);
return *this;
}
@@ -158,49 +159,47 @@ void CServiceDependency<T,I>::setupCallbacks() {
return;
}
- int(*cset)(void*, service_reference_pt, const void*) {nullptr};
- int(*cadd)(void*, service_reference_pt, const void*) {nullptr};
- int(*crem)(void*, service_reference_pt, const void*) {nullptr};
+ int(*cset)(void*, void *, const celix_properties_t*) {nullptr};
+ int(*cadd)(void*, void *, const celix_properties_t*) {nullptr};
+ int(*crem)(void*, void *, const celix_properties_t*) {nullptr};
if (setFp != nullptr) {
- cset = [](void* handle, service_reference_pt ref, const void* service) -> int {
+ cset = [](void* handle, void *service, const celix_properties_t *props) -> int {
auto dep = (CServiceDependency<T,I>*) handle;
- return dep->invokeCallback(dep->setFp, ref, service);
+ return dep->invokeCallback(dep->setFp, props, service);
};
}
if (addFp != nullptr) {
- cadd = [](void* handle, service_reference_pt ref, const void* service) -> int {
+ cadd = [](void* handle, void *service, const celix_properties_t *props) -> int {
auto dep = (CServiceDependency<T,I>*) handle;
- return dep->invokeCallback(dep->addFp, ref, service);
+ return dep->invokeCallback(dep->addFp, props, service);
};
}
if (removeFp != nullptr) {
- crem= [](void* handle, service_reference_pt ref, const void* service) -> int {
+ crem= [](void* handle, void *service, const celix_properties_t *props) -> int {
auto dep = (CServiceDependency<T,I>*) handle;
- return dep->invokeCallback(dep->removeFp, ref, service);
+ return dep->invokeCallback(dep->removeFp, props, service);
};
}
- serviceDependency_setCallbackHandle(this->cServiceDependency(), this);
- serviceDependency_setCallbacksWithServiceReference(this->cServiceDependency(), cset, cadd, nullptr, crem, nullptr);
+ celix_dmServiceDependency_setCallbackHandle(this->cServiceDependency(), this);
+ celix_dm_service_dependency_callback_options_t opts{};
+ opts.addWithProps = cadd;
+ opts.removeWithProps = crem;
+ opts.setWithProps = cset;
+ celix_dmServiceDependency_setCallbacksWithOptions(this->cServiceDependency(), &opts);
}
template<class T, typename I>
-int CServiceDependency<T,I>::invokeCallback(std::function<void(const I*, Properties&&)> fp, service_reference_pt ref, const void* service) {
- service_registration_pt reg {nullptr};
- properties_pt props {nullptr};
-
+int CServiceDependency<T,I>::invokeCallback(std::function<void(const I*, Properties&&)> fp, const celix_properties_t *props, const void* service) {
Properties properties {};
const char* key {nullptr};
const char* value {nullptr};
- if (ref != nullptr) {
- serviceReference_getServiceRegistration(ref, ®);
- serviceRegistration_getProperties(reg, &props);
-
+ if (props != nullptr) {
hash_map_iterator_t iter = hashMapIterator_construct((hash_map_pt)props);
while(hashMapIterator_hasNext(&iter)) {
key = (const char*) hashMapIterator_nextKey(&iter);
- value = properties_get(props, key);
+ value = celix_properties_get(props, key, NULL);
//std::cout << "got property " << key << "=" << value << "\n";
properties[key] = value;
}
@@ -271,7 +270,7 @@ void ServiceDependency<T,I>::setupService() {
this->modifiedFilter = this->filter;
}
- serviceDependency_setService(this->cServiceDependency(), n.c_str(), v, this->modifiedFilter.c_str());
+ celix_dmServiceDependency_setService(this->cServiceDependency(), n.c_str(), v, this->modifiedFilter.c_str());
}
template<class T, class I>
@@ -377,7 +376,7 @@ ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(
template<class T, class I>
ServiceDependency<T,I>& ServiceDependency<T,I>::setRequired(bool req) {
- serviceDependency_setRequired(this->cServiceDependency(), req);
+ celix_dmServiceDependency_setRequired(this->cServiceDependency(), req);
return *this;
}
@@ -388,28 +387,22 @@ ServiceDependency<T,I>& ServiceDependency<T,I>::setStrategy(DependencyUpdateStra
};
template<class T, class I>
-int ServiceDependency<T,I>::invokeCallback(std::function<void(I*, Properties&&)> fp, service_reference_pt ref, const void* service) {
- service_registration_pt reg {nullptr};
- properties_pt props {nullptr};
+int ServiceDependency<T,I>::invokeCallback(std::function<void(I*, Properties&&)> fp, const celix_properties_t *props, const void* service) {
I *svc = (I*)service;
Properties properties {};
const char* key {nullptr};
const char* value {nullptr};
- if (ref != nullptr) {
- serviceReference_getServiceRegistration(ref, ®);
- serviceRegistration_getProperties(reg, &props);
if (props != nullptr) {
hash_map_iterator_t iter = hashMapIterator_construct((hash_map_pt)props);
while(hashMapIterator_hasNext(&iter)) {
key = (const char*) hashMapIterator_nextKey(&iter);
- value = properties_get(props, key);
+ value = celix_properties_get(props, key, NULL);
//std::cout << "got property " << key << "=" << value << "\n";
properties[key] = value;
}
}
- }
fp(svc, std::move(properties)); //explicit move of lvalue properties.
return 0;
@@ -421,29 +414,33 @@ void ServiceDependency<T,I>::setupCallbacks() {
return;
}
- int(*cset)(void*, service_reference_pt, const void*) {nullptr};
- int(*cadd)(void*, service_reference_pt, const void*) {nullptr};
- int(*crem)(void*, service_reference_pt, const void*) {nullptr};
+ int(*cset)(void*, void *, const celix_properties_t*) {nullptr};
+ int(*cadd)(void*, void *, const celix_properties_t*) {nullptr};
+ int(*crem)(void*, void *, const celix_properties_t*) {nullptr};
if (setFp != nullptr) {
- cset = [](void* handle, service_reference_pt ref, const void* service) -> int {
+ cset = [](void* handle, void *service, const celix_properties_t* props) -> int {
auto dep = (ServiceDependency<T,I>*) handle;
- return dep->invokeCallback(dep->setFp, ref, service);
+ return dep->invokeCallback(dep->setFp, props, service);
};
}
if (addFp != nullptr) {
- cadd = [](void* handle, service_reference_pt ref, const void* service) -> int {
+ cadd = [](void* handle, void *service, const celix_properties_t* props) -> int {
auto dep = (ServiceDependency<T,I>*) handle;
- return dep->invokeCallback(dep->addFp, ref, service);
+ return dep->invokeCallback(dep->addFp, props, service);
};
}
if (removeFp != nullptr) {
- crem = [](void* handle, service_reference_pt ref, const void* service) -> int {
+ crem = [](void* handle, void *service, const celix_properties_t*props) -> int {
auto dep = (ServiceDependency<T,I>*) handle;
- return dep->invokeCallback(dep->removeFp, ref, service);
+ return dep->invokeCallback(dep->removeFp, props, service);
};
}
- serviceDependency_setCallbackHandle(this->cServiceDependency(), this);
- serviceDependency_setCallbacksWithServiceReference(this->cServiceDependency(), cset, cadd, nullptr, crem, nullptr);
+ celix_dmServiceDependency_setCallbackHandle(this->cServiceDependency(), this);
+ celix_dm_service_dependency_callback_options_t opts{};
+ opts.setWithProps = cset;
+ opts.addWithProps = cadd;
+ opts.removeWithProps = crem;
+ celix_dmServiceDependency_setCallbacksWithOptions(this->cServiceDependency(), &opts);
};
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_api.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix_api.h b/libs/framework/include/celix_api.h
index b941a78..bb1fd01 100644
--- a/libs/framework/include/celix_api.h
+++ b/libs/framework/include/celix_api.h
@@ -38,7 +38,8 @@
#include "celix_framework_factory.h"
#include "celix_launcher.h"
-#include "dm_dependency_manager.h"
+#include "celix_dependency_manager.h"
+#include "celix_dm_component.h"
#include "dm_service_dependency.h"
#include "celix_bundle_activator.h"
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_bundle_context.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix_bundle_context.h b/libs/framework/include/celix_bundle_context.h
index 6ecc445..fc7d978 100644
--- a/libs/framework/include/celix_bundle_context.h
+++ b/libs/framework/include/celix_bundle_context.h
@@ -770,7 +770,7 @@ long celix_bundleContext_trackServiceTrackers(
*
* @return the dependency manager or NULL if unsuccessful.
*/
-dm_dependency_manager_t* celix_bundleContext_getDependencyManager(celix_bundle_context_t *ctx);
+celix_dependency_manager_t* celix_bundleContext_getDependencyManager(celix_bundle_context_t *ctx);
/**
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_dependency_manager.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix_dependency_manager.h b/libs/framework/include/celix_dependency_manager.h
new file mode 100644
index 0000000..e850d0a
--- /dev/null
+++ b/libs/framework/include/celix_dependency_manager.h
@@ -0,0 +1,86 @@
+/**
+ *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 CELIX_DEPENDENCY_MANAGER_H_
+#define CELIX_DEPENDENCY_MANAGER_H_
+
+#include "celix_types.h"
+
+#include "celix_errno.h"
+#include "celix_array_list.h"
+#include "celix_dm_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * Adds a DM component to the dependency manager
+ */
+celix_status_t celix_dependencyManager_add(celix_dependency_manager_t *manager, celix_dm_component_t *component);
+
+/**
+ * Removes a DM component from the dependency manager and destroys it
+ */
+celix_status_t celix_dependencyManager_remove(celix_dependency_manager_t *manager, celix_dm_component_t *component);
+
+/**
+ * Removes all DM components from the dependency manager
+ */
+celix_status_t celix_dependencyManager_removeAllComponents(celix_dependency_manager_t *manager);
+
+/**
+ * Create and returns a dependency manager info struct for the specified bundle.
+ * The dependency manager info contains information about the state of the dependency manager components
+ *
+ * Caller has ownership of the return value (use celix_dependencyManager_destroyInfo to free the memory).
+ *
+ * @param manager The dependency manager
+ * @param bndId The bundle id to get the info from.
+ * @returns The dependency manager info for the provided bundle id or NULL if the bundle id is invalid.
+ */
+celix_dependency_manager_info_t* celix_dependencyManager_createInfo(celix_dependency_manager_t *manager, long bndId);
+
+/**
+ * Create and returns a dependency manager info structd for all started bundles.
+ * The dependency manager info contains information about the state of the dependency manager components
+ *
+ * Caller has ownership of the return values (use celix_dependencyManager_destroyInfos to free the memory).
+ *
+ * @param manager The dependency manager
+ * @returns A celix array of dependency manager infos for the provided bundle id or NULL if the bundle id is invalid.
+ */
+celix_array_list_t * /*celix_dependency_manager_info_t entries*/ celix_dependencyManager_createInfos(celix_dependency_manager_t *manager);
+
+/**
+ * Destroys a DM info struct.
+ */
+void celix_dependencyManager_destroyInfo(celix_dependency_manager_t *manager, celix_dependency_manager_info_t *info);
+
+/**
+ * Destroys a celix array list of DM info structs.
+ */
+void celix_dependencyManager_destroyInfos(celix_dependency_manager_t *manager, celix_array_list_t * infos /*entries celix_dependency_manager_info_t*/);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CELIX_DEPENDENCY_MANAGER_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_dm_component.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix_dm_component.h b/libs/framework/include/celix_dm_component.h
new file mode 100644
index 0000000..bcfaf52
--- /dev/null
+++ b/libs/framework/include/celix_dm_component.h
@@ -0,0 +1,154 @@
+/**
+ *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 CELIX_COMPONENT_H_
+#define CELIX_COMPONENT_H_
+
+#include <stdbool.h>
+
+#include "celix_types.h"
+#include "celix_errno.h"
+#include "properties.h"
+#include "array_list.h"
+#include "celix_dm_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum celix_dm_component_state_enum {
+ DM_CMP_STATE_INACTIVE = 1,
+ DM_CMP_STATE_WAITING_FOR_REQUIRED = 2,
+ DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED = 3,
+ DM_CMP_STATE_TRACKING_OPTIONAL = 4,
+} celix_dm_component_state_t;
+
+#define CELIX_DM_COMPONENT_MAX_ID_LENGTH 64
+#define CELIX_DM_COMPONENT_MAX_NAME_LENGTH 128
+
+typedef int (*celix_dm_cmp_lifecycle_fpt)(void *userData);
+
+/**
+ * Creates a DM Component
+ * Caller has ownership.
+ */
+celix_dm_component_t* celix_dmComponent_create(celix_bundle_context_t *context, const char* name);
+
+/**
+ * Destroys a DM Component
+ */
+void celix_dmComponent_destroy(celix_dm_component_t *cmp);
+
+/**
+ * Specify if a default 'service.lang=C' should be added to the properties of interfaces if no 'service.lang' has been
+ * provided. Default is false. Note that this should be set before using component_addInterface.
+ */
+celix_status_t celix_dmComponent_setCLanguageProperty(celix_dm_component_t *component, bool setCLangProp);
+
+
+/**
+ * Adds a C interface to provide as service to the Celix framework.
+ *
+ * @param serviceName the service name.
+ * @param version The version of the interface (e.g. "1.0.0"), Can be a NULL pointer.
+ * @param properties To (meta) properties to provide with the service. Can be a NULL pointer.
+ */
+celix_status_t celix_dmComponent_addInterface(celix_dm_component_t *component, const char* serviceName, const char* serviceVersion, const void* service, celix_properties_t *properties);
+
+/**
+ * Removed a C interface from a component the Celix framework.
+ *
+ * @param serviceName the service name.
+ * @return CELIX_SUCCESS when removed, CELIX_ILLEGAL_ARGUMENT when the component does not provide the interface
+ */
+celix_status_t celix_dmComponent_removeInterface(celix_dm_component_t *component, const void* service);
+/**
+ * Sets the implementation of the component. e.g. the component handle/self/this pointer.
+ */
+celix_status_t celix_dmComponent_setImplementation(celix_dm_component_t *component, void* implementation);
+
+/**
+ * Returns an arraylist of service names. The caller owns the arraylist and strings (char *)
+ */
+celix_status_t celix_dmComponent_getInterfaces(celix_dm_component_t *component, celix_array_list_t **servicesNames);
+
+/**
+ * Adds a C service dependency to the component
+ */
+celix_status_t celix_dmComponent_addServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dep);
+
+/**
+ * Removes a C service dependency to the component
+ */
+celix_status_t celix_dmComponent_removeServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency);
+
+/**
+ * Returns the current state of the component.
+ */
+celix_dm_component_state_t celix_dmComponent_currentState(celix_dm_component_t *cmp);
+
+/**
+ * Returns the implementation of the component. e.g. the component handle/self/this pointer.
+ */
+void * celix_dmComponent_getImplementation(celix_dm_component_t *cmp);
+
+/**
+ * Returns the DM component name. This is used when printing information about the component.
+ */
+const char* celix_dmComponent_getName(celix_dm_component_t *cmp);
+
+/**
+ * Returns bundle context for the bundle where this DM component is part of.
+ */
+celix_status_t celix_dmComponent_getBundleContext(celix_dm_component_t *component, celix_bundle_context_t **out);
+
+/**
+ * Set the component life cycle callbacks.
+ * The first argument will be the component implementation (@see component_getImplementation)
+ */
+celix_status_t celix_dmComponent_setCallbacks(celix_dm_component_t *component, celix_dm_cmp_lifecycle_fpt init, celix_dm_cmp_lifecycle_fpt start, celix_dm_cmp_lifecycle_fpt stop, celix_dm_cmp_lifecycle_fpt deinit);
+
+/**
+ * Set the component life cycle callbacks using a MACRO for improving the type safety.
+ */
+#define CELIX_DMCOMPONENT_SETCALLBACKS(dmCmp, type, init, start, stop, deinit) \
+ do { \
+ int (*tmp_init)(type) = (init); \
+ int (*tmp_start)(type) = (start); \
+ int (*tmp_stop)(type) = (stop); \
+ int (*tmp_deinit)(type) = (deinit); \
+ celix_dmComponent_setCallbacks((dmCmp), (celix_dm_cmp_lifecycle_fpt)tmp_init, (celix_dm_cmp_lifecycle_fpt)tmp_start, (celix_dm_cmp_lifecycle_fpt)tmp_stop, (celix_dm_cmp_lifecycle_fpt)tmp_deinit); \
+ } while(0)
+
+/**
+ * Create a DM Component info struct. Containing information about the component.
+ * Caller has ownership.
+ */
+celix_status_t celix_dmComponent_getComponentInfo(celix_dm_component_t *component, dm_component_info_pt *info);
+
+/**
+ * Destroys a DM Component info struct.
+ */
+void celix_dmComponent_destroyComponentInfo(dm_component_info_pt info);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* COMPONENT_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_dm_info.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix_dm_info.h b/libs/framework/include/celix_dm_info.h
new file mode 100644
index 0000000..3010b9c
--- /dev/null
+++ b/libs/framework/include/celix_dm_info.h
@@ -0,0 +1,76 @@
+/**
+ *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 CELIX_DM_INFO_H_
+#define CELIX_DM_INFO_H_
+
+
+
+#include <stdbool.h>
+#include "celix_array_list.h"
+#include "celix_properties.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+struct celix_dm_interface_info_struct {
+ char* name;
+ celix_properties_t *properties;
+};
+typedef struct celix_dm_interface_info_struct *dm_interface_info_pt; //deprecated
+typedef struct celix_dm_interface_info_struct dm_interface_info_t; //deprecated
+typedef struct celix_dm_interface_info_struct celix_dm_interface_info_t;
+
+struct celix_dm_service_dependency_info_struct {
+ char *filter;
+ bool available;
+ bool required;
+ size_t count;
+};
+typedef struct celix_dm_service_dependency_info_struct *dm_service_dependency_info_pt; //deprecated
+typedef struct celix_dm_service_dependency_info_struct dm_service_dependency_info_t; //deprecated
+typedef struct celix_dm_service_dependency_info_struct celix_dm_service_dependency_info_t;
+
+struct celix_dm_component_info_struct {
+ char id[64];
+ char name[128];
+ bool active;
+ char * state;
+ celix_array_list_t *interfaces; // type dm_interface_info_pt
+ celix_array_list_t *dependency_list; // type dm_service_dependency_info_pt
+};
+typedef struct celix_dm_component_info_struct *dm_component_info_pt; //deprecated
+typedef struct celix_dm_component_info_struct dm_component_info_t; //deprecated
+typedef struct celix_dm_component_info_struct celix_dm_component_info_t;
+
+struct celix_dm_dependency_manager_info_struct {
+ long bndId;
+ celix_array_list_t *components; // type dm_component_info
+};
+typedef struct celix_dm_dependency_manager_info_struct *dm_dependency_manager_info_pt; //deprecated
+typedef struct celix_dm_dependency_manager_info_struct dm_dependency_manager_info_t; //deprecated
+typedef struct celix_dm_dependency_manager_info_struct celix_dependency_manager_info_t;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //CELIX_DM_INFO_H_
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_dm_service_dependency.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix_dm_service_dependency.h b/libs/framework/include/celix_dm_service_dependency.h
new file mode 100644
index 0000000..6908096
--- /dev/null
+++ b/libs/framework/include/celix_dm_service_dependency.h
@@ -0,0 +1,169 @@
+/**
+ *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 CELIX_DM_SERVICE_DEPENDENCY_H_
+#define CELIX_DM_SERVICE_DEPENDENCY_H_
+
+#include "celix_types.h"
+#include "celix_errno.h"
+#include "celix_threads.h"
+
+#include "celix_dm_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef enum celix_dm_service_dependency_strategy_enum {
+ DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING,
+ DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
+} celix_dm_service_dependency_strategy_t;
+
+typedef int (*celix_dm_service_update_fp)(void *handle, void* service);
+typedef int (*celix_dm_service_swap_fp)(void *handle, void* oldService, void* newService);
+
+typedef int (*celix_dm_service_update_with_props_fp)(void *handle, void* service, const celix_properties_t *props);
+typedef int (*celix_dm_service_swap_with_props_fp)(void *handle, void* oldService, void* newService, const celix_properties_t *newProps);
+
+typedef struct celix_dm_service_dependency_callback_options {
+ celix_dm_service_update_fp set;
+ celix_dm_service_update_fp add;
+ celix_dm_service_update_fp remove;
+ celix_dm_service_swap_fp swap;
+
+ celix_dm_service_update_with_props_fp setWithProps;
+ celix_dm_service_update_with_props_fp addWithProps;
+ celix_dm_service_update_with_props_fp removeWithProps;
+ celix_dm_service_swap_with_props_fp swapWithProps;
+} celix_dm_service_dependency_callback_options_t;
+
+#define CELIX_EMPTY_DM_SERVICE_DEPENDENCY_CALLBACK_OPTIONS { .set = NULL, \
+ .add = NULL, \
+ .remove = NULL, \
+ .swap = NULL, \
+ .setWithProps = NULL, \
+ .addWithProps = NULL, \
+ .removeWithProps = NULL, \
+ .swapWithProps = NULL }
+
+/**
+ * Create a service dependency.
+ * Caller has ownership.
+ */
+celix_dm_service_dependency_t* celix_dmServiceDependency_create(void);
+
+/**
+ * Destroys a service dependency.
+ * Caller has ownership.
+ */
+void celix_dmServiceDependency_destroy(celix_dm_service_dependency_t *dep);
+
+/**
+ * Specify if the service dependency is required. default is false
+ */
+celix_status_t celix_dmServiceDependency_setRequired(celix_dm_service_dependency_t *dependency, bool required);
+
+/**
+ * Specify if the servide dependency should add a C language filter for this dependency if no "service.lang" part if found the in the provided filter.
+ * Default is false
+ */
+celix_status_t celix_dmServiceDependency_setAddCLanguageFilter(celix_dm_service_dependency_t *dependency, bool addCLangFilter);
+
+
+/**
+ * Specify if the service dependency update strategy.
+ *
+ * The DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING strategy notifies the component in case the dependencies set
+ * changes (e.g. a dependency is added/removed): the component is responsible for protecting via locks
+ * the dependencies list and check (always under lock) if the service he's depending on is still available.
+ *
+ * The DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND (default when no strategy is explicitly set) reliefs the programmer
+ * from dealing with service dependencies' consistency issues: in case this strategy is adopted, the component
+ * is stopped and restarted (i.e. temporarily suspended) upon service dependencies' changes.
+ *
+ * Default strategy is DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
+ */
+celix_status_t celix_dmServiceDependency_setStrategy(celix_dm_service_dependency_t *dependency, celix_dm_service_dependency_strategy_t strategy);
+
+/**
+ * Return the service dependency update strategy.
+ */
+celix_dm_service_dependency_strategy_t celix_dmServiceDependency_getStrategy(celix_dm_service_dependency_t *dependency);
+
+/**
+ * Set the service name, version range and filter.
+ *
+ * @param serviceName The service name. Must have a value.
+ * @param serviceVersionRange The service version range, can be a NULL pointer.
+ * @param filter The (additional) filter to use (e.g. "(location=front)"). Can be a NULL pointer.
+ */
+celix_status_t celix_dmServiceDependency_setService(celix_dm_service_dependency_t *dependency, const char* serviceName, const char* serviceVersionRange, const char* filter);
+
+/**
+ * Returns the service depenendy filter.
+ */
+const char* celix_dmServiceDependency_getFilter(celix_dm_service_dependency_t *dependency);
+
+/**
+ * Set the set callbacks when services specified by the service dependency
+ * The first argument of the callbacks will be the component implement (@see component_getImplementation)
+ * The second the argument a pointer to an instance of a service struct of the specified service dependency.
+ */
+celix_status_t celix_dmServiceDependency_setCallback(celix_dm_service_dependency_t *dependency, celix_dm_service_update_fp set);
+
+/**
+ * Set the set function callbacks when services specified by the service dependency
+ * The first argument of the callbacks will be the component implement (@see component_getImplementation)
+ * The second argument of th callbacks will be a pointer to an instance of a service struct of the specified service dependency.
+ * The third argument of th callbacks will be a pointer to a service properties of the a service instance of the specified service dependency.
+ */
+celix_status_t celix_dmServiceDependency_setCallbackWithProperties(celix_dm_service_dependency_t *dependency, celix_dm_service_update_with_props_fp set);
+
+/**
+ * Set the set, add, change, remove and swap function callbacks when services specified by the service dependency
+ * are (respectively) set, added, changed, removed or swapped.
+ *
+ * The version with the WithProps suffix will be called with as third argument the service properties.
+ */
+celix_status_t celix_dmServiceDependency_setCallbacksWithOptions(celix_dm_service_dependency_t *dependency, const celix_dm_service_dependency_callback_options_t *opts);
+
+/**
+ * Set the callback handle to be used in the callbacks. Note that this normally should not be set, because the
+ * result of component_getImplementation() is used
+ * This can be used in rare cases when the callbacks are actually interceptors. e.g. in the case of C++ support.
+ */
+celix_status_t celix_dmServiceDependency_setCallbackHandle(celix_dm_service_dependency_t *dependency, void* handle);
+
+/**
+ * Creates a service dependency info. The service dependency info struct contains information about the service dependency.
+ * The caller is the owner
+ */
+dm_service_dependency_info_t* celix_dmServiceDependency_createInfo(celix_dm_service_dependency_t* dep);
+
+/**
+ * Destroy a provided service dependency info struct.
+ */
+void celix_dmServiceDependency_destroyInfo(celix_dm_service_dependency_t *dep, dm_service_dependency_info_t *info);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CELIX_DM_SERVICE_DEPENDENCY_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_framework.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix_framework.h b/libs/framework/include/celix_framework.h
index 39116f6..a4c784b 100644
--- a/libs/framework/include/celix_framework.h
+++ b/libs/framework/include/celix_framework.h
@@ -19,8 +19,6 @@
#ifndef CELIX_FRAMEWORK_H_
#define CELIX_FRAMEWORK_H_
-typedef struct framework celix_framework_t;
-
#include "celix_types.h"
#include "celix_properties.h"
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_framework_factory.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix_framework_factory.h b/libs/framework/include/celix_framework_factory.h
index 70d2678..74e7c06 100644
--- a/libs/framework/include/celix_framework_factory.h
+++ b/libs/framework/include/celix_framework_factory.h
@@ -31,7 +31,7 @@ extern "C" {
* @param config The framework configuration. Can be NULL.
* @return a started framework or NULL
*/
-framework_t* frameworkFactory_newFramework(properties_t *config);
+celix_framework_t* frameworkFactory_newFramework(celix_properties_t *config);
#ifdef __cplusplus
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_launcher.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix_launcher.h b/libs/framework/include/celix_launcher.h
index 579eef7..19ab9f9 100644
--- a/libs/framework/include/celix_launcher.h
+++ b/libs/framework/include/celix_launcher.h
@@ -49,7 +49,7 @@ extern "C" {
* @param embeddedConfig The optional embbeded config, will be overriden with the config.properties if found.
* @return CELIX_SUCCESS if successful.
*/
-int celixLauncher_launchAndWaitForShutdown(int argc, char *argv[], properties_t *embeddedConfig);
+int celixLauncher_launchAndWaitForShutdown(int argc, char *argv[], celix_properties_t *embeddedConfig);
/**
@@ -63,7 +63,7 @@ int celixLauncher_launchAndWaitForShutdown(int argc, char *argv[], properties_t
* @param framework Output parameter for the framework.
* @return CELIX_SUCCESS if successful.
*/
-int celixLauncher_launch(const char *configFile, framework_t **framework);
+int celixLauncher_launch(const char *configFile, celix_framework_t **framework);
/**
* Launches the a celix framework and returns the framework.
@@ -76,7 +76,7 @@ int celixLauncher_launch(const char *configFile, framework_t **framework);
* @param framework Output parameter for the framework.
* @return CELIX_SUCCESS if successful.
*/
-int celixLauncher_launchWithStream(FILE *config, framework_t **framework);
+int celixLauncher_launchWithStream(FILE *config, celix_framework_t **framework);
/**
* Launches the a celix framework and returns the framework.
@@ -89,25 +89,25 @@ int celixLauncher_launchWithStream(FILE *config, framework_t **framework);
* @param framework Output parameter for the framework.
* @return CELIX_SUCCESS if successful.
*/
-int celixLauncher_launchWithProperties(properties_t *config, framework_t **framework);
+int celixLauncher_launchWithProperties(celix_properties_t *config, celix_framework_t **framework);
/**
* Wait (blocks) for the shutdown of the provided celix framework.
* @param framework The framework to wait for.
*/
-void celixLauncher_waitForShutdown(framework_t *framework);
+void celixLauncher_waitForShutdown(celix_framework_t *framework);
/**
* Stop the provided celix framework.
* @param framework The framework to stop.
*/
-void celixLauncher_stop(framework_t *framework);
+void celixLauncher_stop(celix_framework_t *framework);
/**
* Destroys the provided framework and if needed stops it first.
* @param framework The framework to stop.
*/
-void celixLauncher_destroy(framework_t *framework);
+void celixLauncher_destroy(celix_framework_t *framework);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_types.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/celix_types.h b/libs/framework/include/celix_types.h
index 9f73a42..f59c8aa 100644
--- a/libs/framework/include/celix_types.h
+++ b/libs/framework/include/celix_types.h
@@ -25,30 +25,44 @@
* These types are declared in a separate header for forward declaration
*/
-typedef struct bundle * bundle_pt;
-typedef struct bundle bundle_t;
-typedef struct bundle celix_bundle_t;
-typedef struct bundleArchive *bundle_archive_pt;
-typedef struct bundleArchive bundle_archive_t;
-
-typedef struct bundleRevision *bundle_revision_pt;
-typedef struct bundleRevision bundle_revision_t;
+#ifdef ADD_CELIX_DEPRECATED_WARNING
+#define CELIX_DEPRECATED_ATTR __attribute__ ((deprecated))
+#define CELIX_DEPRECATED_ATTR_MSG(msg) __attribute__ ((deprecated(msg)))
+#else
+#define CELIX_DEPRECATED_ATTR
+#define CELIX_DEPRECATED_ATTR_MSG(msg)
+#endif
-typedef struct bundleContext *bundle_context_pt;
-typedef struct bundleContext bundle_context_t;
-typedef struct bundleContext celix_bundle_context_t;
-typedef struct dm_dependency_manager *dm_dependency_manager_pt;
-typedef struct dm_dependency_manager dm_dependency_manager_t;
+typedef struct celix_framework celix_framework_t;
+typedef struct celix_bundle celix_bundle_t;
+typedef struct celix_bundle_context celix_bundle_context_t;
+typedef struct celix_dependency_manager celix_dependency_manager_t;
+typedef struct celix_dm_component_struct celix_dm_component_t;
+typedef struct celix_dm_service_dependency celix_dm_service_dependency_t;
-typedef struct dm_component_struct *dm_component_pt;
-typedef struct dm_component_struct dm_component_t;
+//deprecated
+typedef struct celix_dependency_manager dm_dependency_manager_t CELIX_DEPRECATED_ATTR;
+typedef struct celix_dependency_manager *dm_dependency_manager_pt CELIX_DEPRECATED_ATTR;
+typedef struct celix_dm_component_struct *dm_component_pt CELIX_DEPRECATED_ATTR;
+typedef struct celix_dm_component_struct dm_component_t CELIX_DEPRECATED_ATTR;
+typedef struct celix_dm_service_dependency *dm_service_dependency_pt CELIX_DEPRECATED_ATTR;
+typedef struct celix_dm_service_dependency dm_service_dependency_t CELIX_DEPRECATED_ATTR;
-typedef struct dm_service_dependency *dm_service_dependency_pt;
-typedef struct dm_service_dependency dm_service_dependency_t;
+typedef struct celix_bundle_context *bundle_context_pt CELIX_DEPRECATED_ATTR;
+typedef struct celix_bundle_context bundle_context_t CELIX_DEPRECATED_ATTR;
+typedef struct celix_framework *framework_pt CELIX_DEPRECATED_ATTR;
+typedef struct celix_framework framework_t CELIX_DEPRECATED_ATTR;
+typedef struct celix_bundle * bundle_pt CELIX_DEPRECATED_ATTR;
+typedef struct celix_bundle bundle_t CELIX_DEPRECATED_ATTR;
-typedef struct service_factory *service_factory_pt; //deprecated
+// will be deprecated in the future
+typedef struct bundleArchive *bundle_archive_pt;
+typedef struct bundleArchive bundle_archive_t;
+typedef struct bundleRevision *bundle_revision_pt;
+typedef struct bundleRevision bundle_revision_t;
+typedef struct service_factory *service_factory_pt;
typedef struct serviceReference * service_reference_pt;
#endif //CELIX_CELIX_TYPES_H
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/dm_activator.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/dm_activator.h b/libs/framework/include/dm_activator.h
index 1e06331..3b9d89a 100644
--- a/libs/framework/include/dm_activator.h
+++ b/libs/framework/include/dm_activator.h
@@ -29,10 +29,10 @@
#ifndef DM_ACTIVATOR_BASE_H_
#define DM_ACTIVATOR_BASE_H_
-
+#include "celix_types.h"
#include "bundle_context.h"
#include "celix_errno.h"
-#include "dm_dependency_manager.h"
+#include "celix_dependency_manager.h"
#include "dm_component.h"
#include "dm_service_dependency.h"
#include "celix_bundle_activator.h"
@@ -41,6 +41,10 @@
extern "C" {
#endif
+#ifdef ADD_CELIX_DEPRECATED_WARNING
+#warning This header is deprecated, use the celix_bundle_activator instead. the Dependency manager can be retreived from the bundle context.
+#endif
+
/**
* Should be implemented by a bundle specific DM activator.
* Should allocate and initialize a bundle specific activator struct.
@@ -52,13 +56,13 @@ celix_status_t dm_create(bundle_context_pt context, void ** userData);
* Will be called after the dm_create function.
* Can be used to specify with use of the provided dependency manager the bundle specific components.
*/
-celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager);
+celix_status_t dm_init(void * userData, bundle_context_pt context, celix_dependency_manager_t *manager);
/**
* Should be implemented by a bundle specific DM activator.
* Should deinitialize and deallocate the undle specific activator struct.
*/
-celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager);
+celix_status_t dm_destroy(void * userData, bundle_context_pt context, celix_dependency_manager_t *manager);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/dm_component.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/dm_component.h b/libs/framework/include/dm_component.h
index 0e5bd6b..88b9f37 100644
--- a/libs/framework/include/dm_component.h
+++ b/libs/framework/include/dm_component.h
@@ -33,44 +33,40 @@
#include "celix_errno.h"
#include "properties.h"
#include "array_list.h"
-#include "dm_info.h"
+#include "celix_dm_info.h"
+#include "celix_dm_component.h"
#ifdef __cplusplus
extern "C" {
#endif
-typedef enum dm_component_state_enum {
- DM_CMP_STATE_INACTIVE = 1,
- DM_CMP_STATE_WAITING_FOR_REQUIRED = 2,
- DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED = 3,
- DM_CMP_STATE_TRACKING_OPTIONAL = 4,
-} dm_component_state_t;
+typedef enum celix_dm_component_state_enum dm_component_state_t CELIX_DEPRECATED_ATTR; //deprecated
#define DM_COMPONENT_MAX_ID_LENGTH 64
#define DM_COMPONENT_MAX_NAME_LENGTH 128
-typedef int (*init_fpt)(void *userData);
-typedef int (*start_fpt)(void *userData);
-typedef int (*stop_fpt)(void *userData);
-typedef int (*deinit_fpt)(void *userData);
+typedef int (*init_fpt)(void *userData) CELIX_DEPRECATED_ATTR;
+typedef int (*start_fpt)(void *userData) CELIX_DEPRECATED_ATTR;
+typedef int (*stop_fpt)(void *userData) CELIX_DEPRECATED_ATTR;
+typedef int (*deinit_fpt)(void *userData) CELIX_DEPRECATED_ATTR;
/**
* Creates a DM Component
* Caller has ownership.
*/
-celix_status_t component_create(bundle_context_t *context, const char* name, dm_component_t **component);
+celix_status_t component_create(celix_bundle_context_t *context, const char* name, celix_dm_component_t **component) CELIX_DEPRECATED_ATTR;
/**
* Destroys a DM Component
*/
-void component_destroy(dm_component_t *component);
+void component_destroy(celix_dm_component_t *component) CELIX_DEPRECATED_ATTR;
/**
* Specify if a default 'service.lang=C' should be added to the properties of interfaces if no 'service.lang' has been
* provided. Default is false. Note that this should be set before using component_addInterface.
*/
-celix_status_t component_setCLanguageProperty(dm_component_t *component, bool setCLangProp);
+celix_status_t component_setCLanguageProperty(celix_dm_component_t *component, bool setCLangProp) CELIX_DEPRECATED_ATTR;
/**
@@ -80,7 +76,7 @@ celix_status_t component_setCLanguageProperty(dm_component_t *component, bool se
* @param version The version of the interface (e.g. "1.0.0"), Can be a NULL pointer.
* @param properties To (meta) properties to provide with the service. Can be a NULL pointer.
*/
-celix_status_t component_addInterface(dm_component_t *component, const char* serviceName, const char* serviceVersion, const void* service, properties_t *properties);
+celix_status_t component_addInterface(celix_dm_component_t *component, const char* serviceName, const char* serviceVersion, const void* service, celix_properties_t *properties) CELIX_DEPRECATED_ATTR;
/**
* Removed a C interface from a component the Celix framework.
@@ -88,52 +84,52 @@ celix_status_t component_addInterface(dm_component_t *component, const char* ser
* @param serviceName the service name.
* @return CELIX_SUCCESS when removed, CELIX_ILLEGAL_ARGUMENT when the component does not provide the interface
*/
-celix_status_t component_removeInterface(dm_component_pt component, const void* service);
+celix_status_t component_removeInterface(celix_dm_component_t *component, const void* service) CELIX_DEPRECATED_ATTR;
/**
* Sets the implementation of the component. e.g. the component handle/self/this pointer.
*/
-celix_status_t component_setImplementation(dm_component_t *component, void* implementation);
+celix_status_t component_setImplementation(celix_dm_component_t *component, void* implementation) CELIX_DEPRECATED_ATTR;
/**
* Returns an arraylist of service names. The caller owns the arraylist and strings (char *)
*/
-celix_status_t component_getInterfaces(dm_component_t *component, array_list_t **servicesNames);
+celix_status_t component_getInterfaces(celix_dm_component_t *component, celix_array_list_t **servicesNames) CELIX_DEPRECATED_ATTR;
/**
* Adds a C service dependency to the component
*/
-celix_status_t component_addServiceDependency(dm_component_t *component, dm_service_dependency_t *dep);
+celix_status_t component_addServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dep) CELIX_DEPRECATED_ATTR;
/**
* Removes a C service dependency to the component
*/
-celix_status_t component_removeServiceDependency(dm_component_t *component, dm_service_dependency_t *dependency);
+celix_status_t component_removeServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency) CELIX_DEPRECATED_ATTR;
/**
* Returns the current state of the component.
*/
-dm_component_state_t component_currentState(dm_component_t *cmp);
+celix_dm_component_state_t component_currentState(celix_dm_component_t *cmp) CELIX_DEPRECATED_ATTR;
/**
* Returns the implementation of the component. e.g. the component handle/self/this pointer.
*/
-void * component_getImplementation(dm_component_t *cmp);
+void * component_getImplementation(celix_dm_component_t *cmp) CELIX_DEPRECATED_ATTR;
/**
* Returns the DM component name. This is used when printing information about the component.
*/
-const char * component_getName(dm_component_t *cmp);
+const char * component_getName(celix_dm_component_t *cmp) CELIX_DEPRECATED_ATTR;
/**
* Returns bundle context for the bundle where this DM component is part of.
*/
-celix_status_t component_getBundleContext(dm_component_t *component, bundle_context_t **out);
+celix_status_t component_getBundleContext(celix_dm_component_t *component, celix_bundle_context_t **out) CELIX_DEPRECATED_ATTR;
/**
* Set the component life cycle callbacks.
* The first argument will be the component implementation (@see component_getImplementation)
*/
-celix_status_t component_setCallbacks(dm_component_t *component, init_fpt init, start_fpt start, stop_fpt stop, deinit_fpt deinit);
+celix_status_t component_setCallbacks(celix_dm_component_t *component, celix_dm_cmp_lifecycle_fpt init, celix_dm_cmp_lifecycle_fpt start, celix_dm_cmp_lifecycle_fpt stop, celix_dm_cmp_lifecycle_fpt deinit) CELIX_DEPRECATED_ATTR;
/**
* Set the component life cycle callbacks using a MACRO for improving the type safety.
@@ -144,19 +140,19 @@ celix_status_t component_setCallbacks(dm_component_t *component, init_fpt init,
int (*tmp_start)(type) = (start); \
int (*tmp_stop)(type) = (stop); \
int (*tmp_deinit)(type) = (deinit); \
- component_setCallbacks((dmCmp), (init_fpt)tmp_init, (start_fpt)tmp_start, (stop_fpt)tmp_stop, (deinit_fpt)tmp_deinit); \
+ component_setCallbacks((dmCmp), (celix_dm_cmp_lifecycle_fpt)tmp_init, (celix_dm_cmp_lifecycle_fpt)tmp_start, (celix_dm_cmp_lifecycle_fpt)tmp_stop, (celix_dm_cmp_lifecycle_fpt)tmp_deinit); \
} while(0)
/**
* Create a DM Component info struct. Containing information about the component.
* Caller has ownership.
*/
-celix_status_t component_getComponentInfo(dm_component_t *component, dm_component_info_pt *info);
+celix_status_t component_getComponentInfo(celix_dm_component_t *component, dm_component_info_pt *info) CELIX_DEPRECATED_ATTR;
/**
* Destroys a DM Component info struct.
*/
-void component_destroyComponentInfo(dm_component_info_pt info);
+void component_destroyComponentInfo(dm_component_info_pt info) CELIX_DEPRECATED_ATTR;
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/dm_dependency_manager.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/dm_dependency_manager.h b/libs/framework/include/dm_dependency_manager.h
index 1fce27f..034a6bf 100644
--- a/libs/framework/include/dm_dependency_manager.h
+++ b/libs/framework/include/dm_dependency_manager.h
@@ -31,50 +31,48 @@
#include "celix_errno.h"
#include "array_list.h"
-#include "dm_info.h"
+#include "celix_dm_info.h"
#ifdef __cplusplus
extern "C" {
#endif
-
/**
* Creates a dependency manager.
* Caller has ownership.
*/
- //TODO make this private, dep man should always be retrieved from the bundle context
-celix_status_t dependencyManager_create(bundle_context_t *context, dm_dependency_manager_t **manager);
+celix_status_t dependencyManager_create(celix_bundle_context_t *context, celix_dependency_manager_t **manager) CELIX_DEPRECATED_ATTR;
/**
* Destroys the provided dependency manager
*/
-void dependencyManager_destroy(dm_dependency_manager_t *manager);
+void dependencyManager_destroy(celix_dependency_manager_t *manager) CELIX_DEPRECATED_ATTR;
/**
* Adds a DM component to the dependency manager
*/
-celix_status_t dependencyManager_add(dm_dependency_manager_t *manager, dm_component_t *component);
+celix_status_t dependencyManager_add(celix_dependency_manager_t *manager, celix_dm_component_t *component)CELIX_DEPRECATED_ATTR;
/**
* Removes a DM component from the dependency manager and destroys it
*/
-celix_status_t dependencyManager_remove(dm_dependency_manager_t *manager, dm_component_t *component);
+celix_status_t dependencyManager_remove(celix_dependency_manager_t *manager, celix_dm_component_t *component) CELIX_DEPRECATED_ATTR;
/**
* Removes all DM components from the dependency manager
*/
-celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_t *manager);
+celix_status_t dependencyManager_removeAllComponents(celix_dependency_manager_t *manager) CELIX_DEPRECATED_ATTR;
/**
* Create and returns a DM Info struct. Which contains information about the state of the DM components
* Caller has ownership.
*/
-celix_status_t dependencyManager_getInfo(dm_dependency_manager_t *manager, dm_dependency_manager_info_t **info);
+celix_status_t dependencyManager_getInfo(celix_dependency_manager_t *manager, dm_dependency_manager_info_pt *info) CELIX_DEPRECATED_ATTR;
/**
* Destroys a DM info struct.
*/
-void dependencyManager_destroyInfo(dm_dependency_manager_t *manager, dm_dependency_manager_info_t *info);
+void dependencyManager_destroyInfo(celix_dependency_manager_t *manager, dm_dependency_manager_info_pt info) CELIX_DEPRECATED_ATTR;
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/dm_info.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/dm_info.h b/libs/framework/include/dm_info.h
deleted file mode 100644
index 8074ab6..0000000
--- a/libs/framework/include/dm_info.h
+++ /dev/null
@@ -1,76 +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.
- */
-/*
- * dm_server.h
- *
- * \date 15 Oct 2015
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#ifndef CELIX_DM_INFO_SERVICE_H
-#define CELIX_DM_INFO_SERVICE_H
-
-
-
-#include <stdbool.h>
-#include "array_list.h"
-#include "properties.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define DM_INFO_SERVICE_NAME "dm_info"
-
-
-typedef struct dm_interface_info_struct {
- char* name;
- properties_pt properties;
-} dm_interface_info_t;
-typedef struct dm_interface_info_struct *dm_interface_info_pt;
-
-typedef struct dm_service_dependency_info_struct {
- char *filter;
- bool available;
- bool required;
- size_t count;
-} dm_service_dependency_info_t;
-typedef struct dm_service_dependency_info_struct *dm_service_dependency_info_pt;
-
-typedef struct dm_component_info_struct {
- char id[64];
- char name[128];
- bool active;
- char * state;
- array_list_pt interfaces; // type dm_interface_info_pt
- array_list_pt dependency_list; // type dm_service_dependency_info_pt
-} dm_component_info_t;
-typedef struct dm_component_info_struct *dm_component_info_pt;
-
-typedef struct dm_dependency_manager_info_struct {
- array_list_pt components; // type dm_component_info
-} dm_dependency_manager_info_t;
-typedef struct dm_dependency_manager_info_struct *dm_dependency_manager_info_pt;
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //CELIX_DM_INFO_SERVICE_H
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/dm_service_dependency.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/dm_service_dependency.h b/libs/framework/include/dm_service_dependency.h
index 9ed78e3..0ff549e 100644
--- a/libs/framework/include/dm_service_dependency.h
+++ b/libs/framework/include/dm_service_dependency.h
@@ -32,17 +32,15 @@
#include "celix_threads.h"
#include "service_reference.h"
-#include "dm_info.h"
+#include "celix_dm_info.h"
+#include "celix_dm_service_dependency.h"
#ifdef __cplusplus
extern "C" {
#endif
-typedef enum dm_service_dependency_strategy_enum {
- DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING,
- DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
-} dm_service_dependency_strategy_t;
+typedef enum celix_dm_service_dependency_strategy_enum dm_service_dependency_strategy_t CELIX_DEPRECATED_ATTR;
typedef int (*service_set_fpt)(void *handle, const void* service);
typedef int (*service_add_fpt)(void *handle, const void* service);
@@ -60,24 +58,24 @@ typedef celix_status_t (*service_swap_with_ref_fpt)(void *handle, service_refere
* Create a service dependency.
* Caller has ownership.
*/
-celix_status_t serviceDependency_create(dm_service_dependency_t **dep);
+celix_status_t serviceDependency_create(celix_dm_service_dependency_t **dep) CELIX_DEPRECATED_ATTR;
/**
* Destroys a service dependency.
* Caller has ownership.
*/
-celix_status_t serviceDependency_destroy(dm_service_dependency_t **dep);
+celix_status_t serviceDependency_destroy(celix_dm_service_dependency_t **dep) CELIX_DEPRECATED_ATTR;
/**
* Specify if the service dependency is required. default is false
*/
-celix_status_t serviceDependency_setRequired(dm_service_dependency_t *dependency, bool required);
+celix_status_t serviceDependency_setRequired(celix_dm_service_dependency_t *dependency, bool required) CELIX_DEPRECATED_ATTR;
/**
* Specify if the servide dependency should add a C language filter for this dependency if no "service.lang" part if found the in the provided filter.
* Default is false
*/
-celix_status_t serviceDependency_setAddCLanguageFilter(dm_service_dependency_t *dependency, bool addCLangFilter);
+celix_status_t serviceDependency_setAddCLanguageFilter(celix_dm_service_dependency_t *dependency, bool addCLangFilter) CELIX_DEPRECATED_ATTR;
/**
@@ -93,12 +91,12 @@ celix_status_t serviceDependency_setAddCLanguageFilter(dm_service_dependency_t *
*
* Default strategy is DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
*/
-celix_status_t serviceDependency_setStrategy(dm_service_dependency_t *dependency,dm_service_dependency_strategy_t strategy);
+celix_status_t serviceDependency_setStrategy(celix_dm_service_dependency_t *dependency, celix_dm_service_dependency_strategy_t strategy) CELIX_DEPRECATED_ATTR;
/**
* Return the service dependency update strategy.
*/
-celix_status_t serviceDependency_getStrategy(dm_service_dependency_t *dependency,dm_service_dependency_strategy_t* strategy);
+celix_status_t serviceDependency_getStrategy(celix_dm_service_dependency_t *dependency, celix_dm_service_dependency_strategy_t* strategy) CELIX_DEPRECATED_ATTR;
/**
* Set the service name, version range and filter.
@@ -107,12 +105,12 @@ celix_status_t serviceDependency_getStrategy(dm_service_dependency_t *dependency
* @param serviceVersionRange The service version range, can be a NULL pointer.
* @param filter The (additional) filter to use (e.g. "(location=front)"). Can be a NULL pointer.
*/
-celix_status_t serviceDependency_setService(dm_service_dependency_t *dependency, const char* serviceName, const char* serviceVersionRange, const char* filter);
+celix_status_t serviceDependency_setService(celix_dm_service_dependency_t *dependency, const char* serviceName, const char* serviceVersionRange, const char* filter) CELIX_DEPRECATED_ATTR;
/**
* Returns the service depenendy filter.
*/
-celix_status_t serviceDependency_getFilter(dm_service_dependency_t *dependency, const char** filter);
+celix_status_t serviceDependency_getFilter(celix_dm_service_dependency_t *dependency, const char** filter) CELIX_DEPRECATED_ATTR;
/**
* Set the set, add, change, remove and swap function callbacks when services specified by the service dependency
@@ -120,7 +118,7 @@ celix_status_t serviceDependency_getFilter(dm_service_dependency_t *dependency,
* The first argument of the callbacks will be the component implement (@see component_getImplementation)
* The second the argument a pointer to an instance of a service struct of the specified service dependency.
*/
-celix_status_t serviceDependency_setCallbacks(dm_service_dependency_t *dependency, service_set_fpt set, service_add_fpt add, service_change_fpt change, service_remove_fpt remove, service_swap_fpt swap);
+celix_status_t serviceDependency_setCallbacks(celix_dm_service_dependency_t *dependency, service_set_fpt set, service_add_fpt add, service_change_fpt change, service_remove_fpt remove, service_swap_fpt swap) CELIX_DEPRECATED_ATTR;
/**
* Set the set, add, change, remove and swap function callbacks when services specified by the service dependency
@@ -129,13 +127,13 @@ celix_status_t serviceDependency_setCallbacks(dm_service_dependency_t *dependenc
* The second argument of th callbacks will be a pointer to an instance of a service struct of the specified service dependency.
* The third argument of th callbacks will be a pointer to a service reference of the a service instance of the specified service dependency.
*/
-celix_status_t serviceDependency_setCallbacksWithServiceReference(dm_service_dependency_t *dependency, service_set_with_ref_fpt set, service_add_with_ref_fpt add, service_change_with_ref_fpt change, service_remove_with_ref_fpt remove, service_swap_with_ref_fpt swap);
+celix_status_t serviceDependency_setCallbacksWithServiceReference(celix_dm_service_dependency_t *dependency, service_set_with_ref_fpt set, service_add_with_ref_fpt add, service_change_with_ref_fpt change, service_remove_with_ref_fpt remove, service_swap_with_ref_fpt swap) CELIX_DEPRECATED_ATTR;
/**
* Specifies which field member (pointer to) to update when a service dependencies is set.
* If provided the provided service_lock will be used for locking when updating the service instance.
*/
-celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_t *dependency, celix_thread_mutex_t *service_lock, const void** field);
+celix_status_t serviceDependency_setAutoConfigure(celix_dm_service_dependency_t *dependency, celix_thread_mutex_t *service_lock, const void** field) CELIX_DEPRECATED_ATTR;
#define serviceDependency_setCallbacksSafe(dep, cmpType, servType, set, add, change, remove, swap) \
do { \
@@ -152,18 +150,18 @@ celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_t *depen
* result of component_getImplementation() is used
* This can be used in rare cases when the callbacks are actually interceptors. e.g. in the case of C++ support.
*/
-celix_status_t serviceDependency_setCallbackHandle(dm_service_dependency_t *dependency, void* handle);
+celix_status_t serviceDependency_setCallbackHandle(celix_dm_service_dependency_t *dependency, void* handle) CELIX_DEPRECATED_ATTR;
/**
* Creates a service dependency info. The service dependency info struct contains information about the service dependency.
* The caller is the owner
*/
-celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_t* dep, dm_service_dependency_info_t **info);
+celix_status_t serviceDependency_getServiceDependencyInfo(celix_dm_service_dependency_t* dep, dm_service_dependency_info_t **info) CELIX_DEPRECATED_ATTR;
/**
* Destroy a provided service dependency info struct.
*/
-void dependency_destroyDependencyInfo(dm_service_dependency_info_t *info);
+void dependency_destroyDependencyInfo(dm_service_dependency_info_t *info) CELIX_DEPRECATED_ATTR;
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/framework.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/framework.h b/libs/framework/include/framework.h
index f02b784..6864da5 100644
--- a/libs/framework/include/framework.h
+++ b/libs/framework/include/framework.h
@@ -27,9 +27,6 @@
#ifndef FRAMEWORK_H_
#define FRAMEWORK_H_
-typedef struct framework *framework_pt;
-typedef struct framework framework_t;
-
#include "celix_errno.h"
#include "framework_exports.h"
#include "bundle.h"
@@ -41,19 +38,19 @@ extern "C" {
#endif
// #TODO: Move to FrameworkFactory according the OSGi Spec
-FRAMEWORK_EXPORT celix_status_t framework_create(framework_t **framework, properties_t *config);
+FRAMEWORK_EXPORT celix_status_t framework_create(celix_framework_t **framework, celix_properties_t *config);
-FRAMEWORK_EXPORT celix_status_t framework_start(framework_t *framework);
+FRAMEWORK_EXPORT celix_status_t framework_start(celix_framework_t *framework);
-FRAMEWORK_EXPORT celix_status_t framework_stop(framework_t *framework);
+FRAMEWORK_EXPORT celix_status_t framework_stop(celix_framework_t *framework);
-FRAMEWORK_EXPORT celix_status_t framework_destroy(framework_t *framework);
+FRAMEWORK_EXPORT celix_status_t framework_destroy(celix_framework_t *framework);
-FRAMEWORK_EXPORT celix_status_t framework_waitForStop(framework_t *framework);
+FRAMEWORK_EXPORT celix_status_t framework_waitForStop(celix_framework_t *framework);
-FRAMEWORK_EXPORT celix_status_t framework_getFrameworkBundle(framework_t *framework, bundle_t **bundle);
+FRAMEWORK_EXPORT celix_status_t framework_getFrameworkBundle(celix_framework_t *framework, celix_bundle_t **bundle);
-bundle_context_t* framework_getContext(framework_t *framework);
+celix_bundle_context_t* framework_getContext(celix_framework_t *framework);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/listener_hook_service.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/listener_hook_service.h b/libs/framework/include/listener_hook_service.h
index d80c09e..ce1befe 100644
--- a/libs/framework/include/listener_hook_service.h
+++ b/libs/framework/include/listener_hook_service.h
@@ -39,7 +39,7 @@ extern "C" {
#endif
struct listener_hook_info {
- bundle_context_pt context;
+ celix_bundle_context_t *context;
const char *filter;
bool removed;
};
@@ -47,9 +47,9 @@ struct listener_hook_info {
struct listener_hook_service {
void *handle;
- celix_status_t (*added)(void *hook, array_list_pt listeners);
+ celix_status_t (*added)(void *hook, celix_array_list_t *listeners);
- celix_status_t (*removed)(void *hook, array_list_pt listeners);
+ celix_status_t (*removed)(void *hook, celix_array_list_t *listeners);
};
#ifdef __cplusplus
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/manifest.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/manifest.h b/libs/framework/include/manifest.h
index eeccfbc..a6b5d59 100644
--- a/libs/framework/include/manifest.h
+++ b/libs/framework/include/manifest.h
@@ -36,7 +36,7 @@ extern "C" {
#endif
struct manifest {
- properties_pt mainAttributes;
+ celix_properties_t *mainAttributes;
hash_map_pt attributes;
};
@@ -50,7 +50,7 @@ FRAMEWORK_EXPORT celix_status_t manifest_destroy(manifest_pt manifest);
FRAMEWORK_EXPORT void manifest_clear(manifest_pt manifest);
-FRAMEWORK_EXPORT properties_pt manifest_getMainAttributes(manifest_pt manifest);
+FRAMEWORK_EXPORT celix_properties_t *manifest_getMainAttributes(manifest_pt manifest);
FRAMEWORK_EXPORT celix_status_t manifest_getEntries(manifest_pt manifest, hash_map_pt *map);
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/module.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/module.h b/libs/framework/include/module.h
index 463fd86..446547a 100644
--- a/libs/framework/include/module.h
+++ b/libs/framework/include/module.h
@@ -41,9 +41,9 @@ typedef struct module *module_pt;
extern "C" {
#endif
-module_pt module_create(manifest_pt headerMap, const char *moduleId, bundle_pt bundle);
+module_pt module_create(manifest_pt headerMap, const char *moduleId, celix_bundle_t *bundle);
-module_pt module_createFrameworkModule(bundle_pt bundle);
+module_pt module_createFrameworkModule(celix_bundle_t *bundle);
void module_destroy(module_pt module);
@@ -67,25 +67,25 @@ FRAMEWORK_EXPORT bool module_isResolved(module_pt module);
FRAMEWORK_EXPORT void module_setResolved(module_pt module);
-FRAMEWORK_EXPORT bundle_pt module_getBundle(module_pt module);
+FRAMEWORK_EXPORT celix_bundle_t *module_getBundle(module_pt module);
FRAMEWORK_EXPORT linked_list_pt module_getRequirements(module_pt module);
FRAMEWORK_EXPORT linked_list_pt module_getCapabilities(module_pt module);
-FRAMEWORK_EXPORT array_list_pt module_getDependentImporters(module_pt module);
+FRAMEWORK_EXPORT celix_array_list_t *module_getDependentImporters(module_pt module);
FRAMEWORK_EXPORT void module_addDependentImporter(module_pt module, module_pt importer);
FRAMEWORK_EXPORT void module_removeDependentImporter(module_pt module, module_pt importer);
-FRAMEWORK_EXPORT array_list_pt module_getDependentRequirers(module_pt module);
+FRAMEWORK_EXPORT celix_array_list_t *module_getDependentRequirers(module_pt module);
FRAMEWORK_EXPORT void module_addDependentRequirer(module_pt module, module_pt requirer);
FRAMEWORK_EXPORT void module_removeDependentRequirer(module_pt module, module_pt requirer);
-FRAMEWORK_EXPORT array_list_pt module_getDependents(module_pt module);
+FRAMEWORK_EXPORT celix_array_list_t *module_getDependents(module_pt module);
FRAMEWORK_EXPORT celix_status_t module_getGroup(module_pt module, const char **group);
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/service_reference.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/service_reference.h b/libs/framework/include/service_reference.h
index e094b4c..8c32106 100644
--- a/libs/framework/include/service_reference.h
+++ b/libs/framework/include/service_reference.h
@@ -31,10 +31,10 @@
extern "C" {
#endif
-FRAMEWORK_EXPORT celix_status_t serviceReference_getBundle(service_reference_pt reference, bundle_pt *bundle);
+FRAMEWORK_EXPORT celix_status_t serviceReference_getBundle(service_reference_pt reference, celix_bundle_t **bundle);
FRAMEWORK_EXPORT bool
-serviceReference_isAssignableTo(service_reference_pt reference, bundle_pt requester, const char *serviceName);
+serviceReference_isAssignableTo(service_reference_pt reference, celix_bundle_t *requester, const char *serviceName);
FRAMEWORK_EXPORT celix_status_t
serviceReference_getProperty(service_reference_pt reference, const char *key, const char **value);
@@ -58,7 +58,7 @@ FRAMEWORK_EXPORT int serviceReference_equals2(const void *reference1, const void
FRAMEWORK_EXPORT celix_status_t
serviceReference_compareTo(service_reference_pt reference, service_reference_pt compareTo, int *compare);
-FRAMEWORK_EXPORT celix_status_t serviceReference_getUsingBundles(service_reference_pt ref, array_list_pt *out);
+FRAMEWORK_EXPORT celix_status_t serviceReference_getUsingBundles(service_reference_pt ref, celix_array_list_t **out);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/service_registration.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/service_registration.h b/libs/framework/include/service_registration.h
index 8e661ec..ea44155 100644
--- a/libs/framework/include/service_registration.h
+++ b/libs/framework/include/service_registration.h
@@ -38,10 +38,10 @@ extern "C" {
FRAMEWORK_EXPORT celix_status_t serviceRegistration_unregister(service_registration_t *registration);
FRAMEWORK_EXPORT celix_status_t
-serviceRegistration_getProperties(service_registration_t *registration, properties_pt *properties);
+serviceRegistration_getProperties(service_registration_t *registration, celix_properties_t **properties);
FRAMEWORK_EXPORT celix_status_t
-serviceRegistration_setProperties(service_registration_t *registration, properties_pt properties);
+serviceRegistration_setProperties(service_registration_t *registration, celix_properties_t *properties);
FRAMEWORK_EXPORT celix_status_t
serviceRegistration_getServiceName(service_registration_t *registration, const char **serviceName);