celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ejans...@apache.org
Subject [4/7] celix git commit: Work on event handler and publisher demo alsmost working again
Date Wed, 13 Jul 2016 06:09:28 GMT
Work on event handler and publisher demo alsmost working again


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

Branch: refs/heads/develop
Commit: 514e274ca004c404427aded8a578608d764b51df
Parents: c72fbba
Author: Erik Jansman <ejansman@apache.org>
Authored: Tue Jul 12 15:06:17 2016 +0200
Committer: Ealanrian <erik@jansman.eu>
Committed: Tue Jul 12 15:06:17 2016 +0200

----------------------------------------------------------------------
 event_admin/CMakeLists.txt                      |  12 +-
 .../private/src/event_admin_activator.c         |   6 +-
 .../event_admin/private/src/event_admin_impl.c  |  14 +-
 event_admin/event_handler/CMakeLists.txt        |   5 +-
 .../private/include/event_handler_impl.h        |   2 +-
 .../private/src/event_handler_activator.c       |  77 +++---
 .../private/src/event_handler_impl.c            |  15 +-
 event_admin/event_publisher/CMakeLists.txt      |  14 +-
 .../private/include/event_publisher_impl.h      |  10 +-
 .../private/src/event_publisher_activator.c     |  37 +--
 .../private/src/event_publisher_impl.c          |  56 ++--
 event_admin/utils/private/src/event_impl.c      | 266 +++++++++----------
 12 files changed, 266 insertions(+), 248 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/514e274c/event_admin/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/event_admin/CMakeLists.txt b/event_admin/CMakeLists.txt
index 3414c90..e0d830c 100644
--- a/event_admin/CMakeLists.txt
+++ b/event_admin/CMakeLists.txt
@@ -20,8 +20,8 @@ if(EVENT_ADMIN)
 
 	#add_subdirectory(utils)
 	add_subdirectory(event_admin)
-#	add_subdirectory(event_handler)
-#	add_subdirectory(event_publisher)
+	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)
@@ -32,4 +32,12 @@ if(EVENT_ADMIN)
 			GROUP "event_admin/event_admin"
 			BUNDLES event_admin shell shell_tui log_service log_writer
 			)
+	add_deploy(event_handler_consumer
+			NAME "event_handler_consumer"
+			GROUP "event_handler"
+			BUNDLES event_handler event_admin shell shell_tui log_service log_writer)
+	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)
 endif(EVENT_ADMIN)

http://git-wip-us.apache.org/repos/asf/celix/blob/514e274c/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 bf89236..a5f8cb2 100644
--- a/event_admin/event_admin/private/src/event_admin_activator.c
+++ b/event_admin/event_admin/private/src/event_admin_activator.c
@@ -119,16 +119,16 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt
context)
 	serviceTracker_close(data->tracker);
 	status = logHelper_stop(data->loghelper);
     logHelper_destroy(&data->loghelper);
-    free(data->event_admin_service);
+
 	return status;
 }
 
 
 celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
 	celix_status_t status = CELIX_SUCCESS;
-    struct activator *activator = userData;
+    //stop  struct activator *activator = userData;
 
-    free(activator);
+    // free(activator);
 
 	return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/514e274c/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 d074323..a7eeb49 100644
--- a/event_admin/event_admin/private/src/event_admin_impl.c
+++ b/event_admin/event_admin/private/src/event_admin_impl.c
@@ -127,7 +127,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_INFO, "Creating channel: %s",
topic);
+		logHelper_log(*(*event_admin)->loghelper, OSGI_LOGSERVICE_ERROR, "Creating channel:
%s", topic);
 
 
 
@@ -171,7 +171,7 @@ 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_DEBUG, "UNLOCK: %s!", topic);
+		logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "UNLOCK: %s!", topic);
     }
 	return status;
 }
@@ -180,6 +180,8 @@ celix_status_t eventAdmin_addingService(void * handle, service_reference_pt
ref,
 	celix_status_t status = CELIX_SUCCESS;
 	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;
 }
 
@@ -190,19 +192,21 @@ 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, (char*)EVENT_TOPIC, &topic);
-	logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_DEBUG, "Original TOPIC: %s", topic);
+	logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "Original TOPIC: %s", 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_DEBUG, "Event admin Modified");
+	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;
-	logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_DEBUG, "Event admin Removed %p",
service);
+	logHelper_log(*event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "Event admin Removed %p",
service);
+	printf("Event admin Removed %p", service);
 	return CELIX_SUCCESS;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/514e274c/event_admin/event_handler/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/event_admin/event_handler/CMakeLists.txt b/event_admin/event_handler/CMakeLists.txt
index 6c269aa..c786a78 100644
--- a/event_admin/event_handler/CMakeLists.txt
+++ b/event_admin/event_handler/CMakeLists.txt
@@ -15,7 +15,6 @@
 # specific language governing permissions and limitations
 # under the License.
 
-find_package(APR REQUIRED)
 
 include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
 include_directories(private/include)
@@ -31,6 +30,6 @@ add_bundle(event_handler
 		${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
 )
 
-install_add_bundle(event_handler)
+install_bundle(event_handler)
 
-target_link_libraries(event_handler celix_framework celix_utils ${APR_LIBRARY} ${APRUTIL_LIBRARY})
+target_link_libraries(event_handler celix_framework celix_utils)

http://git-wip-us.apache.org/repos/asf/celix/blob/514e274c/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 a796733..44fc671 100644
--- a/event_admin/event_handler/private/include/event_handler_impl.h
+++ b/event_admin/event_handler/private/include/event_handler_impl.h
@@ -49,7 +49,7 @@ celix_status_t eventHandlerHandleEvent(event_handler_pt *instance, event_pt
even
  * @param apr_pool_t *pool the apr pool to contain the handler
  * @param event_handler_pt *event_handler. the event handler to be made.
  */
-celix_status_t eventHandlerCreate(apr_pool_t *pool, bundle_context_pt context,  event_handler_pt
*event_handler);
+celix_status_t eventHandlerCreate(bundle_context_pt context, 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/514e274c/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 cadde59..d39cfd9 100644
--- a/event_admin/event_handler/private/src/event_handler_activator.c
+++ b/event_admin/event_handler/private/src/event_handler_activator.c
@@ -31,7 +31,6 @@
 
 static const char * const EVENT_HANDLER_NAME = "demo";
 struct activator {
-	apr_pool_t *pool;
 	event_handler_service_pt event_handler_service;
 	service_registration_pt registration;
 	service_tracker_pt eventAdminTracker;
@@ -39,38 +38,29 @@ struct activator {
 
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
 	celix_status_t status = CELIX_SUCCESS;
-	apr_pool_t *pool = NULL;
-	apr_pool_t *parentPool;
 	struct activator *activator;
 
-	status = bundleContext_getMemoryPool(context, &parentPool);
-	if (status == CELIX_SUCCESS) {
-		if (apr_pool_create(&pool,parentPool) != APR_SUCCESS) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		} else {
-			activator = apr_palloc(pool, sizeof(*activator));
-			activator->pool = pool;
-			activator->registration = NULL;
-			*userData = activator;
-
-			event_handler_pt event_handler = NULL;
-			event_handler_service_pt event_handler_service = NULL;
-
-			status = eventHandlerCreate(activator->pool, context, &event_handler);
-			if (status == CELIX_SUCCESS) {
-				event_handler_service = apr_palloc(activator->pool, sizeof(event_handler_service));
-				if (!event_handler_service) {
-					status = CELIX_ENOMEM;
-				} else {
-					event_handler_service->event_handler = event_handler;
-					event_handler_service->handle_event = eventHandlerHandleEvent;
-				}
-			}
-			activator->event_handler_service = event_handler_service;
+    activator = calloc(1, sizeof(*activator));
+    activator->registration = NULL;
+    *userData = activator;
+
+    event_handler_pt event_handler = NULL;
+    event_handler_service_pt event_handler_service = NULL;
+
+    status = eventHandlerCreate(context, &event_handler);
+    if (status == CELIX_SUCCESS) {
+        event_handler_service = calloc(1, sizeof(event_handler_service));
+        if (!event_handler_service) {
+            status = CELIX_ENOMEM;
+        } else {
+            event_handler_service->event_handler = event_handler;
+            event_handler_service->handle_event = eventHandlerHandleEvent;
 		}
 	}
+    activator->event_handler_service = event_handler_service;
 
-	return status;
+
+    return status;
 }
 
 celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
@@ -79,26 +69,31 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt
context)
 
 	properties_pt properties = NULL;
 	properties = properties_create();
-	properties_set(properties,(char*)EVENT_HANDLER_SERVICE,(char *)EVENT_HANDLER_NAME);
-	properties_set(properties,(char*)EVENT_TOPIC, (char*) "log/error/eventpublishers/event");
+    properties_set(properties, (char *) EVENT_HANDLER_SERVICE, (const char *) EVENT_HANDLER_NAME);
+    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, (char *) EVENT_HANDLER_SERVICE, event_handler_service,
properties, &activator->registration);
-	apr_pool_t *pool;
-	status = bundleContext_getMemoryPool(context, &pool);
-	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, (char *) EVENT_ADMIN_NAME, customizer, &tracker);
-		activator->eventAdminTracker = tracker;
-		serviceTracker_open(tracker);
-	}
+    bundleContext_registerService(context, (const 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;
 }
 
 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;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/514e274c/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 24505e9..13b3c19 100644
--- a/event_admin/event_handler/private/src/event_handler_impl.c
+++ b/event_admin/event_handler/private/src/event_handler_impl.c
@@ -23,25 +23,24 @@
  *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
  *  \copyright	Apache License, Version 2.0
  */
+#include <stdlib.h>
 #include "event_handler.h"
 #include "log_helper.h"
 #include "log_service.h"
 
 struct event_handler {
-	apr_pool_t *pool;
 	event_admin_service_pt event_admin_service;
 	bundle_context_pt context;
 	log_helper_pt loghelper;
 
 };
 
-celix_status_t eventHandlerCreate(apr_pool_t *pool, bundle_context_pt context, event_handler_pt
*event_handler){
+celix_status_t eventHandlerCreate(bundle_context_pt context, event_handler_pt *event_handler)
{
 	celix_status_t status = CELIX_SUCCESS;
-	*event_handler = apr_palloc(pool, sizeof(**event_handler));
+    *event_handler = calloc(1, sizeof(**event_handler));
 	if (!*event_handler) {
         status = CELIX_ENOMEM;
 	} else {
-        (*event_handler)->pool = pool;
         (*event_handler)->event_admin_service = NULL;
         (*event_handler)->context = context;
 
@@ -55,7 +54,7 @@ celix_status_t eventHandlerCreate(apr_pool_t *pool, bundle_context_pt context,
e
 celix_status_t eventHandlerHandleEvent(event_handler_pt *event_handler, event_pt event) {
 	celix_status_t status = CELIX_SUCCESS;
 	if (event != NULL) {
-		char *topic = NULL;
+        const char *topic = NULL;
 		status = (*event_handler)->event_admin_service->getTopic(&event, &topic);
 		logHelper_log((*event_handler)->loghelper, OSGI_LOGSERVICE_INFO, "[SUB] topic of event:
%s.", topic);
 
@@ -65,8 +64,8 @@ celix_status_t eventHandlerHandleEvent(event_handler_pt *event_handler,
event_pt
 
 		array_list_iterator_pt propertyIter = arrayListIterator_create(propertyNames);
 		while (arrayListIterator_hasNext(propertyIter)) {
-			char *key = arrayListIterator_next(propertyIter);
-			char *value = NULL;
+            char *key = arrayListIterator_next(propertyIter);
+            const char *value = NULL;
 			(*event_handler)->event_admin_service->getProperty(&event,key,&value);
 
 			logHelper_log((*event_handler)->loghelper, OSGI_LOGSERVICE_INFO, "[SUB] Key: %s value:
%s.", key, value);
@@ -98,7 +97,7 @@ celix_status_t eventHandlerModifiedService(void * handle, service_reference_pt
r
 
 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.");
+    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/514e274c/event_admin/event_publisher/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/event_admin/event_publisher/CMakeLists.txt b/event_admin/event_publisher/CMakeLists.txt
index a7fd886..1999a9c 100644
--- a/event_admin/event_publisher/CMakeLists.txt
+++ b/event_admin/event_publisher/CMakeLists.txt
@@ -15,20 +15,20 @@
 # specific language governing permissions and limitations
 # under the License.
 
-find_package(APR REQUIRED)
 
 include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
 include_directories(private/include)
 include_directories(${PROJECT_SOURCE_DIR}/event_admin/event_admin/public/include)
 include_directories(${PROJECT_SOURCE_DIR}/log_service/public/include)
 
-add_bundle(event_publisher SOURCES
+add_bundle(event_publisher
     VERSION 0.0.0
-	private/src/event_publisher_activator.c
-	private/src/event_publisher_impl.c
-	${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c	
+		SOURCES
+		private/src/event_publisher_activator.c
+		private/src/event_publisher_impl.c
+		${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
 )
 
-install_add_bundle(event_publisher)
+install_bundle(event_publisher)
 
-target_link_libraries(event_publisher celix_framework celix_utils ${APR_LIBRARY} ${APRUTIL_LIBRARY})
+target_link_libraries(event_publisher celix_framework celix_utils)

http://git-wip-us.apache.org/repos/asf/celix/blob/514e274c/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 31f306d..a2cab83 100644
--- a/event_admin/event_publisher/private/include/event_publisher_impl.h
+++ b/event_admin/event_publisher/private/include/event_publisher_impl.h
@@ -40,17 +40,13 @@
 #include "log_helper.h"
 #include "log_service.h"
 
-#include <apr.h>
-#include <apr_pools.h>
-#include <apr_thread_proc.h>
 
 typedef struct event_publisher *event_publisher_pt;
 struct event_publisher {
-	apr_pool_t *pool;
 	event_admin_service_pt event_admin_service;
 	bool running;
 	bool eventAdminAdded;
-	apr_thread_t *sender;
+	celix_thread_t sender;
 	bundle_context_pt context;
 	log_helper_pt loghelper;
 };
@@ -60,7 +56,7 @@ struct event_publisher {
  * @param bundle_context_pt context the bundle context
  * @param event_publisher_pt *event_publisher. The publisher to be made.
  */
-celix_status_t eventPublisherCreate(apr_pool_t *pool, bundle_context_pt context, event_publisher_pt
*event_publisher);
+celix_status_t eventPublisherCreate(bundle_context_pt context, event_publisher_pt *event_publisher);
 /**
  * @desc start the event publisher. Starts the threads and trackers.
  * @param event_publisher_pt *event_publisher the publisher to start
@@ -82,4 +78,6 @@ celix_status_t eventPublisherRemovedService(void * handle, service_reference_pt
  * @param event_publisher_pt *event_publisher. pointer to the publisher.
  */
 celix_status_t eventPublisherStop(event_publisher_pt *event_publisher);
+
+void *produceEvents(void *handle);
 #endif /* EVENT_PUBLISHER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/514e274c/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 70cd1ec..279942f 100644
--- a/event_admin/event_publisher/private/src/event_publisher_activator.c
+++ b/event_admin/event_publisher/private/src/event_publisher_activator.c
@@ -24,13 +24,11 @@
  *  \copyright	Apache License, Version 2.0
  */
 #include <stdlib.h>
-#include <apr_thread_proc.h>
 
 
 #include "event_publisher_impl.h"
 
 struct activator {
-	apr_pool_t *pool;
 	bundle_context_pt context;
 	event_publisher_pt event_publisher;
 	service_tracker_pt tracker;
@@ -38,24 +36,18 @@ struct activator {
 
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
 	celix_status_t status = CELIX_SUCCESS;
-	apr_pool_t *pool = NULL;
-	apr_pool_t *parentPool;
+
 	struct activator *activator = NULL;
-	status = bundleContext_getMemoryPool(context, &parentPool);
+
+	activator = calloc(1, sizeof(*activator));
+	activator->context = context;
+	*userData = activator;
+
+	event_publisher_pt eventpublisher;
+	status = eventPublisherCreate(context, &eventpublisher);
 	if(status == CELIX_SUCCESS) {
-		if(apr_pool_create(&pool,parentPool) != APR_SUCCESS) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}else {
-			activator = apr_palloc(pool,sizeof(*activator));
-			activator->pool = pool;
-			activator->context = context;
-			*userData = activator;
-		}
-		event_publisher_pt eventpublisher;
-        status = eventPublisherCreate(activator->pool,context,&eventpublisher);
-        if(status == CELIX_SUCCESS) {
-            activator->event_publisher = eventpublisher;
-        }
+		activator->event_publisher = eventpublisher;
+
 	}
 
 	return status;
@@ -64,10 +56,9 @@ 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;
-	apr_pool_t *pool;
-	status = bundleContext_getMemoryPool(context, &pool);
-	if(status == CELIX_SUCCESS){
-		service_tracker_customizer_pt cust = NULL;
+
+
+	service_tracker_customizer_pt cust = NULL;
 		service_tracker_pt tracker = NULL;
 		data->context = context;
 		serviceTrackerCustomizer_create(data->event_publisher, eventPublisherAddingService,
eventPublisherAddedService, eventPublisherModifiedService, eventPublisherRemovedService, &cust);
@@ -75,7 +66,7 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt
context)
 		data->tracker = tracker;
 
 		serviceTracker_open(tracker);
-	}
+
 	eventPublisherStart(&data->event_publisher);
 	return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/514e274c/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 0b3fb40..6a8bc00 100644
--- a/event_admin/event_publisher/private/src/event_publisher_impl.c
+++ b/event_admin/event_publisher/private/src/event_publisher_impl.c
@@ -23,46 +23,69 @@
  * \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
  * \copyright	Apache License, Version 2.0
  */
+#include <stdlib.h>
 
+#include <unistd.h>
+#include <sys/time.h>
 #include "event_publisher_impl.h"
 
-static void *APR_THREAD_FUNC eventPublisherSendEventThread(apr_thread_t *thd, void *handle);
+celix_thread_start_t eventPublisherSendEventThread(celix_thread_t *thd, void *handle);
 
-celix_status_t eventPublisherCreate(apr_pool_t *pool, bundle_context_pt context, event_publisher_pt
*event_publisher) {
+celix_status_t eventPublisherCreate(bundle_context_pt context, event_publisher_pt *event_publisher)
{
     celix_status_t status = CELIX_SUCCESS;
-    *event_publisher = apr_palloc(pool, sizeof(**event_publisher));
+    *event_publisher = calloc(1, sizeof(**event_publisher));
     if (!*event_publisher) {
         status = CELIX_ENOMEM;
     } else {
         (*event_publisher)->event_admin_service = NULL;
-        (*event_publisher)->pool = NULL;
+
         (*event_publisher)->eventAdminAdded = false;
         (*event_publisher)->running = false;
-        (*event_publisher)->pool = pool;
         (*event_publisher)->context = context;
-
+        (*event_publisher)->sender = celix_thread_default;
         logHelper_create(context, &(*event_publisher)->loghelper);
     }
     return status;
 }
 
 celix_status_t eventPublisherStart(event_publisher_pt *event_publisher) {
+    celix_status_t status = CELIX_SUCCESS;
 	(*event_publisher)->running = true;
     logHelper_start((*event_publisher)->loghelper);
-	apr_thread_create(&(*event_publisher)->sender, NULL, eventPublisherSendEventThread,
event_publisher, (*event_publisher)->pool);
-	return CELIX_SUCCESS;
+    // celixThread_create((*event_publisher)->sender, NULL, eventPublisherSendEventThread,
event_publisher);
+    status = celixThread_create(&(*event_publisher)->sender, NULL, produceEvents,
&(*event_publisher));
+    return status;
 }
 
 celix_status_t eventPublisherStop(event_publisher_pt *event_publisher) {
 	(*event_publisher)->running = false;
-	apr_status_t status;
-	apr_thread_join(&status,(*event_publisher)->sender);
+    //void * status;
+    // celixThread_join((*event_publisher)->sender, &status);
 	logHelper_stop((*event_publisher)->loghelper);
 	logHelper_destroy(&(*event_publisher)->loghelper);
 	return CELIX_SUCCESS;
 }
 
-static void *APR_THREAD_FUNC eventPublisherSendEventThread(apr_thread_t *thd, void *handle)
{
+void *produceEvents(void *handle) {
+    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");
+        }
+    }
+    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) {
@@ -79,21 +102,22 @@ static void *APR_THREAD_FUNC eventPublisherSendEventThread(apr_thread_t
*thd, vo
             (*event_admin_service)->sendEvent(event_admin, event);
         }
     }
-	apr_thread_exit(thd, APR_SUCCESS);
-	return NULL;
-}
+    celixThread_exit( APR_SUCCESS);
+	return NULL;*
+}*/
 
 celix_status_t eventPublisherAddingService(void * handle, service_reference_pt ref, void
**service) {
 	celix_status_t status = CELIX_SUCCESS;
 	event_publisher_pt event_publisher = handle;
 	status = bundleContext_getService(event_publisher->context, ref, service);
-	return status;
+
+    return status;
 }
 
 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");
     data->event_admin_service = (event_admin_service_pt) service;
     data->eventAdminAdded = true;
 	return CELIX_SUCCESS;

http://git-wip-us.apache.org/repos/asf/celix/blob/514e274c/event_admin/utils/private/src/event_impl.c
----------------------------------------------------------------------
diff --git a/event_admin/utils/private/src/event_impl.c b/event_admin/utils/private/src/event_impl.c
index 3a5d07c..bd87358 100644
--- a/event_admin/utils/private/src/event_impl.c
+++ b/event_admin/utils/private/src/event_impl.c
@@ -1,133 +1,133 @@
-/**
- *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_impl.c
- *
- *  \Created on: Aug 22, 2013
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- *
- */
-
-
-#include "event.h"
-#include "event_constants.h"
-#include "celix_errno.h"
-#include "stddef.h"
-#include <apr.h>
-#include <apr_pools.h>
-struct event {
-	char *topic;
-	properties_pt properties;
-};
-
-celix_status_t createEvent(char *topic, properties_pt properties, apr_pool_t *pool, event_pt
*event){
-	celix_status_t status = CELIX_SUCCESS;
-
-	*event= apr_palloc(pool,sizeof(**event));
-	if(!*event){
-	       status = CELIX_ENOMEM;
-	}else {
-		(*event)->topic = topic;
-		(*event)->properties = properties;
-		properties_set((*event)->properties, (char *)EVENT_TOPIC, topic);
-	}
-	return status;
-}
-
-celix_status_t containsProperty(event_pt *event, char *property, bool *result){
-	celix_status_t status = CELIX_SUCCESS;
-	if((*event)==NULL || property == NULL){
-		status = CELIX_BUNDLE_EXCEPTION;
-	}else {
-		char * propertyValue = properties_get((*event)->properties,property);
-		if(propertyValue == NULL){
-			(*result)= false;
-		}else {
-			(*result) = true;
-		}
-	}
-	return status;
-}
-
-celix_status_t event_equals(event_pt *event, event_pt *compare, bool *result){
-	celix_status_t status = CELIX_SUCCESS;
-	if(event == compare){
-		(*result) = true;
-	}else {
-		int sizeofEvent = hashMap_size((*event)->properties);
-		int sizeofCompare = hashMap_size((*compare)->properties);
-		if(sizeofEvent == sizeofCompare){
-			(*result) = true;
-		}else {
-
-		}
-	}
-	return status;
-}
-
-celix_status_t getProperty(event_pt *event, char *propertyKey,  char **propertyValue){
-	celix_status_t status = CELIX_SUCCESS;
-	*propertyValue = properties_get((*event)->properties,propertyKey);
-
-	return status;
-}
-
-celix_status_t getPropertyNames(event_pt *event, array_list_pt *names){
-	celix_status_t status = CELIX_SUCCESS;
-	properties_pt properties =  (*event)->properties;
-	if (hashMap_size(properties) > 0) {
-		hash_map_iterator_pt iterator = hashMapIterator_create(properties);
-		while (hashMapIterator_hasNext(iterator)) {
-			hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
-			char * key =hashMapEntry_getKey(entry);
-			arrayList_add((*names),key);
-		}
-	}
-	return status;
-}
-
-celix_status_t getTopic(event_pt *event, char **topic){
-	celix_status_t status = CELIX_SUCCESS;
-	char *value;
-	value = properties_get((*event)->properties,(char*) EVENT_TOPIC);
-	*topic = value;
-
-	return status;
-}
-
-celix_status_t hashCode(event_pt *event, int *hashCode){
-	celix_status_t status = CELIX_SUCCESS;
-	return status;
-}
-
-celix_status_t matches(event_pt *event){
-	celix_status_t status = CELIX_SUCCESS;
-	return status;
-}
-
-celix_status_t toString(event_pt *event, char *eventString){
-	celix_status_t status = CELIX_SUCCESS;
-	return status;
-}
-
-
-
-
-
+///**
+// *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_impl.c
+// *
+// *  \Created on: Aug 22, 2013
+// *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+// *  \copyright	Apache License, Version 2.0
+// *
+// */
+//
+//
+//#include "event.h"
+//#include "event_constants.h"
+//#include "celix_errno.h"
+//#include "stddef.h"
+//#include <apr.h>
+//#include <apr_pools.h>
+//struct event {
+//	char *topic;
+//	properties_pt properties;
+//};
+//
+//celix_status_t createEvent(char *topic, properties_pt properties, apr_pool_t *pool, event_pt
*event){
+//	celix_status_t status = CELIX_SUCCESS;
+//
+//	*event= apr_palloc(pool,sizeof(**event));
+//	if(!*event){
+//	       status = CELIX_ENOMEM;
+//	}else {
+//		(*event)->topic = topic;
+//		(*event)->properties = properties;
+//		properties_set((*event)->properties, (char *)EVENT_TOPIC, topic);
+//	}
+//	return status;
+//}
+//
+//celix_status_t containsProperty(event_pt *event, char *property, bool *result){
+//	celix_status_t status = CELIX_SUCCESS;
+//	if((*event)==NULL || property == NULL){
+//		status = CELIX_BUNDLE_EXCEPTION;
+//	}else {
+//		char * propertyValue = properties_get((*event)->properties,property);
+//		if(propertyValue == NULL){
+//			(*result)= false;
+//		}else {
+//			(*result) = true;
+//		}
+//	}
+//	return status;
+//}
+//
+//celix_status_t event_equals(event_pt *event, event_pt *compare, bool *result){
+//	celix_status_t status = CELIX_SUCCESS;
+//	if(event == compare){
+//		(*result) = true;
+//	}else {
+//		int sizeofEvent = hashMap_size((*event)->properties);
+//		int sizeofCompare = hashMap_size((*compare)->properties);
+//		if(sizeofEvent == sizeofCompare){
+//			(*result) = true;
+//		}else {
+//
+//		}
+//	}
+//	return status;
+//}
+//
+//celix_status_t getProperty(event_pt *event, char *propertyKey,  char **propertyValue){
+//	celix_status_t status = CELIX_SUCCESS;
+//	*propertyValue = properties_get((*event)->properties,propertyKey);
+//
+//	return status;
+//}
+//
+//celix_status_t getPropertyNames(event_pt *event, array_list_pt *names){
+//	celix_status_t status = CELIX_SUCCESS;
+//	properties_pt properties =  (*event)->properties;
+//	if (hashMap_size(properties) > 0) {
+//		hash_map_iterator_pt iterator = hashMapIterator_create(properties);
+//		while (hashMapIterator_hasNext(iterator)) {
+//			hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
+//			char * key =hashMapEntry_getKey(entry);
+//			arrayList_add((*names),key);
+//		}
+//	}
+//	return status;
+//}
+//
+//celix_status_t getTopic(event_pt *event, char **topic){
+//	celix_status_t status = CELIX_SUCCESS;
+//	char *value;
+//	value = properties_get((*event)->properties,(char*) EVENT_TOPIC);
+//	*topic = value;
+//
+//	return status;
+//}
+//
+//celix_status_t hashCode(event_pt *event, int *hashCode){
+//	celix_status_t status = CELIX_SUCCESS;
+//	return status;
+//}
+//
+//celix_status_t matches(event_pt *event){
+//	celix_status_t status = CELIX_SUCCESS;
+//	return status;
+//}
+//
+//celix_status_t toString(event_pt *event, char *eventString){
+//	celix_status_t status = CELIX_SUCCESS;
+//	return status;
+//}
+//
+//
+//
+//
+//


Mime
View raw message