celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [5/7] celix git commit: CELIX-425: Adds the c dependency manager to the framework. Also adds some empty interface libraries so that the changes are backwards compatible.
Date Wed, 25 Apr 2018 19:12:09 GMT
http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/dependency_manager/src/dm_service_dependency.c
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_service_dependency.c b/dependency_manager/src/dm_service_dependency.c
deleted file mode 100644
index 65a0593..0000000
--- a/dependency_manager/src/dm_service_dependency.c
+++ /dev/null
@@ -1,811 +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_service_dependency.c
- *
- *  \date       17 Oct 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <assert.h>
-
-#include "constants.h"
-
-#include "dm_service_dependency_impl.h"
-#include "dm_component_impl.h"
-
-#define DEFAULT_RANKING     0
-#define DM_SERVICE_DEPENDENCY_DEFAULT_STRATEGY DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
-
-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);
-
-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_destroy(dm_service_dependency_pt *dependency_ptr) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!*dependency_ptr) {
-		status = CELIX_ENOMEM;
-	}
-
-	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;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_lock(dm_service_dependency_pt dependency) {
-	celixThreadMutex_lock(&dependency->lock);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t serviceDependency_unlock(dm_service_dependency_pt dependency) {
-	celixThreadMutex_unlock(&dependency->lock);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t serviceDependency_setRequired(dm_service_dependency_pt dependency, bool required) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->required = required;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_setAddCLanguageFilter(dm_service_dependency_pt 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 status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		dependency->strategy = strategy;
-	}
-
-	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;
-	}
-
-	return status;
-
-}
-
-celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency, const char* serviceName, const char* serviceVersionRange, const char* filter) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (!dependency || !serviceName) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		array_list_pt filterElements = NULL;
-		arrayList_create(&filterElements);
-
-		free(dependency->tracked_service);
-		dependency->tracked_service = strdup(serviceName);
-
-		if (serviceVersionRange != NULL) {
-			version_range_pt versionRange = NULL;
-
-			if (versionRange_parse(serviceVersionRange, &versionRange) == CELIX_SUCCESS) {
-				version_pt lowVersion = NULL;
-				version_pt highVersion = NULL;
-
-				if ((versionRange_getHighVersion(versionRange, &highVersion) == CELIX_SUCCESS) && (highVersion != NULL)) {
-					bool isHighInclusive;
-					char* highOperator;
-					char* highVersionStr = NULL;
-
-					versionRange_isHighInclusive(versionRange, &isHighInclusive);
-					version_toString(highVersion, &highVersionStr);
-
-					highOperator = isHighInclusive ? "<=" : "<";
-
-					if(highVersionStr != NULL){
-						size_t len = strlen(CELIX_FRAMEWORK_SERVICE_VERSION) + strlen(highVersionStr) + strlen(highOperator) + 3;
-						char serviceVersionFilter[len];
-						snprintf(serviceVersionFilter, len, "(%s%s%s)", CELIX_FRAMEWORK_SERVICE_VERSION, highOperator, highVersionStr);
-						arrayList_add(filterElements, strdup(serviceVersionFilter));
-						free(highVersionStr);
-					}
-				}
-
-				if ((versionRange_getLowVersion(versionRange, &lowVersion) == CELIX_SUCCESS) && (lowVersion != NULL)) {
-					bool isLowInclusive;
-					char* lowOperator;
-					char* lowVersionStr = NULL;
-
-					versionRange_isLowInclusive(versionRange, &isLowInclusive);
-					version_toString(lowVersion, &lowVersionStr);
-
-					lowOperator = isLowInclusive ? ">=" : ">";
-
-					if(lowVersionStr != NULL){
-						size_t len = strlen(CELIX_FRAMEWORK_SERVICE_VERSION) + strlen(lowVersionStr) + strlen(lowOperator) + 3;
-						char serviceVersionFilter[len];
-						snprintf(serviceVersionFilter, len, "(%s%s%s)", CELIX_FRAMEWORK_SERVICE_VERSION, lowOperator, lowVersionStr);
-						arrayList_add(filterElements, strdup(serviceVersionFilter));
-						free(lowVersionStr);
-					}
-				}
-			}
-
-			if(versionRange!=NULL){
-				versionRange_destroy(versionRange);
-			}
-		}
-
-		if (filter != NULL) {
-			free(dependency->tracked_filter_unmodified);
-			dependency->tracked_filter_unmodified = strdup(filter);
-			arrayList_add(filterElements, strdup(filter));
-		}
-
-
-
-        bool needLangFilter = true;
-		if (filter != NULL) {
-            char needle[128];
-            snprintf(needle, sizeof(needle), "(%s=", CELIX_FRAMEWORK_SERVICE_LANGUAGE);
-            if (strstr(filter, needle) != NULL) {
-                needLangFilter = false;
-            }
-        }
-
-        if (needLangFilter && dependency->addCLanguageFilter) {
-			char langFilter[128];
-			snprintf(langFilter, sizeof(langFilter), "(%s=%s)", CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
-            arrayList_add(filterElements, strdup(langFilter));
-		}
-
-		if (arrayList_size(filterElements) > 0) {
-			array_list_iterator_pt filterElementsIter = arrayListIterator_create(filterElements);
-
-			size_t len = strlen(serviceName) + strlen(OSGI_FRAMEWORK_OBJECTCLASS) + 4;
-			free(dependency->tracked_filter);
-			dependency->tracked_filter = calloc(len, sizeof(*dependency->tracked_filter));
-			snprintf(dependency->tracked_filter, len, "(%s=%s)", OSGI_FRAMEWORK_OBJECTCLASS, serviceName);
-
-			while (arrayListIterator_hasNext(filterElementsIter) == true) {
-				char* filterElement = (char*) arrayListIterator_next(filterElementsIter);
-				size_t len = strnlen(dependency->tracked_filter, 1024*1024) + strnlen(filterElement, 1024*1024) + 4;
-				char* newFilter = calloc(len, sizeof(*newFilter));
-
-				if (dependency->tracked_filter[0] == '(' && dependency->tracked_filter[1] == '&') {
-					//already have an & (AND) can combine with additional filter -> easier to read
-					size_t orgLen = strnlen(dependency->tracked_filter, 1024*1024);
-					snprintf(newFilter, len, "%.*s%s)", (int)orgLen -1, dependency->tracked_filter, filterElement);
-				} else {
-					snprintf(newFilter, len, "(&%s%s)", dependency->tracked_filter, filterElement);
-				}
-
-				free(dependency->tracked_filter);
-				free(filterElement);
-
-				dependency->tracked_filter = newFilter;
-			}
-
-			arrayListIterator_destroy(filterElementsIter);
-		}
-		else {
-			free(dependency->tracked_filter);
-			dependency->tracked_filter = NULL;
-		}
-
-		arrayList_destroy(filterElements);
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_getFilter(dm_service_dependency_pt dependency, const char** filter) {
-	*filter = (const char*)dependency->tracked_filter;
-	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) {
-	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);
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->set = set;
-		dependency->add = add;
-		dependency->change = change;
-		dependency->remove = remove;
-		dependency->swap = 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,
-		service_swap_with_ref_fpt swap) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->set_with_ref = set;
-		dependency->add_with_ref = add;
-		dependency->change_with_ref = change;
-		dependency->remove_with_ref = remove;
-		dependency->swap_with_ref = swap;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_pt dependency, celix_thread_mutex_t *service_lock, const void **field) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	celix_thread_mutex_t lock;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->autoConfigure = field;
-		celixThreadMutex_create(&lock, NULL);
-		*service_lock = lock;
-		dependency->lock = lock;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_setComponent(dm_service_dependency_pt dependency, dm_component_pt component) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->component = component;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_start(dm_service_dependency_pt dependency) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_context_pt context = NULL;
-
-	if (!dependency || !dependency->component || (!dependency->tracked_service && !dependency->tracked_filter)) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-	if (status == CELIX_SUCCESS) {
-		status = component_getBundleContext(dependency->component, &context);
-		if (!context) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-	if (status == CELIX_SUCCESS) {
-		dependency->tracker_customizer = NULL;
-		status = serviceTrackerCustomizer_create(dependency, NULL, serviceDependency_addedService, serviceDependency_modifiedService, serviceDependency_removedService, &dependency->tracker_customizer);
-	}
-	if (status == CELIX_SUCCESS) {
-		if (dependency->tracked_filter) {
-			status = serviceTracker_createWithFilter(context, dependency->tracked_filter, dependency->tracker_customizer, &dependency->tracker);
-		} else if (dependency->tracked_service) {
-			status = serviceTracker_create(context, dependency->tracked_service, dependency->tracker_customizer, &dependency->tracker);
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = serviceTracker_open(dependency->tracker);
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->isStarted = true;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_stop(dm_service_dependency_pt dependency) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->isStarted = false;
-	}
-
-	if (status == CELIX_SUCCESS && dependency->tracker) {
-		status = serviceTracker_close(dependency->tracker);
-		if (status == CELIX_SUCCESS) {
-			serviceTracker_destroy(dependency->tracker);
-			dependency->tracker = NULL;
-		}
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_setInstanceBound(dm_service_dependency_pt dependency, bool instanceBound) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->instanceBound = instanceBound;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_setAvailable(dm_service_dependency_pt dependency, bool available) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		dependency->available = available;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_invokeSet(dm_service_dependency_pt dependency, dm_event_pt event) {
-	celix_status_t status = CELIX_SUCCESS;
-	assert(dependency->isStarted == true);
-	array_list_pt serviceReferences = NULL;
-	int i;
-	int curRanking = INT_MIN;
-	service_reference_pt curServRef = NULL;
-	void *service = NULL;
-
-	serviceReferences = serviceTracker_getServiceReferences(dependency->tracker);
-
-	/* Find the service with the higest ranking */
-	for (i = 0; i < arrayList_size(serviceReferences); i++) {
-		service_reference_pt serviceReference = arrayList_get(serviceReferences, i);
-		const char* ranking_value;
-		int ranking = 0;
-
-		status = serviceReference_getProperty(serviceReference, ((char *) OSGI_FRAMEWORK_SERVICE_RANKING), &ranking_value);
-
-		if (status == CELIX_SUCCESS) {
-			if (ranking_value == NULL) {
-				ranking = DEFAULT_RANKING;
-			} else {
-				char *end;
-				ranking = strtol(ranking_value, &end, 10);
-				if (end == ranking_value) {
-					ranking = DEFAULT_RANKING;
-				}
-			}
-
-			if (ranking > curRanking) {
-				curRanking = ranking;
-				curServRef = serviceReference;
-			}
-		} else {
-			break;
-		}
-
-	}
-
-	arrayList_destroy(serviceReferences);
-
-	if (status == CELIX_SUCCESS) {
-		if (curServRef) {
-			status = bundleContext_getService(event->context, curServRef, &service);
-		} else {
-			service = NULL;
-		}
-
-		if (dependency->set) {
-			dependency->set(serviceDependency_getCallbackHandle(dependency), service);
-		}
-		if (dependency->set_with_ref) {
-			dependency->set_with_ref(serviceDependency_getCallbackHandle(dependency), curServRef, service);
-		}
-
-		if (curServRef) {
-			bundleContext_ungetService(event->context, curServRef, NULL);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_invokeAdd(dm_service_dependency_pt dependency, dm_event_pt event) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		if (dependency->add) {
-			dependency->add(serviceDependency_getCallbackHandle(dependency), event->service);
-		}
-		if (dependency->add_with_ref) {
-			dependency->add_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_invokeChange(dm_service_dependency_pt dependency, dm_event_pt event) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		if (dependency->change) {
-			dependency->change(serviceDependency_getCallbackHandle(dependency), event->service);
-		}
-		if (dependency->change_with_ref) {
-			dependency->change_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_invokeRemove(dm_service_dependency_pt dependency, dm_event_pt event) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		if (dependency->remove) {
-			dependency->remove(serviceDependency_getCallbackHandle(dependency), event->service);
-		}
-		if (dependency->remove_with_ref) {
-			dependency->remove_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_invokeSwap(dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		if (dependency->swap) {
-			dependency->swap(serviceDependency_getCallbackHandle(dependency), event->service, newEvent->service);
-		}
-		if (dependency->swap_with_ref) {
-			dependency->swap_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service, newEvent->reference, newEvent->service);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_isAvailable(dm_service_dependency_pt dependency, bool *available) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*available = dependency->available;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_isRequired(dm_service_dependency_pt dependency, bool *required) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*required = dependency->required;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_isInstanceBound(dm_service_dependency_pt dependency, bool *instanceBound) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*instanceBound = dependency->instanceBound;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_isAutoConfig(dm_service_dependency_pt dependency, bool *autoConfig) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*autoConfig = dependency->autoConfigure != NULL;
-	}
-
-	return status;
-}
-
-celix_status_t serviceDependency_getAutoConfig(dm_service_dependency_pt dependency, const void*** autoConfigure) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!dependency) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*autoConfigure = dependency->autoConfigure;
-	}
-
-	return status;
-}
-
-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;
-
-	if (!dependency || !reference || !service) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = component_getBundleContext(dependency->component, &context);
-		if (!context) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = bundleContext_getBundle(context, &bundle);
-		if (!bundle) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = event_create(DM_EVENT_ADDED, bundle, context, reference, service, &event);
-	}
-
-	if (status == CELIX_SUCCESS) {
-		component_handleEvent(dependency->component, dependency, event);
-	}
-
-	return status;
-}
-
-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;
-
-	if (!dependency || !reference || !service) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = component_getBundleContext(dependency->component, &context);
-		if (!context) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = bundleContext_getBundle(context, &bundle);
-		if (!bundle) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = event_create(DM_EVENT_CHANGED, bundle, context, reference, service, &event);
-	}
-
-	if (status == CELIX_SUCCESS) {
-		component_handleEvent(dependency->component, dependency, event);
-	}
-
-	return status;
-}
-
-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;
-
-	if (!dependency || !reference || !service) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = component_getBundleContext(dependency->component, &context);
-		if (!context) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = bundleContext_getBundle(context, &bundle);
-		if (!bundle) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = event_create(DM_EVENT_REMOVED, bundle, context, reference, service, &event);
-	}
-
-	if (status == CELIX_SUCCESS) {
-		component_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));
-	if (info != NULL) {
-		celixThreadMutex_lock(&dep->lock);
-		info->available = dep->available;
-		info->filter = dep->tracked_filter != NULL ? strdup(dep->tracked_filter) : NULL;
-		if (info->filter == NULL) {
-			info->filter = dep->tracked_service != NULL ? strdup(dep->tracked_service) : NULL;
-		}
-		info->required = dep->required;
-
-		array_list_pt refs = serviceTracker_getServiceReferences(dep->tracker);
-		if (refs != NULL) {
-			info->count = arrayList_size(refs);
-		}
-		arrayList_destroy(refs);
-
-		celixThreadMutex_unlock(&dep->lock);
-	} else {
-		status = CELIX_ENOMEM;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*out = info;
-	}
-
-	return status;
-}
-
-void dependency_destroyDependencyInfo(dm_service_dependency_info_pt info) {
-	if (info != NULL) {
-		free(info->filter);
-	}
-	free(info);
-}
-
-celix_status_t serviceDependency_setCallbackHandle(dm_service_dependency_pt dependency, void* handle) {
-	dependency->callbackHandle = handle;
-    return CELIX_SUCCESS;
-}
-
-static void* serviceDependency_getCallbackHandle(dm_service_dependency_pt dependency) {
-    return dependency->callbackHandle == NULL ? component_getImplementation(dependency->component) : dependency->callbackHandle;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/dependency_manager/src/dm_service_dependency_impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_service_dependency_impl.h b/dependency_manager/src/dm_service_dependency_impl.h
deleted file mode 100644
index 7026ebf..0000000
--- a/dependency_manager/src/dm_service_dependency_impl.h
+++ /dev/null
@@ -1,104 +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_service_dependency_impl.h
- *
- *  \date       16 Oct 2015
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#ifndef DM_SERVICE_DEPENDENCY_IMPL_H_
-#define DM_SERVICE_DEPENDENCY_IMPL_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdbool.h>
-
-#include "dm_event.h"
-#include "service_tracker.h"
-#include "service_tracker_customizer.h"
-
-#include "dm_service_dependency.h"
-#include "dm_component.h"
-
-struct dm_service_dependency {
-	dm_component_pt 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;
-
-	service_set_with_ref_fpt set_with_ref;
-	service_add_with_ref_fpt add_with_ref;
-	service_change_with_ref_fpt change_with_ref;
-	service_remove_with_ref_fpt remove_with_ref;
-	service_swap_with_ref_fpt swap_with_ref;
-
-	const void **autoConfigure;
-	celix_thread_mutex_t lock;
-
-	bool isStarted;
-
-	bool addCLanguageFilter;
-	char *tracked_service;
-	char *tracked_filter_unmodified;
-	char *tracked_filter;
-
-	service_tracker_pt tracker;
-	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);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DM_SERVICE_DEPENDENCY_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/dependency_manager/src/dm_shell_activator.c
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_shell_activator.c b/dependency_manager/src/dm_shell_activator.c
deleted file mode 100644
index 661ffae..0000000
--- a/dependency_manager/src/dm_shell_activator.c
+++ /dev/null
@@ -1,94 +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_shell_activator.c
- *
- *  \date       16 Oct 2015
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#include <constants.h>
-#include "bundle_context.h"
-#include "command.h"
-
-#include "dm_shell_list_command.h"
-#include "shell_constants.h"
-
-struct bundle_instance {
-    service_registration_pt reg;
-    command_service_t  dmCommand;
-    dm_command_handle_t dmHandle;
-};
-
-typedef struct bundle_instance * bundle_instance_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-
-	if(userData==NULL){
-		return CELIX_ILLEGAL_ARGUMENT;
-	}
-
-    struct bundle_instance *bi = calloc(sizeof (struct bundle_instance), 1);
-
-    if (bi==NULL) {
-        return CELIX_ENOMEM;
-    }
-
-    bi->dmHandle.context = context;
-    const char* config = NULL;
-    bundleContext_getPropertyWithDefault(context, SHELL_USE_ANSI_COLORS, SHELL_USE_ANSI_COLORS_DEFAULT_VALUE, &config);
-    bi->dmHandle.useColors = config != NULL && strncmp("true", config, 5) == 0;
-
-    (*userData) = bi;
-
-    return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-    celix_status_t status = CELIX_SUCCESS;
-    bundle_instance_pt bi = (bundle_instance_pt) userData;
-
-    bi->dmCommand.handle = &bi->dmHandle;
-    bi->dmCommand.executeCommand = (void *)dmListCommand_execute;
-
-    properties_pt props = properties_create();
-    properties_set(props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
-    properties_set(props, OSGI_SHELL_COMMAND_NAME, "dm");
-    properties_set(props, OSGI_SHELL_COMMAND_USAGE, "dm [f|full] [<Bundle ID> [<Bundle ID> [...]]]");
-    properties_set(props, OSGI_SHELL_COMMAND_DESCRIPTION,
-                   "Gives an overview of the component managemed by a dependency manager.");
-
-    status = bundleContext_registerService(context, OSGI_SHELL_COMMAND_SERVICE_NAME, &bi->dmCommand, props, &bi->reg);
-
-    return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-    bundle_instance_pt bi = (bundle_instance_pt) userData;
-    serviceRegistration_unregister(bi->reg);
-    return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-    bundle_instance_pt bi = (bundle_instance_pt) userData;
-    free(bi);
-    return CELIX_SUCCESS;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/dependency_manager/src/dm_shell_list_command.c
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_shell_list_command.c b/dependency_manager/src/dm_shell_list_command.c
deleted file mode 100644
index 8eb989c..0000000
--- a/dependency_manager/src/dm_shell_list_command.c
+++ /dev/null
@@ -1,191 +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_shell_list_command.c
- *
- *  \date       Oct 16, 2015
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-#include <dm_dependency_manager.h>
-#include <dm_shell_list_command.h>
-
-static const char * const OK_COLOR = "\033[92m";
-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) {
-    *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);
-    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);
-        } else {
-            fprintf (err, "DM: Skipping unknown argument: %s", tok );
-        }
-        tok = strtok(NULL," ");
-    }
-    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 = "";
-    if (colors) {
-        startColors = compInfo->active ? OK_COLOR : NOK_COLOR;
-        endColors = END_COLOR;
-    }
-    fprintf(out, "Component: Name=%s\n|- ID=%s, %sActive=%s%s, State=%s\n", compInfo->name, compInfo->id,
-            startColors, compInfo->active ? "true " : "false", endColors, compInfo->state);
-    fprintf(out, "|- Interfaces (%d):\n", arrayList_size(compInfo->interfaces));
-    for (unsigned int interfCnt = 0; interfCnt < arrayList_size(compInfo->interfaces); interfCnt++) {
-        dm_interface_info_pt intfInfo = arrayList_get(compInfo->interfaces, interfCnt);
-        fprintf(out, "   |- Interface: %s\n", intfInfo->name);
-
-        hash_map_iterator_t iter = hashMapIterator_construct((hash_map_pt) intfInfo->properties);
-        char *key = NULL;
-        while ((key = hashMapIterator_nextKey(&iter)) != NULL) {
-            fprintf(out, "      | %15s = %s\n", key, properties_get(intfInfo->properties, key));
-        }
-    }
-
-    fprintf(out, "|- Dependencies (%d):\n", arrayList_size(compInfo->dependency_list));
-    for (unsigned int depCnt = 0; depCnt < arrayList_size(compInfo->dependency_list); depCnt++) {
-        dm_service_dependency_info_pt dependency;
-        dependency = arrayList_get(compInfo->dependency_list, depCnt);
-        const char *depStartColors = "";
-        const char *depEndColors = "";
-        if (colors) {
-            if (dependency->required) {
-                depStartColors = dependency->available ? OK_COLOR : NOK_COLOR;
-            } else {
-                depStartColors = dependency->available ? OK_COLOR : WARNING_COLOR;
-            }
-
-            depEndColors = END_COLOR;
-        }
-        fprintf(out, "   |- Dependency: %sAvailable = %s%s, Required = %s, Filter = %s\n", depStartColors,
-                dependency->available ? "true " : "false", depEndColors,
-                dependency->required ? "true " : "false", dependency->filter);
-    }
-    fprintf(out, "\n");
-
-}
-
-static void printBasicInfo(FILE *out, bool colors, dm_component_info_pt compInfo) {
-    const char *startColors = "";
-    const char *endColors = "";
-    if (colors) {
-        startColors = compInfo->active ? OK_COLOR : NOK_COLOR;
-        endColors = END_COLOR;
-    }
-    fprintf(out, "Component: Name=%s, ID=%s, %sActive=%s%s, State=%s\n", compInfo->name, compInfo->id,
-            startColors, compInfo->active ? "true " : "false", endColors, compInfo->state);
-
-}
-
-void dmListCommand_execute(dm_command_handle_t* handle, char * line, FILE *out, FILE *err) {
-
-    array_list_pt servRefs = NULL;
-    array_list_pt bundleIds = NULL;
-
-    bundleContext_getServiceReferences(handle->context, DM_INFO_SERVICE_NAME ,NULL, &servRefs);
-
-    if(servRefs==NULL){
-	fprintf(out, "Invalid dm_info ServiceReferences List\n");
-	return;
-    }
-
-    bool colors = handle->useColors;
-    bool fullInfo = false;
-    parseCommandLine(line, &bundleIds, &fullInfo, err);
-    unsigned int size =  arrayList_size(servRefs);
-    for(unsigned int i = 0; i < size; i++) {
-        dm_dependency_manager_info_pt info = NULL;
-        dm_info_service_pt infoServ = NULL;
-        service_reference_pt servRef = NULL;
-        servRef = arrayList_get(servRefs, i);
-        bundleContext_getService(handle->context,  servRef, (void**)&infoServ);
-        bundle_pt bundle = NULL;
-        serviceReference_getBundle(servRef, &bundle);
-        long id = 0;
-        bundle_getBundleId(bundle, &id);
-        if (is_bundleId_in_list(bundleIds, id)) {
-
-            infoServ->getInfo(infoServ->handle, &info);
-
-            fprintf(out, "[Bundle: %ld]\n", id);
-            for (unsigned int cmpCnt = 0; cmpCnt < arrayList_size(info->components); cmpCnt++) {
-                dm_component_info_pt compInfo = arrayList_get(info->components, cmpCnt);
-                if (fullInfo) {
-                    printFullInfo(out, colors, compInfo);
-                } else {
-                    printBasicInfo(out, colors, compInfo);
-                }
-            }
-            infoServ->destroyInfo(infoServ->handle, info);
-        }
-        bundleContext_ungetService(handle->context, servRef, NULL);
-        bundleContext_ungetServiceReference(handle->context, servRef);
-    }
-    destroyBundleIdList(bundleIds);
-	if(servRefs!=NULL){
-		arrayList_destroy(servRefs);
-    }
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/dependency_manager/src/dm_shell_list_command.h
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_shell_list_command.h b/dependency_manager/src/dm_shell_list_command.h
deleted file mode 100644
index 6ab0581..0000000
--- a/dependency_manager/src/dm_shell_list_command.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-
-#ifndef DM_SHELL_LIST_COMMAND_H_
-#define DM_SHELL_LIST_COMMAND_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include "command.h"
-
-typedef struct dm_command_handle {
-    bundle_context_pt context;
-    bool useColors;
-} dm_command_handle_t;
-
-void dmListCommand_execute(dm_command_handle_t* handle, char * line, FILE *out, FILE *err);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //DM_SHELL_LSIT_COMMAND_H_
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/dependency_manager_cxx/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/CMakeLists.txt b/dependency_manager_cxx/CMakeLists.txt
index 63d0714..3408440 100644
--- a/dependency_manager_cxx/CMakeLists.txt
+++ b/dependency_manager_cxx/CMakeLists.txt
@@ -30,10 +30,10 @@ if (DEPENDENCY_MANAGER_CXX)
     endif(UNIX AND NOT WIN32)
 
     add_library(dependency_manager_cxx_static STATIC
-            ${CMAKE_SOURCE_DIR}/dependency_manager/src/dm_component_impl
-            ${CMAKE_SOURCE_DIR}/dependency_manager/src/dm_service_dependency
-            ${CMAKE_SOURCE_DIR}/dependency_manager/src/dm_event
-            ${CMAKE_SOURCE_DIR}/dependency_manager/src/dm_dependency_manager_impl
+            ${CMAKE_SOURCE_DIR}/framework/src/dm_component_impl
+            ${CMAKE_SOURCE_DIR}/framework/src/dm_service_dependency
+            ${CMAKE_SOURCE_DIR}/framework/src/dm_event
+            ${CMAKE_SOURCE_DIR}/framework/src/dm_dependency_manager_impl
             src/dm_activator.cc
     )
     set_target_properties(dependency_manager_cxx_static PROPERTIES OUTPUT_NAME "celix_dependency_manager_cxx_static")

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/dependency_manager_cxx/include/celix/dm/DmActivator.h
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/include/celix/dm/DmActivator.h b/dependency_manager_cxx/include/celix/dm/DmActivator.h
index eb19102..d7aac3c 100644
--- a/dependency_manager_cxx/include/celix/dm/DmActivator.h
+++ b/dependency_manager_cxx/include/celix/dm/DmActivator.h
@@ -68,20 +68,11 @@ namespace celix { namespace dm {
         DependencyManager& mng;
         bundle_context_pt ctx;
     private:
-        dm_info_service_t info{nullptr, nullptr, nullptr};
-        service_registration_pt reg{nullptr};
-
         int start() {
             celix_status_t status = CELIX_SUCCESS;
             this->init();
             this->mng.start();
 
-            //Create and register the dm info service
-            this->info.handle = this->mng.cDependencyManager();
-            this->info.getInfo = (celix_status_t (*)(void *, dm_dependency_manager_info_pt *)) dependencyManager_getInfo;
-            this->info.destroyInfo = (void (*)(void *, dm_dependency_manager_info_pt)) dependencyManager_destroyInfo;
-            status = bundleContext_registerService(this->ctx, (char *) DM_INFO_SERVICE_NAME, &this->info, NULL, &(this->reg));
-
             return status;
         }
 
@@ -90,11 +81,6 @@ namespace celix { namespace dm {
 
             this->deinit();
 
-            // Remove the service
-            if (this->reg != nullptr) {
-                status = serviceRegistration_unregister(this->reg);
-                this->reg = nullptr;
-            }
             // Remove all components
             dependencyManager_removeAllComponents(this->mng.cDependencyManager());
 

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/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 6416c68..6fa6919 100644
--- a/examples/celix-examples/dm_example/phase2a/src/phase2a_activator.c
+++ b/examples/celix-examples/dm_example/phase2a/src/phase2a_activator.c
@@ -16,13 +16,7 @@
  *specific language governing permissions and limitations
  *under the License.
  */
-/*
- * activator.c
- *
- *  \date       Oct 29, 2015
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
+
 #include <stdlib.h>
 #include <phase2a_cmp.h>
 

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt
index ee2fa5a..6454c12 100644
--- a/framework/CMakeLists.txt
+++ b/framework/CMakeLists.txt
@@ -33,6 +33,8 @@ set(SOURCES
         src/unzip.c src/wire.c
         src/celix_log.c src/celix_launcher.c
         src/celix_framework_factory.c
+        src/dm_dependency_manager_impl.c src/dm_component_impl.c
+        src/dm_service_dependency.c src/dm_event.c
         ${IO}
 )
 add_library(framework SHARED ${SOURCES})

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/include/bundle.h
----------------------------------------------------------------------
diff --git a/framework/include/bundle.h b/framework/include/bundle.h
index 7f715cc..90f52b1 100644
--- a/framework/include/bundle.h
+++ b/framework/include/bundle.h
@@ -27,8 +27,7 @@
 #ifndef BUNDLE_H_
 #define BUNDLE_H_
 
-typedef struct bundle * bundle_pt;
-typedef struct bundle bundle_t;
+#include "celix_types.h"
 
 #include "celix_errno.h"
 #include "bundle_state.h"

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/include/bundle_activator.h
----------------------------------------------------------------------
diff --git a/framework/include/bundle_activator.h b/framework/include/bundle_activator.h
index 1027351..a03fbb1 100644
--- a/framework/include/bundle_activator.h
+++ b/framework/include/bundle_activator.h
@@ -58,7 +58,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_pt context_ptr, void **userData);
+ACTIVATOR_EXPORT celix_status_t bundleActivator_create(bundle_context_t *context_ptr, void **userData);
 
 /**
  * Called when this bundle is started so the Framework can perform the bundle-specific activities necessary
@@ -76,7 +76,7 @@ ACTIVATOR_EXPORT celix_status_t bundleActivator_create(bundle_context_pt context
  * 		- 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_pt context);
+ACTIVATOR_EXPORT celix_status_t bundleActivator_start(void *userData, bundle_context_t *context);
 
 /**
  * Called when this bundle is stopped so the Framework can perform the bundle-specific activities necessary
@@ -95,7 +95,7 @@ ACTIVATOR_EXPORT celix_status_t bundleActivator_start(void *userData, bundle_con
  * 		- 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_pt context);
+ACTIVATOR_EXPORT celix_status_t bundleActivator_stop(void *userData, bundle_context_t *context);
 
 /**
  * Called when this bundle is stopped so the bundle can destroy the instance of its activator. In general, this
@@ -113,7 +113,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_pt  __attribute__((unused))  __attribute__((unused)) context);
+bundleActivator_destroy(void *userData, bundle_context_t* context);
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/include/bundle_archive.h
----------------------------------------------------------------------
diff --git a/framework/include/bundle_archive.h b/framework/include/bundle_archive.h
index ff3cf16..1a9b2c4 100644
--- a/framework/include/bundle_archive.h
+++ b/framework/include/bundle_archive.h
@@ -27,6 +27,8 @@
 #ifndef BUNDLE_ARCHIVE_H_
 #define BUNDLE_ARCHIVE_H_
 
+#include "celix_types.h"
+
 #include <time.h>
 
 #include "bundle_revision.h"
@@ -40,8 +42,6 @@
 extern "C" {
 #endif
 
-typedef struct bundleArchive *bundle_archive_pt;
-
 celix_status_t bundleArchive_create(const char *archiveRoot, long id, const char *location, const char *inputFile,
                                     bundle_archive_pt *bundle_archive);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/include/bundle_context.h
----------------------------------------------------------------------
diff --git a/framework/include/bundle_context.h b/framework/include/bundle_context.h
index f806cb5..a2b30f2 100644
--- a/framework/include/bundle_context.h
+++ b/framework/include/bundle_context.h
@@ -16,13 +16,6 @@
  *specific language governing permissions and limitations
  *under the License.
  */
-/*
- * bundle_context.h
- *
- *  \date       Mar 26, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
 
 #ifndef BUNDLE_CONTEXT_H_
 #define BUNDLE_CONTEXT_H_
@@ -32,9 +25,8 @@
  * grant access to other methods so that this bundle can interact with the
  * Framework.
  */
-typedef struct bundleContext *bundle_context_pt;
-typedef struct bundleContext bundle_context_t;
 
+#include "celix_types.h"
 
 #include "service_factory.h"
 #include "service_listener.h"
@@ -43,6 +35,8 @@ typedef struct bundleContext bundle_context_t;
 #include "properties.h"
 #include "array_list.h"
 
+#include "dm_dependency_manager.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -225,6 +219,15 @@ bundleContext_getProperty(bundle_context_pt context, const char *name, const cha
 FRAMEWORK_EXPORT celix_status_t
 bundleContext_getPropertyWithDefault(bundle_context_pt context, const char *name, const char *defaultValue, const char **value);
 
+
+/**
+ * Gets the dependency manager for this bundle context.
+ *
+ * @return the dependency manager or NULL
+ */
+dm_dependency_manager_t* bundleContext_getDependencyManager(bundle_context_t *ctx);
+
+
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/include/bundle_listener.h
----------------------------------------------------------------------
diff --git a/framework/include/bundle_listener.h b/framework/include/bundle_listener.h
index a152393..739bcaa 100644
--- a/framework/include/bundle_listener.h
+++ b/framework/include/bundle_listener.h
@@ -16,20 +16,12 @@
  *specific language governing permissions and limitations
  *under the License.
  */
-/**
- *
- * @defgroup BundleListener Bundle Listener
- * @ingroup framework
- * @{
- *
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \date      	June 28, 2012
- *  \copyright	Apache License, Version 2.0
- */
+
 #ifndef BUNDLE_LISTENER_H_
 #define BUNDLE_LISTENER_H_
 
 typedef struct bundle_listener *bundle_listener_pt;
+typedef struct bundle_listener bundle_listener_t;
 
 #include "celix_errno.h"
 #include "bundle_event.h"

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/include/bundle_revision.h
----------------------------------------------------------------------
diff --git a/framework/include/bundle_revision.h b/framework/include/bundle_revision.h
index 9533eb6..7c67a94 100644
--- a/framework/include/bundle_revision.h
+++ b/framework/include/bundle_revision.h
@@ -31,6 +31,8 @@
 
 #include <stdio.h>
 
+#include "celix_types.h"
+
 #include "celix_errno.h"
 #include "manifest.h"
 #include "celix_log.h"
@@ -41,14 +43,12 @@ extern "C" {
 #endif
 
 /**
- * Typedef for bundle_revision_pt.
  *
  * A bundle revision represents the content of a bundle. A revision is associated with a bundle archive.
  * An archive can have multiple revisions, each update of a bundle results in a new one.
  *
  * In a revision the content of a bundle (ZIP file) is extracted to a specified location inside the archive.
  */
-typedef struct bundleRevision *bundle_revision_pt;
 
 /**
  * Creates a new revision for the given inputFile or location.

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/include/celix_api.h
----------------------------------------------------------------------
diff --git a/framework/include/celix_api.h b/framework/include/celix_api.h
index 266b57e..b770876 100644
--- a/framework/include/celix_api.h
+++ b/framework/include/celix_api.h
@@ -33,4 +33,7 @@
 #include "celix_framework_factory.h"
 #include "celix_launcher.h"
 
+#include "dm_dependency_manager.h"
+#include "dm_service_dependency.h"
+
 #endif //CELIX_CELIX_API_H_

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/include/celix_types.h
----------------------------------------------------------------------
diff --git a/framework/include/celix_types.h b/framework/include/celix_types.h
new file mode 100644
index 0000000..49e2548
--- /dev/null
+++ b/framework/include/celix_types.h
@@ -0,0 +1,49 @@
+/**
+ *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_CELIX_TYPES_H
+#define CELIX_CELIX_TYPES_H
+
+/**
+ * Celix types contains the declaration of many of the celix types.
+ * These types are declared in a separate header for forward declaration
+ */
+
+typedef struct bundle * bundle_pt;
+typedef struct bundle 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;
+
+typedef struct bundleContext *bundle_context_pt;
+typedef struct bundleContext bundle_context_t;
+
+typedef struct dm_dependency_manager *dm_dependency_manager_pt;
+typedef struct dm_dependency_manager dm_dependency_manager_t;
+
+typedef struct dm_component_struct *dm_component_pt;
+typedef struct dm_component_struct dm_component_t;
+
+typedef struct dm_service_dependency *dm_service_dependency_pt;
+typedef struct dm_service_dependency dm_service_dependency_t;
+
+#endif //CELIX_CELIX_TYPES_H

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/include/constants.h
----------------------------------------------------------------------
diff --git a/framework/include/constants.h b/framework/include/constants.h
index e0e56cf..3bc40d7 100644
--- a/framework/include/constants.h
+++ b/framework/include/constants.h
@@ -48,6 +48,12 @@ static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_START = "bundleActivato
 static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP = "bundleActivator_stop";
 static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY = "bundleActivator_destroy";
 
+static const char *const OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_CREATE = "dm_create";
+static const char *const OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_START = "dm_init";
+//NOTE dm stop is not available
+static const char *const OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_DESTROY = "dm_destroy";
+
+
 static const char *const OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName";
 static const char *const OSGI_FRAMEWORK_BUNDLE_VERSION = "Bundle-Version";
 static const char *const OSGI_FRAMEWORK_PRIVATE_LIBRARY = "Private-Library";

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/include/dm_activator.h
----------------------------------------------------------------------
diff --git a/framework/include/dm_activator.h b/framework/include/dm_activator.h
new file mode 100644
index 0000000..86f33db
--- /dev/null
+++ b/framework/include/dm_activator.h
@@ -0,0 +1,67 @@
+/**
+ * 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_activator_base.h
+ *
+ *  \date       26 Jul 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef DM_ACTIVATOR_BASE_H_
+#define DM_ACTIVATOR_BASE_H_
+
+
+#include "bundle_context.h"
+#include "celix_errno.h"
+#include "dm_dependency_manager.h"
+#include "dm_component.h"
+#include "dm_service_dependency.h"
+#include "bundle_activator.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Should be implemented by a bundle specific DM activator.
+ * Should allocate and initialize a bundle specific activator struct.
+ */
+celix_status_t dm_create(bundle_context_pt context, void ** userData);
+
+/**
+ * Should be implemented by a bundle specific DM activator.
+ * 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);
+
+/**
+ * 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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DM_ACTIVATOR_BASE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/include/dm_component.h
----------------------------------------------------------------------
diff --git a/framework/include/dm_component.h b/framework/include/dm_component.h
new file mode 100644
index 0000000..b3236a9
--- /dev/null
+++ b/framework/include/dm_component.h
@@ -0,0 +1,158 @@
+/**
+ *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_component.h
+ *
+ *  \date       8 Oct 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#ifndef COMPONENT_H_
+#define COMPONENT_H_
+
+#include <stdbool.h>
+
+#include "celix_types.h"
+#include "celix_errno.h"
+#include "properties.h"
+#include "array_list.h"
+#include "dm_info.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;
+
+#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);
+
+/**
+ * Creates a DM Component
+ * Caller has ownership.
+ */
+celix_status_t component_create(bundle_context_t *context, const char* name, dm_component_t **component);
+
+/**
+ * Destroys a DM Component
+ */
+void component_destroy(dm_component_t *component);
+
+
+/**
+ * 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);
+
+
+/**
+ * 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 component_addInterface(dm_component_t *component, const char* serviceName, const char* serviceVersion, const void* service, properties_t *properties);
+
+/**
+ * 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);
+
+/**
+ * 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);
+
+/**
+ * Adds a C service dependency to the component
+ */
+celix_status_t component_addServiceDependency(dm_component_t *component, dm_service_dependency_t *dep);
+
+/**
+ * Removes a C service dependency to the component
+ */
+celix_status_t component_removeServiceDependency(dm_component_t *component, dm_service_dependency_t *dependency);
+
+/**
+ * Returns the current state of the component.
+ */
+dm_component_state_t component_currentState(dm_component_t *cmp);
+
+/**
+ * Returns the implementation of the component. e.g. the component handle/self/this pointer.
+ */
+void * component_getImplementation(dm_component_t *cmp);
+
+/**
+ * Returns the DM component name. This is used when printing information about the component.
+ */
+const char * component_getName(dm_component_t *cmp);
+
+/**
+ * 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);
+
+/**
+ * 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);
+
+/**
+ * Set the component life cycle callbacks using a MACRO for improving the type safety.
+ */
+#define component_setCallbacksSafe(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); \
+        component_setCallbacks((dmCmp), (init_fpt)tmp_init, (start_fpt)tmp_start, (stop_fpt)tmp_stop, (deinit_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);
+
+/**
+ * Destroys a DM Component info struct.
+ */
+void component_destroyComponentInfo(dm_component_info_pt info);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* COMPONENT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/include/dm_dependency_manager.h
----------------------------------------------------------------------
diff --git a/framework/include/dm_dependency_manager.h b/framework/include/dm_dependency_manager.h
new file mode 100644
index 0000000..f48056e
--- /dev/null
+++ b/framework/include/dm_dependency_manager.h
@@ -0,0 +1,82 @@
+/**
+ *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_dependency_manager.h
+ *
+ *  \date       22 Feb 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#ifndef DM_DEPENDENCY_MANAGER_H_
+#define DM_DEPENDENCY_MANAGER_H_
+
+#include "celix_types.h"
+
+#include "celix_errno.h"
+#include "array_list.h"
+#include "dm_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * Creates a dependency manager.
+ * Caller has ownership.
+ */
+celix_status_t dependencyManager_create(bundle_context_t *context, dm_dependency_manager_t **manager);
+
+/**
+ * Destroys the provided dependency manager
+ */
+void dependencyManager_destroy(dm_dependency_manager_t *manager);
+
+/**
+ * Adds a DM component to the dependency manager
+ */
+celix_status_t dependencyManager_add(dm_dependency_manager_t *manager, dm_component_t *component);
+
+/**
+ * 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);
+
+/**
+ * Removes all DM components from the dependency manager
+ */
+celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_t *manager);
+
+/**
+ * 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);
+
+/**
+ * Destroys a DM info struct.
+ */
+void dependencyManager_destroyInfo(dm_dependency_manager_t *manager, dm_dependency_manager_info_t *info);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DM_DEPENDENCY_MANAGER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/include/dm_info.h
----------------------------------------------------------------------
diff --git a/framework/include/dm_info.h b/framework/include/dm_info.h
new file mode 100644
index 0000000..8074ab6
--- /dev/null
+++ b/framework/include/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.
+ */
+/*
+ * 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/5992be15/framework/include/dm_service_dependency.h
----------------------------------------------------------------------
diff --git a/framework/include/dm_service_dependency.h b/framework/include/dm_service_dependency.h
new file mode 100644
index 0000000..9ed78e3
--- /dev/null
+++ b/framework/include/dm_service_dependency.h
@@ -0,0 +1,172 @@
+/**
+ *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_service_dependency.h
+ *
+ *  \date       8 Oct 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#ifndef DM_SERVICE_DEPENDENCY_H_
+#define DM_SERVICE_DEPENDENCY_H_
+
+#include "celix_types.h"
+#include "celix_errno.h"
+#include "celix_threads.h"
+#include "service_reference.h"
+
+#include "dm_info.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 int (*service_set_fpt)(void *handle, const void* service);
+typedef int (*service_add_fpt)(void *handle, const void* service);
+typedef int (*service_change_fpt)(void *handle, const void* service);
+typedef int (*service_remove_fpt)(void *handle, const void* service);
+typedef int (*service_swap_fpt)(void *handle, const void* oldService, const void* newService);
+
+typedef celix_status_t (*service_set_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
+typedef celix_status_t (*service_add_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
+typedef celix_status_t (*service_change_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
+typedef celix_status_t (*service_remove_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
+typedef celix_status_t (*service_swap_with_ref_fpt)(void *handle, service_reference_pt oldReference, const void* oldService, service_reference_pt newReference, const void* newService);
+
+/**
+ * Create a service dependency.
+ * Caller has ownership.
+ */
+celix_status_t serviceDependency_create(dm_service_dependency_t **dep);
+
+/**
+ * Destroys a service dependency.
+ * Caller has ownership.
+ */
+celix_status_t serviceDependency_destroy(dm_service_dependency_t **dep);
+
+/**
+ * Specify if the service dependency is required. default is false
+ */
+celix_status_t serviceDependency_setRequired(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 serviceDependency_setAddCLanguageFilter(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 serviceDependency_setStrategy(dm_service_dependency_t *dependency,dm_service_dependency_strategy_t strategy);
+
+/**
+ * Return the service dependency update strategy.
+ */
+celix_status_t serviceDependency_getStrategy(dm_service_dependency_t *dependency,dm_service_dependency_strategy_t* strategy);
+
+/**
+ * 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 serviceDependency_setService(dm_service_dependency_t *dependency, const char* serviceName, const char* serviceVersionRange, const char* filter);
+
+/**
+ * Returns the service depenendy filter.
+ */
+celix_status_t serviceDependency_getFilter(dm_service_dependency_t *dependency, const char** filter);
+
+/**
+ * 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 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);
+
+/**
+ * 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 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 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);
+
+/**
+ * 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);
+
+#define serviceDependency_setCallbacksSafe(dep, cmpType, servType, set, add, change, remove, swap) \
+	do { \
+		int (*tmpSet)(cmpType, servType) = set; \
+		int (*tmpAdd)(cmpType, servType) = add; \
+		int (*tmpChange)(cmpType, servType) = change; \
+		int (*tmpRemove)(cmpType, servType) = remove; \
+		int (*tmpSwap)(cmpType, servType, servType) = swap; \
+		serviceDependency_setCallbacks((dep), (service_set_fpt)tmpSet, (service_add_fpt)tmpAdd, (service_change_fpt)tmpChange, (service_remove_fpt)tmpRemove, (service_swap_fpt)tmpSwap); \
+	} while(0)
+
+/**
+ * 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 serviceDependency_setCallbackHandle(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
+ */
+celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_t* dep, dm_service_dependency_info_t **info);
+
+/**
+ * Destroy a provided service dependency info struct.
+ */
+void dependency_destroyDependencyInfo(dm_service_dependency_info_t *info);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DM_SERVICE_DEPENDENCY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/src/bundle_context.c
----------------------------------------------------------------------
diff --git a/framework/src/bundle_context.c b/framework/src/bundle_context.c
index cf609c9..03fe262 100644
--- a/framework/src/bundle_context.c
+++ b/framework/src/bundle_context.c
@@ -42,11 +42,13 @@ celix_status_t bundleContext_create(framework_pt framework, framework_logger_pt
         } else {
             context->framework = framework;
             context->bundle = bundle;
+            context->mng = NULL;
 
             arrayList_create(&context->svcRegistrations);
             celixThreadMutex_create(&context->mutex, NULL);
 
             *bundle_context = context;
+
         }
 	}
 
@@ -485,3 +487,20 @@ bool bundleContext_useServiceWithId(
     }
     return called;
 }
+
+
+dm_dependency_manager_t* bundleContext_getDependencyManager(bundle_context_t *ctx) {
+    dm_dependency_manager_t* result = NULL;
+    if (ctx != NULL) {
+        celixThreadMutex_lock(&ctx->mutex);
+        if (ctx->mng == NULL) {
+            dependencyManager_create(ctx, &ctx->mng);
+        }
+        if (ctx->mng == NULL) {
+            framework_logIfError(logger, CELIX_BUNDLE_EXCEPTION, NULL, "Cannot create dependency manager");
+        }
+        result = ctx->mng;
+        celixThreadMutex_unlock(&ctx->mutex);
+    }
+    return result;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/framework/src/bundle_context_private.h
----------------------------------------------------------------------
diff --git a/framework/src/bundle_context_private.h b/framework/src/bundle_context_private.h
index f4d5425..5ed0196 100644
--- a/framework/src/bundle_context_private.h
+++ b/framework/src/bundle_context_private.h
@@ -38,8 +38,9 @@ struct bundleContext {
 	struct framework * framework;
 	struct bundle * bundle;
 
-	celix_thread_mutex_t mutex; //protect svcRegistrations.
+	celix_thread_mutex_t mutex; //protect svcRegistrations & mng
 	array_list_t *svcRegistrations;
+	dm_dependency_manager_t *mng;
 };
 
 


Mime
View raw message