celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [44/51] [partial] celix git commit: CELIX-424: Cleans up the directory structure. Moves all libraries to the libs subdir and all bundles to the bundles subdir
Date Sun, 27 May 2018 18:37:27 GMT
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/device_access/device_access/src/driver_matcher.h
----------------------------------------------------------------------
diff --git a/bundles/device_access/device_access/src/driver_matcher.h b/bundles/device_access/device_access/src/driver_matcher.h
new file mode 100644
index 0000000..d6cdb22
--- /dev/null
+++ b/bundles/device_access/device_access/src/driver_matcher.h
@@ -0,0 +1,42 @@
+/**
+ *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.
+ */
+/*
+ * driver_matcher.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 DRIVER_MATCHER_H_
+#define DRIVER_MATCHER_H_
+
+#include "match.h"
+#include "driver_selector.h"
+#include "driver_attributes.h"
+
+typedef struct driver_matcher *driver_matcher_pt;
+
+celix_status_t driverMatcher_create(bundle_context_pt context, driver_matcher_pt *matcher);
+celix_status_t driverMatcher_destroy(driver_matcher_pt *matcher);
+
+celix_status_t driverMatcher_add(driver_matcher_pt matcher, int match, driver_attributes_pt attributes);
+
+celix_status_t driverMatcher_getBestMatch(driver_matcher_pt matcher, service_reference_pt reference, match_pt *match);
+
+#endif /* DRIVER_MATCHER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/device_access/driver_locator/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/device_access/driver_locator/CMakeLists.txt b/bundles/device_access/driver_locator/CMakeLists.txt
new file mode 100644
index 0000000..464ccbf
--- /dev/null
+++ b/bundles/device_access/driver_locator/CMakeLists.txt
@@ -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.
+
+add_celix_bundle(driver_locator
+	SYMBOLIC_NAME "apache_celix_driver_locator"
+	VERSION "0.0.2"
+	NAME "Apache Celix Device Access Driver Locator"
+	SOURCES
+		src/activator
+		src/driver_locator
+)
+
+target_include_directories(driver_locator PRIVATE src)
+target_link_libraries(driver_locator PRIVATE Celix::device_access_api)
+
+#Setup target aliases to match external usage
+install_celix_bundle(driver_locator EPXORT celix COMPONENT device_access)
+add_library(Celix::driver_locator ALIAS driver_locator)

http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/device_access/driver_locator/src/activator.c
----------------------------------------------------------------------
diff --git a/bundles/device_access/driver_locator/src/activator.c b/bundles/device_access/driver_locator/src/activator.c
new file mode 100644
index 0000000..abc60c5
--- /dev/null
+++ b/bundles/device_access/driver_locator/src/activator.c
@@ -0,0 +1,89 @@
+/**
+ *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 "bundle_activator.h"
+#include "bundle_context.h"
+#include "driver_locator_private.h"
+
+static const char *DEFAULT_LOCATOR_PATH = "drivers";
+
+struct bundle_instance {
+	driver_locator_service_pt service;
+	driver_locator_pt locator;
+	service_registration_pt locatorRegistration;
+};
+
+typedef struct bundle_instance *bundle_instance_pt;
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+	(*userData) = calloc(1, sizeof(struct bundle_instance));
+	if ( (*userData) == NULL ){
+		status = CELIX_ENOMEM;
+	}
+    return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+    celix_status_t status = CELIX_SUCCESS;
+    bundle_instance_pt bi = (bundle_instance_pt)userData;
+
+    bi->service = calloc(1, sizeof(*(bi->service)));
+    bi->locator = calloc(1, sizeof(*(bi->locator)));
+    if(bi->service != NULL && bi->locator != NULL){
+	bi->service->findDrivers = driverLocator_findDrivers;
+	bi->service->loadDriver = driverLocator_loadDriver;
+
+	bi->service->locator = bi->locator;
+	bi->locator->drivers = NULL;
+	arrayList_create(&bi->locator->drivers);
+	bundleContext_getProperty(context, "DRIVER_LOCATOR_PATH", (const char**)&bi->locator->path);
+	if (bi->locator->path == NULL ) {
+		bi->locator->path = (char *)DEFAULT_LOCATOR_PATH;
+	}
+	status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_LOCATOR_SERVICE_NAME, bi->service, NULL, &bi->locatorRegistration);
+    }
+    else{
+	if(bi->service!=NULL) free(bi->service);
+	if(bi->locator!=NULL) free(bi->locator);
+	status = CELIX_ENOMEM;
+    }
+
+    return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+    celix_status_t status = CELIX_SUCCESS;
+    bundle_instance_pt bi = (bundle_instance_pt)userData;
+    serviceRegistration_unregister(bi->locatorRegistration);
+    arrayList_destroy(bi->locator->drivers);
+    return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+    return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/device_access/driver_locator/src/driver_locator.c
----------------------------------------------------------------------
diff --git a/bundles/device_access/driver_locator/src/driver_locator.c b/bundles/device_access/driver_locator/src/driver_locator.c
new file mode 100644
index 0000000..9c360bf
--- /dev/null
+++ b/bundles/device_access/driver_locator/src/driver_locator.c
@@ -0,0 +1,91 @@
+/**
+ *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.
+ */
+/*
+ * driver_locator.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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+
+#include "driver_locator_private.h"
+#include "device.h"
+
+celix_status_t driverLocator_findDrivers(driver_locator_pt locator, properties_pt props, array_list_pt *drivers) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	const char* category = properties_get(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY);
+
+	status = arrayList_create(drivers);
+	if (status == CELIX_SUCCESS) {
+		DIR *dir;
+		dir = opendir(locator->path);
+		if (!dir) {
+			status = CELIX_FILE_IO_EXCEPTION;
+		} else {
+			struct dirent *dp;
+			while ((dp = readdir(dir)) != NULL) {
+				char str1[256], str2[256], str3[256];
+				if (sscanf(dp->d_name, "%[^_]_%[^.].%s", str1, str2, str3) == 3 &&
+					strcmp(str1, category) == 0 &&
+					strcmp(str3, "zip") == 0) {
+					int length = strlen(str1) + strlen(str2) + 2;
+					char driver[length];
+					snprintf(driver, length, "%s_%s", str1, str2);
+                    arrayList_add(*drivers, strdup(driver));
+				}
+			}
+			closedir(dir);
+		}
+	}
+	return status;
+}
+
+celix_status_t driverLocator_loadDriver(driver_locator_pt locator, char *id, char **stream) {
+	celix_status_t status = CELIX_SUCCESS;
+	*stream = NULL;
+
+	DIR *dir;
+	dir = opendir(locator->path);
+	if (!dir) {
+		status = CELIX_FILE_IO_EXCEPTION;
+	} else {
+		struct dirent *dp;
+		while ((dp = readdir(dir)) != NULL) {
+			char str1[256], str2[256];
+			if (sscanf(dp->d_name, "%[^.].%s", str1, str2) == 2 &&
+				strcmp(str1, id) == 0 &&
+				strcmp(str2, "zip") == 0) {
+				int length = strlen(locator->path) + strlen(dp->d_name) + 2;
+				char stream_str[length];
+				snprintf(stream_str, length, "%s/%s", locator->path, dp->d_name);
+				*stream = strdup(stream_str);
+				break;
+			}
+		}
+		closedir(dir);
+	}
+
+	return status;
+}
+

http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/device_access/driver_locator/src/driver_locator_private.h
----------------------------------------------------------------------
diff --git a/bundles/device_access/driver_locator/src/driver_locator_private.h b/bundles/device_access/driver_locator/src/driver_locator_private.h
new file mode 100644
index 0000000..bf6dcbf
--- /dev/null
+++ b/bundles/device_access/driver_locator/src/driver_locator_private.h
@@ -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.
+ */
+/*
+ * driver_locator_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 DRIVER_LOCATOR_PRIVATE_H_
+#define DRIVER_LOCATOR_PRIVATE_H_
+
+#include "driver_locator.h"
+
+struct driver_locator {
+    char *path;
+    array_list_pt drivers;
+};
+
+celix_status_t driverLocator_findDrivers(driver_locator_pt locator, properties_pt props, array_list_pt *drivers);
+celix_status_t driverLocator_loadDriver(driver_locator_pt locator, char *id, char **driver);
+
+#endif /* DRIVER_LOCATOR_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/device_access/example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/CMakeLists.txt b/bundles/device_access/example/CMakeLists.txt
new file mode 100644
index 0000000..5deaf85
--- /dev/null
+++ b/bundles/device_access/example/CMakeLists.txt
@@ -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.
+
+celix_subproject(DEVICE_ACCESS_EXAMPLE "Option to enable building the Device Access example bundles" OFF DEPS LAUNCHER LOG_SERVICE shell_pt shell_tui)
+if(DEVICE_ACCESS_EXAMPLE)
+	add_subdirectory(base_driver)
+	add_subdirectory(consuming_driver)
+	add_subdirectory(refining_driver)
+
+    add_celix_container(device_access_example
+        BUNDLES Celix::device_manager Celix::driver_locator Celix::shell Celix::shell_tui log_service base_driver
+    )
+
+    celix_container_bundles_dir(device_access_example
+            DIR_NAME "drivers"
+            BUNDLES word_consumingdriver char_refiningdriver
+    )
+endif(DEVICE_ACCESS_EXAMPLE)

http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/device_access/example/base_driver/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/base_driver/CMakeLists.txt b/bundles/device_access/example/base_driver/CMakeLists.txt
new file mode 100644
index 0000000..9b61853
--- /dev/null
+++ b/bundles/device_access/example/base_driver/CMakeLists.txt
@@ -0,0 +1,28 @@
+# 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(base_driver
+ 	SYMBOLIC_NAME "apache_celix_base_driver_example"
+ 	VERSION "0.0.1"
+ 	NAME "Apache Celix Device Access Base Driver Example"
+	SOURCES
+		src/activator
+		src/base_driver
+)
+target_include_directories(base_driver PRIVATE src)
+target_include_directories(base_driver PUBLIC include)
+target_link_libraries(base_driver PRIVATE Celix::device_access_api)

http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/device_access/example/base_driver/README.txt
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/base_driver/README.txt b/bundles/device_access/example/base_driver/README.txt
new file mode 100644
index 0000000..4ff2190
--- /dev/null
+++ b/bundles/device_access/example/base_driver/README.txt
@@ -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.
+
+The base driver is "special" driver that will not be loaded by the device manager.
+Normally the device manager will load drivers if it find device which are idle... But before that can happen 
+at least one device should exists. This is the role of a base driver and it should function like a "normal" OSGi
+bundle which registers a device service.
+
+In this example the base driver will provide two device service with a DEVICE_CATEGORY of "char".
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/device_access/example/base_driver/include/base_driver_device.h
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/base_driver/include/base_driver_device.h b/bundles/device_access/example/base_driver/include/base_driver_device.h
new file mode 100644
index 0000000..78c4f46
--- /dev/null
+++ b/bundles/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/3bce889b/bundles/device_access/example/base_driver/src/activator.c
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/base_driver/src/activator.c b/bundles/device_access/example/base_driver/src/activator.c
new file mode 100644
index 0000000..a6b9d62
--- /dev/null
+++ b/bundles/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/3bce889b/bundles/device_access/example/base_driver/src/base_driver.c
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/base_driver/src/base_driver.c b/bundles/device_access/example/base_driver/src/base_driver.c
new file mode 100644
index 0000000..a48c7de
--- /dev/null
+++ b/bundles/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/3bce889b/bundles/device_access/example/base_driver/src/base_driver_private.h
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/base_driver/src/base_driver_private.h b/bundles/device_access/example/base_driver/src/base_driver_private.h
new file mode 100644
index 0000000..3ee5814
--- /dev/null
+++ b/bundles/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/3bce889b/bundles/device_access/example/consuming_driver/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/consuming_driver/CMakeLists.txt b/bundles/device_access/example/consuming_driver/CMakeLists.txt
new file mode 100644
index 0000000..3f6730e
--- /dev/null
+++ b/bundles/device_access/example/consuming_driver/CMakeLists.txt
@@ -0,0 +1,29 @@
+# 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(word_consumingdriver
+ 	SYMBOLIC_NAME "apache_celix_word_consuming_driver_example"
+ 	VERSION "0.0.1"
+ 	NAME "Apache Celix Device Access Word Consuming Driver Example"
+	SOURCES
+		src/activator
+		src/consuming_driver
+)
+
+target_include_directories(word_consumingdriver PRIVATE src)
+
+target_link_libraries(word_consumingdriver PRIVATE Celix::device_access_api base_driver char_refiningdriver)

http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/device_access/example/consuming_driver/README.txt
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/consuming_driver/README.txt b/bundles/device_access/example/consuming_driver/README.txt
new file mode 100644
index 0000000..769d60f
--- /dev/null
+++ b/bundles/device_access/example/consuming_driver/README.txt
@@ -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.
+
+
+A consuming driver will be able to attach to certain device services, 
+but will not - in contrast with a refining driver - publish device services.
+
+In this example the consuming driver will look for "word" services and will print the result a few times.
+

http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/device_access/example/consuming_driver/src/activator.c
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/consuming_driver/src/activator.c b/bundles/device_access/example/consuming_driver/src/activator.c
new file mode 100644
index 0000000..2004657
--- /dev/null
+++ b/bundles/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/3bce889b/bundles/device_access/example/consuming_driver/src/consuming_driver.c
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/consuming_driver/src/consuming_driver.c b/bundles/device_access/example/consuming_driver/src/consuming_driver.c
new file mode 100644
index 0000000..9106dbd
--- /dev/null
+++ b/bundles/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/3bce889b/bundles/device_access/example/consuming_driver/src/consuming_driver_private.h
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/consuming_driver/src/consuming_driver_private.h b/bundles/device_access/example/consuming_driver/src/consuming_driver_private.h
new file mode 100644
index 0000000..261bb52
--- /dev/null
+++ b/bundles/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/3bce889b/bundles/device_access/example/refining_driver/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/refining_driver/CMakeLists.txt b/bundles/device_access/example/refining_driver/CMakeLists.txt
new file mode 100644
index 0000000..ba0469c
--- /dev/null
+++ b/bundles/device_access/example/refining_driver/CMakeLists.txt
@@ -0,0 +1,29 @@
+# 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(char_refiningdriver
+ 	SYMBOLIC_NAME "apache_celix_char_refining_driver_example"
+ 	NAME "Apache Celix Device Access Char Refining Driver Example"
+ 	VERSION "0.0.1"
+	SOURCES
+		src/activator
+		src/refining_driver
+)
+
+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/3bce889b/bundles/device_access/example/refining_driver/README.txt
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/refining_driver/README.txt b/bundles/device_access/example/refining_driver/README.txt
new file mode 100644
index 0000000..d8697af
--- /dev/null
+++ b/bundles/device_access/example/refining_driver/README.txt
@@ -0,0 +1,22 @@
+# 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.
+
+A refining driver is a driver which is able to attache to certained device services and 
+as result publishes differerent - refined - device services.
+This example will attach to device services with a "char" device category and publish 
+- for every char device services found - a "word" device services.  
+

http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/device_access/example/refining_driver/include/refining_driver_device.h
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/refining_driver/include/refining_driver_device.h b/bundles/device_access/example/refining_driver/include/refining_driver_device.h
new file mode 100644
index 0000000..728725e
--- /dev/null
+++ b/bundles/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/3bce889b/bundles/device_access/example/refining_driver/src/activator.c
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/refining_driver/src/activator.c b/bundles/device_access/example/refining_driver/src/activator.c
new file mode 100644
index 0000000..233b150
--- /dev/null
+++ b/bundles/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/3bce889b/bundles/device_access/example/refining_driver/src/refining_driver.c
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/refining_driver/src/refining_driver.c b/bundles/device_access/example/refining_driver/src/refining_driver.c
new file mode 100644
index 0000000..404bc42
--- /dev/null
+++ b/bundles/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/3bce889b/bundles/device_access/example/refining_driver/src/refining_driver_private.h
----------------------------------------------------------------------
diff --git a/bundles/device_access/example/refining_driver/src/refining_driver_private.h b/bundles/device_access/example/refining_driver/src/refining_driver_private.h
new file mode 100644
index 0000000..37f15a5
--- /dev/null
+++ b/bundles/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_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/event_admin/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/event_admin/CMakeLists.txt b/bundles/event_admin/CMakeLists.txt
new file mode 100644
index 0000000..2882069
--- /dev/null
+++ b/bundles/event_admin/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.
+
+celix_subproject(EVENT_ADMIN "Option to enable building the Event Admin Service bundles" OFF DEPS LAUNCHER LOG_SERVICE SHELL shell_tui)
+if(EVENT_ADMIN)
+
+	#add_subdirectory(utils)
+	add_subdirectory(event_admin)
+	add_subdirectory(event_handler)
+	add_subdirectory(event_publisher)
+
+	#deploy("event_admin_bundle" BUNDLES event_admin shell shell_tui log_service log_writer)
+  #  deploy("event_publisher_example" BUNDLES event_admin event_publisher shell shell_tui log_service log_writer)
+#	deploy("event_handler_example" BUNDLES event_admin event_handler shell shell_tui log_service log_writer)
+#	deploy("event_admin_example" BUNDLES event_admin event_publisher event_handler shell shell_tui log_service log_writer)
+	add_celix_container(event_admin_service
+			NAME "event_admin_service"
+			GROUP "event_admin/event_admin"
+			BUNDLES event_admin shell shell_tui log_service log_writer
+			)
+	add_celix_container(event_handler_consumer
+			NAME "event_handler_consumer"
+			GROUP "event_handler"
+			BUNDLES event_handler event_admin shell shell_tui log_service log_writer)
+	add_celix_container(event_publisher_consumer
+			NAME "event_publisher_consumer"
+			GROUP "event_publisher"
+			BUNDLES event_publisher event_handler event_admin shell shell_tui log_service log_writer)
+endif(EVENT_ADMIN)

http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/event_admin/event_admin/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/event_admin/event_admin/CMakeLists.txt b/bundles/event_admin/event_admin/CMakeLists.txt
new file mode 100644
index 0000000..87b6e62
--- /dev/null
+++ b/bundles/event_admin/event_admin/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(public/include)
+include_directories(private/include)
+include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
+
+add_celix_bundle(event_admin
+    VERSION 0.0.0
+	SOURCES 
+		private/src/event_admin_activator.c
+		private/src/event_admin_impl.c
+		private/src/event_impl.c
+		public/include/event_admin.h
+		public/include/event_handler.h
+		private/include/event_admin_impl.h
+		${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
+)
+
+install_celix_bundle(event_admin)
+
+target_link_libraries(event_admin Celix::framework)

http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/event_admin/event_admin/private/include/event_admin_impl.h
----------------------------------------------------------------------
diff --git a/bundles/event_admin/event_admin/private/include/event_admin_impl.h b/bundles/event_admin/event_admin/private/include/event_admin_impl.h
new file mode 100644
index 0000000..20b0f1b
--- /dev/null
+++ b/bundles/event_admin/event_admin/private/include/event_admin_impl.h
@@ -0,0 +1,169 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * event_admin_impl.h
+ *
+ *  \Created on: Jul 16, 2013
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef EVENT_ADMIN_IMPL_H_
+#define EVENT_ADMIN_IMPL_H_
+#include <string.h>
+#include "celix_errno.h"
+#include "bundle_context.h"
+#include "constants.h"
+#include "event_constants.h"
+#include "event_admin.h"
+#include "event_handler.h"
+#include "bundle_activator.h"
+#include "bundle_context.h"
+#include "service_tracker.h"
+#include "service_listener.h"
+#include "service_registration.h"
+#include "listener_hook_service.h"
+#include "event_admin.h"
+#include "log_helper.h"
+
+struct event_admin {
+        hash_map_pt channels;
+        array_list_pt event_handlers;
+        bundle_context_pt context;
+        log_helper_pt *loghelper;
+};
+typedef struct channel *channel_t;
+struct channel {
+        char *topic;
+        hash_map_pt eventHandlers;///array list containing all listeners subscribed to the channel
+       // hash_map_pt channels;
+       // apr_thread_mutex_t *channelLock;
+
+};
+/**
+ * @desc Create event an event admin and put it in the event_admin parameter.
+ * @param apr_pool_t *pool. Pointer to the apr pool
+ * @param bundle_context_pt context. Pointer to the bundle context.
+ * @param event_admin_pt *event_admin. The event admin result.
+ */
+celix_status_t eventAdmin_create( bundle_context_pt context, event_admin_pt *event_admin);
+
+
+celix_status_t eventAdmin_destroy(event_admin_pt *event_admin);
+
+/**
+ * @desc Post event. sends the event to the handlers in async.
+ * @param event_admin_pt event_admin. the event admin instance
+ * @param event_pt event. the event to be send.
+ *
+ */
+celix_status_t eventAdmin_postEvent(event_admin_pt event_admin, event_pt event);// async event sending
+/**
+ * @desc send event. sends the event to the handlers in sync.
+ * @param event_admin_pt event_admin. the event admin instance
+ * @param event_pt event. the event to be send.
+ *
+ */
+celix_status_t eventAdmin_sendEvent(event_admin_pt event_admin, event_pt event);// sync event sending
+/**
+ * @desc functions for the service tracker
+ * @param void * handle.  Pointer to the event admin.
+ * @param service_reference_pt ref. Pointer to the service reference. Needed to get the service
+ * @param void **service Pointer to the service. Needed to use the service.
+ */
+celix_status_t eventAdmin_addingService(void * handle, service_reference_pt ref, void **service);
+celix_status_t eventAdmin_addedService(void * handle, service_reference_pt ref, void * service);
+celix_status_t eventAdmin_modifiedService(void * handle, service_reference_pt ref, void * service);
+celix_status_t eventAdmin_removedService(void * handle, service_reference_pt ref, void * service) ;
+/*
+ * end functions for service tracker
+ */
+
+/**
+ * @desc finds the handlers interested in the topic.
+ * @param hash_map_pt channels. hashmap contains the channels, key string based
+ * @param char *topic, the topic string.
+ * @param array_list_pt event_handlers. The array list to contain the interested handlers.
+ */
+celix_status_t eventAdmin_findHandlersByTopic(event_admin_pt event_admin, const char *topic,
+                                              array_list_pt event_handlers);
+/**
+ * @desc create the needed event channels for an event handler.
+ * @desc apr_pool_t *pool. a memory pool pointer.
+ * @desc event_handler_service_pt event_handler_service. The handler
+ * @desc char *topic the topic
+ * @desc channel_t *channel. the top level channel.
+ */
+celix_status_t eventAdmin_createEventChannelsByEventHandler(event_handler_service_pt event_handler_service,
+                                                            const char *topic, channel_t *channel);
+/**
+ * @desc mutex functions for the channels
+ * @param event_admin_pt event_admin. the event admin instance.
+ * @param char *topic. the topic for which the channels need to be locked or unlocked
+ */
+celix_status_t eventAdmin_lockHandlersList(event_admin_pt event_admin, const char *topic);
+
+celix_status_t eventAdmin_releaseHandersList(event_admin_pt event_admin, const char *topic);
+
+/**
+ * @desc create an event
+ * @param char *topic. String containing the topic
+ * @param properties_pt properties.
+ */
+celix_status_t eventAdmin_createEvent(event_admin_pt event_admin, const char *topic, properties_pt properties,
+                                      event_pt *event);
+/**
+ * @desc checks if an event contains the property
+ * @param event_pt *event. the event to check
+ * @param char *property. the key for the property to check
+ * @param bool *result. the result.
+ */
+celix_status_t eventAdmin_containsProperty( event_pt *event, char *property, bool *result);
+/**
+ * @desc checks if an event is equal to the second event.
+ * @param event_pt *event, event to compare to
+ * @param event_pt *event, the event to be compared
+ * @param bool *result. the result true if equal.
+ */
+celix_status_t eventAdmin_event_equals( event_pt *event, event_pt *compare, bool *result);
+/**
+ * @desc gets a property from the event.
+ * @param event_pt *event. the event to get the property from
+ * @param char *propertyKey the key of the property to get
+ * @param char **propertyValue. the result param will contain the property if it exists in the event.
+ */
+celix_status_t eventAdmin_getProperty(event_pt *event, char *propertyKey, const char **propertyValue);
+/**
+ * @desc gets all property names from the event
+ * @param event_pt *event. the event to get the property names from
+ * @param array_list_pt *names. will contain the keys
+ */
+celix_status_t eventAdmin_getPropertyNames( event_pt *event, array_list_pt *names);
+/**
+ * @desc gets the topic from an event
+ * @param event_pt *event. the event to get the topic from
+ * @param char **topic, result pointer will contain the topic.
+ */
+celix_status_t eventAdmin_getTopic(event_pt *event, const char **topic);
+celix_status_t eventAdmin_hashCode(event_pt *event, int *hashCode);
+celix_status_t eventAdmin_matches( event_pt *event);
+celix_status_t eventAdmin_toString( event_pt *event, char *eventString);
+
+
+#endif /* EVENT_ADMIN_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/event_admin/event_admin/private/src/event_admin_activator.c
----------------------------------------------------------------------
diff --git a/bundles/event_admin/event_admin/private/src/event_admin_activator.c b/bundles/event_admin/event_admin/private/src/event_admin_activator.c
new file mode 100644
index 0000000..a5f8cb2
--- /dev/null
+++ b/bundles/event_admin/event_admin/private/src/event_admin_activator.c
@@ -0,0 +1,136 @@
+/**
+ *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
+ *
+ *  Created on: Jul 9, 2013
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+
+#include "event_admin_impl.h"
+#include "log_helper.h"
+#include "log_service.h"
+
+struct activator {
+
+	event_admin_service_pt event_admin_service;
+	event_admin_pt event_admin;
+	service_registration_pt registration;
+	service_tracker_pt tracker;
+	bundle_context_pt context;
+	log_helper_pt loghelper;
+};
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	struct activator *activator;
+	activator = calloc(1, sizeof(*activator));
+
+	if(!activator) {
+		status = CELIX_BUNDLE_EXCEPTION;
+	}else {
+		activator->registration = NULL;
+		logHelper_create(context, &activator->loghelper);
+
+		*userData = activator;
+		event_admin_pt event_admin = NULL;
+		event_admin_service_pt event_admin_service = NULL;
+		status = eventAdmin_create(context, &event_admin);
+		if(status == CELIX_SUCCESS){
+			activator->event_admin = event_admin;
+			event_admin_service = calloc(1, sizeof(event_admin_service));
+			if(!event_admin_service){
+				status = CELIX_ENOMEM;
+			} else {
+				event_admin->context = context;
+				event_admin->loghelper = &activator->loghelper;
+				event_admin_service->eventAdmin = event_admin;
+				event_admin_service->postEvent = eventAdmin_postEvent;
+				event_admin_service->sendEvent = eventAdmin_sendEvent;
+				event_admin_service->createEvent = eventAdmin_createEvent;
+				event_admin_service->containsProperty = eventAdmin_containsProperty;
+				event_admin_service->event_equals = eventAdmin_event_equals;
+				event_admin_service->getProperty = eventAdmin_getProperty;
+				event_admin_service->getPropertyNames = eventAdmin_getPropertyNames;
+				event_admin_service->getTopic = eventAdmin_getTopic;
+				event_admin_service->hashCode = eventAdmin_hashCode;
+				event_admin_service->matches = eventAdmin_matches;
+				event_admin_service->toString = eventAdmin_toString;
+
+			}
+		}
+		activator->event_admin_service = event_admin_service;
+	}
+
+
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator *activator = userData;
+	event_admin_service_pt event_admin_service = NULL;
+
+	if(status == CELIX_SUCCESS) {
+		struct activator * data = (struct activator *) userData;
+		service_tracker_customizer_pt cust = NULL;
+		service_tracker_pt tracker = NULL;
+		data->context = context;
+
+		serviceTrackerCustomizer_create(data->event_admin_service->eventAdmin, eventAdmin_addingService, eventAdmin_addedService, eventAdmin_modifiedService, eventAdmin_removedService, &cust);
+		serviceTracker_create(context, (char *) EVENT_HANDLER_SERVICE, cust, &tracker);
+
+		data->tracker = tracker;
+
+		serviceTracker_open(tracker);
+		properties_pt properties = NULL;
+		properties = properties_create();
+		event_admin_service = activator->event_admin_service;
+		bundleContext_registerService(context, (char *) EVENT_ADMIN_NAME, event_admin_service, properties, &activator->registration);
+		logHelper_start(activator->loghelper);
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator * data =  userData;
+    serviceRegistration_unregister(data->registration);
+	serviceTracker_close(data->tracker);
+	status = logHelper_stop(data->loghelper);
+    logHelper_destroy(&data->loghelper);
+
+	return status;
+}
+
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+    //stop  struct activator *activator = userData;
+
+    // free(activator);
+
+	return status;
+}
+
+


Mime
View raw message