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 2017/11/20 20:33:32 UTC

[35/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/include/base_driver_device.h
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/include/base_driver_device.h b/device_access/example/base_driver/include/base_driver_device.h
new file mode 100644
index 0000000..78c4f46
--- /dev/null
+++ b/device_access/example/base_driver/include/base_driver_device.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.
+ */
+/*
+ * base_driver_device.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef BASE_DRIVER_DEVICE_H_
+#define BASE_DRIVER_DEVICE_H_
+
+#include "device.h"
+
+#define BASE_DRIVER_SERVICE_NAME "base_driver_device_service"
+#define BASE_DRIVER_DEVICE_CATEGORY "char"
+
+typedef struct base_driver_device *base_driver_device_pt;
+
+struct base_driver_device_service {
+	struct device_service deviceService; /*NOTE: base_driver_device_service is a device_service.*/
+	base_driver_device_pt baseDriverDevice;
+	celix_status_t (*getNextChar)(base_driver_device_pt baseDriverDevice, char *c);
+};
+
+typedef struct base_driver_device_service * base_driver_device_service_pt;
+
+#endif /* BASE_DRIVER_DEVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/private/include/base_driver_private.h
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/private/include/base_driver_private.h b/device_access/example/base_driver/private/include/base_driver_private.h
deleted file mode 100644
index 3ee5814..0000000
--- a/device_access/example/base_driver/private/include/base_driver_private.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.
- */
-/*
- * base_driver_private.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef BASE_DRIVER_PRIVATE_H_
-#define BASE_DRIVER_PRIVATE_H_
-
-#include "base_driver_device.h"
-
-celix_status_t baseDriver_create(base_driver_device_pt *service);
-celix_status_t baseDriver_createService(base_driver_device_pt device, base_driver_device_service_pt *service);
-
-celix_status_t baseDriver_noDriverFound(device_pt device);
-
-celix_status_t baseDriver_getNextChar(base_driver_device_pt service, char *c);
-
-celix_status_t baseDriver_destroy(base_driver_device_pt device);
-celix_status_t baseDriver_destroyService(base_driver_device_service_pt service);
-
-#endif /* BASE_DRIVER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/private/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/private/src/activator.c b/device_access/example/base_driver/private/src/activator.c
deleted file mode 100644
index a6b9d62..0000000
--- a/device_access/example/base_driver/private/src/activator.c
+++ /dev/null
@@ -1,140 +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.
- */
-/*
- * activator.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include <celix_errno.h>
-#include <bundle_activator.h>
-#include <bundle_context.h>
-#include <celixbool.h>
-#include <device.h>
-
-#include "base_driver_private.h"
-#include "base_driver_device.h"
-
-struct base_driver_bundle_instance {
-	bundle_context_pt context;
-	array_list_pt serviceRegistrations;
-};
-
-typedef struct base_driver_bundle_instance *base_driver_bundle_instance_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	printf("BASE_DRIVER: creating bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-		base_driver_bundle_instance_pt instance = calloc(1, sizeof(*instance));
-		if (instance != NULL) {
-			instance->context = context;
-			status = arrayList_create(&instance->serviceRegistrations);
-			if (status == CELIX_SUCCESS) {
-				(*userData) = instance;
-			}
-		} else {
-			status = CELIX_ENOMEM;
-		}
-	return status;
-}
-
-static celix_status_t bundleActivator_registerBaseDriverDevice(base_driver_bundle_instance_pt bi, char *serial) {
-	celix_status_t status = CELIX_SUCCESS;
-	base_driver_device_pt device = NULL;
-	base_driver_device_service_pt service = NULL;
-	status = baseDriver_create(&device);
-	if (status == CELIX_SUCCESS) {
-		status = baseDriver_createService(device, &service);
-		if (status == CELIX_SUCCESS) {
-			properties_pt props = properties_create();
-			properties_set(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY, BASE_DRIVER_DEVICE_CATEGORY);
-			properties_set(props, OSGI_DEVICEACCESS_DEVICE_SERIAL, serial);
-			service_registration_pt service_registration = NULL;
-			status = bundleContext_registerService(bi->context, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME, service, props, &service_registration);
-			if (status == CELIX_SUCCESS) {
-				arrayList_add(bi->serviceRegistrations, service_registration);
-			}
-			else{
-				properties_destroy(props);
-			}
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		printf("BASE_DRIVER: Successfully registered device service with serial %s.\n", serial);
-	} else {
-		char error[256];
-		printf("BASE_DRIVER: Unsuccessfully registered device service with serial %s. Got error: %s\n",
-				serial, celix_strerror(status, error, 256));
-		if(service != NULL){
-			baseDriver_destroyService(service);
-		}
-		if(device != NULL){
-			baseDriver_destroy(device);
-		}
-	}
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	printf("BASE_DRIVER: starting bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	base_driver_bundle_instance_pt bundleInstance = userData;
-	status = bundleActivator_registerBaseDriverDevice(bundleInstance, "0001");
-//	if (status == CELIX_SUCCESS) {
-//		status = bundleActivator_registerBaseDriverDevice(bundleInstance, "0002");
-//	}
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	printf("BASE_DRIVER: stopping bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	base_driver_bundle_instance_pt bundleInstance = userData;
-
-	array_list_iterator_pt iterator = arrayListIterator_create(bundleInstance->serviceRegistrations);
-	while (arrayListIterator_hasNext(iterator)) {
-		service_registration_pt reg = arrayListIterator_next(iterator);
-		printf("BASE_DRIVER: unregistering service\n");
-		celix_status_t unregStatus = serviceRegistration_unregister(reg);
-		if (unregStatus != CELIX_SUCCESS) {
-			char error[256];
-			status = CELIX_ILLEGAL_STATE;
-			fprintf(stderr, "Cannot unregister service. Got error %s\n", celix_strerror(unregStatus, error, 256));
-		} else {
-			printf("BASE_DRIVER: unregistered base device service\n");
-		}
-	}
-	arrayListIterator_destroy(iterator);
-
-	return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	printf("BASE_DRIVER: destroying bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	base_driver_bundle_instance_pt bundleInstance = userData;
-
-	arrayList_destroy(bundleInstance->serviceRegistrations);
-	return status;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/private/src/base_driver.c
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/private/src/base_driver.c b/device_access/example/base_driver/private/src/base_driver.c
deleted file mode 100644
index a48c7de..0000000
--- a/device_access/example/base_driver/private/src/base_driver.c
+++ /dev/null
@@ -1,111 +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.
- */
-/*
- * base_driver.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-#include <celix_errno.h>
-#include <bundle_activator.h>
-#include <bundle_context.h>
-#include <celixbool.h>
-#include <device.h>
-
-#include "base_driver_device.h"
-#include "base_driver_private.h"
-
-static const char * INPUT_STRING = "Lorem ipsum dolor sit amet consectetur adipiscing elit ";
-
-struct device {
-	/*NOTE: for this example we use a empty device structure*/
-};
-
-struct base_driver_device {
-	device_pt device;
-	char *input;
-	int inputLength;
-	int currentChar;
-};
-
-celix_status_t baseDriver_noDriverFound(device_pt device) {
-	printf("BASE_DRIVER: No driver found\n");
-	return CELIX_SUCCESS;
-}
-
-celix_status_t baseDriver_create(base_driver_device_pt *baseDriverDevice) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*baseDriverDevice) = calloc(1, sizeof(struct base_driver_device));
-	if (*baseDriverDevice != NULL) {
-		(*baseDriverDevice)->currentChar = 0;
-		(*baseDriverDevice)->input = (char *)INPUT_STRING;
-		(*baseDriverDevice)->inputLength=strlen(INPUT_STRING);
-		(*baseDriverDevice)->device = calloc(1, sizeof(*(*baseDriverDevice)->device));
-		if ((*baseDriverDevice)->device == NULL) {
-			status = CELIX_ENOMEM;
-		}
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t baseDriver_createService(base_driver_device_pt baseDriverDevice, base_driver_device_service_pt *service) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*service) = calloc(1, sizeof(struct base_driver_device_service));
-	if ((*service) != NULL) {
-		(*service)->deviceService.noDriverFound = baseDriver_noDriverFound;
-		(*service)->deviceService.device = baseDriverDevice->device;
-		(*service)->getNextChar=baseDriver_getNextChar;
-		(*service)->baseDriverDevice = baseDriverDevice;
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t baseDriver_getNextChar(base_driver_device_pt device, char *c) {
-	(*c) = device->input[device->currentChar];
-	device->currentChar+=1;
-	if (device->currentChar >= device->inputLength) {
-		device->currentChar = 0;
-	}
-	return CELIX_SUCCESS;
-}
-
-celix_status_t baseDriver_destroy(base_driver_device_pt device){
-	if(device != NULL){
-		if(device->device != NULL){
-			free(device->device);
-		}
-		free(device);
-	}
-	return CELIX_SUCCESS;
-}
-
-celix_status_t baseDriver_destroyService(base_driver_device_service_pt service){
-	if(service != NULL){
-		free(service);
-	}
-
-	return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/public/include/base_driver_device.h
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/public/include/base_driver_device.h b/device_access/example/base_driver/public/include/base_driver_device.h
deleted file mode 100644
index 78c4f46..0000000
--- a/device_access/example/base_driver/public/include/base_driver_device.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.
- */
-/*
- * base_driver_device.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef BASE_DRIVER_DEVICE_H_
-#define BASE_DRIVER_DEVICE_H_
-
-#include "device.h"
-
-#define BASE_DRIVER_SERVICE_NAME "base_driver_device_service"
-#define BASE_DRIVER_DEVICE_CATEGORY "char"
-
-typedef struct base_driver_device *base_driver_device_pt;
-
-struct base_driver_device_service {
-	struct device_service deviceService; /*NOTE: base_driver_device_service is a device_service.*/
-	base_driver_device_pt baseDriverDevice;
-	celix_status_t (*getNextChar)(base_driver_device_pt baseDriverDevice, char *c);
-};
-
-typedef struct base_driver_device_service * base_driver_device_service_pt;
-
-#endif /* BASE_DRIVER_DEVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/src/activator.c b/device_access/example/base_driver/src/activator.c
new file mode 100644
index 0000000..a6b9d62
--- /dev/null
+++ b/device_access/example/base_driver/src/activator.c
@@ -0,0 +1,140 @@
+/**
+ *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       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include <celix_errno.h>
+#include <bundle_activator.h>
+#include <bundle_context.h>
+#include <celixbool.h>
+#include <device.h>
+
+#include "base_driver_private.h"
+#include "base_driver_device.h"
+
+struct base_driver_bundle_instance {
+	bundle_context_pt context;
+	array_list_pt serviceRegistrations;
+};
+
+typedef struct base_driver_bundle_instance *base_driver_bundle_instance_pt;
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	printf("BASE_DRIVER: creating bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+		base_driver_bundle_instance_pt instance = calloc(1, sizeof(*instance));
+		if (instance != NULL) {
+			instance->context = context;
+			status = arrayList_create(&instance->serviceRegistrations);
+			if (status == CELIX_SUCCESS) {
+				(*userData) = instance;
+			}
+		} else {
+			status = CELIX_ENOMEM;
+		}
+	return status;
+}
+
+static celix_status_t bundleActivator_registerBaseDriverDevice(base_driver_bundle_instance_pt bi, char *serial) {
+	celix_status_t status = CELIX_SUCCESS;
+	base_driver_device_pt device = NULL;
+	base_driver_device_service_pt service = NULL;
+	status = baseDriver_create(&device);
+	if (status == CELIX_SUCCESS) {
+		status = baseDriver_createService(device, &service);
+		if (status == CELIX_SUCCESS) {
+			properties_pt props = properties_create();
+			properties_set(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY, BASE_DRIVER_DEVICE_CATEGORY);
+			properties_set(props, OSGI_DEVICEACCESS_DEVICE_SERIAL, serial);
+			service_registration_pt service_registration = NULL;
+			status = bundleContext_registerService(bi->context, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME, service, props, &service_registration);
+			if (status == CELIX_SUCCESS) {
+				arrayList_add(bi->serviceRegistrations, service_registration);
+			}
+			else{
+				properties_destroy(props);
+			}
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		printf("BASE_DRIVER: Successfully registered device service with serial %s.\n", serial);
+	} else {
+		char error[256];
+		printf("BASE_DRIVER: Unsuccessfully registered device service with serial %s. Got error: %s\n",
+				serial, celix_strerror(status, error, 256));
+		if(service != NULL){
+			baseDriver_destroyService(service);
+		}
+		if(device != NULL){
+			baseDriver_destroy(device);
+		}
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	printf("BASE_DRIVER: starting bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	base_driver_bundle_instance_pt bundleInstance = userData;
+	status = bundleActivator_registerBaseDriverDevice(bundleInstance, "0001");
+//	if (status == CELIX_SUCCESS) {
+//		status = bundleActivator_registerBaseDriverDevice(bundleInstance, "0002");
+//	}
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	printf("BASE_DRIVER: stopping bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	base_driver_bundle_instance_pt bundleInstance = userData;
+
+	array_list_iterator_pt iterator = arrayListIterator_create(bundleInstance->serviceRegistrations);
+	while (arrayListIterator_hasNext(iterator)) {
+		service_registration_pt reg = arrayListIterator_next(iterator);
+		printf("BASE_DRIVER: unregistering service\n");
+		celix_status_t unregStatus = serviceRegistration_unregister(reg);
+		if (unregStatus != CELIX_SUCCESS) {
+			char error[256];
+			status = CELIX_ILLEGAL_STATE;
+			fprintf(stderr, "Cannot unregister service. Got error %s\n", celix_strerror(unregStatus, error, 256));
+		} else {
+			printf("BASE_DRIVER: unregistered base device service\n");
+		}
+	}
+	arrayListIterator_destroy(iterator);
+
+	return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	printf("BASE_DRIVER: destroying bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	base_driver_bundle_instance_pt bundleInstance = userData;
+
+	arrayList_destroy(bundleInstance->serviceRegistrations);
+	return status;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/src/base_driver.c
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/src/base_driver.c b/device_access/example/base_driver/src/base_driver.c
new file mode 100644
index 0000000..a48c7de
--- /dev/null
+++ b/device_access/example/base_driver/src/base_driver.c
@@ -0,0 +1,111 @@
+/**
+ *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.
+ */
+/*
+ * base_driver.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <celix_errno.h>
+#include <bundle_activator.h>
+#include <bundle_context.h>
+#include <celixbool.h>
+#include <device.h>
+
+#include "base_driver_device.h"
+#include "base_driver_private.h"
+
+static const char * INPUT_STRING = "Lorem ipsum dolor sit amet consectetur adipiscing elit ";
+
+struct device {
+	/*NOTE: for this example we use a empty device structure*/
+};
+
+struct base_driver_device {
+	device_pt device;
+	char *input;
+	int inputLength;
+	int currentChar;
+};
+
+celix_status_t baseDriver_noDriverFound(device_pt device) {
+	printf("BASE_DRIVER: No driver found\n");
+	return CELIX_SUCCESS;
+}
+
+celix_status_t baseDriver_create(base_driver_device_pt *baseDriverDevice) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*baseDriverDevice) = calloc(1, sizeof(struct base_driver_device));
+	if (*baseDriverDevice != NULL) {
+		(*baseDriverDevice)->currentChar = 0;
+		(*baseDriverDevice)->input = (char *)INPUT_STRING;
+		(*baseDriverDevice)->inputLength=strlen(INPUT_STRING);
+		(*baseDriverDevice)->device = calloc(1, sizeof(*(*baseDriverDevice)->device));
+		if ((*baseDriverDevice)->device == NULL) {
+			status = CELIX_ENOMEM;
+		}
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t baseDriver_createService(base_driver_device_pt baseDriverDevice, base_driver_device_service_pt *service) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*service) = calloc(1, sizeof(struct base_driver_device_service));
+	if ((*service) != NULL) {
+		(*service)->deviceService.noDriverFound = baseDriver_noDriverFound;
+		(*service)->deviceService.device = baseDriverDevice->device;
+		(*service)->getNextChar=baseDriver_getNextChar;
+		(*service)->baseDriverDevice = baseDriverDevice;
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t baseDriver_getNextChar(base_driver_device_pt device, char *c) {
+	(*c) = device->input[device->currentChar];
+	device->currentChar+=1;
+	if (device->currentChar >= device->inputLength) {
+		device->currentChar = 0;
+	}
+	return CELIX_SUCCESS;
+}
+
+celix_status_t baseDriver_destroy(base_driver_device_pt device){
+	if(device != NULL){
+		if(device->device != NULL){
+			free(device->device);
+		}
+		free(device);
+	}
+	return CELIX_SUCCESS;
+}
+
+celix_status_t baseDriver_destroyService(base_driver_device_service_pt service){
+	if(service != NULL){
+		free(service);
+	}
+
+	return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/base_driver/src/base_driver_private.h
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/src/base_driver_private.h b/device_access/example/base_driver/src/base_driver_private.h
new file mode 100644
index 0000000..3ee5814
--- /dev/null
+++ b/device_access/example/base_driver/src/base_driver_private.h
@@ -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.
+ */
+/*
+ * base_driver_private.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef BASE_DRIVER_PRIVATE_H_
+#define BASE_DRIVER_PRIVATE_H_
+
+#include "base_driver_device.h"
+
+celix_status_t baseDriver_create(base_driver_device_pt *service);
+celix_status_t baseDriver_createService(base_driver_device_pt device, base_driver_device_service_pt *service);
+
+celix_status_t baseDriver_noDriverFound(device_pt device);
+
+celix_status_t baseDriver_getNextChar(base_driver_device_pt service, char *c);
+
+celix_status_t baseDriver_destroy(base_driver_device_pt device);
+celix_status_t baseDriver_destroyService(base_driver_device_service_pt service);
+
+#endif /* BASE_DRIVER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/consuming_driver/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/device_access/example/consuming_driver/CMakeLists.txt b/device_access/example/consuming_driver/CMakeLists.txt
index 061d350..a9a9281 100644
--- a/device_access/example/consuming_driver/CMakeLists.txt
+++ b/device_access/example/consuming_driver/CMakeLists.txt
@@ -20,14 +20,10 @@ add_bundle(word_consumingdriver
  	VERSION "0.0.1"
  	NAME "Apache Celix Device Access Word Consuming Driver Example"
 	SOURCES
-		private/src/activator
-		private/src/consuming_driver
+		src/activator
+		src/consuming_driver
 )
 
-include_directories(${PROJECT_SOURCE_DIR}/device_access/device_access/public/include)
-include_directories(${PROJECT_SOURCE_DIR}/device_access/example/refining_driver/public/include)
-include_directories(private/include)
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+target_include_directories(word_consumingdriver PRIVATE src)
 
-target_link_libraries(word_consumingdriver celix_utils celix_framework)
+target_link_libraries(word_consumingdriver PRIVATE Celix::device_access_api base_driver char_refiningdriver)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/consuming_driver/private/include/consuming_driver_private.h
----------------------------------------------------------------------
diff --git a/device_access/example/consuming_driver/private/include/consuming_driver_private.h b/device_access/example/consuming_driver/private/include/consuming_driver_private.h
deleted file mode 100644
index 261bb52..0000000
--- a/device_access/example/consuming_driver/private/include/consuming_driver_private.h
+++ /dev/null
@@ -1,43 +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.
- */
-/*
- * consuming_driver_private.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef CONSUMING_DRIVER_PRIVATE_H_
-#define CONSUMING_DRIVER_PRIVATE_H_
-
-#include <celix_errno.h>
-#include <service_reference.h>
-#include <driver.h>
-
-#define CONSUMING_DRIVER_ID "CONSUMING_DRIVER"
-
-typedef struct consuming_driver *consuming_driver_pt;
-
-celix_status_t consumingDriver_create(bundle_context_pt context, consuming_driver_pt *driver);
-celix_status_t consumingDriver_createService(consuming_driver_pt driver, driver_service_pt *service);
-
-celix_status_t consumingDriver_attach(void *driver, service_reference_pt reference, char **result);
-celix_status_t consumingDriver_match(void *driver, service_reference_pt reference, int *value);
-
-#endif /* CONSUMING_DRIVER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/consuming_driver/private/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/example/consuming_driver/private/src/activator.c b/device_access/example/consuming_driver/private/src/activator.c
deleted file mode 100644
index 2004657..0000000
--- a/device_access/example/consuming_driver/private/src/activator.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * activator.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include <celix_errno.h>
-#include <bundle_activator.h>
-#include <bundle_context.h>
-#include <celixbool.h>
-#include <device.h>
-
-#include "consuming_driver_private.h"
-
-struct consuming_driver_bundle_instance {
-	bundle_context_pt context;
-	service_registration_pt registration;
-};
-
-typedef struct consuming_driver_bundle_instance *consuming_driver_bundle_instance_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	printf("CONSUMING_DRIVER: creating bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	consuming_driver_bundle_instance_pt instance = calloc(1, sizeof(*instance));
-	if (instance != NULL) {
-		instance->context = context;
-		instance->registration = NULL;
-		(*userData) = instance;
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	printf("CONSUMING_DRIVER: starting bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	consuming_driver_bundle_instance_pt bi = userData;
-
-	consuming_driver_pt driver = NULL;
-	status = consumingDriver_create(context, &driver);
-	if (status == CELIX_SUCCESS) {
-		driver_service_pt service = NULL;
-		status = consumingDriver_createService(driver, &service);
-		if (status == CELIX_SUCCESS) {
-			properties_pt props = properties_create();
-			properties_set(props, "DRIVER_ID", CONSUMING_DRIVER_ID);
-			status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME, service, props, &bi->registration);
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		printf("CONSUMING_DRIVER: registered driver service.\n");
-	} else {
-		char error[256];
-		printf("CONSUMING_DRIVER: Could not register driver service. Get error %s\n", celix_strerror(status, error, 256));
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	printf("CONSUMING_DRIVER: stopping bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	consuming_driver_bundle_instance_pt bi = userData;
-
-	if (bi->registration != NULL) {
-		serviceRegistration_unregister(bi->registration);
-		printf("CONSUMING_DRIVER: unregistered driver service\n");
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	printf("CONSUMING_DRIVER: destroying bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	return status;
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/consuming_driver/private/src/consuming_driver.c
----------------------------------------------------------------------
diff --git a/device_access/example/consuming_driver/private/src/consuming_driver.c b/device_access/example/consuming_driver/private/src/consuming_driver.c
deleted file mode 100644
index 9106dbd..0000000
--- a/device_access/example/consuming_driver/private/src/consuming_driver.c
+++ /dev/null
@@ -1,125 +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.
- */
-/*
- * consuming_driver.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include <device.h>
-#include <service_tracker.h>
-#include <service_reference.h>
-
-#include "celixbool.h"
-#include "consuming_driver_private.h"
-#include "refining_driver_device.h"
-
-
-struct consuming_driver {
-	bundle_context_pt context;
-	array_list_pt references;
-};
-
-celix_status_t consumingDriver_destroy(consuming_driver_pt driver) {
-	printf("CONSUMING_DRIVER: cleanup\n");
-	if (driver->references != NULL) {
-		array_list_iterator_pt iterator = arrayListIterator_create(driver->references);
-		while (arrayListIterator_hasNext(iterator)) {
-			service_reference_pt reference = arrayListIterator_next(iterator);
-			bool result;
-			bundleContext_ungetService(driver->context, reference, &result);
-		}
-		arrayListIterator_destroy(iterator);
-
-		arrayList_destroy(driver->references);
-		driver->references=NULL;
-	}
-
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t consumingDriver_create(bundle_context_pt context, consuming_driver_pt *driver) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*driver) = calloc(1, sizeof(**driver));
-	if ((*driver) != NULL) {
-		(*driver)->context=context;
-		(*driver)->references=NULL;
-
-		status = arrayList_create(&(*driver)->references);
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t consumingDriver_createService(consuming_driver_pt driver, driver_service_pt *service) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*service) = calloc(1, sizeof(**service));
-	if ((*service) != NULL) {
-		(*service)->driver = driver;
-		(*service)->attach = consumingDriver_attach;
-		(*service)->match = consumingDriver_match;
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t consumingDriver_attach(void * driverHandler, service_reference_pt reference, char **result) {
-	printf("CONSUMING_DRIVER: attached called\n");
-	celix_status_t status = CELIX_SUCCESS;
-	consuming_driver_pt driver = driverHandler;
-	(*result) = NULL;
-	refining_driver_device_service_pt device_service = NULL;
-
-	status = bundleContext_getService(driver->context, reference, (void **)&device_service);
-	if (status == CELIX_SUCCESS) {
-		arrayList_add(driver->references, reference);
-		//consume the device
-		for (int i=0; i<15; i++) {
-			char *str = NULL;
-			device_service->getNextWord(device_service->refiningDriverDevice, &str);
-			printf("CONSUMING_DEVICE: Word Device result is %s\n", str);
-		}
-	}
-	return status;
-}
-
-celix_status_t consumingDriver_match(void *driverHandler, service_reference_pt reference, int *value) {
-	printf("CONSUMING_DRIVER: match called\n");
-	int match=0;
-	celix_status_t status = CELIX_SUCCESS;
-
-    const char* category = NULL;
-    status = serviceReference_getProperty(reference, OSGI_DEVICEACCESS_DEVICE_CATEGORY, &category);
-    if (status == CELIX_SUCCESS) {
-        if (strcmp(category, REFINING_DRIVER_DEVICE_CATEGORY) == 0) {
-            match = 10;
-        }
-    }
-
-	(*value) = match;
-	return status;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/consuming_driver/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/example/consuming_driver/src/activator.c b/device_access/example/consuming_driver/src/activator.c
new file mode 100644
index 0000000..2004657
--- /dev/null
+++ b/device_access/example/consuming_driver/src/activator.c
@@ -0,0 +1,104 @@
+/**
+ *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       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include <celix_errno.h>
+#include <bundle_activator.h>
+#include <bundle_context.h>
+#include <celixbool.h>
+#include <device.h>
+
+#include "consuming_driver_private.h"
+
+struct consuming_driver_bundle_instance {
+	bundle_context_pt context;
+	service_registration_pt registration;
+};
+
+typedef struct consuming_driver_bundle_instance *consuming_driver_bundle_instance_pt;
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	printf("CONSUMING_DRIVER: creating bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	consuming_driver_bundle_instance_pt instance = calloc(1, sizeof(*instance));
+	if (instance != NULL) {
+		instance->context = context;
+		instance->registration = NULL;
+		(*userData) = instance;
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	printf("CONSUMING_DRIVER: starting bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	consuming_driver_bundle_instance_pt bi = userData;
+
+	consuming_driver_pt driver = NULL;
+	status = consumingDriver_create(context, &driver);
+	if (status == CELIX_SUCCESS) {
+		driver_service_pt service = NULL;
+		status = consumingDriver_createService(driver, &service);
+		if (status == CELIX_SUCCESS) {
+			properties_pt props = properties_create();
+			properties_set(props, "DRIVER_ID", CONSUMING_DRIVER_ID);
+			status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME, service, props, &bi->registration);
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		printf("CONSUMING_DRIVER: registered driver service.\n");
+	} else {
+		char error[256];
+		printf("CONSUMING_DRIVER: Could not register driver service. Get error %s\n", celix_strerror(status, error, 256));
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	printf("CONSUMING_DRIVER: stopping bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	consuming_driver_bundle_instance_pt bi = userData;
+
+	if (bi->registration != NULL) {
+		serviceRegistration_unregister(bi->registration);
+		printf("CONSUMING_DRIVER: unregistered driver service\n");
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	printf("CONSUMING_DRIVER: destroying bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
+}
+
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/consuming_driver/src/consuming_driver.c
----------------------------------------------------------------------
diff --git a/device_access/example/consuming_driver/src/consuming_driver.c b/device_access/example/consuming_driver/src/consuming_driver.c
new file mode 100644
index 0000000..9106dbd
--- /dev/null
+++ b/device_access/example/consuming_driver/src/consuming_driver.c
@@ -0,0 +1,125 @@
+/**
+ *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.
+ */
+/*
+ * consuming_driver.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include <device.h>
+#include <service_tracker.h>
+#include <service_reference.h>
+
+#include "celixbool.h"
+#include "consuming_driver_private.h"
+#include "refining_driver_device.h"
+
+
+struct consuming_driver {
+	bundle_context_pt context;
+	array_list_pt references;
+};
+
+celix_status_t consumingDriver_destroy(consuming_driver_pt driver) {
+	printf("CONSUMING_DRIVER: cleanup\n");
+	if (driver->references != NULL) {
+		array_list_iterator_pt iterator = arrayListIterator_create(driver->references);
+		while (arrayListIterator_hasNext(iterator)) {
+			service_reference_pt reference = arrayListIterator_next(iterator);
+			bool result;
+			bundleContext_ungetService(driver->context, reference, &result);
+		}
+		arrayListIterator_destroy(iterator);
+
+		arrayList_destroy(driver->references);
+		driver->references=NULL;
+	}
+
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t consumingDriver_create(bundle_context_pt context, consuming_driver_pt *driver) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*driver) = calloc(1, sizeof(**driver));
+	if ((*driver) != NULL) {
+		(*driver)->context=context;
+		(*driver)->references=NULL;
+
+		status = arrayList_create(&(*driver)->references);
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t consumingDriver_createService(consuming_driver_pt driver, driver_service_pt *service) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*service) = calloc(1, sizeof(**service));
+	if ((*service) != NULL) {
+		(*service)->driver = driver;
+		(*service)->attach = consumingDriver_attach;
+		(*service)->match = consumingDriver_match;
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t consumingDriver_attach(void * driverHandler, service_reference_pt reference, char **result) {
+	printf("CONSUMING_DRIVER: attached called\n");
+	celix_status_t status = CELIX_SUCCESS;
+	consuming_driver_pt driver = driverHandler;
+	(*result) = NULL;
+	refining_driver_device_service_pt device_service = NULL;
+
+	status = bundleContext_getService(driver->context, reference, (void **)&device_service);
+	if (status == CELIX_SUCCESS) {
+		arrayList_add(driver->references, reference);
+		//consume the device
+		for (int i=0; i<15; i++) {
+			char *str = NULL;
+			device_service->getNextWord(device_service->refiningDriverDevice, &str);
+			printf("CONSUMING_DEVICE: Word Device result is %s\n", str);
+		}
+	}
+	return status;
+}
+
+celix_status_t consumingDriver_match(void *driverHandler, service_reference_pt reference, int *value) {
+	printf("CONSUMING_DRIVER: match called\n");
+	int match=0;
+	celix_status_t status = CELIX_SUCCESS;
+
+    const char* category = NULL;
+    status = serviceReference_getProperty(reference, OSGI_DEVICEACCESS_DEVICE_CATEGORY, &category);
+    if (status == CELIX_SUCCESS) {
+        if (strcmp(category, REFINING_DRIVER_DEVICE_CATEGORY) == 0) {
+            match = 10;
+        }
+    }
+
+	(*value) = match;
+	return status;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/consuming_driver/src/consuming_driver_private.h
----------------------------------------------------------------------
diff --git a/device_access/example/consuming_driver/src/consuming_driver_private.h b/device_access/example/consuming_driver/src/consuming_driver_private.h
new file mode 100644
index 0000000..261bb52
--- /dev/null
+++ b/device_access/example/consuming_driver/src/consuming_driver_private.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.
+ */
+/*
+ * consuming_driver_private.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef CONSUMING_DRIVER_PRIVATE_H_
+#define CONSUMING_DRIVER_PRIVATE_H_
+
+#include <celix_errno.h>
+#include <service_reference.h>
+#include <driver.h>
+
+#define CONSUMING_DRIVER_ID "CONSUMING_DRIVER"
+
+typedef struct consuming_driver *consuming_driver_pt;
+
+celix_status_t consumingDriver_create(bundle_context_pt context, consuming_driver_pt *driver);
+celix_status_t consumingDriver_createService(consuming_driver_pt driver, driver_service_pt *service);
+
+celix_status_t consumingDriver_attach(void *driver, service_reference_pt reference, char **result);
+celix_status_t consumingDriver_match(void *driver, service_reference_pt reference, int *value);
+
+#endif /* CONSUMING_DRIVER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/CMakeLists.txt b/device_access/example/refining_driver/CMakeLists.txt
index d16584f..c339b73 100644
--- a/device_access/example/refining_driver/CMakeLists.txt
+++ b/device_access/example/refining_driver/CMakeLists.txt
@@ -20,15 +20,10 @@ add_bundle(char_refiningdriver
  	NAME "Apache Celix Device Access Char Refining Driver Example"
  	VERSION "0.0.1"
 	SOURCES
-		private/src/activator
-		private/src/refining_driver
+		src/activator
+		src/refining_driver
 )
 
-include_directories(${PROJECT_SOURCE_DIR}/device_access/device_access/public/include)
-include_directories(${PROJECT_SOURCE_DIR}/device_access/example/base_driver/public/include)
-include_directories(private/include)
-include_directories(public/include)
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-
-target_link_libraries(char_refiningdriver celix_utils celix_framework)
+target_include_directories(char_refiningdriver PRIVATE src)
+target_include_directories(char_refiningdriver PUBLIC include)
+target_link_libraries(char_refiningdriver PRIVATE Celix::device_access_api base_driver)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/include/refining_driver_device.h
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/include/refining_driver_device.h b/device_access/example/refining_driver/include/refining_driver_device.h
new file mode 100644
index 0000000..728725e
--- /dev/null
+++ b/device_access/example/refining_driver/include/refining_driver_device.h
@@ -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.
+ */
+/*
+ * refining_driver_device.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef REFINING_DRIVER_DEVICE_H_
+#define REFINING_DRIVER_DEVICE_H_
+
+#include "device.h"
+
+#define REFINING_DRIVER_SERVICE_NAME "refining_driver_device_service"
+#define REFINING_DRIVER_DEVICE_CATEGORY "word"
+#define REFINING_DRIVER_DEVICE_SERVIC_NAME "refining_driver_device"
+
+typedef struct refining_driver_device *refining_driver_device_pt;
+
+struct refining_driver_device_service {
+	struct device_service deviceService; /*NOTE: base_driver_device_service is a device_service.*/
+	refining_driver_device_pt refiningDriverDevice;
+	celix_status_t (*getNextWord)(refining_driver_device_pt refiningDriverDevice, char **c);
+};
+
+typedef struct refining_driver_device_service * refining_driver_device_service_pt;
+
+#endif /* REFINING_DRIVER_DEVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/private/include/refining_driver_private.h
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/private/include/refining_driver_private.h b/device_access/example/refining_driver/private/include/refining_driver_private.h
deleted file mode 100644
index 37f15a5..0000000
--- a/device_access/example/refining_driver/private/include/refining_driver_private.h
+++ /dev/null
@@ -1,58 +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.
- */
-/*
- * refining_driver_private.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef REFINING_DRIVER_PRIVATE_H_
-#define REFINING_DRIVER_PRIVATE_H_
-
-#include <celix_errno.h>
-#include <service_reference.h>
-#include <driver.h>
-
-#include "refining_driver_device.h"
-#include "base_driver_device.h"
-
-#define REFINING_DRIVER_ID "REFINING_DRIVER"
-
-typedef struct refining_driver *refining_driver_pt;
-
-celix_status_t refiningDriver_create(bundle_context_pt context, refining_driver_pt *driver);
-celix_status_t refiningDriver_destroy(refining_driver_pt driver);
-
-celix_status_t refiningDriver_createService(refining_driver_pt driver, driver_service_pt *service);
-
-celix_status_t refiningDriver_createDevice(refining_driver_pt driver, service_reference_pt reference, base_driver_device_service_pt baseDevice, refining_driver_device_pt *device);
-celix_status_t refiningDriver_destroyDevice(refining_driver_device_pt device);
-
-
-celix_status_t refiningDriver_attach(void *driver, service_reference_pt reference, char **result);
-celix_status_t refiningDriver_match(void *driver, service_reference_pt reference, int *value);
-
-
-celix_status_t refiningDriverDevice_noDriverFound(device_pt device);
-celix_status_t refiningDriverDevice_createService(refining_driver_device_pt, refining_driver_device_service_pt *service);
-celix_status_t refiningDriverDevice_destroyService(refining_driver_device_service_pt service);
-celix_status_t refiningDriverDevice_getNextWord(refining_driver_device_pt refiningDriverDevice, char **word);
-
-#endif /* REFINING_DRIVER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/private/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/private/src/activator.c b/device_access/example/refining_driver/private/src/activator.c
deleted file mode 100644
index 233b150..0000000
--- a/device_access/example/refining_driver/private/src/activator.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * activator.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include <celix_errno.h>
-#include <bundle_activator.h>
-#include <bundle_context.h>
-#include <celixbool.h>
-#include <device.h>
-
-#include "refining_driver_private.h"
-
-struct refining_driver_bundle_instance {
-	bundle_context_pt context;
-	service_registration_pt registration;
-};
-
-typedef struct refining_driver_bundle_instance *refining_driver_bundle_instance_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	printf("REFINING_DRIVER: creating bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	refining_driver_bundle_instance_pt instance = calloc(1, sizeof(*instance));
-	if (instance != NULL) {
-		instance->context = context;
-		instance->registration = NULL;
-		(*userData) = instance;
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	printf("REFINING_DRIVER: starting bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	refining_driver_bundle_instance_pt bi = userData;
-
-	refining_driver_pt driver = NULL;
-	status = refiningDriver_create(context, &driver);
-	if (status == CELIX_SUCCESS) {
-		driver_service_pt service = NULL;
-		status = refiningDriver_createService(driver, &service);
-		if (status == CELIX_SUCCESS) {
-			properties_pt props = properties_create();
-			properties_set(props, "DRIVER_ID", REFINING_DRIVER_ID);
-			status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME, service, props, &bi->registration);
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		printf("REFINING_DRIVER: registered driver service.\n");
-	} else {
-		char error[256];
-		printf("REFINING_DRIVER: Could not register driver service. Get error %s\n", celix_strerror(status, error, 256));
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	printf("REFINING_DRIVER: stopping bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	refining_driver_bundle_instance_pt bi = userData;
-
-	if (bi->registration != NULL) {
-		serviceRegistration_unregister(bi->registration);
-		printf("REFINING_DRIVER: unregistered driver service\n");
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	printf("REFINING_DRIVER: destroying bundle\n");
-	celix_status_t status = CELIX_SUCCESS;
-	return status;
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/private/src/refining_driver.c
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/private/src/refining_driver.c b/device_access/example/refining_driver/private/src/refining_driver.c
deleted file mode 100644
index 404bc42..0000000
--- a/device_access/example/refining_driver/private/src/refining_driver.c
+++ /dev/null
@@ -1,281 +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.
- */
-/*
- * refining_driver.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include <device.h>
-#include <bundle_context.h>
-#include <service_event.h>
-
-#include "refining_driver_private.h"
-#include "base_driver_device.h"
-
-static const int MAX_BUFF_SIZE = 1024;
-
-struct refining_driver {
-	device_pt device;
-	bundle_context_pt context;
-	int deviceCount;
-	array_list_pt devices;
-};
-
-struct device {
-	/*NOTE: for this example we use a empty device structure*/
-};
-
-struct refining_driver_device {
-	device_pt device;
-	base_driver_device_service_pt baseDriverDeviceService;
-	refining_driver_pt driver;
-	service_reference_pt baseServiceReference;
-	service_registration_pt deviceRegistration;
-	service_listener_pt listener;
-};
-
-celix_status_t refiningDriver_destroy(refining_driver_pt driver) {
-	if (driver != NULL) {
-		if (driver->devices != NULL) {
-			arrayList_destroy(driver->devices);
-			driver->devices=NULL;
-		}
-	}
-	return CELIX_SUCCESS;
-}
-
-celix_status_t refiningDriver_create(bundle_context_pt context, refining_driver_pt *driver) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*driver) = calloc(1, sizeof(**driver));
-	if ((*driver) != NULL) {
-		(*driver)->context=context;
-		(*driver)->deviceCount=0;
-		(*driver)->device = calloc(1, sizeof(*(*driver)->device));
-		(*driver)->devices=NULL;
-		status = arrayList_create(&(*driver)->devices);
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t refiningDriver_createService(refining_driver_pt driver, driver_service_pt *service) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*service) = calloc(1, sizeof(**service));
-	if ((*service) != NULL) {
-		(*service)->driver = driver;
-		(*service)->attach = refiningDriver_attach;
-		(*service)->match = refiningDriver_match;
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-static celix_status_t refiningDriver_stopDevice(refining_driver_device_pt device) {
-	printf("REFINING_DRIVER: stopping device, parent device is unregistered\n");
-	celix_status_t status =  CELIX_SUCCESS;
-
-	if (device->deviceRegistration != NULL) {
-		status = serviceRegistration_unregister(device->deviceRegistration);
-		if (status == CELIX_SUCCESS) {
-			printf("unregistered refining device\n");
-		}
-	}
-
-	arrayList_removeElement(device->driver->devices, device);
-	return status;
-}
-
-
-static celix_status_t refiningDriver_serviceChanged(service_listener_pt listener, service_event_pt event) {
-	celix_status_t status =  CELIX_SUCCESS;
-	refining_driver_device_pt device = listener->handle;
-	if (event->type == OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING) {
-		bool equal = false;
-		status = serviceReference_equals(device->baseServiceReference, event->reference, &equal);
-		if (status == CELIX_SUCCESS && equal) {
-			refiningDriver_stopDevice(device);
-		}
-	}
-	return status;
-}
-
-celix_status_t refiningDriver_destroyDevice(refining_driver_device_pt device) {
-	return CELIX_SUCCESS;
-}
-
-celix_status_t refining_driver_cleanup_device(refining_driver_device_pt handler) {
-	celix_status_t status = CELIX_SUCCESS;;
-	refining_driver_device_pt device = handler;
-	if (device != NULL) {
-		if (device->listener != NULL) {
-			bundleContext_removeServiceListener(device->driver->context, device->listener);
-		}
-	}
-	return status;
-}
-
-celix_status_t refiningDriver_createDevice(refining_driver_pt driver, service_reference_pt reference, base_driver_device_service_pt baseService, refining_driver_device_pt *device) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	(*device) = calloc(1, sizeof(**device));
-	if ((*device) != NULL) {
-		(*device)->driver=driver;
-		(*device)->baseDriverDeviceService=baseService;
-		(*device)->baseServiceReference=reference;
-		(*device)->deviceRegistration=NULL;
-		(*device)->listener=NULL;
-
-		service_listener_pt listener = calloc(1, sizeof(*listener));
-		listener->handle=(void *)(*device);
-		listener->serviceChanged=(celix_status_t (*)(void * listener, service_event_pt event))refiningDriver_serviceChanged;
-		bundleContext_addServiceListener(driver->context, listener, NULL);
-		(*device)->listener=listener;
-
-		arrayList_add(driver->devices, (*device));
-	} else {
-		status = CELIX_ENOMEM;
-	}
-
-	return status;
-}
-
-
-static celix_status_t refiningDriver_registerDevice(refining_driver_pt driver, refining_driver_device_pt device, char *serial) {
-	celix_status_t status = CELIX_SUCCESS;
-	refining_driver_device_service_pt service = NULL;
-	status = refiningDriverDevice_createService(device, &service);
-	properties_pt props = properties_create();
-
-	if (status == CELIX_SUCCESS) {
-		properties_set(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY, REFINING_DRIVER_DEVICE_CATEGORY);
-		properties_set(props, OSGI_DEVICEACCESS_DEVICE_SERIAL, serial);
-		status = bundleContext_registerService(driver->context, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME, service, props, &device->deviceRegistration);
-	}
-
-	if (status == CELIX_SUCCESS) {
-		printf("REFINING_DRIVER: registered refining device with serial %s\n", serial);
-	}
-	else{
-		properties_destroy(props);
-		refiningDriverDevice_destroyService(service);
-	}
-	return status;
-}
-
-celix_status_t refiningDriver_attach(void * driverHandler, service_reference_pt reference, char **result) {
-	printf("REFINING_DRIVER: attached called\n");
-	celix_status_t status = CELIX_SUCCESS;
-	refining_driver_pt driver = driverHandler;
-	(*result) = NULL;
-	base_driver_device_service_pt device_service = NULL;
-	status = bundleContext_getService(driver->context, reference, (void **)&device_service);
-	if (status == CELIX_SUCCESS) {
-		refining_driver_device_pt refiningDevice = NULL;
-		status = refiningDriver_createDevice(driver, reference, device_service, &refiningDevice);
-		if (status == CELIX_SUCCESS) {
-			driver->deviceCount+=1;
-			char serial[5];
-			sprintf(serial, "%4i", driver->deviceCount);
-			status = refiningDriver_registerDevice(driver, refiningDevice, serial);
-		}
-	}
-	return status;
-}
-
-celix_status_t refiningDriver_match(void *driverHandler, service_reference_pt reference, int *value) {
-	printf("REFINING_DRIVER: match called\n");
-	int match = 0;
-	celix_status_t status = CELIX_SUCCESS;
-
-    const char* category = NULL;
-    status = serviceReference_getProperty(reference, OSGI_DEVICEACCESS_DEVICE_CATEGORY, &category);
-    if (status == CELIX_SUCCESS) {
-        if (strcmp(category, BASE_DRIVER_DEVICE_CATEGORY) == 0) {
-            match = 10;
-        }
-    }
-
-	(*value) = match;
-	return status;
-}
-
-celix_status_t refiningDriverDevice_createService(refining_driver_device_pt device, refining_driver_device_service_pt *service) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*service) = calloc(1, sizeof(**service));
-	if ((*service) != NULL) {
-		(*service)->deviceService.device=calloc(1, sizeof(*(*service)->deviceService.device));
-		if ((*service)->deviceService.device != NULL) {
-			(*service)->deviceService.noDriverFound=refiningDriverDevice_noDriverFound;
-			(*service)->refiningDriverDevice=device;
-			(*service)->getNextWord=refiningDriverDevice_getNextWord;
-		} else {
-			status = CELIX_ENOMEM;
-		}
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t refiningDriverDevice_destroyService(refining_driver_device_service_pt service){
-	if(service != NULL){
-		if(service->deviceService.device != NULL){
-			free(service->deviceService.device);
-		}
-		free(service);
-	}
-	return CELIX_SUCCESS;
-}
-
-celix_status_t refiningDriverDevice_getNextWord(refining_driver_device_pt refiningDriverDevice, char **word) {
-	celix_status_t status = CELIX_SUCCESS;
-	base_driver_device_pt baseDevice = refiningDriverDevice->baseDriverDeviceService->baseDriverDevice;
-	char buff[MAX_BUFF_SIZE];
-	int i=0;
-	status = refiningDriverDevice->baseDriverDeviceService->getNextChar(baseDevice, &buff[i]);
-	while (buff[i] != ' ' && i < (MAX_BUFF_SIZE-1) && status == CELIX_SUCCESS) {
-		i+=1;
-		status = refiningDriverDevice->baseDriverDeviceService->getNextChar(baseDevice, &buff[i]);
-	}
-	if (status == CELIX_SUCCESS) {
-		buff[i] = '\0';
-		char *copy = calloc(1, (i+1));
-		if (copy != NULL) {
-			strcpy(copy, buff);
-			(*word)=copy;
-		} else {
-			status = CELIX_ENOMEM;
-		}
-	}
-
-	return status;
-}
-
-celix_status_t refiningDriverDevice_noDriverFound(device_pt device) {
-	printf("REFINING_DRIVER: no driver found");
-	return CELIX_SUCCESS;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/public/include/refining_driver_device.h
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/public/include/refining_driver_device.h b/device_access/example/refining_driver/public/include/refining_driver_device.h
deleted file mode 100644
index 728725e..0000000
--- a/device_access/example/refining_driver/public/include/refining_driver_device.h
+++ /dev/null
@@ -1,45 +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.
- */
-/*
- * refining_driver_device.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef REFINING_DRIVER_DEVICE_H_
-#define REFINING_DRIVER_DEVICE_H_
-
-#include "device.h"
-
-#define REFINING_DRIVER_SERVICE_NAME "refining_driver_device_service"
-#define REFINING_DRIVER_DEVICE_CATEGORY "word"
-#define REFINING_DRIVER_DEVICE_SERVIC_NAME "refining_driver_device"
-
-typedef struct refining_driver_device *refining_driver_device_pt;
-
-struct refining_driver_device_service {
-	struct device_service deviceService; /*NOTE: base_driver_device_service is a device_service.*/
-	refining_driver_device_pt refiningDriverDevice;
-	celix_status_t (*getNextWord)(refining_driver_device_pt refiningDriverDevice, char **c);
-};
-
-typedef struct refining_driver_device_service * refining_driver_device_service_pt;
-
-#endif /* REFINING_DRIVER_DEVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/src/activator.c b/device_access/example/refining_driver/src/activator.c
new file mode 100644
index 0000000..233b150
--- /dev/null
+++ b/device_access/example/refining_driver/src/activator.c
@@ -0,0 +1,104 @@
+/**
+ *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       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+#include <celix_errno.h>
+#include <bundle_activator.h>
+#include <bundle_context.h>
+#include <celixbool.h>
+#include <device.h>
+
+#include "refining_driver_private.h"
+
+struct refining_driver_bundle_instance {
+	bundle_context_pt context;
+	service_registration_pt registration;
+};
+
+typedef struct refining_driver_bundle_instance *refining_driver_bundle_instance_pt;
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	printf("REFINING_DRIVER: creating bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	refining_driver_bundle_instance_pt instance = calloc(1, sizeof(*instance));
+	if (instance != NULL) {
+		instance->context = context;
+		instance->registration = NULL;
+		(*userData) = instance;
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	printf("REFINING_DRIVER: starting bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	refining_driver_bundle_instance_pt bi = userData;
+
+	refining_driver_pt driver = NULL;
+	status = refiningDriver_create(context, &driver);
+	if (status == CELIX_SUCCESS) {
+		driver_service_pt service = NULL;
+		status = refiningDriver_createService(driver, &service);
+		if (status == CELIX_SUCCESS) {
+			properties_pt props = properties_create();
+			properties_set(props, "DRIVER_ID", REFINING_DRIVER_ID);
+			status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME, service, props, &bi->registration);
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		printf("REFINING_DRIVER: registered driver service.\n");
+	} else {
+		char error[256];
+		printf("REFINING_DRIVER: Could not register driver service. Get error %s\n", celix_strerror(status, error, 256));
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	printf("REFINING_DRIVER: stopping bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	refining_driver_bundle_instance_pt bi = userData;
+
+	if (bi->registration != NULL) {
+		serviceRegistration_unregister(bi->registration);
+		printf("REFINING_DRIVER: unregistered driver service\n");
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	printf("REFINING_DRIVER: destroying bundle\n");
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
+}
+
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/src/refining_driver.c
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/src/refining_driver.c b/device_access/example/refining_driver/src/refining_driver.c
new file mode 100644
index 0000000..404bc42
--- /dev/null
+++ b/device_access/example/refining_driver/src/refining_driver.c
@@ -0,0 +1,281 @@
+/**
+ *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.
+ */
+/*
+ * refining_driver.c
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include <device.h>
+#include <bundle_context.h>
+#include <service_event.h>
+
+#include "refining_driver_private.h"
+#include "base_driver_device.h"
+
+static const int MAX_BUFF_SIZE = 1024;
+
+struct refining_driver {
+	device_pt device;
+	bundle_context_pt context;
+	int deviceCount;
+	array_list_pt devices;
+};
+
+struct device {
+	/*NOTE: for this example we use a empty device structure*/
+};
+
+struct refining_driver_device {
+	device_pt device;
+	base_driver_device_service_pt baseDriverDeviceService;
+	refining_driver_pt driver;
+	service_reference_pt baseServiceReference;
+	service_registration_pt deviceRegistration;
+	service_listener_pt listener;
+};
+
+celix_status_t refiningDriver_destroy(refining_driver_pt driver) {
+	if (driver != NULL) {
+		if (driver->devices != NULL) {
+			arrayList_destroy(driver->devices);
+			driver->devices=NULL;
+		}
+	}
+	return CELIX_SUCCESS;
+}
+
+celix_status_t refiningDriver_create(bundle_context_pt context, refining_driver_pt *driver) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*driver) = calloc(1, sizeof(**driver));
+	if ((*driver) != NULL) {
+		(*driver)->context=context;
+		(*driver)->deviceCount=0;
+		(*driver)->device = calloc(1, sizeof(*(*driver)->device));
+		(*driver)->devices=NULL;
+		status = arrayList_create(&(*driver)->devices);
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t refiningDriver_createService(refining_driver_pt driver, driver_service_pt *service) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*service) = calloc(1, sizeof(**service));
+	if ((*service) != NULL) {
+		(*service)->driver = driver;
+		(*service)->attach = refiningDriver_attach;
+		(*service)->match = refiningDriver_match;
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+static celix_status_t refiningDriver_stopDevice(refining_driver_device_pt device) {
+	printf("REFINING_DRIVER: stopping device, parent device is unregistered\n");
+	celix_status_t status =  CELIX_SUCCESS;
+
+	if (device->deviceRegistration != NULL) {
+		status = serviceRegistration_unregister(device->deviceRegistration);
+		if (status == CELIX_SUCCESS) {
+			printf("unregistered refining device\n");
+		}
+	}
+
+	arrayList_removeElement(device->driver->devices, device);
+	return status;
+}
+
+
+static celix_status_t refiningDriver_serviceChanged(service_listener_pt listener, service_event_pt event) {
+	celix_status_t status =  CELIX_SUCCESS;
+	refining_driver_device_pt device = listener->handle;
+	if (event->type == OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING) {
+		bool equal = false;
+		status = serviceReference_equals(device->baseServiceReference, event->reference, &equal);
+		if (status == CELIX_SUCCESS && equal) {
+			refiningDriver_stopDevice(device);
+		}
+	}
+	return status;
+}
+
+celix_status_t refiningDriver_destroyDevice(refining_driver_device_pt device) {
+	return CELIX_SUCCESS;
+}
+
+celix_status_t refining_driver_cleanup_device(refining_driver_device_pt handler) {
+	celix_status_t status = CELIX_SUCCESS;;
+	refining_driver_device_pt device = handler;
+	if (device != NULL) {
+		if (device->listener != NULL) {
+			bundleContext_removeServiceListener(device->driver->context, device->listener);
+		}
+	}
+	return status;
+}
+
+celix_status_t refiningDriver_createDevice(refining_driver_pt driver, service_reference_pt reference, base_driver_device_service_pt baseService, refining_driver_device_pt *device) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	(*device) = calloc(1, sizeof(**device));
+	if ((*device) != NULL) {
+		(*device)->driver=driver;
+		(*device)->baseDriverDeviceService=baseService;
+		(*device)->baseServiceReference=reference;
+		(*device)->deviceRegistration=NULL;
+		(*device)->listener=NULL;
+
+		service_listener_pt listener = calloc(1, sizeof(*listener));
+		listener->handle=(void *)(*device);
+		listener->serviceChanged=(celix_status_t (*)(void * listener, service_event_pt event))refiningDriver_serviceChanged;
+		bundleContext_addServiceListener(driver->context, listener, NULL);
+		(*device)->listener=listener;
+
+		arrayList_add(driver->devices, (*device));
+	} else {
+		status = CELIX_ENOMEM;
+	}
+
+	return status;
+}
+
+
+static celix_status_t refiningDriver_registerDevice(refining_driver_pt driver, refining_driver_device_pt device, char *serial) {
+	celix_status_t status = CELIX_SUCCESS;
+	refining_driver_device_service_pt service = NULL;
+	status = refiningDriverDevice_createService(device, &service);
+	properties_pt props = properties_create();
+
+	if (status == CELIX_SUCCESS) {
+		properties_set(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY, REFINING_DRIVER_DEVICE_CATEGORY);
+		properties_set(props, OSGI_DEVICEACCESS_DEVICE_SERIAL, serial);
+		status = bundleContext_registerService(driver->context, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME, service, props, &device->deviceRegistration);
+	}
+
+	if (status == CELIX_SUCCESS) {
+		printf("REFINING_DRIVER: registered refining device with serial %s\n", serial);
+	}
+	else{
+		properties_destroy(props);
+		refiningDriverDevice_destroyService(service);
+	}
+	return status;
+}
+
+celix_status_t refiningDriver_attach(void * driverHandler, service_reference_pt reference, char **result) {
+	printf("REFINING_DRIVER: attached called\n");
+	celix_status_t status = CELIX_SUCCESS;
+	refining_driver_pt driver = driverHandler;
+	(*result) = NULL;
+	base_driver_device_service_pt device_service = NULL;
+	status = bundleContext_getService(driver->context, reference, (void **)&device_service);
+	if (status == CELIX_SUCCESS) {
+		refining_driver_device_pt refiningDevice = NULL;
+		status = refiningDriver_createDevice(driver, reference, device_service, &refiningDevice);
+		if (status == CELIX_SUCCESS) {
+			driver->deviceCount+=1;
+			char serial[5];
+			sprintf(serial, "%4i", driver->deviceCount);
+			status = refiningDriver_registerDevice(driver, refiningDevice, serial);
+		}
+	}
+	return status;
+}
+
+celix_status_t refiningDriver_match(void *driverHandler, service_reference_pt reference, int *value) {
+	printf("REFINING_DRIVER: match called\n");
+	int match = 0;
+	celix_status_t status = CELIX_SUCCESS;
+
+    const char* category = NULL;
+    status = serviceReference_getProperty(reference, OSGI_DEVICEACCESS_DEVICE_CATEGORY, &category);
+    if (status == CELIX_SUCCESS) {
+        if (strcmp(category, BASE_DRIVER_DEVICE_CATEGORY) == 0) {
+            match = 10;
+        }
+    }
+
+	(*value) = match;
+	return status;
+}
+
+celix_status_t refiningDriverDevice_createService(refining_driver_device_pt device, refining_driver_device_service_pt *service) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*service) = calloc(1, sizeof(**service));
+	if ((*service) != NULL) {
+		(*service)->deviceService.device=calloc(1, sizeof(*(*service)->deviceService.device));
+		if ((*service)->deviceService.device != NULL) {
+			(*service)->deviceService.noDriverFound=refiningDriverDevice_noDriverFound;
+			(*service)->refiningDriverDevice=device;
+			(*service)->getNextWord=refiningDriverDevice_getNextWord;
+		} else {
+			status = CELIX_ENOMEM;
+		}
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t refiningDriverDevice_destroyService(refining_driver_device_service_pt service){
+	if(service != NULL){
+		if(service->deviceService.device != NULL){
+			free(service->deviceService.device);
+		}
+		free(service);
+	}
+	return CELIX_SUCCESS;
+}
+
+celix_status_t refiningDriverDevice_getNextWord(refining_driver_device_pt refiningDriverDevice, char **word) {
+	celix_status_t status = CELIX_SUCCESS;
+	base_driver_device_pt baseDevice = refiningDriverDevice->baseDriverDeviceService->baseDriverDevice;
+	char buff[MAX_BUFF_SIZE];
+	int i=0;
+	status = refiningDriverDevice->baseDriverDeviceService->getNextChar(baseDevice, &buff[i]);
+	while (buff[i] != ' ' && i < (MAX_BUFF_SIZE-1) && status == CELIX_SUCCESS) {
+		i+=1;
+		status = refiningDriverDevice->baseDriverDeviceService->getNextChar(baseDevice, &buff[i]);
+	}
+	if (status == CELIX_SUCCESS) {
+		buff[i] = '\0';
+		char *copy = calloc(1, (i+1));
+		if (copy != NULL) {
+			strcpy(copy, buff);
+			(*word)=copy;
+		} else {
+			status = CELIX_ENOMEM;
+		}
+	}
+
+	return status;
+}
+
+celix_status_t refiningDriverDevice_noDriverFound(device_pt device) {
+	printf("REFINING_DRIVER: no driver found");
+	return CELIX_SUCCESS;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/example/refining_driver/src/refining_driver_private.h
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/src/refining_driver_private.h b/device_access/example/refining_driver/src/refining_driver_private.h
new file mode 100644
index 0000000..37f15a5
--- /dev/null
+++ b/device_access/example/refining_driver/src/refining_driver_private.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.
+ */
+/*
+ * refining_driver_private.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef REFINING_DRIVER_PRIVATE_H_
+#define REFINING_DRIVER_PRIVATE_H_
+
+#include <celix_errno.h>
+#include <service_reference.h>
+#include <driver.h>
+
+#include "refining_driver_device.h"
+#include "base_driver_device.h"
+
+#define REFINING_DRIVER_ID "REFINING_DRIVER"
+
+typedef struct refining_driver *refining_driver_pt;
+
+celix_status_t refiningDriver_create(bundle_context_pt context, refining_driver_pt *driver);
+celix_status_t refiningDriver_destroy(refining_driver_pt driver);
+
+celix_status_t refiningDriver_createService(refining_driver_pt driver, driver_service_pt *service);
+
+celix_status_t refiningDriver_createDevice(refining_driver_pt driver, service_reference_pt reference, base_driver_device_service_pt baseDevice, refining_driver_device_pt *device);
+celix_status_t refiningDriver_destroyDevice(refining_driver_device_pt device);
+
+
+celix_status_t refiningDriver_attach(void *driver, service_reference_pt reference, char **result);
+celix_status_t refiningDriver_match(void *driver, service_reference_pt reference, int *value);
+
+
+celix_status_t refiningDriverDevice_noDriverFound(device_pt device);
+celix_status_t refiningDriverDevice_createService(refining_driver_device_pt, refining_driver_device_service_pt *service);
+celix_status_t refiningDriverDevice_destroyService(refining_driver_device_service_pt service);
+celix_status_t refiningDriverDevice_getNextWord(refining_driver_device_pt refiningDriverDevice, char **word);
+
+#endif /* REFINING_DRIVER_PRIVATE_H_ */