You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by ej...@apache.org on 2016/08/19 13:18:43 UTC

[1/6] celix git commit: Removed APR from the event admin. working again. Needs thread safety and on dangling service ref fixed

Repository: celix
Updated Branches:
  refs/heads/feature/event_admin [created] a59205735


Removed APR from the event admin. working again. Needs thread safety and on dangling service ref fixed


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

Branch: refs/heads/feature/event_admin
Commit: 840f34b6543f42560be32c5fe4385903dda6ddd4
Parents: 216032c
Author: Erik Jansman <ej...@apache.org>
Authored: Wed Aug 17 09:57:25 2016 +0200
Committer: Erik Jansman <ej...@apache.org>
Committed: Wed Aug 17 09:57:25 2016 +0200

----------------------------------------------------------------------
 CMakeLists.txt                                  |  2 +-
 event_admin/CMakeLists.txt                      | 13 +--
 .../private/src/event_admin_activator.c         | 36 ++++-----
 .../event_admin/private/src/event_admin_impl.c  | 39 ++++-----
 .../event_admin/private/src/event_impl.c        |  6 +-
 .../private/include/event_handler_impl.h        |  1 +
 .../private/src/event_handler_activator.c       | 17 +---
 .../private/src/event_handler_impl.c            | 37 +++------
 .../private/include/event_publisher_impl.h      |  2 +
 .../private/src/event_publisher_activator.c     | 19 +++--
 .../private/src/event_publisher_impl.c          | 83 +++++++++++---------
 11 files changed, 116 insertions(+), 139 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/840f34b6/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3088612..bfa37e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -81,7 +81,7 @@ add_subdirectory(shell)
 add_subdirectory(log_writer)
 add_subdirectory(log_service)
 
-#add_subdirectory(event_admin)# event_admin is unstable
+add_subdirectory(event_admin)# event_admin is unstable
 add_subdirectory(dependency_manager)
 add_subdirectory(dependency_manager_cxx)
 #add_subdirectory(scr) scr still needs APR

http://git-wip-us.apache.org/repos/asf/celix/blob/840f34b6/event_admin/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/event_admin/CMakeLists.txt b/event_admin/CMakeLists.txt
index e0d830c..38e0d08 100644
--- a/event_admin/CMakeLists.txt
+++ b/event_admin/CMakeLists.txt
@@ -18,26 +18,21 @@
 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_deploy(event_admin_service
 			NAME "event_admin_service"
-			GROUP "event_admin/event_admin"
-			BUNDLES event_admin shell shell_tui log_service log_writer
+			GROUP "event_admin"
+			BUNDLES event_admin shell_tui shell log_writer log_service
 			)
 	add_deploy(event_handler_consumer
 			NAME "event_handler_consumer"
 			GROUP "event_handler"
-			BUNDLES event_handler event_admin shell shell_tui log_service log_writer)
+			BUNDLES event_handler shell_tui shell log_writer log_service)
 	add_deploy(event_publisher_consumer
 			NAME "event_publisher_consumer"
 			GROUP "event_publisher"
-			BUNDLES event_publisher event_handler event_admin shell shell_tui log_service log_writer)
+			BUNDLES event_admin event_publisher event_handler shell_tui shell log_writer log_service )
 endif(EVENT_ADMIN)

http://git-wip-us.apache.org/repos/asf/celix/blob/840f34b6/event_admin/event_admin/private/src/event_admin_activator.c
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/private/src/event_admin_activator.c b/event_admin/event_admin/private/src/event_admin_activator.c
index a5f8cb2..37ec404 100644
--- a/event_admin/event_admin/private/src/event_admin_activator.c
+++ b/event_admin/event_admin/private/src/event_admin_activator.c
@@ -37,7 +37,6 @@ struct activator {
 	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) {
@@ -50,7 +49,7 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 		status = CELIX_BUNDLE_EXCEPTION;
 	}else {
 		activator->registration = NULL;
-		logHelper_create(context, &activator->loghelper);
+
 
 		*userData = activator;
 		event_admin_pt event_admin = NULL;
@@ -58,12 +57,11 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 		status = eventAdmin_create(context, &event_admin);
 		if(status == CELIX_SUCCESS){
 			activator->event_admin = event_admin;
-			event_admin_service = calloc(1, sizeof(event_admin_service));
+			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;
@@ -77,6 +75,11 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 				event_admin_service->matches = eventAdmin_matches;
 				event_admin_service->toString = eventAdmin_toString;
 
+				service_tracker_customizer_pt cust = NULL;
+				service_tracker_pt tracker = NULL;
+				serviceTrackerCustomizer_create(event_admin_service->eventAdmin, eventAdmin_addingService, eventAdmin_addedService, eventAdmin_modifiedService, eventAdmin_removedService, &cust);
+				serviceTracker_create(context, (char *) EVENT_HANDLER_SERVICE, cust, &tracker);
+				activator->tracker = tracker;
 			}
 		}
 		activator->event_admin_service = event_admin_service;
@@ -90,24 +93,15 @@ 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;
+	properties_pt properties = 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;
+		serviceTracker_open(data->tracker);
 		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;
 }
@@ -117,18 +111,18 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context)
 	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);
+	struct activator * data =  userData;
+	event_admin_pt event_admin = data->event_admin;
+	event_admin_service_pt event_admin_service = data->event_admin_service;
+	eventAdmin_destroy(&event_admin);
+	free(event_admin_service);
+	serviceTracker_destroy(data->tracker);
 
 	return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/840f34b6/event_admin/event_admin/private/src/event_admin_impl.c
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/private/src/event_admin_impl.c b/event_admin/event_admin/private/src/event_admin_impl.c
index a7eeb49..fb5b26c 100644
--- a/event_admin/event_admin/private/src/event_admin_impl.c
+++ b/event_admin/event_admin/private/src/event_admin_impl.c
@@ -49,7 +49,8 @@ celix_status_t eventAdmin_create(bundle_context_pt context, event_admin_pt *even
 celix_status_t eventAdmin_destroy(event_admin_pt *event_admin)
 {
 	celix_status_t status = CELIX_SUCCESS;
-	//free(*event_admin);
+    arrayList_destroy((*event_admin)->event_handlers);
+	free(*event_admin);
 	return status;
 }
 
@@ -74,7 +75,7 @@ celix_status_t eventAdmin_postEvent(event_admin_pt event_admin, event_pt event)
 	array_list_iterator_pt handlers_iterator = arrayListIterator_create(event_handlers);
 	while (arrayListIterator_hasNext(handlers_iterator)) {
 		event_handler_service_pt event_handler_service = (event_handler_service_pt) arrayListIterator_next(handlers_iterator);
-		logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_INFO, "handler found (POST EVENT) for %s", topic);
+		//logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_INFO, "handler found (POST EVENT) for %s", topic);
 		event_handler_service->handle_event(&event_handler_service->event_handler, event);
 	}
 	eventAdmin_releaseHandersList(event_admin, topic);
@@ -94,7 +95,7 @@ celix_status_t eventAdmin_sendEvent(event_admin_pt event_admin, event_pt event)
 	array_list_iterator_pt handlers_iterator = arrayListIterator_create(event_handlers);
 	while (arrayListIterator_hasNext(handlers_iterator)) {
 		event_handler_service_pt event_handler_service = (event_handler_service_pt) arrayListIterator_next(handlers_iterator);
-		logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_INFO, "handler found (SEND EVENT) for %s", topic);
+	//	logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_INFO, "handler found (SEND EVENT) for %s", topic);
 		event_handler_service->handle_event(&event_handler_service->event_handler, event);
 	}
 	eventAdmin_releaseHandersList(event_admin, topic);
@@ -107,7 +108,7 @@ celix_status_t eventAdmin_findHandlersByTopic(event_admin_pt event_admin, const
 	hash_map_pt channels = event_admin->channels;
     channel_t channel = hashMap_get(channels, topic);
 	if (channel != NULL) {
-		logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_INFO, "found channel: %s", topic);
+		//logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_INFO, "found channel: %s", topic);
 		if (channel->eventHandlers != NULL && !hashMap_isEmpty(channel->eventHandlers)) {
 			// iterate throught the handlers and add them to the array list for result.
 			hash_map_iterator_pt hashmap_iterator =  hashMapIterator_create(channel->eventHandlers);
@@ -116,7 +117,7 @@ celix_status_t eventAdmin_findHandlersByTopic(event_admin_pt event_admin, const
 			}
 		}
 	} else {
-		logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_WARNING, "no such channel: %s", topic);
+		//logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_WARNING, "no such channel: %s", topic);
 	}
 	return status;
 }
@@ -127,7 +128,7 @@ celix_status_t eventAdmin_createEventChannels(event_admin_pt *event_admin, const
     channel_t channel = hashMap_get((*event_admin)->channels, topic);
 	if (channel == NULL) {
 		//create channel
-		logHelper_log(*(*event_admin)->loghelper, OSGI_LOGSERVICE_ERROR, "Creating channel: %s", topic);
+		printf("Creating channel: %s", topic);
 
 
 
@@ -138,14 +139,13 @@ celix_status_t eventAdmin_createEventChannels(event_admin_pt *event_admin, const
             char *channel_name = strdup(topic);
 			channel->topic = channel_name;
 			channel->eventHandlers = hashMap_create(NULL,NULL,NULL,NULL);
-			//channel->channelLock = NULL;
-          //  apr_thread_mutex_create(&channel->channelLock, APR_THREAD_MUTEX_NESTED, subPool);
 			hashMap_put((*event_admin)->channels, channel_name, channel);
 		}
     }
     if (channel) {
         hashMap_put(channel->eventHandlers, &event_handler_service, event_handler_service);
     }
+
 	return status;
 
 
@@ -171,17 +171,17 @@ celix_status_t eventAdmin_releaseHandersList(event_admin_pt event_admin, const c
 	if (channel != NULL) {
         // TODO check the result value...
        // apr_thread_mutex_unlock(channel->channelLock);
-		logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "UNLOCK: %s!", topic);
+		//logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "UNLOCK: %s!", topic);
     }
 	return status;
 }
 
 celix_status_t eventAdmin_addingService(void * handle, service_reference_pt ref, void **service) {
 	celix_status_t status = CELIX_SUCCESS;
+	printf("eventadmin adding service \n");
 	event_admin_pt  event_admin = handle;
 	status = bundleContext_getService(event_admin->context, ref, service);
-	logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "test");
-	printf("eventadmin adding service \n");
+
   	return status;
 }
 
@@ -191,22 +191,25 @@ celix_status_t eventAdmin_addedService(void * handle, service_reference_pt ref,
 	event_handler_service_pt event_handler_service = NULL;
 	event_handler_service = (event_handler_service_pt) service;
 	const char *topic = NULL;
-	serviceReference_getProperty(ref, (char*)EVENT_TOPIC, &topic);
-	logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "Original TOPIC: %s", topic);
+	serviceReference_getProperty(ref, (const char*)EVENT_TOPIC, &topic);
 	printf("original topic: %s\n", topic);
 	eventAdmin_createEventChannels(&event_admin,topic,event_handler_service);
 	return status;
 }
 
 celix_status_t eventAdmin_modifiedService(void * handle, service_reference_pt ref, void * service) {
-	event_admin_pt event_admin = (event_admin_pt) handle;
-	logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "Event admin Modified");
+/*	event_admin_pt event_admin = (event_admin_pt) handle;
+	logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "Event admin Modified");*/
 	return CELIX_SUCCESS;
 }
 
 celix_status_t eventAdmin_removedService(void * handle, service_reference_pt ref, void * service) {
-	event_admin_pt event_admin = (event_admin_pt) handle;
+	celix_status_t status = CELIX_SUCCESS;
+	printf("eventadmin removing service \n");
+	//event_admin_pt  event_admin = handle;
+	//hashMap_clear(event_admin->)
+	/*event_admin_pt event_admin = (event_admin_pt) handle;
 	logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "Event admin Removed %p", service);
-	printf("Event admin Removed %p", service);
-	return CELIX_SUCCESS;
+	printf("Event admin Removed %p", service);*/
+	return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/840f34b6/event_admin/event_admin/private/src/event_impl.c
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/private/src/event_impl.c b/event_admin/event_admin/private/src/event_impl.c
index aad9877..8f65c91 100644
--- a/event_admin/event_admin/private/src/event_impl.c
+++ b/event_admin/event_admin/private/src/event_impl.c
@@ -38,15 +38,15 @@ celix_status_t eventAdmin_createEvent(event_admin_pt event_admin, const char *to
 									  event_pt *event) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_DEBUG, "create event event admin pointer: %p",event_admin);
+	//logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_DEBUG, "create event event admin pointer: %p",event_admin);
 
 
 	*event = calloc(1, sizeof(**event));
 	if(!*event){
 	       status = CELIX_ENOMEM;
-	       logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "No MEM");
+	   //    logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "No MEM");
 	}else {
-		logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_INFO, "Event created : %s", topic);
+		//logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_INFO, "Event created : %s", topic);
 		(*event)->topic = topic;
 		(*event)->properties = properties;
 		properties_set((*event)->properties, (char *)EVENT_TOPIC, topic);

http://git-wip-us.apache.org/repos/asf/celix/blob/840f34b6/event_admin/event_handler/private/include/event_handler_impl.h
----------------------------------------------------------------------
diff --git a/event_admin/event_handler/private/include/event_handler_impl.h b/event_admin/event_handler/private/include/event_handler_impl.h
index 44fc671..5ddc56a 100644
--- a/event_admin/event_handler/private/include/event_handler_impl.h
+++ b/event_admin/event_handler/private/include/event_handler_impl.h
@@ -50,6 +50,7 @@ celix_status_t eventHandlerHandleEvent(event_handler_pt *instance, event_pt even
  * @param event_handler_pt *event_handler. the event handler to be made.
  */
 celix_status_t eventHandlerCreate(bundle_context_pt context, event_handler_pt *event_handler);
+celix_status_t eventHandlerDestroy(event_handler_pt *event_handler);
 celix_status_t  eventHandlerRemovedService(void * handle, service_reference_pt ref, void * service) ;
 celix_status_t  eventHandlerModifiedService(void * handle, service_reference_pt ref, void * service) ;
 celix_status_t  eventHandlerAddedService(void * handle, service_reference_pt ref, void * service) ;

http://git-wip-us.apache.org/repos/asf/celix/blob/840f34b6/event_admin/event_handler/private/src/event_handler_activator.c
----------------------------------------------------------------------
diff --git a/event_admin/event_handler/private/src/event_handler_activator.c b/event_admin/event_handler/private/src/event_handler_activator.c
index d39cfd9..9654e95 100644
--- a/event_admin/event_handler/private/src/event_handler_activator.c
+++ b/event_admin/event_handler/private/src/event_handler_activator.c
@@ -33,7 +33,6 @@ static const char * const EVENT_HANDLER_NAME = "demo";
 struct activator {
 	event_handler_service_pt event_handler_service;
 	service_registration_pt registration;
-	service_tracker_pt eventAdminTracker;
 };
 
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
@@ -73,17 +72,8 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
     properties_set(properties, (char *) EVENT_TOPIC, (const char *) "log/error/eventpublishers/event");
 
 	event_handler_service_pt event_handler_service = activator->event_handler_service;
-    bundleContext_registerService(context, (const char *) EVENT_HANDLER_SERVICE, event_handler_service, properties,
+    bundleContext_registerService(context, (char *) EVENT_HANDLER_SERVICE, event_handler_service, properties,
                                   &activator->registration);
-
-    /*if (status == CELIX_SUCCESS) {
-        service_tracker_customizer_pt customizer = NULL;
-        service_tracker_pt tracker = NULL;
-        serviceTrackerCustomizer_create(activator->event_handler_service->event_handler, eventHandlerAddingService, eventHandlerAddedService, eventHandlerModifiedService, eventHandlerRemovedService, &customizer);
-        serviceTracker_create(context, (const char *) EVENT_ADMIN_NAME, customizer, &tracker);
-        activator->eventAdminTracker = tracker;
-        serviceTracker_open(tracker);
-    }*/
 	return status;
 }
 
@@ -91,14 +81,13 @@ 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;
+    struct activator *data = userData;
+    eventHandlerDestroy(&(data->event_handler_service)->event_handler);
 	return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/840f34b6/event_admin/event_handler/private/src/event_handler_impl.c
----------------------------------------------------------------------
diff --git a/event_admin/event_handler/private/src/event_handler_impl.c b/event_admin/event_handler/private/src/event_handler_impl.c
index 52ff1b7..76f2367 100644
--- a/event_admin/event_handler/private/src/event_handler_impl.c
+++ b/event_admin/event_handler/private/src/event_handler_impl.c
@@ -51,11 +51,20 @@ celix_status_t eventHandlerCreate(bundle_context_pt context, event_handler_pt *e
 	return status;
 }
 
+celix_status_t eventHandlerDestroy(event_handler_pt *event_handler)
+{
+    celix_status_t status = CELIX_SUCCESS;
+    logHelper_stop((*event_handler)->loghelper);
+    logHelper_destroy(&(*event_handler)->loghelper);
+    free(*event_handler);
+    return status;
+}
+
 celix_status_t eventHandlerHandleEvent(event_handler_pt *event_handler, event_pt event) {
 	celix_status_t status = CELIX_SUCCESS;
 	if (event != NULL) {
         const char *topic = event->topic;
-        //status = (*event_handler)->event_admin_service->getTopic(&event, &topic);
+
 		logHelper_log((*event_handler)->loghelper, OSGI_LOGSERVICE_INFO, "[SUB] topic of event: %s.", topic);
 
 		array_list_pt propertyNames;
@@ -83,29 +92,3 @@ celix_status_t eventHandlerHandleEvent(event_handler_pt *event_handler, event_pt
 }
 
 
-celix_status_t eventHandlerAddingService(void * handle, service_reference_pt ref, void **service) {
-	celix_status_t status = CELIX_SUCCESS;
-	event_handler_pt event_handler = handle;
-	status = bundleContext_getService(event_handler->context, ref, service);
-	return status;
-}
-
-celix_status_t eventHandlerAddedService(void * handle, service_reference_pt ref, void * service) {
-	event_handler_pt data = (event_handler_pt) handle;
-	logHelper_log(data->loghelper, OSGI_LOGSERVICE_DEBUG, "[SUB] Event admin added.");
-	data->event_admin_service = (event_admin_service_pt) service;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t eventHandlerModifiedService(void * handle, service_reference_pt ref, void * service) {
-	event_handler_pt data = (event_handler_pt) handle;
-	logHelper_log(data->loghelper, OSGI_LOGSERVICE_DEBUG, "[SUB] Event admin modified.");
-	return CELIX_SUCCESS;
-}
-
-celix_status_t eventHandlerRemovedService(void * handle, service_reference_pt ref, void * service) {
-	event_handler_pt data = (event_handler_pt) handle;
-    logHelper_log(data->loghelper, OSGI_LOGSERVICE_DEBUG, "[SUB] Event admin removed.");
-	data->event_admin_service = NULL;
-	return CELIX_SUCCESS;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/840f34b6/event_admin/event_publisher/private/include/event_publisher_impl.h
----------------------------------------------------------------------
diff --git a/event_admin/event_publisher/private/include/event_publisher_impl.h b/event_admin/event_publisher/private/include/event_publisher_impl.h
index a2cab83..5d6ba5b 100644
--- a/event_admin/event_publisher/private/include/event_publisher_impl.h
+++ b/event_admin/event_publisher/private/include/event_publisher_impl.h
@@ -79,5 +79,7 @@ celix_status_t eventPublisherRemovedService(void * handle, service_reference_pt
  */
 celix_status_t eventPublisherStop(event_publisher_pt *event_publisher);
 
+celix_status_t eventPublisherDestroy(event_publisher_pt *event_publisher);
+
 void *produceEvents(void *handle);
 #endif /* EVENT_PUBLISHER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/840f34b6/event_admin/event_publisher/private/src/event_publisher_activator.c
----------------------------------------------------------------------
diff --git a/event_admin/event_publisher/private/src/event_publisher_activator.c b/event_admin/event_publisher/private/src/event_publisher_activator.c
index 279942f..c43bba7 100644
--- a/event_admin/event_publisher/private/src/event_publisher_activator.c
+++ b/event_admin/event_publisher/private/src/event_publisher_activator.c
@@ -47,7 +47,6 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 	status = eventPublisherCreate(context, &eventpublisher);
 	if(status == CELIX_SUCCESS) {
 		activator->event_publisher = eventpublisher;
-
 	}
 
 	return status;
@@ -56,16 +55,14 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
 	celix_status_t 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_publisher, eventPublisherAddingService, eventPublisherAddedService, eventPublisherModifiedService, eventPublisherRemovedService, &cust);
-		serviceTracker_create(context, (char *) EVENT_ADMIN_NAME, cust, &tracker);
-		data->tracker = tracker;
+    service_tracker_pt tracker = NULL;
+    data->context = context;
+    serviceTrackerCustomizer_create(data->event_publisher, eventPublisherAddingService, eventPublisherAddedService, eventPublisherModifiedService, eventPublisherRemovedService, &cust);
+    serviceTracker_create(context, (char *) EVENT_ADMIN_NAME, cust, &tracker);
+    data->tracker = tracker;
 
-		serviceTracker_open(tracker);
+    serviceTracker_open(tracker);
 
 	eventPublisherStart(&data->event_publisher);
 	return status;
@@ -81,6 +78,8 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context)
 
 celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
 	celix_status_t status = CELIX_SUCCESS;
-
+	struct activator * data = (struct activator *) userData;
+	serviceTracker_destroy(data->tracker);
+    eventPublisherDestroy(&data->event_publisher);
 	return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/840f34b6/event_admin/event_publisher/private/src/event_publisher_impl.c
----------------------------------------------------------------------
diff --git a/event_admin/event_publisher/private/src/event_publisher_impl.c b/event_admin/event_publisher/private/src/event_publisher_impl.c
index 6a8bc00..9a43b80 100644
--- a/event_admin/event_publisher/private/src/event_publisher_impl.c
+++ b/event_admin/event_publisher/private/src/event_publisher_impl.c
@@ -52,59 +52,70 @@ celix_status_t eventPublisherStart(event_publisher_pt *event_publisher) {
     celix_status_t status = CELIX_SUCCESS;
 	(*event_publisher)->running = true;
     logHelper_start((*event_publisher)->loghelper);
-    // celixThread_create((*event_publisher)->sender, NULL, eventPublisherSendEventThread, event_publisher);
     status = celixThread_create(&(*event_publisher)->sender, NULL, produceEvents, &(*event_publisher));
+    if(status != CELIX_SUCCESS)
+    {
+        printf("failed to create thread\n");
+    }
+    else
+    {
+       printf("trhead created \n");
+    }
     return status;
 }
 
 celix_status_t eventPublisherStop(event_publisher_pt *event_publisher) {
 	(*event_publisher)->running = false;
-    //void * status;
-    // celixThread_join((*event_publisher)->sender, &status);
 	logHelper_stop((*event_publisher)->loghelper);
-	logHelper_destroy(&(*event_publisher)->loghelper);
 	return CELIX_SUCCESS;
 }
+celix_status_t eventPublisherDestroy(event_publisher_pt *event_publisher)
+{
+    logHelper_destroy(&(*event_publisher)->loghelper);
+    if((*event_publisher)->eventAdminAdded)
+    {
+        (*event_publisher)->event_admin_service = NULL;
+    }
+    return CELIX_SUCCESS;
+}
 
 void *produceEvents(void *handle) {
+    int i =0;
     event_publisher_pt *event_publisher = handle;
-    while ((*event_publisher)->running && (*event_publisher)->eventAdminAdded) {
-        //   sleep(1000000); // 1 sec.
-        event_admin_service_pt *event_admin_service = &(*event_publisher)->event_admin_service;
-        event_admin_pt event_admin = (*event_admin_service)->eventAdmin;
-        if (event_admin_service != NULL) {
-            event_pt event;
-            properties_pt props = properties_create();
-            properties_set(props, "This is a key", "this is a value");
-            (*event_admin_service)->createEvent(event_admin, "log/error/eventpublishers/event", props, &event);
-            (*event_admin_service)->postEvent(event_admin, event);
-            (*event_admin_service)->sendEvent(event_admin, event);
-            printf("send event\n");
+    while ((*event_publisher)->running ) {
+
+        if((*event_publisher)->eventAdminAdded) {
+            event_admin_service_pt *event_admin_service = &(*event_publisher)->event_admin_service;
+            event_admin_pt event_admin = (*event_admin_service)->eventAdmin;
+            if (event_admin_service != NULL) {
+                event_pt event;
+                properties_pt props = properties_create();
+                properties_set(props, "This is a key", "this is a value");
+                printf("create event\n");
+                (*event_admin_service)->createEvent(event_admin, "log/error/eventpublishers/event", props, &event);
+                printf("post event\n");
+                (*event_admin_service)->postEvent(event_admin, event);
+                printf("send event\n");
+                (*event_admin_service)->sendEvent(event_admin, event);
+
+            } else {
+                printf("could not send event\n");
+            }
+        }
+        else
+        {
+            printf("No event admin\n");
+        }
+        for (i=0;i<10000000; i++){
+            continue;
         }
     }
+    printf("end of thread\n");
+
+
     return CELIX_SUCCESS;
 }
 
-/*celix_thread_start_t eventPublisherSendEventThread(celix_thread_t *thd, void *handle) {
-    event_publisher_pt *client = (event_publisher_pt *) handle;
-
-    while ((*client)->running && (*client)->eventAdminAdded) {
-        apr_sleep(1000000); // 1 sec.
-
-        event_admin_service_pt *event_admin_service = &(*client)->event_admin_service;
-        event_admin_pt event_admin = (*event_admin_service)->eventAdmin;
-        if (event_admin_service != NULL) {
-            event_pt event;
-            properties_pt props = properties_create();
-            properties_set(props, "This is a key", "this is a value");
-            (*event_admin_service)->createEvent(event_admin, "log/error/eventpublishers/event", props, &event);
-            (*event_admin_service)->postEvent(event_admin, event);
-            (*event_admin_service)->sendEvent(event_admin, event);
-        }
-    }
-    celixThread_exit( APR_SUCCESS);
-	return NULL;*
-}*/
 
 celix_status_t eventPublisherAddingService(void * handle, service_reference_pt ref, void **service) {
 	celix_status_t status = CELIX_SUCCESS;


[5/6] celix git commit: lock and release handlers list async

Posted by ej...@apache.org.
lock and release handlers list async


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

Branch: refs/heads/feature/event_admin
Commit: aa2c3e28dcc7a490c6de27bc76ea4c2f5bedb11b
Parents: fd41744
Author: Erik Jansman <ej...@apache.org>
Authored: Fri Aug 19 14:48:40 2016 +0200
Committer: Erik Jansman <ej...@apache.org>
Committed: Fri Aug 19 14:48:40 2016 +0200

----------------------------------------------------------------------
 .../private/include/event_admin_impl.h          | 13 +--
 .../event_admin/private/src/event_admin_impl.c  | 96 ++++++++++----------
 2 files changed, 52 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/aa2c3e28/event_admin/event_admin/private/include/event_admin_impl.h
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/private/include/event_admin_impl.h b/event_admin/event_admin/private/include/event_admin_impl.h
index f161543..65a5919 100644
--- a/event_admin/event_admin/private/include/event_admin_impl.h
+++ b/event_admin/event_admin/private/include/event_admin_impl.h
@@ -52,13 +52,13 @@ struct event_admin {
     celix_thread_t eventListProcessor;
     celix_thread_mutex_t *eventListLock;
     bool eventAdminRunning;
+    celix_thread_mutex_t *topicLock;
 };
 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;
+    celix_thread_mutex_t *channelLock;
 
 };
 /**
@@ -120,14 +120,6 @@ celix_status_t eventAdmin_findHandlersByTopic(event_admin_pt event_admin, const
  */
 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
@@ -175,5 +167,6 @@ celix_status_t eventAdmin_toString( event_pt *event, char *eventString);
 
 celix_status_t processEvent(event_admin_pt event_admin, event_pt event);
 
+celix_status_t eventAdmin_unlockTopic(event_admin_pt event_admin, const char *topic);
 void *eventProcessor(void *handle);
 #endif /* EVENT_ADMIN_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/aa2c3e28/event_admin/event_admin/private/src/event_admin_impl.c
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/private/src/event_admin_impl.c b/event_admin/event_admin/private/src/event_admin_impl.c
index e27e89c..ab50d86 100644
--- a/event_admin/event_admin/private/src/event_admin_impl.c
+++ b/event_admin/event_admin/private/src/event_admin_impl.c
@@ -93,6 +93,7 @@ celix_status_t eventAdmin_postEvent(event_admin_pt event_admin, event_pt event)
 }
 
 void *eventProcessor(void *handle) {
+    celix_status_t status = CELIX_SUCCESS;
     event_admin_pt *eventAdminPt = handle;
     event_pt event = NULL;
     int waitcounter = 1;
@@ -118,8 +119,19 @@ void *eventProcessor(void *handle) {
             }
         }
         if (event != NULL) {
-            processEvent((*eventAdminPt), event);
-            event = NULL;
+            status = processEvent((*eventAdminPt), event);
+            if (status == CELIX_SUCCESS) {
+                const char *topic;
+
+                eventAdmin_getTopic(&event, &topic);
+                eventAdmin_unlockTopic((*eventAdminPt), topic);
+                event = NULL;
+
+
+            } else {
+                //processing event unsuccesfull since topic is locked. put event back into list for later processing.
+                eventAdmin_postEvent(*eventAdminPt, event);
+            }
         }
 
         usleep(waitcounter * 1000);
@@ -136,16 +148,17 @@ celix_status_t processEvent(event_admin_pt event_admin, event_pt event) {
 
     array_list_pt event_handlers;
     arrayList_create(&event_handlers);
-    eventAdmin_lockHandlersList(event_admin, topic);
-    eventAdmin_findHandlersByTopic(event_admin, topic, event_handlers);
-
-    array_list_iterator_pt handlers_iterator = arrayListIterator_create(event_handlers);
-    while (arrayListIterator_hasNext(handlers_iterator)) {
-        event_handler_service_pt event_handler_service = (event_handler_service_pt) arrayListIterator_next(
-                handlers_iterator);
-        event_handler_service->handle_event(&event_handler_service->event_handler, event);
+    //eventAdmin_lockHandlersList(event_admin, topic);
+    status = eventAdmin_findHandlersByTopic(event_admin, topic, event_handlers);
+    if (status == CELIX_SUCCESS) {
+        array_list_iterator_pt handlers_iterator = arrayListIterator_create(event_handlers);
+        while (arrayListIterator_hasNext(handlers_iterator)) {
+            event_handler_service_pt event_handler_service = (event_handler_service_pt) arrayListIterator_next(
+                    handlers_iterator);
+            event_handler_service->handle_event(&event_handler_service->event_handler, event);
+        }
     }
-    eventAdmin_releaseHandersList(event_admin, topic);
+    //eventAdmin_releaseHandersList(event_admin, topic);
     return status;
 }
 celix_status_t eventAdmin_sendEvent(event_admin_pt event_admin, event_pt event) {
@@ -158,17 +171,33 @@ celix_status_t eventAdmin_findHandlersByTopic(event_admin_pt event_admin, const
 	hash_map_pt channels = event_admin->channels;
     channel_t channel = hashMap_get(channels, topic);
 	if (channel != NULL) {
-		if (channel->eventHandlers != NULL && !hashMap_isEmpty(channel->eventHandlers)) {
-			// iterate throught the handlers and add them to the array list for result.
-			hash_map_iterator_pt hashmap_iterator =  hashMapIterator_create(channel->eventHandlers);
-			while (hashMapIterator_hasNext(hashmap_iterator)) {
-				arrayList_add(event_handlers, (event_handler_service_pt) hashMapIterator_nextValue(hashmap_iterator));
-			}
-		}
+        status = celixThreadMutex_tryLock(channel->channelLock);
+        if (status == 0) {
+            if (channel->eventHandlers != NULL && !hashMap_isEmpty(channel->eventHandlers)) {
+                // iterate throught the handlers and add them to the array list for result.
+                hash_map_iterator_pt hashmap_iterator = hashMapIterator_create(channel->eventHandlers);
+                while (hashMapIterator_hasNext(hashmap_iterator)) {
+                    arrayList_add(event_handlers,
+                                  (event_handler_service_pt) hashMapIterator_nextValue(hashmap_iterator));
+                }
+            }
+        } else {
+            status = CELIX_ILLEGAL_STATE;
+        }
 	}
 	return status;
 }
 
+celix_status_t eventAdmin_unlockTopic(event_admin_pt event_admin, const char *topic) {
+    celix_status_t status = CELIX_SUCCESS;
+    hash_map_pt channels = event_admin->channels;
+    channel_t channel = hashMap_get(channels, topic);
+    if (channel != NULL) {
+        status = celixThreadMutex_unlock(channel->channelLock);
+    }
+    return status;
+}
+
 celix_status_t eventAdmin_createEventChannels(event_admin_pt *event_admin, const char *topic,
 											  event_handler_service_pt event_handler_service) {
 	celix_status_t status = CELIX_SUCCESS;
@@ -182,6 +211,8 @@ celix_status_t eventAdmin_createEventChannels(event_admin_pt *event_admin, const
             char *channel_name = strdup(topic);
 			channel->topic = channel_name;
 			channel->eventHandlers = hashMap_create(NULL,NULL,NULL,NULL);
+            channel->channelLock = calloc(1, sizeof(celix_thread_mutex_t));
+            celixThreadMutex_create(channel->channelLock, NULL);
 			hashMap_put((*event_admin)->channels, channel_name, channel);
 		}
     }
@@ -194,37 +225,10 @@ celix_status_t eventAdmin_createEventChannels(event_admin_pt *event_admin, const
 
 }
 
-celix_status_t eventAdmin_lockHandlersList(event_admin_pt event_admin, const char *topic) {
-	celix_status_t status = CELIX_SUCCESS;
-    /*channel_t channel = hashMap_get(event_admin->channels, topic);
-	if (channel != NULL) {
-        // TODO verify this will never deadlock...
-       // apr_status_t status;
-        do {
-         //   status = apr_thread_mutex_trylock(channel->channelLock);
-        } while (status != 0 && !APR_STATUS_IS_EBUSY(status));
-        logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_DEBUG, "LOCK: %s!", topic);
-    }*/
-	return status;
-}
-
-celix_status_t eventAdmin_releaseHandersList(event_admin_pt event_admin, const char *topic) {
-	celix_status_t status = CELIX_SUCCESS;
-    channel_t channel = hashMap_get(event_admin->channels, topic);
-	if (channel != NULL) {
-        // TODO check the result value...
-       // apr_thread_mutex_unlock(channel->channelLock);
-		//logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "UNLOCK: %s!", topic);
-    }
-	return status;
-}
-
 celix_status_t eventAdmin_addingService(void * handle, service_reference_pt ref, void **service) {
 	celix_status_t status = CELIX_SUCCESS;
-	printf("eventadmin adding service \n");
 	event_admin_pt  event_admin = handle;
 	status = bundleContext_getService(event_admin->context, ref, service);
-
   	return status;
 }
 
@@ -235,7 +239,6 @@ celix_status_t eventAdmin_addedService(void * handle, service_reference_pt ref,
 	event_handler_service = (event_handler_service_pt) service;
 	const char *topic = NULL;
 	serviceReference_getProperty(ref, (const char*)EVENT_TOPIC, &topic);
-	printf("original topic: %s\n", topic);
 	eventAdmin_createEventChannels(&event_admin,topic,event_handler_service);
 	return status;
 }
@@ -248,7 +251,6 @@ celix_status_t eventAdmin_modifiedService(void * handle, service_reference_pt re
 
 celix_status_t eventAdmin_removedService(void * handle, service_reference_pt ref, void * service) {
 	celix_status_t status = CELIX_SUCCESS;
-	printf("eventadmin removing service \n");
 	//event_admin_pt  event_admin = handle;
 	//hashMap_clear(event_admin->)
 	/*event_admin_pt event_admin = (event_admin_pt) handle;


[4/6] celix git commit: made Post event async. next step make lock and release handlers list async

Posted by ej...@apache.org.
made Post event async. next step make lock and release handlers list async


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

Branch: refs/heads/feature/event_admin
Commit: fd4174482f382e19f1f080e4c3ad08857d2b3772
Parents: 7291bef
Author: Erik Jansman <ej...@apache.org>
Authored: Thu Aug 18 15:21:35 2016 +0200
Committer: Erik Jansman <ej...@apache.org>
Committed: Thu Aug 18 15:21:35 2016 +0200

----------------------------------------------------------------------
 .../private/include/event_admin_impl.h          |  18 ++-
 .../private/src/event_admin_activator.c         |   3 +
 .../event_admin/private/src/event_admin_impl.c  | 127 +++++++++++++------
 .../event_admin/private/src/event_impl.c        |   3 -
 .../private/src/event_publisher_impl.c          |  15 +--
 5 files changed, 106 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/fd417448/event_admin/event_admin/private/include/event_admin_impl.h
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/private/include/event_admin_impl.h b/event_admin/event_admin/private/include/event_admin_impl.h
index 20b0f1b..f161543 100644
--- a/event_admin/event_admin/private/include/event_admin_impl.h
+++ b/event_admin/event_admin/private/include/event_admin_impl.h
@@ -42,11 +42,16 @@
 #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;
+    hash_map_pt channels;
+    array_list_pt event_handlers;
+    bundle_context_pt context;
+    log_helper_pt *loghelper;
+    linked_list_pt eventList;
+    celix_thread_t eventListProcessor;
+    celix_thread_mutex_t *eventListLock;
+    bool eventAdminRunning;
 };
 typedef struct channel *channel_t;
 struct channel {
@@ -64,6 +69,9 @@ struct channel {
  */
 celix_status_t eventAdmin_create( bundle_context_pt context, event_admin_pt *event_admin);
 
+celix_status_t eventAdmin_start(event_admin_pt *event_admin);
+
+celix_status_t eventAdmin_stop(event_admin_pt *event_admin);
 
 celix_status_t eventAdmin_destroy(event_admin_pt *event_admin);
 
@@ -165,5 +173,7 @@ 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);
 
+celix_status_t processEvent(event_admin_pt event_admin, event_pt event);
 
+void *eventProcessor(void *handle);
 #endif /* EVENT_ADMIN_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/fd417448/event_admin/event_admin/private/src/event_admin_activator.c
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/private/src/event_admin_activator.c b/event_admin/event_admin/private/src/event_admin_activator.c
index 37ec404..f951968 100644
--- a/event_admin/event_admin/private/src/event_admin_activator.c
+++ b/event_admin/event_admin/private/src/event_admin_activator.c
@@ -101,7 +101,9 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
 		serviceTracker_open(data->tracker);
 		properties = properties_create();
 		event_admin_service = activator->event_admin_service;
+		eventAdmin_start(&event_admin_service->eventAdmin);
 		bundleContext_registerService(context, (char *) EVENT_ADMIN_NAME, event_admin_service, properties, &activator->registration);
+
 	}
 	return status;
 }
@@ -111,6 +113,7 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context)
 	struct activator * data =  userData;
     serviceRegistration_unregister(data->registration);
 	serviceTracker_close(data->tracker);
+	eventAdmin_stop(&data->event_admin_service->eventAdmin);
 	return status;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/fd417448/event_admin/event_admin/private/src/event_admin_impl.c
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/private/src/event_admin_impl.c b/event_admin/event_admin/private/src/event_admin_impl.c
index fb5b26c..e27e89c 100644
--- a/event_admin/event_admin/private/src/event_admin_impl.c
+++ b/event_admin/event_admin/private/src/event_admin_impl.c
@@ -24,6 +24,7 @@
  *  \copyright	Apache License, Version 2.0
  */
 #include <stdlib.h>
+#include <unistd.h>
 
 #include "event_admin.h"
 #include "event_admin_impl.h"
@@ -33,7 +34,7 @@
 #include "celix_log.h"
 
 
-celix_status_t eventAdmin_create(bundle_context_pt context, event_admin_pt *event_admin){
+celix_status_t eventAdmin_create(bundle_context_pt context, event_admin_pt *event_admin) {
 	celix_status_t status = CELIX_SUCCESS;
 	*event_admin = calloc(1,sizeof(**event_admin));
 	if (!*event_admin) {
@@ -41,13 +42,31 @@ celix_status_t eventAdmin_create(bundle_context_pt context, event_admin_pt *even
     } else {
         (*event_admin)->channels = hashMap_create(utils_stringHash, utils_stringHash, utils_stringEquals, utils_stringEquals);
         (*event_admin)->context =context;
+        (*event_admin)->eventListLock = calloc(1, sizeof(celix_thread_mutex_t));
+        (*event_admin)->eventListProcessor = celix_thread_default;
+        (*event_admin)->eventAdminRunning = false;
+        linkedList_create(&(*event_admin)->eventList);//
+
         status = arrayList_create(&(*event_admin)->event_handlers);
     }
 	return status;
 }
 
-celix_status_t eventAdmin_destroy(event_admin_pt *event_admin)
+celix_status_t eventAdmin_start(event_admin_pt *event_admin) {
+    celix_status_t status = CELIX_SUCCESS;
+    status = celixThread_create(&(*event_admin)->eventListProcessor, NULL, eventProcessor, &(*event_admin));
+    celixThreadMutex_create((*event_admin)->eventListLock, NULL);
+    (*event_admin)->eventAdminRunning = true;
+    return status;
+}
+
+celix_status_t eventAdmin_stop(event_admin_pt *event_admin)
 {
+    (*event_admin)->eventAdminRunning = false;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t eventAdmin_destroy(event_admin_pt *event_admin) {
 	celix_status_t status = CELIX_SUCCESS;
     arrayList_destroy((*event_admin)->event_handlers);
 	free(*event_admin);
@@ -61,45 +80,76 @@ celix_status_t eventAdmin_getEventHandlersByChannel(bundle_context_pt context, c
 }
 
 celix_status_t eventAdmin_postEvent(event_admin_pt event_admin, event_pt event) {
-	celix_status_t status = CELIX_SUCCESS;
+    bool added = false;
+    while (event_admin->eventAdminRunning && added == false) {
+        if (celixThreadMutex_tryLock(event_admin->eventListLock) == 0) {
+            linkedList_addLast(event_admin->eventList, event);
+            celixThreadMutex_unlock(event_admin->eventListLock);
+            added = true;
+        }
+
+    }
+    return CELIX_SUCCESS;
+}
 
-	const char *topic;
+void *eventProcessor(void *handle) {
+    event_admin_pt *eventAdminPt = handle;
+    event_pt event = NULL;
+    int waitcounter = 1;
+    while ((*eventAdminPt)->eventAdminRunning) {
+        if (celixThreadMutex_tryLock((*eventAdminPt)->eventListLock) == 0) {
+            if (linkedList_isEmpty((*eventAdminPt)->eventList)) {
+                if (waitcounter < 10) {
+                    waitcounter++;
+                } else {
+                    waitcounter = 1;
+                }
+            } else {
+                event = linkedList_removeFirst((*eventAdminPt)->eventList);
+                waitcounter = 1;
 
-    eventAdmin_getTopic(&event, &topic);
+            }
+            celixThreadMutex_unlock((*eventAdminPt)->eventListLock);
+        } else {
+            if (waitcounter < 10) {
+                waitcounter++;
+            } else {
+                waitcounter = 1;
+            }
+        }
+        if (event != NULL) {
+            processEvent((*eventAdminPt), event);
+            event = NULL;
+        }
 
-	array_list_pt event_handlers;
-	arrayList_create(&event_handlers);
-	eventAdmin_lockHandlersList(event_admin, topic);
-	eventAdmin_findHandlersByTopic(event_admin, topic, event_handlers);
-    // TODO make this async!
-	array_list_iterator_pt handlers_iterator = arrayListIterator_create(event_handlers);
-	while (arrayListIterator_hasNext(handlers_iterator)) {
-		event_handler_service_pt event_handler_service = (event_handler_service_pt) arrayListIterator_next(handlers_iterator);
-		//logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_INFO, "handler found (POST EVENT) for %s", topic);
-		event_handler_service->handle_event(&event_handler_service->event_handler, event);
-	}
-	eventAdmin_releaseHandersList(event_admin, topic);
-	return status;
+        usleep(waitcounter * 1000);
+    }
+    return CELIX_SUCCESS;
 }
 
-celix_status_t eventAdmin_sendEvent(event_admin_pt event_admin, event_pt event) {
-	celix_status_t status = CELIX_SUCCESS;
+celix_status_t processEvent(event_admin_pt event_admin, event_pt event) {
+    celix_status_t status = CELIX_SUCCESS;
 
-	const char *topic;
-	eventAdmin_getTopic(&event, &topic);
-
-	array_list_pt event_handlers;
-	arrayList_create(&event_handlers);
-	eventAdmin_lockHandlersList(event_admin, topic);
-	eventAdmin_findHandlersByTopic(event_admin, topic, event_handlers);
-	array_list_iterator_pt handlers_iterator = arrayListIterator_create(event_handlers);
-	while (arrayListIterator_hasNext(handlers_iterator)) {
-		event_handler_service_pt event_handler_service = (event_handler_service_pt) arrayListIterator_next(handlers_iterator);
-	//	logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_INFO, "handler found (SEND EVENT) for %s", topic);
-		event_handler_service->handle_event(&event_handler_service->event_handler, event);
-	}
-	eventAdmin_releaseHandersList(event_admin, topic);
-	return status;
+    const char *topic;
+
+    eventAdmin_getTopic(&event, &topic);
+
+    array_list_pt event_handlers;
+    arrayList_create(&event_handlers);
+    eventAdmin_lockHandlersList(event_admin, topic);
+    eventAdmin_findHandlersByTopic(event_admin, topic, event_handlers);
+
+    array_list_iterator_pt handlers_iterator = arrayListIterator_create(event_handlers);
+    while (arrayListIterator_hasNext(handlers_iterator)) {
+        event_handler_service_pt event_handler_service = (event_handler_service_pt) arrayListIterator_next(
+                handlers_iterator);
+        event_handler_service->handle_event(&event_handler_service->event_handler, event);
+    }
+    eventAdmin_releaseHandersList(event_admin, topic);
+    return status;
+}
+celix_status_t eventAdmin_sendEvent(event_admin_pt event_admin, event_pt event) {
+    return processEvent(event_admin, event);
 }
 
 celix_status_t eventAdmin_findHandlersByTopic(event_admin_pt event_admin, const char *topic,
@@ -108,7 +158,6 @@ celix_status_t eventAdmin_findHandlersByTopic(event_admin_pt event_admin, const
 	hash_map_pt channels = event_admin->channels;
     channel_t channel = hashMap_get(channels, topic);
 	if (channel != NULL) {
-		//logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_INFO, "found channel: %s", topic);
 		if (channel->eventHandlers != NULL && !hashMap_isEmpty(channel->eventHandlers)) {
 			// iterate throught the handlers and add them to the array list for result.
 			hash_map_iterator_pt hashmap_iterator =  hashMapIterator_create(channel->eventHandlers);
@@ -116,8 +165,6 @@ celix_status_t eventAdmin_findHandlersByTopic(event_admin_pt event_admin, const
 				arrayList_add(event_handlers, (event_handler_service_pt) hashMapIterator_nextValue(hashmap_iterator));
 			}
 		}
-	} else {
-		//logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_WARNING, "no such channel: %s", topic);
 	}
 	return status;
 }
@@ -128,10 +175,6 @@ celix_status_t eventAdmin_createEventChannels(event_admin_pt *event_admin, const
     channel_t channel = hashMap_get((*event_admin)->channels, topic);
 	if (channel == NULL) {
 		//create channel
-		printf("Creating channel: %s", topic);
-
-
-
 		channel = calloc(1, sizeof(*channel));
 		if (!channel) {
             status = CELIX_ENOMEM;

http://git-wip-us.apache.org/repos/asf/celix/blob/fd417448/event_admin/event_admin/private/src/event_impl.c
----------------------------------------------------------------------
diff --git a/event_admin/event_admin/private/src/event_impl.c b/event_admin/event_admin/private/src/event_impl.c
index 8f65c91..5a95474 100644
--- a/event_admin/event_admin/private/src/event_impl.c
+++ b/event_admin/event_admin/private/src/event_impl.c
@@ -38,15 +38,12 @@ celix_status_t eventAdmin_createEvent(event_admin_pt event_admin, const char *to
 									  event_pt *event) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	//logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_DEBUG, "create event event admin pointer: %p",event_admin);
 
 
 	*event = calloc(1, sizeof(**event));
 	if(!*event){
 	       status = CELIX_ENOMEM;
-	   //    logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "No MEM");
 	}else {
-		//logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_INFO, "Event created : %s", topic);
 		(*event)->topic = topic;
 		(*event)->properties = properties;
 		properties_set((*event)->properties, (char *)EVENT_TOPIC, topic);

http://git-wip-us.apache.org/repos/asf/celix/blob/fd417448/event_admin/event_publisher/private/src/event_publisher_impl.c
----------------------------------------------------------------------
diff --git a/event_admin/event_publisher/private/src/event_publisher_impl.c b/event_admin/event_publisher/private/src/event_publisher_impl.c
index 49583b6..c21aaf1 100644
--- a/event_admin/event_publisher/private/src/event_publisher_impl.c
+++ b/event_admin/event_publisher/private/src/event_publisher_impl.c
@@ -55,14 +55,6 @@ celix_status_t eventPublisherStart(event_publisher_pt *event_publisher) {
     logHelper_start((*event_publisher)->loghelper);
     status = celixThread_create(&(*event_publisher)->sender, NULL, produceEvents, &(*event_publisher));
     celixThreadMutex_create((*event_publisher)->eventAdminAvailility,NULL);
-    if(status != CELIX_SUCCESS)
-    {
-        printf("failed to create thread\n");
-    }
-    else
-    {
-       printf("thread created \n");
-    }
     return status;
 }
 
@@ -91,14 +83,15 @@ void *produceEvents(void *handle) {
             if (event_admin_service != NULL) {
                 event_pt event;
                 properties_pt props = properties_create();
-                properties_set(props, "Error ", "No Error, Just testing");
+                properties_set(props, "Error ", "No Error, Just testing ");
+
                 (*event_admin_service)->createEvent(event_admin, "log/error/eventpublishers/event", props, &event);
                 (*event_admin_service)->postEvent(event_admin, event);
-                (*event_admin_service)->sendEvent(event_admin, event);
+                //  (*event_admin_service)->sendEvent(event_admin, event);
             }
             celixThreadMutex_unlock((*event_publisher)->eventAdminAvailility);
         }
-        usleep(1*10000);
+        usleep(1 * 1000000);
     }
     return CELIX_SUCCESS;
 }


[2/6] celix git commit: added celixThreadMutex_tryLock as non block alternative to celixThreadMutex_lock

Posted by ej...@apache.org.
added celixThreadMutex_tryLock as non block alternative to celixThreadMutex_lock


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

Branch: refs/heads/feature/event_admin
Commit: f358e33a714a820e1d07c9b809d48dfef691062d
Parents: 840f34b
Author: Erik Jansman <ej...@apache.org>
Authored: Wed Aug 17 15:35:03 2016 +0200
Committer: Erik Jansman <ej...@apache.org>
Committed: Wed Aug 17 15:35:59 2016 +0200

----------------------------------------------------------------------
 utils/private/src/celix_threads.c    | 4 ++++
 utils/public/include/celix_threads.h | 1 +
 2 files changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/f358e33a/utils/private/src/celix_threads.c
----------------------------------------------------------------------
diff --git a/utils/private/src/celix_threads.c b/utils/private/src/celix_threads.c
index 64bdf5b..d5b9437 100644
--- a/utils/private/src/celix_threads.c
+++ b/utils/private/src/celix_threads.c
@@ -97,6 +97,10 @@ celix_status_t celixThreadMutex_lock(celix_thread_mutex_t *mutex) {
     return pthread_mutex_lock(mutex);
 }
 
+celix_status_t celixThreadMutex_tryLock(celix_thread_mutex_t *mutex) {
+	return  pthread_mutex_trylock(mutex);
+}
+
 celix_status_t celixThreadMutex_unlock(celix_thread_mutex_t *mutex) {
     return pthread_mutex_unlock(mutex);
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/f358e33a/utils/public/include/celix_threads.h
----------------------------------------------------------------------
diff --git a/utils/public/include/celix_threads.h b/utils/public/include/celix_threads.h
index 8fc043e..c110154 100644
--- a/utils/public/include/celix_threads.h
+++ b/utils/public/include/celix_threads.h
@@ -73,6 +73,7 @@ enum {
 celix_status_t celixThreadMutex_create(celix_thread_mutex_t *mutex, celix_thread_mutexattr_t *attr);
 celix_status_t celixThreadMutex_destroy(celix_thread_mutex_t *mutex);
 celix_status_t celixThreadMutex_lock(celix_thread_mutex_t *mutex);
+celix_status_t celixThreadMutex_tryLock(celix_thread_mutex_t *mutex);
 celix_status_t celixThreadMutex_unlock(celix_thread_mutex_t *mutex);
 
 celix_status_t celixThreadMutexAttr_create(celix_thread_mutexattr_t *attr);


[6/6] celix git commit: changed travis config to make travis build this branch

Posted by ej...@apache.org.
changed travis config to make travis build this branch


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

Branch: refs/heads/feature/event_admin
Commit: a59205735806b42421601a74ba0d79243159375d
Parents: aa2c3e2
Author: Erik Jansman <ej...@apache.org>
Authored: Fri Aug 19 15:16:31 2016 +0200
Committer: Erik Jansman <ej...@apache.org>
Committed: Fri Aug 19 15:16:31 2016 +0200

----------------------------------------------------------------------
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/a5920573/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 1e86283..2a52b80 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -21,7 +21,7 @@ env:
         - COVERITY_SCAN_BUILD_COMMAND="make"
         - COVERITY_SCAN_PROJECT_NAME="Apache Celix"
         - COVERITY_SCAN_NOTIFICATION_EMAIL="bpetri@apache.org"
-        - COVERITY_SCAN_BRANCH_PATTERN="develop"
+        - COVERITY_SCAN_BRANCH_PATTERN="feature/event_admin"
         - COVERITY_SCAN_TOKEN="iomLSuaE8KOZLDog-KK7Ug"
         - COVERITY_SCAN_BUILD_URL="https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh"
         - COVERITY_SCAN_BUILD="curl -s $COVERITY_SCAN_BUILD_URL | sed 's/https:\/\/scan.coverity.com\/builds/https:\/\/scan.coverity.com\/builds?project=Apache+Celix/g' | bash"


[3/6] celix git commit: event publisher now thread safe. still 1 dangling service ref. now make event handler thread safe

Posted by ej...@apache.org.
event publisher now thread safe. still 1 dangling service ref. now make event handler thread safe


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

Branch: refs/heads/feature/event_admin
Commit: 7291bef802417bd7e5f7d1793b30198c5670a1d1
Parents: f358e33
Author: Erik Jansman <ej...@apache.org>
Authored: Wed Aug 17 15:36:47 2016 +0200
Committer: Erik Jansman <ej...@apache.org>
Committed: Wed Aug 17 15:36:47 2016 +0200

----------------------------------------------------------------------
 event_admin/CMakeLists.txt                      |  1 +
 .../private/include/event_publisher_impl.h      |  1 +
 .../private/src/event_publisher_impl.c          | 34 +++++++-------------
 3 files changed, 14 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/7291bef8/event_admin/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/event_admin/CMakeLists.txt b/event_admin/CMakeLists.txt
index 38e0d08..44d7169 100644
--- a/event_admin/CMakeLists.txt
+++ b/event_admin/CMakeLists.txt
@@ -35,4 +35,5 @@ if(EVENT_ADMIN)
 			NAME "event_publisher_consumer"
 			GROUP "event_publisher"
 			BUNDLES event_admin event_publisher event_handler shell_tui shell log_writer log_service )
+            #BUNDLES event_publisher shell_tui shell log_writer log_service )
 endif(EVENT_ADMIN)

http://git-wip-us.apache.org/repos/asf/celix/blob/7291bef8/event_admin/event_publisher/private/include/event_publisher_impl.h
----------------------------------------------------------------------
diff --git a/event_admin/event_publisher/private/include/event_publisher_impl.h b/event_admin/event_publisher/private/include/event_publisher_impl.h
index 5d6ba5b..ce38aa5 100644
--- a/event_admin/event_publisher/private/include/event_publisher_impl.h
+++ b/event_admin/event_publisher/private/include/event_publisher_impl.h
@@ -47,6 +47,7 @@ struct event_publisher {
 	bool running;
 	bool eventAdminAdded;
 	celix_thread_t sender;
+    celix_thread_mutex_t *eventAdminAvailility;
 	bundle_context_pt context;
 	log_helper_pt loghelper;
 };

http://git-wip-us.apache.org/repos/asf/celix/blob/7291bef8/event_admin/event_publisher/private/src/event_publisher_impl.c
----------------------------------------------------------------------
diff --git a/event_admin/event_publisher/private/src/event_publisher_impl.c b/event_admin/event_publisher/private/src/event_publisher_impl.c
index 9a43b80..49583b6 100644
--- a/event_admin/event_publisher/private/src/event_publisher_impl.c
+++ b/event_admin/event_publisher/private/src/event_publisher_impl.c
@@ -43,6 +43,7 @@ celix_status_t eventPublisherCreate(bundle_context_pt context, event_publisher_p
         (*event_publisher)->running = false;
         (*event_publisher)->context = context;
         (*event_publisher)->sender = celix_thread_default;
+        (*event_publisher)->eventAdminAvailility = calloc(1, sizeof(celix_thread_mutex_t));
         logHelper_create(context, &(*event_publisher)->loghelper);
     }
     return status;
@@ -53,13 +54,14 @@ celix_status_t eventPublisherStart(event_publisher_pt *event_publisher) {
 	(*event_publisher)->running = true;
     logHelper_start((*event_publisher)->loghelper);
     status = celixThread_create(&(*event_publisher)->sender, NULL, produceEvents, &(*event_publisher));
+    celixThreadMutex_create((*event_publisher)->eventAdminAvailility,NULL);
     if(status != CELIX_SUCCESS)
     {
         printf("failed to create thread\n");
     }
     else
     {
-       printf("trhead created \n");
+       printf("thread created \n");
     }
     return status;
 }
@@ -80,39 +82,24 @@ celix_status_t eventPublisherDestroy(event_publisher_pt *event_publisher)
 }
 
 void *produceEvents(void *handle) {
-    int i =0;
     event_publisher_pt *event_publisher = handle;
     while ((*event_publisher)->running ) {
 
-        if((*event_publisher)->eventAdminAdded) {
+        if((*event_publisher)->eventAdminAdded && celixThreadMutex_tryLock((*event_publisher)->eventAdminAvailility) == 0) {
             event_admin_service_pt *event_admin_service = &(*event_publisher)->event_admin_service;
             event_admin_pt event_admin = (*event_admin_service)->eventAdmin;
             if (event_admin_service != NULL) {
                 event_pt event;
                 properties_pt props = properties_create();
-                properties_set(props, "This is a key", "this is a value");
-                printf("create event\n");
+                properties_set(props, "Error ", "No Error, Just testing");
                 (*event_admin_service)->createEvent(event_admin, "log/error/eventpublishers/event", props, &event);
-                printf("post event\n");
                 (*event_admin_service)->postEvent(event_admin, event);
-                printf("send event\n");
                 (*event_admin_service)->sendEvent(event_admin, event);
-
-            } else {
-                printf("could not send event\n");
             }
+            celixThreadMutex_unlock((*event_publisher)->eventAdminAvailility);
         }
-        else
-        {
-            printf("No event admin\n");
-        }
-        for (i=0;i<10000000; i++){
-            continue;
-        }
+        usleep(1*10000);
     }
-    printf("end of thread\n");
-
-
     return CELIX_SUCCESS;
 }
 
@@ -128,9 +115,11 @@ celix_status_t eventPublisherAddingService(void * handle, service_reference_pt r
 celix_status_t eventPublisherAddedService(void * handle, service_reference_pt ref, void * service) {
     event_publisher_pt data = (event_publisher_pt) handle;
 	logHelper_log(data->loghelper, OSGI_LOGSERVICE_DEBUG, "[PUB] Event admin added.");
-    printf(" added event admin");
+    printf(" added event admin\n");
+    celixThreadMutex_lock(data->eventAdminAvailility);
     data->event_admin_service = (event_admin_service_pt) service;
     data->eventAdminAdded = true;
+    celixThreadMutex_unlock(data->eventAdminAvailility);
 	return CELIX_SUCCESS;
 }
 
@@ -143,9 +132,10 @@ celix_status_t eventPublisherModifiedService(void * handle, service_reference_pt
 celix_status_t eventPublisherRemovedService(void * handle, service_reference_pt ref, void * service) {
 	event_publisher_pt data = (event_publisher_pt) handle;
 	logHelper_log(data->loghelper, OSGI_LOGSERVICE_DEBUG, "[PUB] Event admin removed.");
-
+    celixThreadMutex_lock(data->eventAdminAvailility);
     data->event_admin_service = NULL;
     data->eventAdminAdded = false;
+    celixThreadMutex_unlock(data->eventAdminAvailility);
 	return CELIX_SUCCESS;
 }