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 2016/07/20 13:52:13 UTC

[2/2] celix git commit: CELIX-370: Initial drop of the C++ Dependency Manager

CELIX-370: Initial drop of the C++ Dependency Manager


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/a9a75c51
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/a9a75c51
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/a9a75c51

Branch: refs/heads/develop
Commit: a9a75c5159925b0d25180e5ff8c686bb1cc97c8d
Parents: ffc2a9a
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Fri Jul 1 21:43:36 2016 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Wed Jul 20 15:28:10 2016 +0200

----------------------------------------------------------------------
 CMakeLists.txt                                  |   9 +-
 dependency_manager/CMakeLists.txt               |  31 +--
 .../private/include/dm_component_impl.h         |  11 +-
 .../private/include/dm_dependency.h             |   7 +
 .../include/dm_dependency_manager_impl.h        |   9 +
 dependency_manager/private/include/dm_event.h   |   7 +
 .../include/dm_service_dependency_impl.h        |   8 +
 .../private/include/dm_shell_list_command.h     |  23 +-
 .../private/src/dm_component_impl.c             |   2 +-
 .../private/src/dm_service_dependency.c         |  37 ++-
 .../public/include/dm_activator.h               |   8 +
 .../public/include/dm_component.h               |   7 +
 .../public/include/dm_dependency_manager.h      |   8 +
 dependency_manager/public/include/dm_info.h     |  11 +-
 .../public/include/dm_service_dependency.h      |  15 ++
 dependency_manager_cxx/CMakeLists.txt           |  76 ++++++
 .../include/celix/dm/Component.h                |  93 +++++++
 .../include/celix/dm/Component_Impl.h           | 187 ++++++++++++++
 .../include/celix/dm/DependencyManager.h        |  93 +++++++
 .../include/celix/dm/DmActivator.h              |  58 +++++
 .../include/celix/dm/Properties.h               |  30 +++
 .../include/celix/dm/ServiceDependency.h        | 131 ++++++++++
 .../include/celix/dm/ServiceDependency_Impl.h   | 241 +++++++++++++++++++
 dependency_manager_cxx/include/celix/dm/types.h |  60 +++++
 dependency_manager_cxx/src/Component.cc         |  43 ++++
 dependency_manager_cxx/src/DependencyManager.cc |  57 +++++
 .../src/dm_activator_base_cxx.cc                | 115 +++++++++
 examples/CMakeLists.txt                         |   3 +-
 .../phase2a/private/src/phase2a_activator.c     |   2 +-
 .../phase2b/private/src/phase2b_activator.c     |   1 +
 .../phase3/private/src/phase3_activator.c       |   2 +-
 examples/dm_example_cxx/CMakeLists.txt          |  52 ++++
 examples/dm_example_cxx/api/IPhase1.h           |  30 +++
 examples/dm_example_cxx/api/IPhase2.h           |  30 +++
 examples/dm_example_cxx/phase1/CMakeLists.txt   |  40 +++
 .../phase1/include/Phase1Activator.h            |  36 +++
 .../dm_example_cxx/phase1/include/Phase1Cmp.h   |  44 ++++
 .../phase1/src/Phase1Activator.cc               |  59 +++++
 examples/dm_example_cxx/phase1/src/Phase1Cmp.cc |  49 ++++
 .../phase2/include/Phase2Activator.h            |  34 +++
 .../dm_example_cxx/phase2/include/Phase2Cmp.h   |  40 +++
 examples/dm_example_cxx/phase2a/CMakeLists.txt  |  41 ++++
 .../phase2a/src/Phase2aActivator.cc             |  53 ++++
 .../dm_example_cxx/phase2a/src/Phase2aCmp.cc    |  32 +++
 examples/dm_example_cxx/phase2b/CMakeLists.txt  |  41 ++++
 .../phase2b/src/Phase2bActivator.cc             |  52 ++++
 .../dm_example_cxx/phase2b/src/Phase2bCmp.cc    |  32 +++
 examples/dm_example_cxx/phase3/CMakeLists.txt   |  41 ++++
 .../phase3/include/Phase3Activator.h            |  33 +++
 .../dm_example_cxx/phase3/include/Phase3Cmp.h   |  50 ++++
 .../phase3/src/Phase3LockingActivator.cc        |  45 ++++
 .../phase3/src/Phase3LockingCmp.cc              |  63 +++++
 .../phase3_locking/CMakeLists.txt               |  40 +++
 .../include/Phase3LockingActivator.h            |  33 +++
 .../phase3_locking/include/Phase3LockingCmp.h   |  50 ++++
 .../src/Phase3LockingActivator.cc               |  40 +++
 .../phase3_locking/src/Phase3LockingCmp.cc      |  63 +++++
 57 files changed, 2465 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0756cab..25bf186 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,7 +36,7 @@ IF (ANDROID)
     SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -Wall ${CMAKE_C_FLAGS}")
 ENDIF()
 IF(UNIX AND NOT ANDROID)
-    SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -Wall -Werror ${CMAKE_C_FLAGS}")
+    SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -Wall -Werror -fPIC ${CMAKE_C_FLAGS}")
     #SET(CMAKE_CXX_FLAGS "-Wall -Werror ${CMAKE_CXX_FLAGS}")
 ENDIF()
 IF(UNIX AND NOT APPLE) 
@@ -47,6 +47,8 @@ IF(WIN32)
 	SET(CMAKE_C_FLAGS "-D_CRT_SECURE_NO_WARNINGS ${CMAKE_C_FLAGS}")
 ENDIF()
 
+set(CMAKE_CXX_FLAGS "-std=c++11 -pthread ${CMAKE_CXX_FLAGS}")
+
 # Set version for the framework package/release
 SET(CELIX_MAJOR "1")
 SET(CELIX_MINOR "0")
@@ -70,7 +72,6 @@ set(DEFAULT_VERSION 1.0.0)
 ## Sub projects depending on another sub project automatically enable these dependencies
 ## For this to work, the order off "add_subdirectory" has to be correct (ie backwards)
 add_subdirectory(config_admin)
-add_subdirectory(examples)
 add_subdirectory(device_access)
 add_subdirectory(deployment_admin)
 add_subdirectory(remote_services)
@@ -83,9 +84,13 @@ add_subdirectory(log_service)
 
 #add_subdirectory(event_admin)# event_admin is unstable
 add_subdirectory(dependency_manager)
+add_subdirectory(dependency_manager_cxx)
 #add_subdirectory(scr) scr still needs APR
 
 add_subdirectory(launcher)
 add_subdirectory(framework)
 add_subdirectory(utils)
 add_subdirectory(dfi)
+
+#Example as last, because some example will check if underlining options are enabled
+add_subdirectory(examples)

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/dependency_manager/CMakeLists.txt b/dependency_manager/CMakeLists.txt
index 4c7c3f8..1161959 100644
--- a/dependency_manager/CMakeLists.txt
+++ b/dependency_manager/CMakeLists.txt
@@ -48,20 +48,22 @@ if (DEPENDENCY_MANAGER)
     	private/src/dm_event
     	private/src/dm_dependency_manager_impl
     )
+    #set_target_properties(dependency_manager_static PROPERTIES SOVERSION 1)
 
-    add_library(dependency_manager_so SHARED 
-    	private/src/dm_activator_base 
-    	private/src/dm_component_impl 
-    	private/src/dm_service_dependency
-    	private/src/dm_event
-        private/src/dm_dependency_manager_impl
-    )
-    set_target_properties(dependency_manager_so PROPERTIES SOVERSION 1)
-    if (APPLE) 
-        target_link_libraries(dependency_manager_so celix_framework "-undefined dynamic_lookup")
-    else()
-        target_link_libraries(dependency_manager_so celix_framework)
-    endif()
+    #add_library(dependency_manager_so SHARED 
+    # 	private/src/dm_activator_base 
+    #	private/src/dm_component_impl 
+    #	private/src/dm_service_dependency
+    # 	private/src/dm_event
+    #    private/src/dm_dependency_manager_impl
+    #)
+    #set_target_properties(dependency_manager_so PROPERTIES SOVERSION 1)
+
+    #if (APPLE) 
+    #    target_link_libraries(dependency_manager_so celix_framework "-undefined dynamic_lookup")
+    #else()
+    #    target_link_libraries(dependency_manager_so celix_framework)
+    #endif()
 
    	include_directories("public/include")
    	include_directories("private/include")
@@ -82,7 +84,6 @@ if (DEPENDENCY_MANAGER)
 			dependency_manager
 	)
     install_bundle(dm_shell)
-    #install(TARGETS dependency_manager dependency_manager_static DESTINATION lib COMPONENT dependency_manager)
     install(TARGETS dependency_manager_static DESTINATION lib COMPONENT dependency_manager)
-    install(TARGETS dependency_manager_so DESTINATION lib COMPONENT dependency_manager)
+    #install(TARGETS dependency_manager_so DESTINATION lib COMPONENT dependency_manager)
 endif (DEPENDENCY_MANAGER)

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager/private/include/dm_component_impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_component_impl.h b/dependency_manager/private/include/dm_component_impl.h
index bb093ff..495197c 100644
--- a/dependency_manager/private/include/dm_component_impl.h
+++ b/dependency_manager/private/include/dm_component_impl.h
@@ -27,15 +27,22 @@
 #ifndef COMPONENT_IMPL_H_
 #define COMPONENT_IMPL_H_
 
-#include "dm_component.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
 
+#include "dm_component.h"
 #include "dm_service_dependency_impl.h"
-
 #include "dm_event.h"
 
 celix_status_t component_start(dm_component_pt component);
+
 celix_status_t component_stop(dm_component_pt component);
 
 celix_status_t component_handleEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* COMPONENT_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager/private/include/dm_dependency.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_dependency.h b/dependency_manager/private/include/dm_dependency.h
index e7ad5fb..6923239 100644
--- a/dependency_manager/private/include/dm_dependency.h
+++ b/dependency_manager/private/include/dm_dependency.h
@@ -27,8 +27,15 @@
 #ifndef DM_DEPENDENCY_H_
 #define DM_DEPENDENCY_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 
 
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* DM_DEPENDENCY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager/private/include/dm_dependency_manager_impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_dependency_manager_impl.h b/dependency_manager/private/include/dm_dependency_manager_impl.h
index 3c9db01..c673605 100644
--- a/dependency_manager/private/include/dm_dependency_manager_impl.h
+++ b/dependency_manager/private/include/dm_dependency_manager_impl.h
@@ -27,10 +27,19 @@
 #ifndef CELIX_DM_DEPENDENCY_MANAGER_IMPL_H
 #define CELIX_DM_DEPENDENCY_MANAGER_IMPL_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
 struct dm_dependency_manager {
     array_list_pt components;
 
     pthread_mutex_t mutex;
 };
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif //CELIX_DM_DEPENDENCY_MANAGER_IMPL_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager/private/include/dm_event.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_event.h b/dependency_manager/private/include/dm_event.h
index d04e9b0..8ba1be7 100644
--- a/dependency_manager/private/include/dm_event.h
+++ b/dependency_manager/private/include/dm_event.h
@@ -27,6 +27,10 @@
 #ifndef DM_EVENT_H_
 #define DM_EVENT_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "service_reference.h"
 #include "bundle_context.h"
 #include "bundle.h"
@@ -61,5 +65,8 @@ celix_status_t event_equals(const void* a, const void* b, bool* equals);
 celix_status_t event_getService(dm_event_pt event, const void** service);
 celix_status_t event_compareTo(dm_event_pt event, dm_event_pt compareTo, int* compare);
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* DM_EVENT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager/private/include/dm_service_dependency_impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_service_dependency_impl.h b/dependency_manager/private/include/dm_service_dependency_impl.h
index b67c4af..c565b2f 100644
--- a/dependency_manager/private/include/dm_service_dependency_impl.h
+++ b/dependency_manager/private/include/dm_service_dependency_impl.h
@@ -27,6 +27,10 @@
 #ifndef DM_SERVICE_DEPENDENCY_IMPL_H_
 #define DM_SERVICE_DEPENDENCY_IMPL_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdbool.h>
 
 #include "dm_event.h"
@@ -43,6 +47,7 @@ struct dm_service_dependency {
 	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;
@@ -91,5 +96,8 @@ celix_status_t serviceDependency_getAutoConfig(dm_service_dependency_pt dependen
 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/a9a75c51/dependency_manager/private/include/dm_shell_list_command.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_shell_list_command.h b/dependency_manager/private/include/dm_shell_list_command.h
index 01c5065..e8405c2 100644
--- a/dependency_manager/private/include/dm_shell_list_command.h
+++ b/dependency_manager/private/include/dm_shell_list_command.h
@@ -16,16 +16,23 @@
  *specific language governing permissions and limitations
  *under the License.
  */
-/*
- * dm_shell_list_command.h
- *
- *  \date       Oct 16, 2015
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
+
+#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"
 
-void dmListCommand_execute(bundle_context_pt context, char * line, FILE *out, FILE *err);
\ No newline at end of file
+void dmListCommand_execute(bundle_context_pt context, 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/a9a75c51/dependency_manager/private/src/dm_component_impl.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_component_impl.c b/dependency_manager/private/src/dm_component_impl.c
index 270142c..d556c35 100644
--- a/dependency_manager/private/src/dm_component_impl.c
+++ b/dependency_manager/private/src/dm_component_impl.c
@@ -1159,7 +1159,7 @@ celix_status_t component_configureImplementation(dm_component_pt component, dm_s
 celix_status_t component_registerServices(dm_component_pt component) {
     celix_status_t status = CELIX_SUCCESS;
 
-    if (component->context) {
+    if (component->context != NULL) {
 	    unsigned int i;
         for (i = 0; i < arrayList_size(component->dm_interfaces); i++) {
             dm_interface_t *interface = arrayList_get(component->dm_interfaces, i);

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager/private/src/dm_service_dependency.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_service_dependency.c b/dependency_manager/private/src/dm_service_dependency.c
index 2c713c5..0121c5c 100644
--- a/dependency_manager/private/src/dm_service_dependency.c
+++ b/dependency_manager/private/src/dm_service_dependency.c
@@ -36,11 +36,12 @@
 #include "dm_component_impl.h"
 
 #define DEFAULT_RANKING     0
-#define DM_SERVICE_DEPENDENCY_DEFAULT_STRATEGY DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING
+#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;
@@ -55,6 +56,7 @@ celix_status_t serviceDependency_create(dm_service_dependency_pt *dependency_ptr
 		(*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;
@@ -158,6 +160,7 @@ celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency,
 		array_list_pt filterElements = NULL;
 		arrayList_create(&filterElements);
 
+		free(dependency->tracked_service);
 		dependency->tracked_service = strdup(serviceName);
 
 		if (serviceVersionRange != NULL) {
@@ -212,6 +215,7 @@ celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency,
 		}
 
 		if (filter != NULL) {
+			free(dependency->tracked_filter_unmodified);
 			dependency->tracked_filter_unmodified = strdup(filter);
 			arrayList_add(filterElements, strdup(filter));
 		}
@@ -220,6 +224,7 @@ celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency,
 			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);
 
@@ -245,6 +250,7 @@ celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency,
 			arrayListIterator_destroy(filterElementsIter);
 		}
 		else {
+			free(dependency->tracked_filter);
 			dependency->tracked_filter = NULL;
 		}
 
@@ -471,10 +477,10 @@ celix_status_t serviceDependency_invokeSet(dm_service_dependency_pt dependency,
 	}
 
 	if (dependency->set) {
-		dependency->set(component_getImplementation(dependency->component), service);
+		dependency->set(serviceDependency_getCallbackHandle(dependency), service);
 	}
 	if (dependency->set_with_ref) {
-		dependency->set_with_ref(component_getImplementation(dependency->component), curServRef, service);
+		dependency->set_with_ref(serviceDependency_getCallbackHandle(dependency), curServRef, service);
 	}
 
 	if (curServRef) {
@@ -493,10 +499,10 @@ celix_status_t serviceDependency_invokeAdd(dm_service_dependency_pt dependency,
 
 	if (status == CELIX_SUCCESS) {
 		if (dependency->add) {
-			dependency->add(component_getImplementation(dependency->component), event->service);
+			dependency->add(serviceDependency_getCallbackHandle(dependency), event->service);
 		}
 		if (dependency->add_with_ref) {
-			dependency->add_with_ref(component_getImplementation(dependency->component), event->reference, event->service);
+			dependency->add_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service);
 		}
 	}
 
@@ -512,10 +518,10 @@ celix_status_t serviceDependency_invokeChange(dm_service_dependency_pt dependenc
 
 	if (status == CELIX_SUCCESS) {
 		if (dependency->change) {
-			dependency->change(component_getImplementation(dependency->component), event->service);
+			dependency->change(serviceDependency_getCallbackHandle(dependency), event->service);
 		}
 		if (dependency->change_with_ref) {
-			dependency->change_with_ref(component_getImplementation(dependency->component), event->reference, event->service);
+			dependency->change_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service);
 		}
 	}
 
@@ -531,10 +537,10 @@ celix_status_t serviceDependency_invokeRemove(dm_service_dependency_pt dependenc
 
 	if (status == CELIX_SUCCESS) {
 		if (dependency->remove) {
-			dependency->remove(component_getImplementation(dependency->component), event->service);
+			dependency->remove(serviceDependency_getCallbackHandle(dependency), event->service);
 		}
 		if (dependency->remove_with_ref) {
-			dependency->remove_with_ref(component_getImplementation(dependency->component), event->reference, event->service);
+			dependency->remove_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service);
 		}
 	}
 
@@ -550,10 +556,10 @@ celix_status_t serviceDependency_invokeSwap(dm_service_dependency_pt dependency,
 
 	if (status == CELIX_SUCCESS) {
 		if (dependency->swap) {
-			dependency->swap(component_getImplementation(dependency->component), event->service, newEvent->service);
+			dependency->swap(serviceDependency_getCallbackHandle(dependency), event->service, newEvent->service);
 		}
 		if (dependency->swap_with_ref) {
-			dependency->swap_with_ref(component_getImplementation(dependency->component), event->reference, event->service, newEvent->reference, newEvent->service);
+			dependency->swap_with_ref(serviceDependency_getCallbackHandle(dependency), event->reference, event->service, newEvent->reference, newEvent->service);
 		}
 	}
 
@@ -774,3 +780,12 @@ void dependency_destroyDependencyInfo(dm_service_dependency_info_pt info) {
 	}
 	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;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager/public/include/dm_activator.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_activator.h b/dependency_manager/public/include/dm_activator.h
index a439ee5..898d53f 100644
--- a/dependency_manager/public/include/dm_activator.h
+++ b/dependency_manager/public/include/dm_activator.h
@@ -29,6 +29,10 @@
 #ifndef DM_ACTIVATOR_BASE_H_
 #define DM_ACTIVATOR_BASE_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "bundle_context.h"
 #include "celix_errno.h"
 #include "dm_dependency_manager.h"
@@ -37,4 +41,8 @@ celix_status_t dm_create(bundle_context_pt context, void ** userData);
 celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager);
 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/a9a75c51/dependency_manager/public/include/dm_component.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_component.h b/dependency_manager/public/include/dm_component.h
index 2720a03..997bd1a 100644
--- a/dependency_manager/public/include/dm_component.h
+++ b/dependency_manager/public/include/dm_component.h
@@ -27,6 +27,10 @@
 #ifndef COMPONENT_H_
 #define COMPONENT_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <bundle_context.h>
 #include <celix_errno.h>
 
@@ -86,5 +90,8 @@ celix_status_t component_setCallbacks(dm_component_pt component, init_fpt init,
 celix_status_t component_getComponentInfo(dm_component_pt component, dm_component_info_pt *info);
 void component_destroyComponentInfo(dm_component_info_pt info);
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* COMPONENT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager/public/include/dm_dependency_manager.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_dependency_manager.h b/dependency_manager/public/include/dm_dependency_manager.h
index 2eceeb9..339fa55 100644
--- a/dependency_manager/public/include/dm_dependency_manager.h
+++ b/dependency_manager/public/include/dm_dependency_manager.h
@@ -27,6 +27,10 @@
 #ifndef DM_DEPENDENCY_MANAGER_H_
 #define DM_DEPENDENCY_MANAGER_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "bundle_context.h"
 #include "celix_errno.h"
 #include "array_list.h"
@@ -48,4 +52,8 @@ celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_pt ma
 celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt *info);
 void dependencyManager_destroyInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt info);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* DM_DEPENDENCY_MANAGER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager/public/include/dm_info.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_info.h b/dependency_manager/public/include/dm_info.h
index 99bb46a..b56ba91 100644
--- a/dependency_manager/public/include/dm_info.h
+++ b/dependency_manager/public/include/dm_info.h
@@ -26,6 +26,11 @@
 #ifndef CELIX_DM_INFO_SERVICE_H
 #define CELIX_DM_INFO_SERVICE_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
 #include <stdbool.h>
 #include "array_list.h"
 
@@ -60,7 +65,11 @@ struct dm_info_service {
     void (*destroyInfo)(void *handle, dm_dependency_manager_info_pt info);
 };
 
-typedef struct dm_info_service * dm_info_service_pt;
+typedef struct dm_info_service dm_info_service_t;
+typedef dm_info_service_t* dm_info_service_pt;
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif //CELIX_DM_INFO_SERVICE_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager/public/include/dm_service_dependency.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_service_dependency.h b/dependency_manager/public/include/dm_service_dependency.h
index 8088809..ed19b55 100644
--- a/dependency_manager/public/include/dm_service_dependency.h
+++ b/dependency_manager/public/include/dm_service_dependency.h
@@ -27,6 +27,11 @@
 #ifndef DM_SERVICE_DEPENDENCY_H_
 #define DM_SERVICE_DEPENDENCY_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "service_reference.h"
 #include "celix_errno.h"
 #include "dm_info.h"
 
@@ -73,6 +78,12 @@ celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_pt depen
 		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_pt dependency, void* handle);
 
 /**
  * Return a service dependency info. The caller is the owner
@@ -80,4 +91,8 @@ celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_pt depen
 celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_pt, dm_service_dependency_info_pt *info);
 void dependency_destroyDependencyInfo(dm_service_dependency_info_pt info);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* DM_SERVICE_DEPENDENCY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager_cxx/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/CMakeLists.txt b/dependency_manager_cxx/CMakeLists.txt
new file mode 100644
index 0000000..49ff327
--- /dev/null
+++ b/dependency_manager_cxx/CMakeLists.txt
@@ -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.
+
+celix_subproject(DEPENDENCY_MANAGER_CXX "Option to build the C++ dependency manager static library" ON DEPS framework DEPENDENCY_MANAGER)
+if (DEPENDENCY_MANAGER_CXX)
+
+    # Add -fPIC for x86_64 Unix platforms; this lib will be linked to a shared lib
+    if(UNIX AND NOT WIN32)
+        find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin )
+        if(CMAKE_UNAME)
+            exec_program(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR)
+            set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL "processor type (i386 and x86_64)")
+            if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+                add_definitions(-fPIC)
+            endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+        endif(CMAKE_UNAME)
+    endif(UNIX AND NOT WIN32)
+
+    include_directories(include)
+    include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+    include_directories("${PROJECT_SOURCE_DIR}/dependency_manager/public/include")
+    include_directories("${PROJECT_SOURCE_DIR}/dependency_manager/private/include")
+
+    set(DM_DIR "${PROJECT_SOURCE_DIR}/dependency_manager")
+
+    add_library(dependency_manager_cxx_static STATIC
+    	${DM_DIR}/private/src/dm_component_impl.c
+        ${DM_DIR}/private/src/dm_service_dependency.c
+        ${DM_DIR}/private/src/dm_event.c
+        ${DM_DIR}/private/src/dm_dependency_manager_impl.c
+
+        src/DependencyManager.cc
+        src/Component.cc
+        src/dm_activator_base_cxx.cc
+    )
+    #set_target_properties(dependency_manager_cxx_static PROPERTIES SOVERSION 1)
+    target_link_libraries(dependency_manager_cxx_static celix_framework)
+
+    #NOTE need to install dep man headers? or depend on install of dependency manager?
+    install(
+        FILES
+            ${DM_DIR}/public/include/dm_activator.h
+            ${DM_DIR}/public/include/dm_component.h
+            ${DM_DIR}/public/include/dm_dependency_manager.h
+            ${DM_DIR}/public/include/dm_service_dependency.h
+            ${DM_DIR}/public/include/dm_info.h
+        DESTINATION
+            include/celix/dependency_manager_cxx
+        COMPONENT
+            dependency_manager_cxx
+    )
+    install(
+        DIRECTORY
+            include
+        DESTINATION
+            include/celix/dependency_manager_cxx
+        COMPONENT
+            dependency_manager_cxx
+    )
+
+    install(TARGETS dependency_manager_cxx_static DESTINATION lib COMPONENT dependency_manager_cxx)
+endif (DEPENDENCY_MANAGER_CXX)

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager_cxx/include/celix/dm/Component.h
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/include/celix/dm/Component.h b/dependency_manager_cxx/include/celix/dm/Component.h
new file mode 100644
index 0000000..612ced6
--- /dev/null
+++ b/dependency_manager_cxx/include/celix/dm/Component.h
@@ -0,0 +1,93 @@
+/**
+ * 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_COMPONENT_H
+#define CELIX_DM_COMPONENT_H
+
+#include "celix/dm/types.h"
+#include "dm_component.h"
+
+#include <map>
+#include <string>
+#include <list>
+#include <tuple>
+
+namespace celix { namespace dm {
+
+    class BaseComponent {
+        std::string name {};
+        bundle_context_pt context {nullptr};
+        dm_component_pt cCmp {nullptr};
+    public:
+        BaseComponent(const bundle_context_pt context, std::string name);
+        virtual ~BaseComponent();
+
+        const dm_component_pt cComponent() const;
+        const bundle_context_pt bundleContext() const;
+    };
+        
+
+    template<class T>
+    class Component : public BaseComponent {
+        std::shared_ptr<T> instance = {nullptr};
+        std::list<T> refInstance {};
+
+        void (T::*initFp)() = {};
+        void (T::*startFp)() = {};
+        void (T::*stopFp)() = {};
+        void (T::*deinitFp)() = {};
+    public:
+        Component(const bundle_context_pt context, std::string name);
+        virtual ~Component();
+
+        T& getInstance();
+
+        Component<T>& setInstance(std::shared_ptr<T> inst);
+
+        Component<T>& setInstance(T&& inst);
+
+        //provided interfaces
+        template<class I> Component<T>& addInterface(const std::string version);
+        template<class I> Component<T>& addInterface(const std::string version, const Properties properties);
+        Component<T>& addInterface(const std::string intfName, const std::string version, const Properties properties);
+        Component<T>& addCInterface(const void* svc, const std::string serviceName, const std::string version, const Properties properties);
+
+        //dependencies
+        template<class I>
+        Component<T>& add(ServiceDependency<T,I>& dep);
+        template<class I>
+        Component<T>& remove(ServiceDependency<T,I>& dep);
+
+        Component<T>& add(CServiceDependency<T>& dep);
+        Component<T>& remove(CServiceDependency<T>& dep);
+
+        //callbacks
+        Component<T>& setCallbacks(
+            void (T::*init)(),
+            void (T::*start)(),
+            void (T::*stop)(),
+            void (T::*deinit)()
+        );
+    };
+
+}}
+
+#include "celix/dm/Component_Impl.h"
+
+#endif //CELIX_DM_COMPONENT_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager_cxx/include/celix/dm/Component_Impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/include/celix/dm/Component_Impl.h b/dependency_manager_cxx/include/celix/dm/Component_Impl.h
new file mode 100644
index 0000000..17805ff
--- /dev/null
+++ b/dependency_manager_cxx/include/celix/dm/Component_Impl.h
@@ -0,0 +1,187 @@
+/**
+ * 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.
+ */
+
+#include "celix/dm/Component.h"
+#include "celix/dm/DependencyManager.h"
+#include "celix/dm/ServiceDependency.h"
+
+#include <memory>
+#include <iostream>
+
+using namespace celix::dm;
+
+template<class T>
+Component<T>::Component(const bundle_context_pt context, std::string name) : BaseComponent(context, name) { }
+
+template<class T>
+Component<T>::~Component() { }
+
+template<class T>
+template<class I>
+Component<T>& Component<T>::addInterface(const std::string version) {
+    Properties props;
+    return addInterface<I>(version, props);
+}
+
+template<class T>
+template<class I>
+Component<T>& Component<T>::addInterface(const std::string version, const Properties props) {
+    if (dynamic_cast<I*>(&this->getInstance()) != nullptr) {
+        this->addInterface(typeName<I>(), version.c_str(), props);
+    } else {
+        std::cerr << "Error casting to type " << typeName<I>() << "\n";
+    }
+    return *this;
+}
+
+template<class T>
+Component<T>& Component<T>::addInterface(const std::string serviceName, const std::string version, const Properties properties) {
+    properties_pt cProperties = properties_create();
+    properties_set(cProperties, (char*)"lang", (char*)"c++");
+    for (auto iter = properties.begin(); iter != properties.end(); iter++) {
+        properties_set(cProperties, (char*)iter->first.c_str(), (char*)iter->second.c_str());
+    }
+
+    const char *cVersion = version.empty() ? nullptr : version.c_str();
+    component_addInterface(this->cComponent(), (char*)serviceName.c_str(), (char*)cVersion, &this->getInstance(), cProperties);
+
+    return *this;
+};
+
+template<class T>
+Component<T>& Component<T>::addCInterface(const void* svc, const std::string serviceName, const std::string version, const Properties properties) {
+    properties_pt cProperties = properties_create();
+    properties_set(cProperties, (char*)"lang", (char*)"c");
+    for (auto iter = properties.begin(); iter != properties.end(); iter++) {
+        properties_set(cProperties, (char*)iter->first.c_str(), (char*)iter->second.c_str());
+    }
+
+    const char *cVersion = version.empty() ? nullptr : version.c_str();
+    component_addInterface(this->cComponent(), (char*)serviceName.c_str(), (char*)cVersion, svc, cProperties);
+
+    return *this;
+};
+
+template<class T>
+template<class I>
+Component<T>& Component<T>::add(ServiceDependency<T,I>& dep) {
+    component_addServiceDependency(cComponent(), dep.cServiceDependency());
+    dep.setComponentInstance(&getInstance());
+    return *this;
+}
+
+template<class T>
+template<class I>
+Component<T>& Component<T>::remove(ServiceDependency<T,I>& dep) {
+    component_removeServiceDependency(cComponent(), dep.cServiceDependency());
+    return *this;
+}
+
+template<class T>
+Component<T>& Component<T>::add(CServiceDependency<T>& dep) {
+    component_addServiceDependency(cComponent(), dep.cServiceDependency());
+
+    dep.setComponentInstance(&getInstance());
+    return *this;
+}
+
+template<class T>
+Component<T>& Component<T>::remove(CServiceDependency<T>& dep) {
+    component_removeServiceDependency(cComponent(), dep.cServiceDependency());
+    return *this;
+}
+
+template<class T>
+T& Component<T>::getInstance() {
+    if (this->refInstance.size() == 1) {
+        return refInstance.front();
+    } else {
+        if (this->instance.get() == nullptr) {
+            this->instance = std::shared_ptr<T> {new T()};
+        }
+        return *this->instance.get();
+    }
+}
+
+template<class T>
+Component<T>& Component<T>::setInstance(std::shared_ptr<T> inst) {
+    this->instance = inst;
+    return *this;
+}
+
+template<class T>
+Component<T>& Component<T>::setInstance(T&& inst) {
+    this->refInstance.clear();
+    this->refInstance.push_back(inst);
+    return *this;
+}
+
+template<class T>
+Component<T>& Component<T>::setCallbacks(
+            void (T::*init)(),
+            void (T::*start)(),
+            void (T::*stop)(),
+            void (T::*deinit)() ) {
+
+    this->initFp = init;
+    this->startFp = start;
+    this->stopFp = stop;
+    this->deinitFp = deinit;
+
+    int (*cInit)(void *) = [](void *handle) {
+        Component<T>* cmp = (Component<T>*)(handle);
+        T* inst = &cmp->getInstance();
+        void (T::*fp)() = cmp->initFp;
+        if (fp != nullptr) {
+            (inst->*fp)();
+        }
+        return 0;
+    };
+    int (*cStart)(void *) = [](void *handle) {
+        Component<T>* cmp = (Component<T>*)(handle);
+        T* inst = &cmp->getInstance();
+        void (T::*fp)() = cmp->startFp;
+        if (fp != nullptr) {
+            (inst->*fp)();
+        }
+        return 0;
+    };
+    int (*cStop)(void *) = [](void *handle) {
+        Component<T>* cmp = (Component<T>*)(handle);
+        T* inst = &cmp->getInstance();
+        void (T::*fp)() = cmp->stopFp;
+        if (fp != nullptr) {
+            (inst->*fp)();
+        }
+        return 0;
+    };
+    int (*cDeinit)(void *) = [](void *handle) {
+        Component<T>* cmp = (Component<T>*)(handle);
+        T* inst = &cmp->getInstance();
+        void (T::*fp)() = cmp->deinitFp;
+        if (fp != nullptr) {
+            (inst->*fp)();
+        }
+        return 0;
+    };
+
+    component_setCallbacks(this->cComponent(), cInit, cStart, cStop, cDeinit);
+
+    return *this;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager_cxx/include/celix/dm/DependencyManager.h
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/include/celix/dm/DependencyManager.h b/dependency_manager_cxx/include/celix/dm/DependencyManager.h
new file mode 100644
index 0000000..4d188ee
--- /dev/null
+++ b/dependency_manager_cxx/include/celix/dm/DependencyManager.h
@@ -0,0 +1,93 @@
+/**
+ * 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_DEPENDENCYMANAGER_H
+#define CELIX_DEPENDENCYMANAGER_H
+
+
+#include "celix/dm/types.h"
+#include "celix/dm/Component.h"
+#include "celix/dm/ServiceDependency.h"
+
+extern "C" {
+#include "bundle_context.h"
+#include "dm_dependency_manager.h"
+}
+
+#include <list>
+
+namespace celix { namespace dm {
+
+    class DependencyManager {
+        bundle_context_pt context = {nullptr};
+        std::list<std::shared_ptr<BaseComponent>> components {};
+        std::list<BaseComponent*> addedComponents {};
+        dm_dependency_manager_pt cDepMan {nullptr};
+        std::list<std::shared_ptr<BaseServiceDependency>> dependencies {};
+    public:
+        DependencyManager(bundle_context_pt context);
+        virtual ~DependencyManager();
+
+        const bundle_context_pt bundleContext() const;
+        const dm_dependency_manager_pt cDependencyManager() const;
+
+        //components
+        template<class T>
+        Component<T>& createComponent() {
+            std::shared_ptr<Component<T>> cmp {new Component<T>(this->context, typeName<T>())};
+            components.push_back(cmp);
+            return *cmp;
+        }
+
+        template<class T>
+        Component<T>& add(Component<T>& cmp) {
+            addedComponents.push_back(&cmp);
+            return cmp;
+        }
+
+        template<class T>
+        Component<T>& remove(Component<T>& cmp) {
+            addedComponents.remove(&cmp);
+            return cmp;
+        }
+
+        //service dependencies
+        template<class T, class I>
+        ServiceDependency<T,I>& createServiceDependency() {
+            auto dep = std::shared_ptr<ServiceDependency<T,I>> {new ServiceDependency<T,I>()};
+            dependencies.push_back(dep);
+            return *dep;
+        };
+
+
+        template<class T>
+        CServiceDependency<T>& createCServiceDependency() {
+            auto dep = std::shared_ptr<CServiceDependency<T>> {new CServiceDependency<T>()};
+            dependencies.push_back(dep);
+            return *dep;
+        }
+
+        //life cycle
+        void start();
+        void stop();
+    };
+
+}}
+
+#endif //CELIX_DEPENDENCYMANAGER_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/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
new file mode 100644
index 0000000..cfb1f29
--- /dev/null
+++ b/dependency_manager_cxx/include/celix/dm/DmActivator.h
@@ -0,0 +1,58 @@
+/**
+ * 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_ACTIVATOR_H
+#define CELIX_DM_ACTIVATOR_H
+
+#include "celix/dm/DependencyManager.h"
+
+namespace celix { namespace dm {
+
+    class DmActivator {
+    protected:
+        DependencyManager& manager;
+        DmActivator(DependencyManager& mng) : manager{mng} {}
+    public:
+        ~DmActivator() = default;
+        virtual void init(DependencyManager& manager) {};
+        virtual void deinit(DependencyManager& manager) {};
+
+        template< class T>
+        Component<T>& createComponent() { return manager.createComponent<T>(); }
+
+        template<class T>
+        Component<T>& add(Component<T>& cmp) { return manager.add(cmp); }
+
+        template<class T>
+        Component<T>& remove(Component<T>& cmp) { return manager.remove(cmp); }
+
+        template<class T, class I>
+        ServiceDependency<T,I>& createServiceDependency() { return manager.createServiceDependency<T,I>(); }
+
+        template<class T>
+        CServiceDependency<T>& createCServiceDependency() { return manager.createCServiceDependency<T>(); }
+
+        /* NOTE the following static method is intentionally not implemented
+         * This should be done by the bundle activator.
+         */
+        static DmActivator* create(DependencyManager& mng);
+    };
+}}
+
+#endif //CELIX_DM_ACTIVATOR_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager_cxx/include/celix/dm/Properties.h
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/include/celix/dm/Properties.h b/dependency_manager_cxx/include/celix/dm/Properties.h
new file mode 100644
index 0000000..7e4ca95
--- /dev/null
+++ b/dependency_manager_cxx/include/celix/dm/Properties.h
@@ -0,0 +1,30 @@
+/**
+ * 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_PROPERTIES_H
+#define CELIX_DM_PROPERTIES_H
+
+#include <map>
+#include <string>
+
+namespace celix { namespace dm {
+    typedef std::map<std::string, std::string> Properties;
+}}
+
+#endif //CELIX_DM_PROPERTIES_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager_cxx/include/celix/dm/ServiceDependency.h
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/include/celix/dm/ServiceDependency.h b/dependency_manager_cxx/include/celix/dm/ServiceDependency.h
new file mode 100644
index 0000000..b39d1b3
--- /dev/null
+++ b/dependency_manager_cxx/include/celix/dm/ServiceDependency.h
@@ -0,0 +1,131 @@
+/**
+ * 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_SERVICEDEPENDENCY_H
+#define CELIX_DM_SERVICEDEPENDENCY_H
+
+#include "dm_service_dependency.h"
+#include "celix/dm/types.h"
+
+#include <map>
+#include <string>
+#include <list>
+#include <tuple>
+#include <memory>
+#include <iostream>
+
+namespace celix { namespace dm {
+
+    class DependencyManager; //forward declaration
+
+
+    enum class DependencyUpdateStrategy {
+        suspend,
+        locking
+    };
+
+    class BaseServiceDependency {
+    protected:
+        dm_service_dependency_pt cServiceDep {nullptr};
+    public:
+        BaseServiceDependency() {
+            serviceDependency_create(&this->cServiceDep);
+            serviceDependency_setStrategy(this->cServiceDep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND); //NOTE using suspend as default strategy
+        }
+        virtual ~BaseServiceDependency() = default;
+
+        dm_service_dependency_pt cServiceDependency() const { return cServiceDep; }
+    };
+
+    template<class T>
+    class TypedServiceDependency :  public BaseServiceDependency {
+    protected:
+        T* componentInstance {nullptr};
+    public:
+        TypedServiceDependency() : BaseServiceDependency() {}
+        virtual ~TypedServiceDependency() = default;
+
+        void setComponentInstance(T* cmp) { componentInstance = cmp;}
+    };
+
+    template<class T>
+    class CServiceDependency : public TypedServiceDependency<T> {
+    public:
+        CServiceDependency() : TypedServiceDependency<T>() {};
+        virtual ~CServiceDependency() = default;
+
+        CServiceDependency<T>& setCService(const std::string serviceName, const std::string serviceVersion, const std::string filter);
+
+        CServiceDependency<T>& setRequired(bool req);
+        CServiceDependency<T>& setStrategy(DependencyUpdateStrategy strategy);
+    };
+
+    template<class T, class I>
+    class ServiceDependency : public TypedServiceDependency<T> {
+    protected:
+        std::string name {};
+        std::string filter {};
+        std::string version {};
+        std::string modifiedFilter {};
+
+        void (T::*setFp)(I* service) {nullptr};
+        void (T::*setFpWithProperties)(I* service, Properties&& properties) {nullptr};
+
+        void (T::*addFp)(I* service) {nullptr};
+        void (T::*addFpWithProperties)(I* service, Properties&& properties) {nullptr};
+
+        void (T::*removeFp)(I* service) {nullptr};
+        void (T::*removeFpWithProperties)(I* service, Properties&& properties) {nullptr};
+    private:
+        void setupService();
+        void setupCallbacks();
+        int invokeCallback(void(T::*fp)(I*), const void* service);
+        int invokeCallbackWithProperties(void(T::*fp)(I*, Properties&&), service_reference_pt  ref, const void* service);
+    public:
+        ServiceDependency();
+        virtual ~ServiceDependency() = default;
+
+        ServiceDependency<T,I>& setName(std::string name);
+
+        ServiceDependency<T,I>& setFilter(std::string filter);
+
+        ServiceDependency<T,I>& setVersion(std::string version);
+
+        //set callbacks
+        ServiceDependency<T,I>& setCallbacks(void (T::*set)(I* service));
+
+        ServiceDependency<T,I>& setCallbacks(void (T::*set)(I* service, Properties&& properties));
+
+        //add remove callbacks
+        ServiceDependency<T,I>& setCallbacks( void (T::*add)(I* service),  void (T::*remove)(I* service));
+        ServiceDependency<T,I>& setCallbacks(
+                void (T::*add)(I* service, Properties&& properties),
+                void (T::*remove)(I* service, Properties&& properties)
+        );
+
+        ServiceDependency<T,I>& setRequired(bool req);
+
+        ServiceDependency<T,I>& setStrategy(DependencyUpdateStrategy strategy);
+    };
+}}
+
+#include "celix/dm/ServiceDependency_Impl.h"
+
+
+#endif //CELIX_DM_SERVICEDEPENDENCY_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h b/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h
new file mode 100644
index 0000000..7c3eaf3
--- /dev/null
+++ b/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h
@@ -0,0 +1,241 @@
+/**
+ * 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.
+ */
+
+#include <vector>
+#include <iostream>
+
+using namespace celix::dm;
+
+template<class T>
+CServiceDependency<T>& CServiceDependency<T>::setCService(const std::string serviceName, const std::string serviceVersion, const std::string filter) {
+    const char* cversion = serviceVersion.empty() ? nullptr : serviceVersion.c_str();
+    const char* cfilter = filter.empty() ? nullptr : filter.c_str();
+    serviceDependency_setService(this->cServiceDependency(), serviceName.c_str(), cversion, cfilter);
+    return *this;
+}
+
+template<class T>
+CServiceDependency<T>& CServiceDependency<T>::setRequired(bool req) {
+    serviceDependency_setRequired(this->cServiceDependency(), req);
+    return *this;
+}
+
+static void dep_setStrategy(dm_service_dependency_pt dep, DependencyUpdateStrategy strategy) {
+    if (strategy == DependencyUpdateStrategy::locking) {
+        serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING);
+    } else if (strategy == DependencyUpdateStrategy::suspend) {
+        serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND);
+    } else {
+        std::cerr << "Unexpected dependency update strategy. Cannot convert for dm_depdendency\n";
+    }
+}
+
+template<class T>
+CServiceDependency<T>& CServiceDependency<T>::setStrategy(DependencyUpdateStrategy strategy) {
+    dep_setStrategy(this->cServiceDependency(), strategy);
+    return *this;
+}
+
+template<class T, class I>
+ServiceDependency<T,I>::ServiceDependency() : TypedServiceDependency<T>() {
+    setupService();
+};
+
+static std::string filterWithCxx(std::string filter) {
+    std::string result {"(lang=c++)"};
+    if (!filter.empty()) {
+        if (strncmp(filter.c_str(), "(&", 2) == 0 && filter[filter.size()-1] == ')') {
+            result = filter.substr(0, filter.size()-1);
+            result = result.append("(lang=c++))");
+        } else if (filter[0] == '(' && filter[filter.size()-1] == ')') {
+            result = "(&";
+            result = result.append(filter);
+            result = result.append("(lang=c++))");
+        } else {
+            std::cerr << "Unexpected filter layout: '" << filter << "'\n";
+        }
+    }
+    return result;
+}
+
+template<class T, class I>
+void ServiceDependency<T,I>::setupService() {
+    std::string n = name.empty() ? typeName<I>() : name;
+    const char* v =  version.empty() ? nullptr : version.c_str();
+    this->modifiedFilter = filterWithCxx(filter);
+    serviceDependency_setService(this->cServiceDependency(), n.c_str(), v, this->modifiedFilter.c_str());
+}
+
+template<class T, class I>
+ServiceDependency<T,I>& ServiceDependency<T,I>::setName(std::string name) {
+    this->name = name;
+    setupService();
+    return *this;
+};
+
+template<class T, class I>
+ServiceDependency<T,I>& ServiceDependency<T,I>::setFilter(std::string filter) {
+    this->filter = filter;
+    setupService();
+    return *this;
+};
+
+template<class T, class I>
+ServiceDependency<T,I>& ServiceDependency<T,I>::setVersion(std::string version) {
+    this->version = version;
+    setupService();
+    return *this;
+};
+
+//set callbacks
+template<class T, class I>
+ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(void (T::*set)(I* service)) {
+    this->setFp = set;
+    this->setupCallbacks();
+    return *this;
+}
+
+template<class T, class I>
+ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(void (T::*set)(I* service, Properties&& properties)) {
+    this->setFpWithProperties = set;
+    this->setupCallbacks();
+    return *this;
+}
+
+//add remove callbacks
+template<class T, class I>
+ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(
+        void (T::*add)(I* service),
+        void (T::*remove)(I* service)) {
+    this->addFp = add;
+    this->removeFp = remove;
+    this->setupCallbacks();
+    return *this;
+}
+
+template<class T, class I>
+ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks(
+        void (T::*add)(I* service, Properties&& properties),
+        void (T::*remove)(I* service, Properties&& properties)
+        ) {
+    this->addFpWithProperties = add;
+    this->removeFpWithProperties = remove;
+    this->setupCallbacks();
+    return *this;
+}
+
+template<class T, class I>
+ServiceDependency<T,I>& ServiceDependency<T,I>::setRequired(bool req) {
+    serviceDependency_setRequired(this->cServiceDependency(), req);
+    return *this;
+}
+
+template<class T, class I>
+ServiceDependency<T,I>& ServiceDependency<T,I>::setStrategy(DependencyUpdateStrategy strategy) {
+    dep_setStrategy(this->cServiceDependency(), strategy);
+    return *this;
+};
+
+template<class T, class I>
+int ServiceDependency<T,I>::invokeCallback(void(T::*fp)(I*), const void* service) {
+    T *cmp = this->componentInstance;
+    I *svc = (I *) service;
+    (cmp->*fp)(svc);
+    return 0;
+};
+
+template<class T, class I>
+int ServiceDependency<T,I>::invokeCallbackWithProperties(void(T::*fp)(I*, Properties&&), service_reference_pt  ref, const void* service) {
+    service_registration_pt reg {nullptr};
+    properties_pt props {nullptr};
+    T *cmp = this->componentInstance;
+    I *svc = (I *) service;
+    serviceReference_getServiceRegistration(ref, &reg);
+    serviceRegistration_getProperties(reg, &props);
+
+    Properties properties {};
+    const char* key {nullptr};
+    const char* value {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);
+        //std::cout << "got property " << key << "=" << value << "\n";
+        properties[key] = value;
+    }
+
+    (cmp->*fp)(svc, static_cast<Properties&&>(properties)); //explicit move of lvalue properties.
+    return 0;
+}
+
+template<class T, class I>
+void ServiceDependency<T,I>::setupCallbacks() {
+
+    int(*cset)(void*,const void*) {nullptr};
+    int(*cadd)(void*, const void*) {nullptr};
+    int(*cremove)(void*, const void*) {nullptr};
+
+
+    if (setFp != nullptr) {
+        cset = [](void* handle, const void*service) -> int {
+            auto dep = (ServiceDependency<T, I> *) handle;
+            return dep->invokeCallback(dep->setFp, service);
+        };
+    }
+    if (addFp != nullptr) {
+        cadd = [](void* handle, const void*service) -> int {
+            auto dep = (ServiceDependency<T, I> *) handle;
+            return dep->invokeCallback(dep->addFp, service);
+        };
+    }
+    if (removeFp != nullptr) {
+        cremove = [](void* handle, const void*service) -> int {
+            auto dep = (ServiceDependency<T, I> *) handle;
+            return dep->invokeCallback(dep->removeFp, service);
+        };
+    }
+
+    int(*csetWithRef)(void*, service_reference_pt, const void*) {nullptr};
+    int(*caddWithRef)(void*, service_reference_pt, const void*) {nullptr};
+    int(*cremoveWithRef)(void*, service_reference_pt, const void*) {nullptr};
+
+    if (setFpWithProperties != nullptr) {
+        csetWithRef = [](void* handle, service_reference_pt ref, const void* service) -> int {
+            auto dep = (ServiceDependency<T,I>*) handle;
+            return dep->invokeCallbackWithProperties(dep->setFpWithProperties, ref, service);
+        };
+    }
+    if (addFpWithProperties != nullptr) {
+        caddWithRef = [](void* handle, service_reference_pt ref, const void* service) -> int {
+            auto dep = (ServiceDependency<T,I>*) handle;
+            return dep->invokeCallbackWithProperties(dep->addFpWithProperties, ref, service);
+        };
+    }
+    if (removeFpWithProperties != nullptr) {
+        cremoveWithRef = [](void* handle, service_reference_pt ref, const void* service) -> int {
+            auto dep = (ServiceDependency<T,I>*) handle;
+            return dep->invokeCallbackWithProperties(dep->removeFpWithProperties, ref, service);
+        };
+    }
+
+    serviceDependency_setCallbackHandle(this->cServiceDependency(), this);
+    serviceDependency_setCallbacks(this->cServiceDependency(), cset, cadd, nullptr, cremove, nullptr);
+    serviceDependency_setCallbacksWithServiceReference(this->cServiceDependency(), csetWithRef, caddWithRef, nullptr, cremoveWithRef, nullptr);
+};

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager_cxx/include/celix/dm/types.h
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/include/celix/dm/types.h b/dependency_manager_cxx/include/celix/dm/types.h
new file mode 100644
index 0000000..a1ca728
--- /dev/null
+++ b/dependency_manager_cxx/include/celix/dm/types.h
@@ -0,0 +1,60 @@
+/**
+ * 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_TYPES_H
+#define CELIX_DM_TYPES_H
+
+#include <map>
+#include <string>
+#include <list>
+#include <tuple>
+#include <typeinfo>
+#include <memory>
+#include <cxxabi.h>
+#include <string.h>
+#include "celix/dm/Properties.h"
+
+namespace celix { namespace dm {
+    //forward declarations
+    class DependencyManager;
+
+
+    class BaseServiceDependency;
+
+    template<class T>
+    class CServiceDependency;
+
+    template<class T, class I>
+    class ServiceDependency;
+
+    template<typename T>
+    const std::string typeName() {
+        std::string result = std::string(typeid(T).name());
+        int status = 0;
+        char* demangled_name {abi::__cxa_demangle(result.c_str(), NULL, NULL, &status)};
+        if(status == 0) {
+            result = std::string(demangled_name);
+            free(demangled_name);
+        }
+        return result;
+    }
+
+}}
+
+#endif //CELIX_DM_TYPES_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager_cxx/src/Component.cc
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/src/Component.cc b/dependency_manager_cxx/src/Component.cc
new file mode 100644
index 0000000..cab3da5
--- /dev/null
+++ b/dependency_manager_cxx/src/Component.cc
@@ -0,0 +1,43 @@
+/**
+ * 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.
+ */
+
+#include "celix/dm/Component.h"
+#include "celix/dm/DependencyManager.h"
+
+#include <typeinfo>
+
+using namespace celix::dm;
+
+BaseComponent::BaseComponent(const bundle_context_pt context, std::string name) : context(context), name(name) {
+    cCmp = nullptr;
+    component_create(context, name.c_str(), &this->cCmp);
+    component_setImplementation(this->cCmp, this);
+}
+
+BaseComponent::~BaseComponent() {
+
+}
+
+const dm_component_pt BaseComponent::cComponent() const {
+    return this->cCmp;
+}
+
+const bundle_context_pt BaseComponent::bundleContext() const {
+    return this->context;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager_cxx/src/DependencyManager.cc
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/src/DependencyManager.cc b/dependency_manager_cxx/src/DependencyManager.cc
new file mode 100644
index 0000000..f3a2109
--- /dev/null
+++ b/dependency_manager_cxx/src/DependencyManager.cc
@@ -0,0 +1,57 @@
+/**
+ * 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.
+ */
+
+#include "celix/dm/DependencyManager.h"
+#include <typeinfo>
+
+using namespace celix::dm;
+
+DependencyManager::DependencyManager(bundle_context_pt context) : context(context), components() {
+    this->cDepMan = nullptr;
+    dependencyManager_create(context, &this->cDepMan);
+}
+
+DependencyManager::~DependencyManager() {
+    dependencyManager_destroy(this->cDepMan);
+    this->cDepMan = nullptr;
+}
+
+const bundle_context_pt DependencyManager::bundleContext() const {
+    return context;
+}
+
+const dm_dependency_manager_pt DependencyManager::cDependencyManager() const {
+    return cDepMan;
+}
+
+void DependencyManager::start() {
+    for(BaseComponent* cmp : addedComponents)  {
+        dependencyManager_add(cDepMan, cmp->cComponent());
+    }
+}
+
+void DependencyManager::stop() {
+    dependencyManager_removeAllComponents(cDepMan);
+    components.clear();
+    addedComponents.clear();
+    dependencies.clear();
+}
+
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/dependency_manager_cxx/src/dm_activator_base_cxx.cc
----------------------------------------------------------------------
diff --git a/dependency_manager_cxx/src/dm_activator_base_cxx.cc b/dependency_manager_cxx/src/dm_activator_base_cxx.cc
new file mode 100644
index 0000000..8cc8d85
--- /dev/null
+++ b/dependency_manager_cxx/src/dm_activator_base_cxx.cc
@@ -0,0 +1,115 @@
+/**
+ * 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.
+ */
+#include "celix/dm/DmActivator.h"
+#include "celix/dm/DependencyManager.h"
+
+extern "C" {
+#include <stdlib.h>
+#include "bundle_context.h"
+#include "celix_errno.h"
+#include "dm_dependency_manager.h"
+#include "bundle_activator.h"
+#include "dm_info.h"
+#include "dm_activator.h"
+
+
+struct dm_dependency_activator_base {
+    dm_dependency_activator_base(std::shared_ptr<celix::dm::DependencyManager> man, std::shared_ptr<celix::dm::DmActivator> act) : manager(man), activator(act) {}
+    bundle_context_pt context {nullptr};
+    service_registration_pt reg {nullptr};
+    dm_info_service_t info;
+
+    std::shared_ptr<celix::dm::DependencyManager> manager;
+    std::shared_ptr<celix::dm::DmActivator> activator;
+};
+
+typedef struct dm_dependency_activator_base *dependency_activator_base_pt;
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    auto man = std::shared_ptr<celix::dm::DependencyManager>{new celix::dm::DependencyManager(context)};
+    auto dmAct = std::shared_ptr<celix::dm::DmActivator> {DmActivator::create(*man)};
+    dependency_activator_base_pt act = new dm_dependency_activator_base(man, dmAct);
+
+    if (act != nullptr) {
+        act->context = context;
+        act->reg = nullptr;
+        act->info.handle = nullptr;
+        act->info.destroyInfo = nullptr;
+        act->info.getInfo = nullptr;
+    } else {
+        status = CELIX_ENOMEM;
+    }
+
+    if (status == CELIX_SUCCESS) {
+        *userData = act;
+    } else {
+        delete act;
+    }
+
+    return status;
+}
+
+celix_status_t bundleActivator_start(void *userData, bundle_context_pt context) {
+    celix_status_t status = CELIX_SUCCESS;
+    dependency_activator_base_pt act = (dependency_activator_base_pt) userData;
+
+    act->activator->init(*act->manager);
+    act->manager->start();
+
+    if (status == CELIX_SUCCESS) {
+        //Create the service
+        act->info.handle = act->manager->cDependencyManager();
+        act->info.getInfo = (celix_status_t (*)(void *, dm_dependency_manager_info_pt *)) dependencyManager_getInfo;
+        act->info.destroyInfo = (void (*)(void *, dm_dependency_manager_info_pt)) dependencyManager_destroyInfo;
+
+        status = bundleContext_registerService(context, (char *) DM_INFO_SERVICE_NAME, &act->info, NULL, &(act->reg));
+    }
+
+    return status;
+}
+
+celix_status_t bundleActivator_stop(void *userData, bundle_context_pt context __attribute__((unused))) {
+    celix_status_t status = CELIX_SUCCESS;
+    dependency_activator_base_pt act = (dependency_activator_base_pt) userData;
+
+    // Remove the service
+    status = serviceRegistration_unregister(act->reg);
+    dependencyManager_removeAllComponents(act->manager->cDependencyManager());
+
+    return status;
+}
+
+celix_status_t bundleActivator_destroy(void *userData, bundle_context_pt context __attribute__((unused))) {
+    celix_status_t status = CELIX_SUCCESS;
+    dependency_activator_base_pt act = (dependency_activator_base_pt) userData;
+
+    if (act == NULL) {
+        return CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    act->activator->deinit(*act->manager);
+    act->manager->stop();
+
+    delete act;
+    return status;
+}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/examples/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 81fe2e1..7de04ca 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -14,7 +14,7 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-celix_subproject(EXAMPLES "Option to enable building the Examples" "OFF" DEPS FRAMEWORK DEPENDENCY_MANAGER2 LAUNCHER SHELL_TUI LOG_SERVICE LOG_WRITER)
+celix_subproject(EXAMPLES "Option to enable building the Examples" ON DEPS FRAMEWORK LAUNCHER SHELL_TUI LOG_SERVICE LOG_WRITER)
 if (EXAMPLES)
     add_subdirectory(hello_world)
     add_subdirectory(hello_world_test)
@@ -27,6 +27,7 @@ if (EXAMPLES)
     add_subdirectory(echo_service)
     add_subdirectory(producer_consumer)
     add_subdirectory(dm_example)
+    add_subdirectory(dm_example_cxx)
     
     add_subdirectory(osgi-in-action/chapter04-correct-lookup)
     add_subdirectory(osgi-in-action/chapter04-correct-listener)

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/examples/dm_example/phase2a/private/src/phase2a_activator.c
----------------------------------------------------------------------
diff --git a/examples/dm_example/phase2a/private/src/phase2a_activator.c b/examples/dm_example/phase2a/private/src/phase2a_activator.c
index 9abf54c..6416c68 100644
--- a/examples/dm_example/phase2a/private/src/phase2a_activator.c
+++ b/examples/dm_example/phase2a/private/src/phase2a_activator.c
@@ -69,8 +69,8 @@ celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency
 		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);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/examples/dm_example/phase2b/private/src/phase2b_activator.c
----------------------------------------------------------------------
diff --git a/examples/dm_example/phase2b/private/src/phase2b_activator.c b/examples/dm_example/phase2b/private/src/phase2b_activator.c
index dd35f94..c7692d4 100644
--- a/examples/dm_example/phase2b/private/src/phase2b_activator.c
+++ b/examples/dm_example/phase2b/private/src/phase2b_activator.c
@@ -71,6 +71,7 @@ celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency
 		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);
 
 		dependencyManager_add(manager, cmp);

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/examples/dm_example/phase3/private/src/phase3_activator.c
----------------------------------------------------------------------
diff --git a/examples/dm_example/phase3/private/src/phase3_activator.c b/examples/dm_example/phase3/private/src/phase3_activator.c
index 8cd20d0..64b7a0b 100644
--- a/examples/dm_example/phase3/private/src/phase3_activator.c
+++ b/examples/dm_example/phase3/private/src/phase3_activator.c
@@ -58,7 +58,7 @@ celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency
 		dm_service_dependency_pt dep;
 		serviceDependency_create(&dep);
 		serviceDependency_setService(dep, PHASE2_NAME, NULL, NULL);
-		serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND);
+		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);

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/examples/dm_example_cxx/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/CMakeLists.txt b/examples/dm_example_cxx/CMakeLists.txt
new file mode 100644
index 0000000..7539366
--- /dev/null
+++ b/examples/dm_example_cxx/CMakeLists.txt
@@ -0,0 +1,52 @@
+# 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.
+if (BUILD_DEPENDENCY_MANAGER_CXX)
+    include_directories(
+            ${PROJECT_SOURCE_DIR}/dependency_manager/public/include
+            ${PROJECT_SOURCE_DIR}/dependency_manager_cxx/include
+            ${PROJECT_SOURCE_DIR}/utils/public/include
+            ${PROJECT_SOURCE_DIR}/shell/public/include
+            ${PROJECT_SOURCE_DIR}/log_service/public/include
+            api
+    )
+
+    add_subdirectory(phase1)
+    add_subdirectory(phase2a)
+    add_subdirectory(phase2b)
+    add_subdirectory(phase3)
+    add_subdirectory(phase3_locking)
+
+
+    add_deploy("dm_example_cxx"
+        COPY 
+        BUNDLES
+            shell
+            shell_tui
+            dm_shell
+            log_service
+            log_writer
+
+            phase1_cxx
+            phase2a_cxx
+            phase2b_cxx
+            phase3_cxx
+            phase3_locking_cxx
+        PROPERTIES
+            LOGHELPER_ENABLE_STDOUT_FALLBACK=true
+    )
+
+endif ()

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/examples/dm_example_cxx/api/IPhase1.h
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/api/IPhase1.h b/examples/dm_example_cxx/api/IPhase1.h
new file mode 100644
index 0000000..241f90d
--- /dev/null
+++ b/examples/dm_example_cxx/api/IPhase1.h
@@ -0,0 +1,30 @@
+/**
+ * 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_PHASE1_H
+#define CELIX_PHASE1_H
+
+#define IPHASE1_VERSION "1.0.0"
+
+class IPhase1 {
+public:
+    virtual int getData() = 0;
+};
+
+#endif //CELIX_PHASE1_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/examples/dm_example_cxx/api/IPhase2.h
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/api/IPhase2.h b/examples/dm_example_cxx/api/IPhase2.h
new file mode 100644
index 0000000..2640358
--- /dev/null
+++ b/examples/dm_example_cxx/api/IPhase2.h
@@ -0,0 +1,30 @@
+/**
+ * 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_PHASE2_H
+#define CELIX_PHASE2_H
+
+#define IPHASE2_VERSION "1.0.0"
+
+class IPhase2 {
+public:
+    virtual double getData() = 0;
+};
+
+#endif //CELIX_PHASE2_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/examples/dm_example_cxx/phase1/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/phase1/CMakeLists.txt b/examples/dm_example_cxx/phase1/CMakeLists.txt
new file mode 100644
index 0000000..9f125ef
--- /dev/null
+++ b/examples/dm_example_cxx/phase1/CMakeLists.txt
@@ -0,0 +1,40 @@
+# 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.
+
+include_directories(
+        include
+        ../api
+)
+
+add_bundle(phase1_cxx
+    SYMBOLIC_NAME phase1_cxx
+    VERSION 0.0.1
+    SOURCES
+        src/Phase1Activator.cc
+        src/Phase1Cmp.cc
+)
+
+IF(APPLE)
+    target_link_libraries(phase1_cxx celix_framework -Wl,-all_load dependency_manager_cxx_static)
+else()
+    if(ENABLE_ADDRESS_SANITIZER)
+        #With asan there can be undefined symbols
+        target_link_libraries(phase1_cxx -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+    else()
+        target_link_libraries(phase1_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework)
+    endif()
+endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/examples/dm_example_cxx/phase1/include/Phase1Activator.h
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/phase1/include/Phase1Activator.h b/examples/dm_example_cxx/phase1/include/Phase1Activator.h
new file mode 100644
index 0000000..f1157f6
--- /dev/null
+++ b/examples/dm_example_cxx/phase1/include/Phase1Activator.h
@@ -0,0 +1,36 @@
+/**
+ * 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_PHASE1ACTIVATOR_H
+#define CELIX_PHASE1ACTIVATOR_H
+
+#include "celix/dm/DmActivator.h"
+#include "command.h"
+
+using namespace celix::dm;
+
+class Phase1Activator : public DmActivator {
+    command_service_t cmd {};
+public:
+    Phase1Activator(DependencyManager& mng) : DmActivator(mng) {}
+    virtual void init(DependencyManager& manager);
+    virtual void deinit(DependencyManager& manager);
+};
+
+#endif //CELIX_PHASE1ACTIVATOR_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a9a75c51/examples/dm_example_cxx/phase1/include/Phase1Cmp.h
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/phase1/include/Phase1Cmp.h b/examples/dm_example_cxx/phase1/include/Phase1Cmp.h
new file mode 100644
index 0000000..f847413
--- /dev/null
+++ b/examples/dm_example_cxx/phase1/include/Phase1Cmp.h
@@ -0,0 +1,44 @@
+/**
+ * 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_PHASE1CMP_H
+#define CELIX_PHASE1CMP_H
+
+#include "IPhase1.h"
+#include <stdint.h>
+#include <stdio.h>
+
+#define IPHASE1_VERSION "1.0.0"
+
+class Phase1Cmp : public IPhase1 {
+    uint32_t counter;
+public:
+    Phase1Cmp() = default;
+    virtual ~Phase1Cmp() = default;
+
+    void init();
+    void start();
+    void stop();
+    void deinit();
+
+    virtual int getData(); //implements IPhase1
+    virtual int infoCmd(char* line, FILE *out, FILE* err);  //implements cmd service
+};
+
+#endif //CELIX_PHASE1CMP_H