celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [5/8] celix git commit: CELIX-413: Moves the example to an additional dir, so that examples can also be build outside the celix project
Date Wed, 31 Jan 2018 20:05:29 GMT
http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/mongoose/root/index.html
----------------------------------------------------------------------
diff --git a/examples/celix-examples/mongoose/root/index.html b/examples/celix-examples/mongoose/root/index.html
new file mode 100644
index 0000000..255758f
--- /dev/null
+++ b/examples/celix-examples/mongoose/root/index.html
@@ -0,0 +1,23 @@
+<!--
+ *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.
+-->
+<div align="center"><FONT 
+color="#ffffff" size="+1"><MARQUEE bgcolor="#000080" 
+direction="right" loop="20" width="75%"><STRONG>
+Serving content from within a bundle works!!1!11!!
+</STRONG></MARQUEE></FONT></DIV>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/service_hook_example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/service_hook_example/CMakeLists.txt b/examples/celix-examples/service_hook_example/CMakeLists.txt
new file mode 100644
index 0000000..9dbe7c0
--- /dev/null
+++ b/examples/celix-examples/service_hook_example/CMakeLists.txt
@@ -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.
+
+add_celix_bundle(hook_example
+    BUNDLE_SYMBOLICNAME "Hook_Example"
+    VERSION "1.0.0"
+    SOURCES
+        src/activator
+)
+
+add_celix_container(hook_service_example
+    BUNDLES
+        Celix::shell
+        Celix::shell_tui
+        hook_example
+)

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/service_hook_example/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/service_hook_example/src/activator.c b/examples/celix-examples/service_hook_example/src/activator.c
new file mode 100644
index 0000000..f2d2a15
--- /dev/null
+++ b/examples/celix-examples/service_hook_example/src/activator.c
@@ -0,0 +1,137 @@
+/**
+ *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.
+ */
+/*
+ * activator.c
+ *
+ *  \date       Aug 20, 2010
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+
+#include "bundle_activator.h"
+#include "service_tracker_customizer.h"
+#include "service_tracker.h"
+#include "bundle_context.h"
+#include "listener_hook_service.h"
+#include "service_registry.h"
+
+struct userData {
+    service_registration_pt hookReg;
+    service_tracker_pt trackerBefore;
+    service_tracker_pt trackerAfter;
+    listener_hook_service_pt hookService; 
+};
+
+
+celix_status_t tracker_added(void*hook, array_list_pt listeners) {
+    for(unsigned int i = 0; i < arrayList_size(listeners); i++) {
+        listener_hook_info_pt info = arrayList_get(listeners, i);
+        printf("Added tracker for service %s\n", info->filter);
+    }
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t tracker_removed(void*hook, array_list_pt listeners) {
+    for(unsigned int i = 0; i < arrayList_size(listeners); i++) {
+        listener_hook_info_pt info = arrayList_get(listeners, i);
+        printf("Removed tracker for service %s\n", info->filter);
+    }
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+    *userData = malloc(sizeof(struct userData));
+    if (*userData != NULL) {
+       
+	} else {
+		status = CELIX_START_ERROR;
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * handle, bundle_context_pt context) {
+	printf("Starting hook example bundle\n");
+    struct userData *userData = (struct userData*)handle;   
+    
+    userData->trackerBefore = 0;
+    serviceTracker_create(context, "MY_SERVICE_BEFORE_REGISTERING_HOOK", NULL, &userData->trackerBefore);
+    serviceTracker_open(userData->trackerBefore);
+    
+    listener_hook_service_pt hookService = calloc(1, sizeof(*hookService));
+    hookService->handle = userData;
+    hookService->added = tracker_added;
+    hookService->removed = tracker_removed;
+
+    userData->hookService = hookService;
+    userData->hookReg = NULL;
+
+    printf("Registering hook service\n");
+    bundleContext_registerService(context, OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, hookService, NULL, &userData->hookReg);
+
+    printf("Unregistering hook service\n");
+    serviceRegistration_unregister(userData->hookReg);
+
+    printf("Re-Registering hook service\n");
+    userData->hookReg = NULL;
+    bundleContext_registerService(context, OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, hookService, NULL, &userData->hookReg);
+
+    userData->trackerAfter = 0;
+    serviceTracker_create(context, "MY_SERVICE_AFTER_REGISTERING_HOOK", NULL, &userData->trackerAfter);
+    serviceTracker_open(userData->trackerAfter);
+  
+    sleep(1);
+    printf("Closing tracker\n");
+    serviceTracker_close(userData->trackerAfter);
+    printf("Reopening tracker\n");
+    serviceTracker_open(userData->trackerAfter);
+    
+    sleep(1);
+    printf("Closing tracker\n");
+    serviceTracker_close(userData->trackerAfter);
+    printf("Reopening tracker\n");
+    serviceTracker_open(userData->trackerAfter);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_stop(void * handle, bundle_context_pt context) {
+	printf("Stopping hook example bundle\n");
+    struct userData *userData = (struct userData*)handle;   
+
+    serviceTracker_close(userData->trackerAfter);
+    serviceTracker_close(userData->trackerBefore);
+    serviceTracker_destroy(userData->trackerAfter);
+    serviceTracker_destroy(userData->trackerBefore);
+
+    serviceRegistration_unregister(userData->hookReg);
+    free(userData->hookService);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_destroy(void * handle, bundle_context_pt context) {
+    free(handle);
+	return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/CMakeLists.txt b/examples/celix-examples/services_example_c/CMakeLists.txt
new file mode 100644
index 0000000..65760b7
--- /dev/null
+++ b/examples/celix-examples/services_example_c/CMakeLists.txt
@@ -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.
+if (BUILD_DEPENDENCY_MANAGER)
+
+    include_directories(
+            ${PROJECT_SOURCE_DIR}/dependency_manager/public/include
+            ${PROJECT_SOURCE_DIR}/utils/public/include
+            api
+    )
+
+    add_subdirectory(foo1)
+    add_subdirectory(foo2)
+    add_subdirectory(bar)
+
+    add_celix_container(services_example_c
+        GROUP services_example
+        COPY
+        BUNDLES
+            Celix::shell
+            Celix::shell_tui
+            dm_shell
+            bar
+            foo1
+            foo2
+        PROPERTIES
+            example=value
+    )
+
+endif ()

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_c/api/example.h
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/api/example.h b/examples/celix-examples/services_example_c/api/example.h
new file mode 100644
index 0000000..b0e0166
--- /dev/null
+++ b/examples/celix-examples/services_example_c/api/example.h
@@ -0,0 +1,34 @@
+/**
+ *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 EXAMPLE_H_
+#define EXAMPLE_H_
+
+#define EXAMPLE_NAME 			"org.example"
+#define EXAMPLE_VERSION 		"1.0.0"
+#define EXAMPLE_CONSUMER_RANGE   "[1.0.0,2.0.0)"
+
+
+struct example_struct {
+	void *handle;
+	int (*method)(void *handle, int arg1, double arg2, double *result);
+} ;
+
+typedef struct example_struct example_t;
+
+#endif /* EXAMPLE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_c/bar/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/bar/CMakeLists.txt b/examples/celix-examples/services_example_c/bar/CMakeLists.txt
new file mode 100644
index 0000000..7df3051
--- /dev/null
+++ b/examples/celix-examples/services_example_c/bar/CMakeLists.txt
@@ -0,0 +1,39 @@
+# 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(
+        private/include
+)
+
+add_celix_bundle(bar
+    SYMBOLIC_NAME bar
+    VERSION 1.0.0
+    SOURCES
+        private/src/bar_activator
+        private/src/bar.c
+)
+
+IF(APPLE)
+    target_link_libraries(bar PRIVATE Celix::framework  -Wl,-all_load dependency_manager_static)
+else()
+    if(ENABLE_ADDRESS_SANITIZER)
+        #With asan there can be undefined symbols
+        target_link_libraries(bar PRIVATE -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive Celix::framework )
+    else()
+        target_link_libraries(bar PRIVATE -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive Celix::framework )
+    endif()
+endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_c/bar/private/include/bar.h
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/bar/private/include/bar.h b/examples/celix-examples/services_example_c/bar/private/include/bar.h
new file mode 100644
index 0000000..5e1da8b
--- /dev/null
+++ b/examples/celix-examples/services_example_c/bar/private/include/bar.h
@@ -0,0 +1,32 @@
+/**
+ *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 BAR_H_
+#define BAR_H_
+
+#include "example.h"
+
+typedef struct bar_struct bar_t;
+
+bar_t* bar_create(void);
+void bar_destroy(bar_t *self);
+
+int bar_method(bar_t *self, int arg1, double arg2, double *out);
+
+#endif //BAR_H_

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_c/bar/private/src/bar.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/bar/private/src/bar.c b/examples/celix-examples/services_example_c/bar/private/src/bar.c
new file mode 100644
index 0000000..5099201
--- /dev/null
+++ b/examples/celix-examples/services_example_c/bar/private/src/bar.c
@@ -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.
+ */
+
+#include "bar.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <pthread.h>
+#include <assert.h>
+
+
+#define OK 0
+#define ERROR 1
+
+struct bar_struct {
+    double prefValue;
+};
+
+bar_t* bar_create(void) {
+    bar_t *self = calloc(1, sizeof(*self));
+    if (self != NULL) {
+        self->prefValue = 42;
+    } else {
+        //log error
+    }
+    return self;
+};
+
+void bar_destroy(bar_t *self) {
+    free(self);
+}
+
+int bar_method(bar_t *self, int arg1, double arg2, double *out) {
+    double update = (self->prefValue + arg1) * arg2;
+    self->prefValue = update;
+    *out = update;
+    return OK;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_c/bar/private/src/bar_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/bar/private/src/bar_activator.c b/examples/celix-examples/services_example_c/bar/private/src/bar_activator.c
new file mode 100644
index 0000000..0fa7889
--- /dev/null
+++ b/examples/celix-examples/services_example_c/bar/private/src/bar_activator.c
@@ -0,0 +1,70 @@
+/**
+ *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 "dm_activator.h"
+#include "bar.h"
+
+#include <stdlib.h>
+
+struct activator {
+	bar_t *bar;
+	example_t exampleService;
+};
+
+celix_status_t dm_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator *act = calloc(1, sizeof(*act));
+	if (act != NULL) {
+
+		act->bar = bar_create();
+		act->exampleService.handle = act->bar;
+		act->exampleService.method = (void*) bar_method;
+
+		if (act->bar != NULL) {
+            *userData = act;
+        } else {
+            free(act);
+        }
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t dm_init(void *userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
+    celix_status_t status = CELIX_SUCCESS;
+	struct activator *activator = userData;
+
+	dm_component_pt cmp = NULL;
+	component_create(context, "BAR", &cmp);
+	component_setImplementation(cmp, activator->bar);
+	component_addInterface(cmp, EXAMPLE_NAME, EXAMPLE_VERSION, &activator->exampleService, NULL);
+
+	dependencyManager_add(manager, cmp);
+    return status;
+}
+
+celix_status_t dm_destroy(void *userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator *activator = userData;
+	bar_destroy(activator->bar);
+	free(activator);
+	return status;
+};
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_c/foo1/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/foo1/CMakeLists.txt b/examples/celix-examples/services_example_c/foo1/CMakeLists.txt
new file mode 100644
index 0000000..d732c76
--- /dev/null
+++ b/examples/celix-examples/services_example_c/foo1/CMakeLists.txt
@@ -0,0 +1,39 @@
+# 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(
+        private/include
+)
+
+add_celix_bundle(foo1
+    SYMBOLIC_NAME foo1
+    VERSION 1.0.0
+    SOURCES
+        private/src/foo1_activator
+        private/src/foo1.c
+)
+
+IF(APPLE)
+    target_link_libraries(foo1 PRIVATE -Wl,-all_load dependency_manager_static)
+else()
+    if(ENABLE_ADDRESS_SANITIZER)
+        #With asan there can be undefined symbols
+        target_link_libraries(foo1 PRIVATE -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
+    else()
+        target_link_libraries(foo1 PRIVATE -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
+    endif()
+endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_c/foo1/private/include/foo1.h
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/foo1/private/include/foo1.h b/examples/celix-examples/services_example_c/foo1/private/include/foo1.h
new file mode 100644
index 0000000..f556b44
--- /dev/null
+++ b/examples/celix-examples/services_example_c/foo1/private/include/foo1.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 FOO1_H_
+#define FOO1_H_
+
+#include "example.h"
+
+typedef struct foo1_struct foo1_t;
+
+foo1_t* foo1_create(void);
+void foo1_destroy(foo1_t *self);
+
+int foo1_start(foo1_t *self);
+int foo1_stop(foo1_t *self);
+
+int foo1_setExample(foo1_t *self, const example_t *example);
+
+
+#endif //FOO1_H_

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_c/foo1/private/src/foo1.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/foo1/private/src/foo1.c b/examples/celix-examples/services_example_c/foo1/private/src/foo1.c
new file mode 100644
index 0000000..1f1f56f
--- /dev/null
+++ b/examples/celix-examples/services_example_c/foo1/private/src/foo1.c
@@ -0,0 +1,102 @@
+/**
+ *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 "foo1.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <pthread.h>
+#include <assert.h>
+
+
+#define OK 0
+#define ERROR 1
+
+static void* foo1_thread(void*);
+
+struct foo1_struct {
+    const example_t *example;
+    pthread_mutex_t mutex; //protecting example
+    pthread_t thread;
+    bool running;
+};
+
+foo1_t* foo1_create(void) {
+    foo1_t *self = calloc(1, sizeof(*self));
+    if (self != NULL) {
+        pthread_mutex_init(&self->mutex, NULL);
+        self->running = false;
+    } else {
+        //log error
+    }
+    return self;
+};
+
+void foo1_destroy(foo1_t *self) {
+    assert(!self->running);
+    pthread_mutex_destroy(&self->mutex);
+    free(self);
+}
+
+int foo1_start(foo1_t *self) {
+    printf("starting foo1\n");
+    self->running = true;
+    pthread_create(&self->thread, NULL, foo1_thread, self);
+    return OK;
+}
+
+int foo1_stop(foo1_t *self) {
+    printf("stopping foo1\n");
+    self->running = false;
+    pthread_kill(self->thread, SIGUSR1);
+    pthread_join(self->thread, NULL);
+    return OK;
+}
+
+int foo1_setExample(foo1_t *self, const example_t *example) {
+    printf("Setting example %p for foo1\n", example);
+    pthread_mutex_lock(&self->mutex);
+    self->example = example; //NOTE could be NULL if req is not mandatory
+    pthread_mutex_unlock(&self->mutex);
+    return OK;
+}
+
+static void* foo1_thread(void *userdata) {
+    foo1_t *self = userdata;
+    double result;
+    int rc;
+    while (self->running) {
+        pthread_mutex_lock(&self->mutex);
+        if (self->example != NULL) {
+            rc = self->example->method(self->example->handle, 1, 2.0, &result);
+            if (rc == 0) {
+                printf("Result is %f\n", result);
+            } else {
+                printf("Error invoking method for example\n");
+            }
+        }
+        pthread_mutex_unlock(&self->mutex);
+        usleep(30000000);
+    }
+    return NULL;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_c/foo1/private/src/foo1_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/foo1/private/src/foo1_activator.c b/examples/celix-examples/services_example_c/foo1/private/src/foo1_activator.c
new file mode 100644
index 0000000..f94888b
--- /dev/null
+++ b/examples/celix-examples/services_example_c/foo1/private/src/foo1_activator.c
@@ -0,0 +1,88 @@
+/**
+ *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 "dm_activator.h"
+#include "foo1.h"
+
+#include <stdlib.h>
+
+struct activator {
+	foo1_t *foo;
+};
+
+celix_status_t dm_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator *act = calloc(1, sizeof(*act));
+	if (act != NULL) {
+		act->foo = foo1_create();
+        if (act->foo != NULL) {
+            *userData = act;
+        } else {
+            free(act);
+        }
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t dm_init(void *userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
+    celix_status_t status = CELIX_SUCCESS;
+	struct activator *activator = userData;
+
+	dm_component_pt cmp = NULL;
+	component_create(context, "FOO1", &cmp);
+	component_setImplementation(cmp, activator->foo);
+
+	/*
+	With the component_setCallbacksSafe we register callbacks when a component is started / stopped using a component
+	 with type foo1_t*
+	*/
+    component_setCallbacksSafe(cmp, foo1_t*, NULL, foo1_start, foo1_stop, NULL);
+
+	dm_service_dependency_pt dep = NULL;
+	serviceDependency_create(&dep);
+	serviceDependency_setRequired(dep, true);
+	serviceDependency_setService(dep, EXAMPLE_NAME, EXAMPLE_CONSUMER_RANGE, NULL);
+	serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING);
+
+	/*
+	With the serviceDependency_setCallbacksSafe we register callbacks when a service
+	is added and about to be removed for the component type foo1_t* and service type example_t*.
+
+	We should protect the usage of the
+ 	service because after removal of the service the memory location of that service
+	could be freed
+	*/
+    serviceDependency_setCallbacksSafe(dep, foo1_t*, const example_t*, foo1_setExample, NULL, NULL, NULL, NULL);
+	component_addServiceDependency(cmp, dep);
+
+	dependencyManager_add(manager, cmp);
+
+    return status;
+}
+
+celix_status_t dm_destroy(void *userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator *activator = userData;
+	foo1_destroy(activator->foo);
+	free(activator);
+	return status;
+};
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_c/foo2/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/foo2/CMakeLists.txt b/examples/celix-examples/services_example_c/foo2/CMakeLists.txt
new file mode 100644
index 0000000..adb8f64
--- /dev/null
+++ b/examples/celix-examples/services_example_c/foo2/CMakeLists.txt
@@ -0,0 +1,39 @@
+# 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(
+        private/include
+)
+
+add_celix_bundle(foo2
+    SYMBOLIC_NAME foo2
+    VERSION 1.0.0
+    SOURCES
+        private/src/foo2_activator
+        private/src/foo2.c
+)
+
+IF(APPLE)
+    target_link_libraries(foo2 PRIVATE -Wl,-all_load dependency_manager_static)
+else()
+    if(ENABLE_ADDRESS_SANITIZER)
+        #With asan there can be undefined symbols
+        target_link_libraries(foo2 PRIVATE -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
+    else()
+        target_link_libraries(foo2 PRIVATE -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive)
+    endif()
+endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_c/foo2/private/include/foo2.h
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/foo2/private/include/foo2.h b/examples/celix-examples/services_example_c/foo2/private/include/foo2.h
new file mode 100644
index 0000000..9f09276
--- /dev/null
+++ b/examples/celix-examples/services_example_c/foo2/private/include/foo2.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 FOO2_H_
+#define FOO2_H_
+
+#include "example.h"
+
+typedef struct foo2_struct foo2_t;
+
+foo2_t* foo2_create(void);
+void foo2_destroy(foo2_t *self);
+
+int foo2_start(foo2_t *self);
+int foo2_stop(foo2_t *self);
+
+int foo2_addExample(foo2_t *self, const example_t *example);
+int foo2_removeExample(foo2_t *self, const example_t *example);
+
+#endif //FOO2_H_
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_c/foo2/private/src/foo2.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/foo2/private/src/foo2.c b/examples/celix-examples/services_example_c/foo2/private/src/foo2.c
new file mode 100644
index 0000000..b98e20b
--- /dev/null
+++ b/examples/celix-examples/services_example_c/foo2/private/src/foo2.c
@@ -0,0 +1,113 @@
+/**
+ *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 "foo2.h"
+
+#include "array_list.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <pthread.h>
+#include <assert.h>
+
+
+#define OK 0
+#define ERROR 1
+
+static void* foo2_thread(void*);
+
+struct foo2_struct {
+    array_list_pt examples;
+    pthread_t thread;
+    bool running;
+};
+
+foo2_t* foo2_create(void) {
+    foo2_t *self = calloc(1, sizeof(*self));
+    if (self != NULL) {
+        self->examples = NULL;
+        arrayList_create(&self->examples);
+        self->running = false;
+    } else {
+        //log error
+    }
+    return self;
+};
+
+void foo2_destroy(foo2_t *self) {
+    assert(!self->running);
+    arrayList_destroy(self->examples);
+    free(self);
+}
+
+int foo2_start(foo2_t *self) {
+    printf("starting foo2\n");
+    self->running = true;
+    pthread_create(&self->thread, NULL, foo2_thread, self);
+    return OK;
+}
+
+int foo2_stop(foo2_t *self) {
+    printf("stopping foo2\n");
+    self->running = false;
+    pthread_kill(self->thread, SIGUSR1);
+    pthread_join(self->thread, NULL);
+    return OK;
+}
+
+int foo2_addExample(foo2_t *self, const example_t *example) {
+    //NOTE foo2 is suspended -> thread is not running  -> safe to update
+    int status = OK;
+    printf("Adding example %p for foo2\n", example);
+    status = arrayList_add(self->examples, (void *)example);
+    return status;
+}
+
+int foo2_removeExample(foo2_t *self, const example_t *example) {
+    //NOTE foo2 is suspended -> thread is not running  -> safe to update
+    int status = OK;
+    printf("Removing example %p for foo2\n", example);
+    status = arrayList_removeElement(self->examples, (void*)example);
+    return status;
+}
+
+static void* foo2_thread(void *userdata) {
+    foo2_t *self = userdata;
+    double result;
+    int rc;
+    while (self->running) {
+        unsigned int size = arrayList_size(self->examples);
+        int i;
+        for (i = 0; i < size; i += 1) {
+            const example_t* example = arrayList_get(self->examples, i);
+            rc = example->method(example->handle, 1, 2.0, &result);
+            if (rc == 0) {
+                printf("Result is %f\n", result);
+            } else {
+                printf("Error invoking method for example\n");
+            }
+        }
+        usleep(15000000);
+    }
+    return NULL;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_c/foo2/private/src/foo2_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_c/foo2/private/src/foo2_activator.c b/examples/celix-examples/services_example_c/foo2/private/src/foo2_activator.c
new file mode 100644
index 0000000..5c047da
--- /dev/null
+++ b/examples/celix-examples/services_example_c/foo2/private/src/foo2_activator.c
@@ -0,0 +1,88 @@
+/**
+ *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 "dm_activator.h"
+#include "foo2.h"
+
+#include <stdlib.h>
+
+struct activator {
+	foo2_t *foo;
+};
+
+celix_status_t dm_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator *act = calloc(1, sizeof(*act));
+	if (act != NULL) {
+		act->foo = foo2_create();
+        if (act->foo != NULL) {
+            *userData = act;
+        } else {
+            free(act);
+        }
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t dm_init(void *userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
+    celix_status_t status = CELIX_SUCCESS;
+	struct activator *activator = userData;
+
+	dm_component_pt cmp = NULL;
+	component_create(context, "FOO2", &cmp);
+	component_setImplementation(cmp, activator->foo);
+
+	/*
+	With the component_setCallbacksSafe we register callbacks when a component is started / stopped using a component
+	 with type foo1_t*
+	*/
+    component_setCallbacksSafe(cmp, foo2_t*, NULL, foo2_start, foo2_stop, NULL);
+
+	dm_service_dependency_pt dep = NULL;
+	serviceDependency_create(&dep);
+	serviceDependency_setRequired(dep, false);
+	serviceDependency_setService(dep, EXAMPLE_NAME, EXAMPLE_CONSUMER_RANGE, NULL);
+	serviceDependency_setStrategy(dep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND);
+
+	/*
+	With the serviceDependency_setCallbacksSafe we register callbacks when a service
+	is added and about to be removed for the component type foo1_t* and service type example_t*.
+
+	We should protect the usage of the
+ 	service because after removal of the service the memory location of that service
+	could be freed
+	*/
+    serviceDependency_setCallbacksSafe(dep, foo2_t*, const example_t*, NULL, foo2_addExample, NULL, foo2_removeExample, NULL);
+	component_addServiceDependency(cmp, dep);
+
+	dependencyManager_add(manager, cmp);
+
+    return status;
+}
+
+celix_status_t dm_destroy(void *userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator *activator = userData;
+	foo2_destroy(activator->foo);
+	free(activator);
+	return status;
+};
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/CMakeLists.txt b/examples/celix-examples/services_example_cxx/CMakeLists.txt
new file mode 100644
index 0000000..ba13251
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/CMakeLists.txt
@@ -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.
+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
+            api
+    )
+
+    add_subdirectory(bar)
+    add_subdirectory(foo)
+    add_subdirectory(baz)
+
+    add_celix_container(services_example_cxx
+        GROUP services_example
+        COPY
+        BUNDLES
+            Celix::shell
+            Celix::shell_tui
+            dm_shell
+            bar_cxx
+            foo_cxx
+            baz_cxx
+        PROPERTIES
+            example=value
+    )
+
+endif ()

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/api/IAnotherExample.h
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/api/IAnotherExample.h b/examples/celix-examples/services_example_cxx/api/IAnotherExample.h
new file mode 100644
index 0000000..0cd6c22
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/api/IAnotherExample.h
@@ -0,0 +1,34 @@
+/**
+ * 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 IANOTHER_EXAMPLE_H
+#define IANOTHER_EXAMPLE_H
+
+#define IANOTHER_EXAMPLE_VERSION "1.0.0"
+#define IANOTHER_EXAMPLE_CONSUMER_RANGE "[1.0.0,2.0.0)"
+
+class IAnotherExample {
+protected:
+    IAnotherExample() = default;
+    virtual ~IAnotherExample() = default;
+public:
+    virtual double method(int arg1, double arg2) = 0;
+};
+
+#endif //IANOTHER_EXAMPLE_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/api/example.h
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/api/example.h b/examples/celix-examples/services_example_cxx/api/example.h
new file mode 100644
index 0000000..68ce0e3
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/api/example.h
@@ -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.
+ */
+
+#ifndef EXAMPLE_H_
+#define EXAMPLE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define EXAMPLE_NAME 			"org.example"
+#define EXAMPLE_VERSION 		"1.0.0"
+#define EXAMPLE_CONSUMER_RANGE   "[1.0.0,2.0.0)"
+
+
+struct example_struct {
+	void *handle;
+	int (*method)(void *handle, int arg1, double arg2, double *result);
+} ;
+
+typedef struct example_struct example_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* EXAMPLE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/bar/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/bar/CMakeLists.txt b/examples/celix-examples/services_example_cxx/bar/CMakeLists.txt
new file mode 100644
index 0000000..c660ce6
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/bar/CMakeLists.txt
@@ -0,0 +1,41 @@
+# 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(
+        private/include
+)
+
+add_celix_bundle(bar_cxx
+    SYMBOLIC_NAME Bar
+    VERSION 1.0.0
+    SOURCES
+        private/src/Bar.cc
+        private/src/BarActivator.cc
+)
+
+target_compile_options(bar_cxx PUBLIC -Wall -Wextra -Weffc++ -Werror)
+
+IF(APPLE)
+    target_link_libraries(bar_cxx PRIVATE -Wl,-all_load  dependency_manager_cxx_static)
+else()
+    if(ENABLE_ADDRESS_SANITIZER)
+        #With asan there can be undefined symbols
+        target_link_libraries(bar_cxx PRIVATE -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive)
+    else()
+        target_link_libraries(bar_cxx PRIVATE -Wl,--no-undefined -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive)
+    endif()
+endif()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/bar/private/include/Bar.h
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/bar/private/include/Bar.h b/examples/celix-examples/services_example_cxx/bar/private/include/Bar.h
new file mode 100644
index 0000000..799f8a9
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/bar/private/include/Bar.h
@@ -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.
+ */
+
+#ifndef BAR_H
+#define BAR_H
+
+#include "IAnotherExample.h"
+
+class Bar : public IAnotherExample {
+    const double seed = 42;
+public:
+    Bar() = default;
+    virtual ~Bar() = default;
+
+    void init();
+    void start();
+    void stop();
+    void deinit();
+
+    virtual double method(int arg1, double arg2) override; //implementation of IAnotherExample::method
+    int cMethod(int arg1, double arg2, double *out); //implementation of example_t->method;
+};
+
+#endif //BAR_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/bar/private/include/BarActivator.h
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/bar/private/include/BarActivator.h b/examples/celix-examples/services_example_cxx/bar/private/include/BarActivator.h
new file mode 100644
index 0000000..0c635a8
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/bar/private/include/BarActivator.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 BAR_ACTIVATOR_H
+#define BAR_ACTIVATOR_H
+
+#include "celix/dm/DmActivator.h"
+#include "example.h"
+
+using namespace celix::dm;
+
+class BarActivator : public DmActivator {
+private:
+    example_t cExample {nullptr, nullptr};
+public:
+    BarActivator(DependencyManager& mng) : DmActivator(mng) {}
+    virtual void init() override;
+};
+
+#endif //BAR_ACTIVATOR_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/bar/private/src/Bar.cc
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/bar/private/src/Bar.cc b/examples/celix-examples/services_example_cxx/bar/private/src/Bar.cc
new file mode 100644
index 0000000..7490005
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/bar/private/src/Bar.cc
@@ -0,0 +1,48 @@
+/**
+ * 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 "Bar.h"
+#include <iostream>
+
+void Bar::init() {
+    std::cout << "init Bar\n";
+}
+
+void Bar::start() {
+    std::cout << "start Bar\n";
+}
+
+void Bar::stop() {
+    std::cout << "stop Bar\n";
+}
+
+void Bar::deinit() {
+    std::cout << "deinit Bar\n";
+}
+
+double Bar::method(int arg1, double arg2) {
+    double update = (this->seed + arg1) * arg2;
+    return update;
+}
+
+int Bar::cMethod(int arg1, double arg2, double *out) {
+    double r = this->method(arg1, arg2);
+    *out = r;
+    return 0;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/bar/private/src/BarActivator.cc
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/bar/private/src/BarActivator.cc b/examples/celix-examples/services_example_cxx/bar/private/src/BarActivator.cc
new file mode 100644
index 0000000..e4b8bec
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/bar/private/src/BarActivator.cc
@@ -0,0 +1,48 @@
+/**
+ * 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 "Bar.h"
+#include "BarActivator.h"
+
+using namespace celix::dm;
+
+DmActivator* DmActivator::create(DependencyManager& mng) {
+    return new BarActivator(mng);
+}
+
+void BarActivator::init() {
+    auto bar = std::unique_ptr<Bar>{new Bar{}};
+
+    Properties props;
+    props["meta.info.key"] = "meta.info.value";
+
+    Properties cProps;
+    cProps["also.meta.info.key"] = "also.meta.info.value";
+
+    this->cExample.handle = bar.get();
+    this->cExample.method = [](void *handle, int arg1, double arg2, double *out) {
+        Bar* bar = static_cast<Bar*>(handle);
+        return bar->cMethod(arg1, arg2, out);
+    };
+
+    mng.createComponent(std::move(bar))  //using a pointer a instance. Also supported is lazy initialization (default constructor needed) or a rvalue reference (move)
+        .addInterface<IAnotherExample>(IANOTHER_EXAMPLE_VERSION, props)
+        .addCInterface(&this->cExample, EXAMPLE_NAME, EXAMPLE_VERSION, cProps)
+        .setCallbacks(&Bar::init, &Bar::start, &Bar::stop, &Bar::deinit);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/baz/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/baz/CMakeLists.txt b/examples/celix-examples/services_example_cxx/baz/CMakeLists.txt
new file mode 100644
index 0000000..ce5bfd0
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/baz/CMakeLists.txt
@@ -0,0 +1,41 @@
+# 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(
+        private/include
+)
+
+add_celix_bundle(baz_cxx
+    SYMBOLIC_NAME Baz
+    VERSION 1.0.0
+    SOURCES
+        private/src/Baz.cc
+        private/src/BazActivator.cc
+)
+
+target_compile_options(baz_cxx PUBLIC -Wall -Wextra -Weffc++ -Werror)
+
+IF(APPLE)
+    target_link_libraries(baz_cxx PRIVATE  -Wl,-all_load  dependency_manager_cxx_static)
+else()
+    if(ENABLE_ADDRESS_SANITIZER)
+        #With asan there can be undefined symbols
+        target_link_libraries(baz_cxx PRIVATE -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive)
+    else()
+        target_link_libraries(baz_cxx PRIVATE -Wl,--no-undefined -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive)
+    endif()
+endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/baz/private/include/Baz.h
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/baz/private/include/Baz.h b/examples/celix-examples/services_example_cxx/baz/private/include/Baz.h
new file mode 100644
index 0000000..d881627
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/baz/private/include/Baz.h
@@ -0,0 +1,54 @@
+/**
+ * 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 BAZ_H
+#define BAZ_H
+
+#include "example.h"
+#include "IAnotherExample.h"
+#include <thread>
+#include <list>
+#include <mutex>
+
+class Baz  {
+    std::list<IAnotherExample*> examples {};
+    std::mutex lock_for_examples {};
+
+    std::list<const example_t*> cExamples {};
+    std::mutex lock_for_cExamples {};
+
+    std::thread pollThread {};
+    bool running = false;
+public:
+    Baz() = default;
+    virtual ~Baz() = default;
+
+    void start();
+    void stop();
+
+    void addAnotherExample(IAnotherExample* e);
+    void removeAnotherExample(IAnotherExample* e);
+
+    void addExample(const example_t* e);
+    void removeExample(const example_t* e);
+
+    void poll();
+};
+
+#endif //BAZ_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/baz/private/include/BazActivator.h
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/baz/private/include/BazActivator.h b/examples/celix-examples/services_example_cxx/baz/private/include/BazActivator.h
new file mode 100644
index 0000000..fe24918
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/baz/private/include/BazActivator.h
@@ -0,0 +1,34 @@
+/**
+ * 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 BAZ_ACTIVATOR_H
+#define BAZ_ACTIVATOR_H
+
+#include "celix/dm/DmActivator.h"
+
+using namespace celix::dm;
+
+class BazActivator : public DmActivator {
+private:
+public:
+    BazActivator(DependencyManager& mng) : DmActivator(mng) {}
+    virtual void init() override;
+};
+
+#endif //BAZ_ACTIVATOR_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/baz/private/src/Baz.cc
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/baz/private/src/Baz.cc b/examples/celix-examples/services_example_cxx/baz/private/src/Baz.cc
new file mode 100644
index 0000000..bf258fb
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/baz/private/src/Baz.cc
@@ -0,0 +1,84 @@
+/**
+ * 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 "Baz.h"
+#include <iostream>
+
+void Baz::start() {
+    std::cout << "start Baz\n";
+    this->running = true;
+    pollThread = std::thread {&Baz::poll, this};
+}
+
+void Baz::stop() {
+    std::cout << "stop Baz\n";
+    this->running = false;
+    this->pollThread.join();
+}
+
+void Baz::addAnotherExample(IAnotherExample *e) {
+    std::lock_guard<std::mutex> lock(this->lock_for_examples);
+    this->examples.push_back(e);
+}
+
+void Baz::removeAnotherExample(IAnotherExample *e) {
+    std::lock_guard<std::mutex> lock(this->lock_for_examples);
+    this->examples.remove(e);
+}
+
+void Baz::addExample(const example_t *e) {
+    std::lock_guard<std::mutex> lock(this->lock_for_cExamples);
+    this->cExamples.push_back(e);
+}
+
+void Baz::removeExample(const example_t *e) {
+    std::lock_guard<std::mutex> lock(this->lock_for_cExamples);
+    this->cExamples.remove(e);
+}
+
+void Baz::poll() {
+    double r1 = 1.0;
+    double r2 = 1.0;
+    while (this->running) {
+        //c++ service required -> if component started always available
+
+        {
+            std::lock_guard<std::mutex> lock(this->lock_for_examples);
+            int index = 0;
+            for (IAnotherExample *e : this->examples) {
+                r1 = e->method(3, r1);
+                std::cout << "Result IAnotherExample " << index++ << " is " << r1 << "\n";
+            }
+        }
+
+
+        {
+            std::lock_guard<std::mutex> lock(this->lock_for_cExamples);
+            int index = 0;
+            for (const example_t *e : this->cExamples) {
+                double out;
+                e->method(e->handle, 4, r2, &out);
+                r2 = out;
+                std::cout << "Result example_t " << index++ << " is " << r2 << "\n";
+            }
+        }
+
+        std::this_thread::sleep_for(std::chrono::milliseconds(4000));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/baz/private/src/BazActivator.cc
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/baz/private/src/BazActivator.cc b/examples/celix-examples/services_example_cxx/baz/private/src/BazActivator.cc
new file mode 100644
index 0000000..3f17b5a
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/baz/private/src/BazActivator.cc
@@ -0,0 +1,45 @@
+/**
+ * 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 "Baz.h"
+#include "BazActivator.h"
+
+using namespace celix::dm;
+
+DmActivator* DmActivator::create(DependencyManager& mng) {
+    return new BazActivator(mng);
+}
+
+void BazActivator::init() {
+
+    Component<Baz>& cmp = mng.createComponent<Baz>()
+        .setCallbacks(nullptr, &Baz::start, &Baz::stop, nullptr);
+
+    cmp.createServiceDependency<IAnotherExample>()
+            .setRequired(true)
+            .setStrategy(DependencyUpdateStrategy::locking)
+            .setVersionRange(IANOTHER_EXAMPLE_CONSUMER_RANGE)
+            .setCallbacks(&Baz::addAnotherExample, &Baz::removeAnotherExample);
+
+    cmp.createCServiceDependency<example_t>(EXAMPLE_NAME)
+            .setRequired(false)
+            .setStrategy(DependencyUpdateStrategy::locking)
+            .setVersionRange(EXAMPLE_CONSUMER_RANGE)
+            .setCallbacks(&Baz::addExample, &Baz::removeExample);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/foo/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/foo/CMakeLists.txt b/examples/celix-examples/services_example_cxx/foo/CMakeLists.txt
new file mode 100644
index 0000000..ba2aa55
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/foo/CMakeLists.txt
@@ -0,0 +1,41 @@
+# 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(
+        private/include
+)
+
+add_celix_bundle(foo_cxx
+    SYMBOLIC_NAME Foo
+    VERSION 1.0.0
+    SOURCES
+        private/src/Foo.cc
+        private/src/FooActivator.cc
+)
+
+target_compile_options(foo_cxx PUBLIC -Wall -Wextra -Weffc++ -Werror)
+
+IF(APPLE)
+    target_link_libraries(foo_cxx PRIVATE -Wl,-all_load  dependency_manager_cxx_static)
+else()
+    if(ENABLE_ADDRESS_SANITIZER)
+        #With asan there can be undefined symbols
+        target_link_libraries(foo_cxx PRIVATE -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive)
+    else()
+        target_link_libraries(foo_cxx PRIVATE -Wl,--no-undefined -Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive)
+    endif()
+endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/foo/private/include/Foo.h
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/foo/private/include/Foo.h b/examples/celix-examples/services_example_cxx/foo/private/include/Foo.h
new file mode 100644
index 0000000..0035b77
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/foo/private/include/Foo.h
@@ -0,0 +1,48 @@
+/**
+ * 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 FOO_H
+#define FOO_H
+
+#include "example.h"
+#include "IAnotherExample.h"
+#include <thread>
+
+class Foo  {
+    IAnotherExample* example {nullptr};
+    const example_t* cExample {nullptr};
+    std::thread pollThread {};
+    bool running = false;
+public:
+    Foo() = default;
+    virtual ~Foo() = default;
+
+    Foo(const Foo&) = delete;
+    Foo& operator=(const Foo&) = delete;
+
+    void start();
+    void stop();
+
+    void setAnotherExample(IAnotherExample* e);
+    void setExample(const example_t* e);
+
+    void poll();
+};
+
+#endif //FOO_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/foo/private/include/FooActivator.h
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/foo/private/include/FooActivator.h b/examples/celix-examples/services_example_cxx/foo/private/include/FooActivator.h
new file mode 100644
index 0000000..2917cbd
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/foo/private/include/FooActivator.h
@@ -0,0 +1,34 @@
+/**
+ * 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 FOO_ACTIVATOR_H
+#define FOO_ACTIVATOR_H
+
+#include "celix/dm/DmActivator.h"
+
+using namespace celix::dm;
+
+class FooActivator : public DmActivator {
+private:
+public:
+    FooActivator(DependencyManager& mng) : DmActivator(mng) {}
+    virtual void init() override;
+};
+
+#endif //FOO_ACTIVATOR_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/foo/private/src/Foo.cc
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/foo/private/src/Foo.cc b/examples/celix-examples/services_example_cxx/foo/private/src/Foo.cc
new file mode 100644
index 0000000..241513c
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/foo/private/src/Foo.cc
@@ -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.
+ */
+
+#include "Foo.h"
+#include <iostream>
+
+void Foo::start() {
+    std::cout << "start Foo\n";
+    this->running = true;
+    pollThread = std::thread {&Foo::poll, this};
+}
+
+void Foo::stop() {
+    std::cout << "stop Foo\n";
+    this->running = false;
+    this->pollThread.join();
+}
+
+void Foo::setAnotherExample(IAnotherExample *e) {
+    this->example = e;
+}
+
+void Foo::setExample(const example_t *e) {
+    this->cExample = e;
+}
+
+void Foo::poll() {
+    double r1 = 1.0;
+    double r2 = 1.0;
+    while (this->running) {
+        //c++ service required -> if component started always available
+        r1 = this->example->method(3, r1);
+        std::cout << "Result IAnotherExample is " << r1 << "\n";
+
+        //c service is optional, can be nullptr
+        if (this->cExample != nullptr) {
+            double out;
+            this->cExample->method(this->cExample->handle, 4, r2, &out);
+            r2 = out;
+            std::cout << "Result example_t is " << r2 << "\n";
+        }
+        std::this_thread::sleep_for(std::chrono::milliseconds(5000));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/celix-examples/services_example_cxx/foo/private/src/FooActivator.cc
----------------------------------------------------------------------
diff --git a/examples/celix-examples/services_example_cxx/foo/private/src/FooActivator.cc b/examples/celix-examples/services_example_cxx/foo/private/src/FooActivator.cc
new file mode 100644
index 0000000..fba10ce
--- /dev/null
+++ b/examples/celix-examples/services_example_cxx/foo/private/src/FooActivator.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 "Foo.h"
+#include "FooActivator.h"
+
+using namespace celix::dm;
+
+DmActivator* DmActivator::create(DependencyManager& mng) {
+    return new FooActivator(mng);
+}
+
+void FooActivator::init() {
+
+    Component<Foo>& cmp = mng.createComponent<Foo>()
+        .setCallbacks(nullptr, &Foo::start, &Foo::stop, nullptr);
+
+    cmp.createServiceDependency<IAnotherExample>()
+            .setRequired(true)
+            .setVersionRange(IANOTHER_EXAMPLE_CONSUMER_RANGE)
+            .setCallbacks(&Foo::setAnotherExample);
+
+    cmp.createCServiceDependency<example_t>(EXAMPLE_NAME)
+            .setRequired(false)
+            .setVersionRange(EXAMPLE_CONSUMER_RANGE)
+            .setCallbacks(&Foo::setExample);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example/CMakeLists.txt b/examples/dm_example/CMakeLists.txt
deleted file mode 100644
index 9759702..0000000
--- a/examples/dm_example/CMakeLists.txt
+++ /dev/null
@@ -1,63 +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.
-if (TARGET Celix::dependency_manager_static AND TARGET Celix::dm_shell)
-
-    add_subdirectory(api)
-
-    add_subdirectory(phase1)
-    add_subdirectory(phase2a)
-    add_subdirectory(phase2b)
-    add_subdirectory(phase3)
-
-
-    add_celix_container(dm_example
-        COPY 
-        BUNDLES
-            Celix::shell
-            Celix::shell_tui
-            Celix::dm_shell
-            dm_example_phase1
-            dm_example_phase2a
-            dm_example_phase2b
-            dm_example_phase3
-        PROPERTIES
-            LOGHELPER_ENABLE_STDOUT_FALLBACK=true
-    )
-
-    add_celix_docker(dm_exmpl_base
-            NAME dmbase
-            IMAGE_NAME dmbase
-            GROUP examples
-            INSTRUCTIONS
-                "LABEL exmpl=value"
-    )
-    add_celix_docker(dm_exmpl
-        FROM dmbase
-        GROUP examples
-        BUNDLES
-            Celix::shell
-            Celix::shell_tui
-            Celix::dm_shell
-            dm_example_phase1
-            dm_example_phase2a
-            dm_example_phase2b
-            dm_example_phase3
-        PROPERTIES
-            LOGHELPER_ENABLE_STDOUT_FALLBACK=true
-    )
-
-endif ()

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/api/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example/api/CMakeLists.txt b/examples/dm_example/api/CMakeLists.txt
deleted file mode 100644
index edbb643..0000000
--- a/examples/dm_example/api/CMakeLists.txt
+++ /dev/null
@@ -1,19 +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.
-
-add_library(dm_example_api INTERFACE)
-target_include_directories(dm_example_api INTERFACE include)

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/api/include/phase1.h
----------------------------------------------------------------------
diff --git a/examples/dm_example/api/include/phase1.h b/examples/dm_example/api/include/phase1.h
deleted file mode 100644
index 04e9da7..0000000
--- a/examples/dm_example/api/include/phase1.h
+++ /dev/null
@@ -1,44 +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.
- */
-/*
- * publisher.h
- *
- *  \date       Aug 23, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef PHASE1_H_
-#define PHASE1_H_
-
-#define PHASE1_NAME         "PHASE1"
-#define PHASE1_VERSION      "1.2.2.0"
-#define PHASE1_RANGE_ALL    "[1.2.2.0,4.5.6.x)"
-#define PHASE1_RANGE_EXACT  "[1.2.2.0,1.2.2.0]"
-
-
-
-struct phase1_struct {
-	void *handle;
-	int (*getData)(void *handle, unsigned int *data);
-};
-
-typedef struct phase1_struct phase1_t;
-
-#endif /* PHASE1_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/api/include/phase2.h
----------------------------------------------------------------------
diff --git a/examples/dm_example/api/include/phase2.h b/examples/dm_example/api/include/phase2.h
deleted file mode 100644
index 2f4df86..0000000
--- a/examples/dm_example/api/include/phase2.h
+++ /dev/null
@@ -1,41 +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.
- */
-/*
- * publisher.h
- *
- *  \date       Aug 23, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-#ifndef PHASE2_H
-#define PHASE2_H
-
-#define PHASE2_NAME     "PHASE2"
-#define PHASE2_VERSION  "1.0.0.0"
-
-struct phase2_struct {
-	void *handle;
-	void (*getData)(void *handle, double *data);
-};
-
-typedef struct phase2_struct phase2_t;
-
-
-#endif /* PHASE2_H */

http://git-wip-us.apache.org/repos/asf/celix/blob/a8b8410f/examples/dm_example/phase1/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example/phase1/CMakeLists.txt b/examples/dm_example/phase1/CMakeLists.txt
deleted file mode 100644
index 09402ea..0000000
--- a/examples/dm_example/phase1/CMakeLists.txt
+++ /dev/null
@@ -1,38 +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.
-
-
-add_celix_bundle(dm_example_phase1
-    SYMBOLIC_NAME phase1
-    VERSION 0.0.1
-    SOURCES
-        src/phase1_activator
-        src/phase1_cmp.c
-)
-target_include_directories(dm_example_phase1 PRIVATE src)
-target_link_libraries(dm_example_phase1 PRIVATE dm_example_api)
-
-IF(APPLE)
-    target_link_libraries(dm_example_phase1 PRIVATE -Wl,-all_load Celix::dependency_manager_static)
-else()
-    if(ENABLE_ADDRESS_SANITIZER)
-        #With asan there can be undefined symbols
-        target_link_libraries(dm_example_phase1 PRIVATE -Wl,--whole-archive Celix::dependency_manager_static -Wl,--no-whole-archive)
-    else()
-        target_link_libraries(dm_example_phase1 PRIVATE -Wl,--no-undefined -Wl,--whole-archive Celix::dependency_manager_static -Wl,--no-whole-archive)
-    endif()
-endif()


Mime
View raw message