celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject svn commit: r1644182 - in /celix/trunk/event_admin: event_admin/private/include/ event_admin/private/src/ event_handler/private/src/ event_publisher/private/include/ event_publisher/private/src/
Date Tue, 09 Dec 2014 21:07:22 GMT
Author: bpetri
Date: Tue Dec  9 21:07:22 2014
New Revision: 1644182

URL: http://svn.apache.org/r1644182
Log:
CELIX-182: replace event_admin fw_log calls w/ loghelper

Modified:
    celix/trunk/event_admin/event_admin/private/include/event_admin_impl.h
    celix/trunk/event_admin/event_admin/private/src/event_admin_activator.c
    celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c
    celix/trunk/event_admin/event_admin/private/src/event_impl.c
    celix/trunk/event_admin/event_handler/private/src/event_handler_impl.c
    celix/trunk/event_admin/event_publisher/private/include/event_publisher_impl.h
    celix/trunk/event_admin/event_publisher/private/src/event_publisher_impl.c

Modified: celix/trunk/event_admin/event_admin/private/include/event_admin_impl.h
URL: http://svn.apache.org/viewvc/celix/trunk/event_admin/event_admin/private/include/event_admin_impl.h?rev=1644182&r1=1644181&r2=1644182&view=diff
==============================================================================
--- celix/trunk/event_admin/event_admin/private/include/event_admin_impl.h (original)
+++ celix/trunk/event_admin/event_admin/private/include/event_admin_impl.h Tue Dec  9 21:07:22
2014
@@ -48,6 +48,7 @@ struct event_admin {
         hash_map_pt channels;
         array_list_pt event_handlers;
         bundle_context_pt context;
+        log_helper_pt *loghelper;
 };
 typedef struct channel *channel_t;
 struct channel {

Modified: celix/trunk/event_admin/event_admin/private/src/event_admin_activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/event_admin/event_admin/private/src/event_admin_activator.c?rev=1644182&r1=1644181&r2=1644182&view=diff
==============================================================================
--- celix/trunk/event_admin/event_admin/private/src/event_admin_activator.c (original)
+++ celix/trunk/event_admin/event_admin/private/src/event_admin_activator.c Tue Dec  9 21:07:22
2014
@@ -27,6 +27,8 @@
 #include <stdlib.h>
 
 #include "event_admin_impl.h"
+#include "log_helper.h"
+#include "log_service.h"
 
 struct activator {
 	apr_pool_t *pool;
@@ -35,6 +37,7 @@ 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,11 +53,12 @@ celix_status_t bundleActivator_create(bu
 			activator = apr_palloc(pool,sizeof(*activator));
 			activator->pool = pool;
 			activator->registration = NULL;
+			logHelper_create(context, &activator->loghelper);
+
 			*userData = activator;
 			event_admin_pt event_admin = NULL;
 			event_admin_service_pt event_admin_service = NULL;
 			status = eventAdmin_create(activator->pool,context, &event_admin);
-			fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "event admin activator pointer: %p ",event_admin);
 			if(status == CELIX_SUCCESS){
 				activator->event_admin = event_admin;
 				event_admin_service = apr_palloc(activator->pool, sizeof(event_admin_service));
@@ -62,6 +66,7 @@ celix_status_t bundleActivator_create(bu
 					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;
@@ -78,7 +83,6 @@ celix_status_t bundleActivator_create(bu
 				}
 			}
 			activator->event_admin_service = event_admin_service;
-			fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "event admin service pointer: %p ",event_admin_service);
 		}
 	}
 
@@ -108,7 +112,7 @@ celix_status_t bundleActivator_start(voi
 		event_admin_service = activator->event_admin_service;
 		//printf("pointer of event admin service %p\n",event_admin_service);
 		bundleContext_registerService(context, (char *) EVENT_ADMIN_NAME, event_admin_service,
properties, &activator->registration);
-
+		logHelper_start(activator->loghelper);
 	}
 	return status;
 }
@@ -116,13 +120,19 @@ celix_status_t bundleActivator_start(voi
 celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
 	celix_status_t status = CELIX_SUCCESS;
 	struct activator * data =  userData;
-		serviceTracker_close(data->tracker);
+
+	serviceTracker_close(data->tracker);
+	status = logHelper_stop(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;
+
+	status = logHelper_destroy(&data->loghelper);
 
 	return status;
 }

Modified: celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c?rev=1644182&r1=1644181&r2=1644182&view=diff
==============================================================================
--- celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c (original)
+++ celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c Tue Dec  9 21:07:22
2014
@@ -61,12 +61,12 @@ celix_status_t eventAdmin_postEvent(even
 	array_list_pt event_handlers;
 	arrayList_create(&event_handlers);
 	eventAdmin_lockHandlersList(event_admin, topic);
-	eventAdmin_findHandlersByTopic(event_admin->channels, topic, event_handlers);
+	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);
-		fw_log(logger, OSGI_FRAMEWORK_LOG_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);
@@ -82,22 +82,23 @@ celix_status_t eventAdmin_sendEvent(even
 	array_list_pt event_handlers;
 	arrayList_create(&event_handlers);
 	eventAdmin_lockHandlersList(event_admin, topic);
-	eventAdmin_findHandlersByTopic(event_admin->channels, topic, event_handlers);
+	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);
-		fw_log(logger, OSGI_FRAMEWORK_LOG_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);
 	return status;
 }
 
-celix_status_t eventAdmin_findHandlersByTopic(hash_map_pt channels, char *topic, array_list_pt
event_handlers) {
+celix_status_t eventAdmin_findHandlersByTopic(event_admin_pt event_admin, char *topic, array_list_pt
event_handlers) {
 	celix_status_t status = CELIX_SUCCESS;
+	hash_map_pt channels = event_admin->channels;
     channel_t channel = hashMap_get(channels, topic);
 	if (channel != NULL) {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_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);
@@ -106,7 +107,7 @@ celix_status_t eventAdmin_findHandlersBy
 			}
 		}
 	} else {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "no such channel: %s", topic);
+		logHelper_log(event_admin->loghelper, OSGI_LOGSERVICE_WARNING, "no such channel: %s",
topic);
 	}
 	return status;
 }
@@ -116,7 +117,7 @@ celix_status_t eventAdmin_createEventCha
     channel_t channel = hashMap_get((*event_admin)->channels, topic);
 	if (channel == NULL) {
 		//create channel
-		fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Creating channel: %s", topic);
+		logHelper_log((*event_admin)->loghelper, OSGI_LOGSERVICE_INFO, "Creating channel: %s",
topic);
 
         apr_pool_t *subPool = NULL;
         apr_pool_create(&subPool, (*event_admin)->pool);
@@ -184,7 +185,7 @@ celix_status_t eventAdmin_lockHandlersLi
         do {
             status = apr_thread_mutex_trylock(channel->channelLock);
         } while (status != 0 && !APR_STATUS_IS_EBUSY(status));
-        fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "LOCK: %s!", topic);
+        logHelper_log(event_admin->loghelper, OSGI_LOGSERVICE_DEBUG, "LOCK: %s!", topic);
     }
 	return status;
 }
@@ -195,7 +196,7 @@ celix_status_t eventAdmin_releaseHanders
 	if (channel != NULL) {
         // TODO check the result value...
         apr_thread_mutex_unlock(channel->channelLock);
-        fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "UNLOCK: %s!", topic);
+        logHelper_log(event_admin->loghelper, OSGI_LOGSERVICE_DEBUG, "UNLOCK: %s!", topic);
     }
 	return status;
 }
@@ -214,17 +215,19 @@ celix_status_t eventAdmin_addedService(v
 	event_handler_service = (event_handler_service_pt) service;
 	char *topic = NULL;
 	serviceReference_getProperty(ref, (char*)EVENT_TOPIC, &topic);
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "Original TOPIC: %s", topic);
+	logHelper_log(event_admin->loghelper, OSGI_LOGSERVICE_DEBUG, "Original TOPIC: %s", topic);
 	eventAdmin_createEventChannels(&event_admin,topic,event_handler_service);
 	return status;
 }
 
 celix_status_t eventAdmin_modifiedService(void * handle, service_reference_pt ref, void *
service) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "Event admin Modified");
+	event_admin_pt event_admin = (event_admin_pt) handle;
+	logHelper_log(event_admin->loghelper, OSGI_LOGSERVICE_DEBUG, "Event admin Modified");
 	return CELIX_SUCCESS;
 }
 
 celix_status_t eventAdmin_removedService(void * handle, service_reference_pt ref, void *
service) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "Event admin Removed %p", service);
+	event_admin_pt event_admin = (event_admin_pt) handle;
+	logHelper_log(event_admin->loghelper, OSGI_LOGSERVICE_DEBUG, "Event admin Removed %p",
service);
 	return CELIX_SUCCESS;
 }

Modified: celix/trunk/event_admin/event_admin/private/src/event_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/event_admin/event_admin/private/src/event_impl.c?rev=1644182&r1=1644181&r2=1644182&view=diff
==============================================================================
--- celix/trunk/event_admin/event_admin/private/src/event_impl.c (original)
+++ celix/trunk/event_admin/event_admin/private/src/event_impl.c Tue Dec  9 21:07:22 2014
@@ -33,6 +33,7 @@
 #include "stddef.h"
 #include <apr.h>
 #include <apr_pools.h>
+
 struct event {
 	char *topic;
 	properties_pt properties;
@@ -41,15 +42,15 @@ struct event {
 celix_status_t eventAdmin_createEvent(event_admin_pt event_admin, char *topic, properties_pt
properties, event_pt *event){
 	celix_status_t status = CELIX_SUCCESS;
 
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "create event event admin pointer: %p",event_admin);
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "pool create event: %p",event_admin->pool);
+	logHelper_log(event_admin->loghelper, OSGI_LOGSERVICE_DEBUG, "create event event admin
pointer: %p",event_admin);
+	logHelper_log(event_admin->loghelper, OSGI_LOGSERVICE_DEBUG, "pool create event: %p",event_admin->pool);
 
 	*event = apr_palloc(event_admin->pool,sizeof(**event));
 	if(!*event){
 	       status = CELIX_ENOMEM;
-	       fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "No MEM");
+	       logHelper_log(event_admin->loghelper, OSGI_LOGSERVICE_ERROR, "No MEM");
 	}else {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_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);

Modified: celix/trunk/event_admin/event_handler/private/src/event_handler_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/event_admin/event_handler/private/src/event_handler_impl.c?rev=1644182&r1=1644181&r2=1644182&view=diff
==============================================================================
--- celix/trunk/event_admin/event_handler/private/src/event_handler_impl.c (original)
+++ celix/trunk/event_admin/event_handler/private/src/event_handler_impl.c Tue Dec  9 21:07:22
2014
@@ -24,11 +24,15 @@
  *  \copyright	Apache License, Version 2.0
  */
 #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){
@@ -40,6 +44,10 @@ celix_status_t eventHandlerCreate(apr_po
         (*event_handler)->pool = pool;
         (*event_handler)->event_admin_service = NULL;
         (*event_handler)->context = context;
+
+        if (logHelper_create(context, &(*event_handler)->loghelper) == CELIX_SUCCESS)
{
+        	logHelper_start((*event_handler)->loghelper);
+        }
 	}
 	return status;
 }
@@ -49,7 +57,7 @@ celix_status_t eventHandlerHandleEvent(e
 	if (event != NULL) {
 		char *topic = NULL;
 		status = (*event_handler)->event_admin_service->getTopic(&event, &topic);
-		fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "[SUB] topic of event: %s.", topic);
+		logHelper_log((*event_handler)->loghelper, OSGI_LOGSERVICE_INFO, "[SUB] topic of event:
%s.", topic);
 
 		array_list_pt propertyNames;
 		arrayList_create(&propertyNames);
@@ -61,7 +69,7 @@ celix_status_t eventHandlerHandleEvent(e
 			char *value = NULL;
 			(*event_handler)->event_admin_service->getProperty(&event,key,&value);
 
-			fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "[SUB] Key: %s value: %s.", key, value);
+			logHelper_log((*event_handler)->loghelper, OSGI_LOGSERVICE_INFO, "[SUB] Key: %s value:
%s.", key, value);
 		}
 	}
 	return status;
@@ -76,20 +84,21 @@ celix_status_t eventHandlerAddingService
 }
 
 celix_status_t eventHandlerAddedService(void * handle, service_reference_pt ref, void * service)
{
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "[SUB] Event admin added.");
-	event_handler_pt data = handle;
+	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) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "[SUB] Event admin modified.");
+	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) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "[SUB] Event admin removed.");
-	event_handler_pt data = handle;
+	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;
 }

Modified: celix/trunk/event_admin/event_publisher/private/include/event_publisher_impl.h
URL: http://svn.apache.org/viewvc/celix/trunk/event_admin/event_publisher/private/include/event_publisher_impl.h?rev=1644182&r1=1644181&r2=1644182&view=diff
==============================================================================
--- celix/trunk/event_admin/event_publisher/private/include/event_publisher_impl.h (original)
+++ celix/trunk/event_admin/event_publisher/private/include/event_publisher_impl.h Tue Dec
 9 21:07:22 2014
@@ -37,6 +37,9 @@
 #include "service_listener.h"
 #include "service_registration.h"
 #include "event_constants.h"
+#include "log_helper.h"
+#include "log_service.h"
+
 #include <apr.h>
 #include <apr_pools.h>
 #include <apr_thread_proc.h>
@@ -49,6 +52,7 @@ struct event_publisher {
 	bool eventAdminAdded;
 	apr_thread_t *sender;
 	bundle_context_pt context;
+	log_helper_pt loghelper;
 };
 /**
  * @desc create the event publisher

Modified: celix/trunk/event_admin/event_publisher/private/src/event_publisher_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/event_admin/event_publisher/private/src/event_publisher_impl.c?rev=1644182&r1=1644181&r2=1644182&view=diff
==============================================================================
--- celix/trunk/event_admin/event_publisher/private/src/event_publisher_impl.c (original)
+++ celix/trunk/event_admin/event_publisher/private/src/event_publisher_impl.c Tue Dec  9
21:07:22 2014
@@ -40,12 +40,15 @@ celix_status_t eventPublisherCreate(apr_
         (*event_publisher)->running = false;
         (*event_publisher)->pool = pool;
         (*event_publisher)->context = context;
+
+        logHelper_create(context, &(*event_publisher)->loghelper);
     }
     return status;
 }
 
 celix_status_t eventPublisherStart(event_publisher_pt *event_publisher) {
 	(*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;
 }
@@ -54,6 +57,8 @@ celix_status_t eventPublisherStop(event_
 	(*event_publisher)->running = false;
 	apr_status_t status;
 	apr_thread_join(&status,(*event_publisher)->sender);
+	logHelper_stop((*event_publisher)->loghelper);
+	logHelper_destroy(&(*event_publisher)->loghelper);
 	return CELIX_SUCCESS;
 }
 
@@ -86,21 +91,24 @@ celix_status_t eventPublisherAddingServi
 }
 
 celix_status_t eventPublisherAddedService(void * handle, service_reference_pt ref, void *
service) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "[PUB] Event admin added.");
-    event_publisher_pt data = handle;
+    event_publisher_pt data = (event_publisher_pt) handle;
+	loghelper_log(data->loghelper, OSGI_LOGSERVICE_DEBUG, "[PUB] Event admin added.");
+
     data->event_admin_service = (event_admin_service_pt) service;
     data->eventAdminAdded = true;
 	return CELIX_SUCCESS;
 }
 
 celix_status_t eventPublisherModifiedService(void * handle, service_reference_pt ref, void
* service) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "[PUB] Event admin modified.");
+	event_publisher_pt data = (event_publisher_pt) handle;
+	loghelper_log(data->loghelper, OSGI_LOGSERVICE_DEBUG, "[PUB] Event admin modified.");
 	return CELIX_SUCCESS;
 }
 
 celix_status_t eventPublisherRemovedService(void * handle, service_reference_pt ref, void
* service) {
-	fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "[PUB] Event admin removed.");
-    event_publisher_pt data = handle;
+	event_publisher_pt data = (event_publisher_pt) handle;
+	loghelper_log(data->loghelper, OSGI_LOGSERVICE_DEBUG, "[PUB] Event admin removed.");
+
     data->event_admin_service = NULL;
     data->eventAdminAdded = false;
 	return CELIX_SUCCESS;



Mime
View raw message