celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1652984 [2/5] - in /celix/branches/celix_config_admin: ./ cmake/cmake_celix/ dependency_manager_2/ deployment_admin/private/include/ deployment_admin/private/src/ device_access/device_access/ device_access/device_access/private/src/ event_...
Date Mon, 19 Jan 2015 12:26:55 GMT
Modified: celix/branches/celix_config_admin/examples/whiteboard/tracker_depman/private/src/dependency_activator.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/examples/whiteboard/tracker_depman/private/src/dependency_activator.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/examples/whiteboard/tracker_depman/private/src/dependency_activator.c (original)
+++ celix/branches/celix_config_admin/examples/whiteboard/tracker_depman/private/src/dependency_activator.c Mon Jan 19 12:26:54 2015
@@ -27,14 +27,16 @@
 #include <stdio.h>
 #include "celixbool.h"
 
-#include "dependency_activator_base.h"
-#include "service_component_private.h"
+#include "dm_activator_base.h"
+#include "dm_service_dependency.h"
+#include "dm_component.h"
 #include "publisher.h"
 #include "tracker.h"
 #include "log_service.h"
 #include "bundle_context.h"
 
-void * dm_create(bundle_context_pt context) {
+celix_status_t dm_create(bundle_context_pt context, void **userData) {
+	printf("Create\n");
 	struct data * data = malloc(sizeof(*data));
 	data->publishers = NULL;
 	arrayList_create(&data->publishers);
@@ -43,42 +45,60 @@ void * dm_create(bundle_context_pt conte
 	data->sender = 0;
 	data->service = NULL;
 	data->logger = NULL;
-	return data;
+	*userData = data;
+	return CELIX_SUCCESS;
 }
 
-void dm_init(void * userData, bundle_context_pt context, dependency_manager_pt manager) {
+celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
+	printf("Init\n");
 	struct data * data = (struct data *) userData;
-	service_pt service = NULL;
-	service_dependency_pt dep = NULL;
-	service_dependency_pt dep2 = NULL;
+	dm_component_pt service = NULL;
+	dm_service_dependency_pt dep = NULL;
+	dm_service_dependency_pt dep2 = NULL;
 
 	data->context = context;
 
-	service = dependencyActivatorBase_createService(manager);
-	serviceComponent_setImplementation(service, data);
+	component_create(context, manager, &service);
+	component_setImplementation(service, data);
+	component_setCallbacks(service, service_init, service_start, service_stop, service_destroy);
 
-	dep = dependencyActivatorBase_createServiceDependency(manager);
+	serviceDependency_create(&dep);
 	serviceDependency_setRequired(dep, false);
 	serviceDependency_setService(dep, PUBLISHER_NAME, "(|(id=A)(id=B))");
-	serviceDependency_setCallbacks(dep, tracker_addedServ, tracker_modifiedServ, tracker_removedServ);
-	serviceComponent_addServiceDependency(service, dep);
+	serviceDependency_setCallbacks(dep, tracker_addedServ, tracker_modifiedServ, tracker_removedServ, NULL);
+	component_addServiceDependency(service, dep, NULL);
 
-	dep2 = dependencyActivatorBase_createServiceDependency(manager);
+	serviceDependency_create(&dep2);
     serviceDependency_setRequired(dep2, false);
     serviceDependency_setService(dep2, (char *) OSGI_LOGSERVICE_NAME, NULL);
-    serviceDependency_setCallbacks(dep2, tracker_addLog, tracker_modifiedLog, tracker_removeLog);
-    serviceComponent_addServiceDependency(service, dep2);
+    serviceDependency_setCallbacks(dep2, tracker_addLog, tracker_modifiedLog, tracker_removeLog, NULL);
+    component_addServiceDependency(service, dep2, NULL);
 
 	data->service = service;
+	data->dep = dep;
+	data->dep2 = dep2;
+
 	dependencyManager_add(manager, service);
+
+	return CELIX_SUCCESS;
 }
 
-void dm_destroy(void * userData, bundle_context_pt context, dependency_manager_pt manager) {
+celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
 	struct data * data = (struct data *) userData;
 	dependencyManager_remove(manager, data->service);
+
+	component_removeServiceDependency(data->service, data->dep);
+	serviceDependency_destroy(&data->dep);
+
+	component_removeServiceDependency(data->service, data->dep2);
+	serviceDependency_destroy(&data->dep2);
+
+	component_destroy(&data->service);
+
 	arrayList_destroy(data->publishers);
 	data->publishers = NULL;
 	free(data);
 	data = NULL;
+	return CELIX_SUCCESS;
 }
 

Modified: celix/branches/celix_config_admin/examples/whiteboard/tracker_depman/private/src/tracker.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/examples/whiteboard/tracker_depman/private/src/tracker.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/examples/whiteboard/tracker_depman/private/src/tracker.c (original)
+++ celix/branches/celix_config_admin/examples/whiteboard/tracker_depman/private/src/tracker.c Mon Jan 19 12:26:54 2015
@@ -25,16 +25,18 @@
  */
 #include <stdlib.h>
 #include <stdio.h>
+#include <unistd.h>
+
 #include "celixbool.h"
 
-#include "service.h"
 #include "publisher.h"
 #include "tracker.h"
 #include "log_service.h"
 
-static void *APR_THREAD_FUNC dp_send(apr_thread_t *thd, void *handle) {
+static void *dp_send(void *handle) {
 	struct data * data = (struct data *) handle;
 	while (data->running) {
+		printf("Running\n");
 		int i;
 		for (i = 0; i < arrayList_size(data->publishers); i++) {
 			publisher_service_pt pub = (publisher_service_pt) arrayList_get(data->publishers, i);
@@ -43,69 +45,74 @@ static void *APR_THREAD_FUNC dp_send(apr
 				data->logger->log(data->logger->logger, OSGI_LOGSERVICE_INFO, "Sending message to publisher");
 			}
 		}
-		apr_sleep(1000000);
+		usleep(1000000);
 	}
-	apr_thread_exit(thd, APR_SUCCESS);
+	pthread_exit(NULL);
 	return NULL;
 }
 
-void service_init(void * userData) {
-
+celix_status_t service_init(void * userData) {
+	return CELIX_SUCCESS;
 }
 
-void service_start(void * userData) {
+celix_status_t service_start(void * userData) {
 	struct data * data = (struct data *) userData;
-	apr_pool_t *pool = NULL;
 
 	data->running = true;
-	bundleContext_getMemoryPool(data->context, &pool);
-	apr_thread_create(&data->sender, NULL, dp_send, data, pool);
+	pthread_create(&data->sender, NULL, dp_send, data);
+	return CELIX_SUCCESS;
 }
 
-void service_stop(void * userData) {
-	apr_status_t stat;
+celix_status_t service_stop(void * userData) {
 	struct data * data = (struct data *) userData;
 	data->running = false;
-	apr_thread_join(&stat, data->sender);
+	pthread_join(data->sender, NULL);
+	return CELIX_SUCCESS;
 }
 
-void service_destroy(void * userData) {
-
+celix_status_t service_destroy(void * userData) {
+	return CELIX_SUCCESS;
 }
 
-void tracker_addedServ(void * handle, service_reference_pt ref, void * service) {
+celix_status_t tracker_addedServ(void * handle, service_reference_pt ref, void * service) {
 	struct data * data = (struct data *) handle;
 	arrayList_add(data->publishers, service);
-	printf("Service Added\n");
+	printf("Service Added %p\n", service);
+	return CELIX_SUCCESS;
 }
 
-void tracker_modifiedServ(void * handle, service_reference_pt ref, void * service) {
+celix_status_t tracker_modifiedServ(void * handle, service_reference_pt ref, void * service) {
 	struct data * data = (struct data *) handle;
 	printf("Service Changed\n");
+	return CELIX_SUCCESS;
 }
 
-void tracker_removedServ(void * handle, service_reference_pt ref, void * service) {
+celix_status_t tracker_removedServ(void * handle, service_reference_pt ref, void * service) {
 	struct data * data = (struct data *) handle;
 	arrayList_removeElement(data->publishers, service);
 	printf("Service Removed\n");
+	return CELIX_SUCCESS;
 }
 
-void tracker_addLog(void *handle, service_reference_pt ref, void *service) {
+celix_status_t tracker_addLog(void *handle, service_reference_pt ref, void *service) {
     struct data * data = (struct data *) handle;
     printf("Add log\n");
     data->logger = service;
     ((log_service_pt) service)->log(((log_service_pt) service)->logger, OSGI_LOGSERVICE_DEBUG, "test");
+    return CELIX_SUCCESS;
 }
 
-void tracker_modifiedLog(void *handle, service_reference_pt ref, void *service) {
+celix_status_t tracker_modifiedLog(void *handle, service_reference_pt ref, void *service) {
     struct data * data = (struct data *) handle;
     printf("Modify log\n");
     data->logger = service;
     ((log_service_pt) service)->log(((log_service_pt) service)->logger, OSGI_LOGSERVICE_DEBUG, "test");
+    return CELIX_SUCCESS;
 }
 
-void tracker_removeLog(void *handle, service_reference_pt ref, void *service) {
+celix_status_t tracker_removeLog(void *handle, service_reference_pt ref, void *service) {
     struct data * data = (struct data *) handle;
     data->logger = NULL;
     printf("Remove log\n");
+    return CELIX_SUCCESS;
 }

Modified: celix/branches/celix_config_admin/framework/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/CMakeLists.txt?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/CMakeLists.txt (original)
+++ celix/branches/celix_config_admin/framework/CMakeLists.txt Mon Jan 19 12:26:54 2015
@@ -238,6 +238,7 @@ if (FRAMEWORK)
 	    
         add_executable(service_reference_test 
             private/test/service_reference_test.cpp
+            private/mock/properties_mock.c
             private/mock/service_registration_mock.c
             private/mock/service_registry_mock.c
             private/src/service_reference.c

Modified: celix/branches/celix_config_admin/framework/private/include/bundle_cache.h
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/include/bundle_cache.h?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/include/bundle_cache.h (original)
+++ celix/branches/celix_config_admin/framework/private/include/bundle_cache.h Mon Jan 19 12:26:54 2015
@@ -57,6 +57,15 @@ typedef struct bundleCache *bundle_cache
 celix_status_t bundleCache_create(properties_pt configurationMap, framework_logger_pt logger, bundle_cache_pt *bundle_cache);
 
 /**
+ * Frees the bundle_cache memory allocated in bundleCache_create
+ *
+ * @param bundle_cache Output parameter for the created cache
+ * @return Status code indication failure or success:
+ *      - CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t bundleCache_destroy(bundle_cache_pt *cache);
+
+/**
  * Recreates and retrieves the list of archives for the given bundle cache.
  * Archives are recreated on the bundle cache memory pool, the list for the results is created on the suplied pool, and is owned by the caller.
  *

Modified: celix/branches/celix_config_admin/framework/private/include/service_reference_private.h
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/include/service_reference_private.h?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/include/service_reference_private.h (original)
+++ celix/branches/celix_config_admin/framework/private/include/service_reference_private.h Mon Jan 19 12:26:54 2015
@@ -36,7 +36,7 @@ struct serviceReference {
 };
 
 celix_status_t serviceReference_create(bundle_pt bundle, service_registration_pt registration, service_reference_pt *reference);
-celix_status_t serviceReference_destroy(service_reference_pt reference);
+celix_status_t serviceReference_destroy(service_reference_pt *reference);
 
 celix_status_t serviceReference_invalidate(service_reference_pt reference);
 celix_status_t serviceRefernce_isValid(service_reference_pt reference, bool *result);

Modified: celix/branches/celix_config_admin/framework/private/include/service_registration_private.h
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/include/service_registration_private.h?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/include/service_registration_private.h (original)
+++ celix/branches/celix_config_admin/framework/private/include/service_registration_private.h Mon Jan 19 12:26:54 2015
@@ -61,6 +61,7 @@ bool serviceRegistration_isValid(service
 void serviceRegistration_invalidate(service_registration_pt registration);
 
 celix_status_t serviceRegistration_getService(service_registration_pt registration, bundle_pt bundle, void **service);
+celix_status_t serviceRegistration_ungetService(service_registration_pt registration, bundle_pt bundle, void **service);
 celix_status_t serviceRegistration_getProperties(service_registration_pt registration, properties_pt *properties);
 celix_status_t serviceRegistration_getRegistry(service_registration_pt registration, service_registry_pt *registry);
 celix_status_t serviceRegistration_getBundle(service_registration_pt registration, bundle_pt *bundle);

Modified: celix/branches/celix_config_admin/framework/private/mock/service_reference_mock.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/mock/service_reference_mock.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/mock/service_reference_mock.c (original)
+++ celix/branches/celix_config_admin/framework/private/mock/service_reference_mock.c Mon Jan 19 12:26:54 2015
@@ -47,6 +47,14 @@ celix_status_t serviceReference_invalida
 	return mock_c()->returnValue().value.intValue;
 }
 
+celix_status_t serviceRefernce_isValid(service_reference_pt reference, bool *result) {
+	mock_c()->actualCall("serviceRefernce_isValid")
+			->withPointerParameters("reference", reference)
+			->withOutputParameter("result", result);
+	return mock_c()->returnValue().value.intValue;
+}
+
+
 celix_status_t serviceReference_getServiceRegistration(service_reference_pt reference, service_registration_pt *registration) {
 	mock_c()->actualCall("serviceReference_getServiceRegistration")
 			->withPointerParameters("reference", reference)

Modified: celix/branches/celix_config_admin/framework/private/mock/service_registry_mock.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/mock/service_registry_mock.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/mock/service_registry_mock.c (original)
+++ celix/branches/celix_config_admin/framework/private/mock/service_registry_mock.c Mon Jan 19 12:26:54 2015
@@ -70,7 +70,7 @@ celix_status_t serviceRegistry_unregiste
 	return mock_c()->returnValue().value.intValue;
 }
 
-celix_status_t serviceRegistry_getServiceReferences(service_registry_pt registry, const char *serviceName, filter_pt filter, array_list_pt *references) {
+celix_status_t serviceRegistry_getServiceReferences(service_registry_pt registry, bundle_pt bundle, const char *serviceName, filter_pt filter, array_list_pt *references) {
 	mock_c()->actualCall("serviceRegistry_getServiceReferences");
 	return mock_c()->returnValue().value.intValue;
 }
@@ -101,12 +101,17 @@ service_registration_pt serviceRegistry_
 	return mock_c()->returnValue().value.pointerValue;
 }
 
-celix_status_t serviceRegistry_createServiceReference(service_registry_pt registry, service_registration_pt registration, service_reference_pt *reference) {
+celix_status_t serviceRegistry_createServiceReference(service_registry_pt registry, bundle_pt bundle, service_registration_pt registration, service_reference_pt *reference) {
 	mock_c()->actualCall("serviceRegistry_createServiceReference");
 	return mock_c()->returnValue().value.intValue;
 }
 
-celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry, array_list_pt *hooks) {
+celix_status_t serviceRegistry_getServiceReferencesForRegistration(service_registry_pt registry, service_registration_pt registration, array_list_pt *references) {
+	mock_c()->actualCall("serviceRegistry_getServiceReferencesForRegistration");
+	return mock_c()->returnValue().value.intValue;
+}
+
+celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry, bundle_pt bundle, array_list_pt *hooks) {
 	mock_c()->actualCall("serviceRegistry_getListenerHooks");
 	return mock_c()->returnValue().value.intValue;
 }

Modified: celix/branches/celix_config_admin/framework/private/mock/service_tracker_customizer_mock.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/mock/service_tracker_customizer_mock.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/mock/service_tracker_customizer_mock.c (original)
+++ celix/branches/celix_config_admin/framework/private/mock/service_tracker_customizer_mock.c Mon Jan 19 12:26:54 2015
@@ -35,6 +35,12 @@ celix_status_t serviceTrackerCustomizer_
 	return mock_c()->returnValue().value.intValue;
 }
 
+celix_status_t serviceTrackerCustomizer_destroy(service_tracker_customizer_pt customizer) {
+	mock_c()->actualCall("serviceTrackerCustomizer_destroy")
+			->withPointerParameters("customizer", customizer);
+	return mock_c()->returnValue().value.intValue;
+}
+
 celix_status_t serviceTrackerCustomizer_getHandle(service_tracker_customizer_pt customizer, void **handle) {
 	mock_c()->actualCall("serviceTrackerCustomizer_getHandle")
 			->withPointerParameters("customizer", customizer)

Modified: celix/branches/celix_config_admin/framework/private/src/bundle.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/src/bundle.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/src/bundle.c (original)
+++ celix/branches/celix_config_admin/framework/private/src/bundle.c Mon Jan 19 12:26:54 2015
@@ -72,7 +72,7 @@ celix_status_t bundle_create(bundle_pt *
         	status = CELIX_ILLEGAL_STATE;
         } else {
 			(*bundle)->lockCount = 0;
-			(*bundle)->lockThread = 0;
+			(*bundle)->lockThread = celix_thread_default;
 
 			resolver_addModule(module);
         }
@@ -108,7 +108,7 @@ celix_status_t bundle_createFromArchive(
 			status = CELIX_ILLEGAL_STATE;
 		} else {
 			(*bundle)->lockCount = 0;
-			(*bundle)->lockThread = 0;
+			(*bundle)->lockThread = celix_thread_default;
 
 			resolver_addModule(module);
 		}
@@ -557,7 +557,7 @@ celix_status_t bundle_unlock(bundle_pt b
 			}
 			bundle->lockCount--;
 			if (bundle->lockCount == 0) {
-				bundle->lockThread = 0;
+				bundle->lockThread = celix_thread_default;
 			}
 			*unlocked = true;
 		}

Modified: celix/branches/celix_config_admin/framework/private/src/bundle_cache.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/src/bundle_cache.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/src/bundle_cache.c (original)
+++ celix/branches/celix_config_admin/framework/private/src/bundle_cache.c Mon Jan 19 12:26:54 2015
@@ -67,6 +67,10 @@ celix_status_t bundleCache_create(proper
 }
 
 celix_status_t bundleCache_destroy(bundle_cache_pt *cache) {
+
+    free(*cache);
+    *cache = NULL;
+
     return CELIX_SUCCESS;
 }
 

Modified: celix/branches/celix_config_admin/framework/private/src/bundle_revision.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/src/bundle_revision.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/src/bundle_revision.c (original)
+++ celix/branches/celix_config_admin/framework/private/src/bundle_revision.c Mon Jan 19 12:26:54 2015
@@ -45,6 +45,7 @@ celix_status_t bundleRevision_create(fra
     	// TODO: This overwrites an existing revision, is this supposed to happen?
         int state = mkdir(root, S_IRWXU);
         if ((state != 0) && (errno != EEXIST)) {
+            free(revision);
             status = CELIX_FILE_IO_EXCEPTION;
         } else {
             if (inputFile != NULL) {
@@ -68,6 +69,10 @@ celix_status_t bundleRevision_create(fra
                 snprintf(manifest, sizeof(manifest), "%s/META-INF/MANIFEST.MF", revision->root);
 				status = manifest_createFromFile(manifest, &revision->manifest);
             }
+            else {
+            	free(revision);
+            }
+
         }
     }
 

Modified: celix/branches/celix_config_admin/framework/private/src/filter.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/src/filter.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/src/filter.c (original)
+++ celix/branches/celix_config_admin/framework/private/src/filter.c Mon Jan 19 12:26:54 2015
@@ -80,6 +80,9 @@ void filter_destroy(filter_pt filter) {
 			}
 			arrayList_destroy(filter->value);
 			filter->value = NULL;
+		} else  if (filter->operand == NOT) {
+			filter_destroy(filter->value);
+			filter->value = NULL;
 		} else {
 			free(filter->value);
 			filter->value = NULL;
@@ -314,7 +317,7 @@ char * filter_parseAttr(char * filterStr
 }
 
 char * filter_parseValue(char * filterString, int * pos) {
-	char * value = strdup("");
+	char *value = calloc(strlen(filterString) + 1, sizeof(*value));
 	int keepRunning = 1;
 
 	while (keepRunning) {
@@ -353,13 +356,12 @@ char * filter_parseValue(char * filterSt
 }
 
 array_list_pt filter_parseSubstring(char * filterString, int * pos) {
-	char * sub = (char *) malloc(strlen(filterString));
+	char *sub = calloc(strlen(filterString) + 1, sizeof(*sub));
 	array_list_pt operands = NULL;
 	int keepRunning = 1;
 	int size;
 
 	arrayList_create(&operands);
-	sub[0] = '\0';
 	while (keepRunning) {
 		char c = filterString[*pos];
 		

Modified: celix/branches/celix_config_admin/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/src/framework.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/src/framework.c (original)
+++ celix/branches/celix_config_admin/framework/private/src/framework.c Mon Jan 19 12:26:54 2015
@@ -186,7 +186,7 @@ celix_status_t framework_create(framewor
             (*framework)->shutdown = false;
             (*framework)->globalLockWaitersList = NULL;
             (*framework)->globalLockCount = 0;
-            (*framework)->globalLockThread = 0;
+            (*framework)->globalLockThread = celix_thread_default;
             (*framework)->nextBundleId = 1l;
             (*framework)->cache = NULL;
             (*framework)->installRequestMap = hashMap_create(utils_stringHash, utils_stringHash, utils_stringEquals, utils_stringEquals);
@@ -229,9 +229,6 @@ celix_status_t framework_destroy(framewo
 		bundle_pt bundle = (bundle_pt) hashMapEntry_getValue(entry);
 		bundle_archive_pt archive = NULL;
 
-		if (bundle_getArchive(bundle, &archive) == CELIX_SUCCESS) {
-			bundleArchive_destroy(archive);
-		}
 		bool systemBundle = false;
 		bundle_isSystemBundle(bundle, &systemBundle);
 		if (systemBundle) {
@@ -239,8 +236,11 @@ celix_status_t framework_destroy(framewo
             bundle_getContext(framework->bundle, &context);
             bundleContext_destroy(context);
 		}
+
+		if (bundle_getArchive(bundle, &archive) == CELIX_SUCCESS) {
+			bundleArchive_destroy(archive);
+		}
 		bundle_destroy(bundle);
-		hashMapIterator_remove(iterator);
 	}
 	hashMapIterator_destroy(iterator);
 	}
@@ -270,9 +270,15 @@ celix_status_t framework_destroy(framewo
 	    arrayList_destroy(framework->requests);
 	}
 	if(framework->installedBundleMap!=NULL){
-	hashMap_destroy(framework->installedBundleMap, false, false);
+		hashMap_destroy(framework->installedBundleMap, true, false);
 	}
 
+	bundleCache_destroy(&framework->cache);
+
+	unsetenv(OSGI_FRAMEWORK_FRAMEWORK_UUID);
+
+	free(framework);
+
 	return status;
 }
 
@@ -338,6 +344,7 @@ celix_status_t fw_init(framework_pt fram
 	    uuid_t uid;
         uuid_generate(uid);
         uuid_unparse(uid, uuid);
+        // #TODO setenv has a memory leak
         setenv(OSGI_FRAMEWORK_FRAMEWORK_UUID, uuid, true);
 
         framework->installedBundleMap = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
@@ -346,7 +353,7 @@ celix_status_t fw_init(framework_pt fram
     status = CELIX_DO_IF(status, bundle_getArchive(framework->bundle, &archive));
     status = CELIX_DO_IF(status, bundleArchive_getLocation(archive, &location));
     if (status == CELIX_SUCCESS) {
-        hashMap_put(framework->installedBundleMap, location, framework->bundle);
+        hashMap_put(framework->installedBundleMap, strdup(location), framework->bundle);
     }
     status = CELIX_DO_IF(status, bundle_getCurrentModule(framework->bundle, &module));
     if (status == CELIX_SUCCESS) {
@@ -527,7 +534,12 @@ celix_status_t fw_installBundle2(framewo
 
         if (archive == NULL) {
             id = framework_getNextBundleId(framework);
+
             status = CELIX_DO_IF(status, bundleCache_createArchive(framework->cache, id, location, inputFile, &archive));
+
+            if (status != CELIX_SUCCESS) {
+            	bundleArchive_destroy(archive);
+            }
         } else {
             // purge revision
             // multiple revisions not yet implemented
@@ -542,7 +554,7 @@ celix_status_t fw_installBundle2(framewo
 
                 framework_releaseGlobalLock(framework);
                 if (status == CELIX_SUCCESS) {
-                    hashMap_put(framework->installedBundleMap, location, *bundle);
+                    hashMap_put(framework->installedBundleMap, strdup(location), *bundle);
                 } else {
                     status = CELIX_BUNDLE_EXCEPTION;
                     status = CELIX_DO_IF(status, bundleArchive_closeAndDelete(archive));
@@ -550,6 +562,7 @@ celix_status_t fw_installBundle2(framewo
             }
         }
     }
+
     framework_releaseInstallLock(framework, location);
 
     if (status != CELIX_SUCCESS) {
@@ -921,9 +934,13 @@ celix_status_t fw_uninstallBundle(framew
     status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
     status = CELIX_DO_IF(status, bundleArchive_getLocation(archive, &location));
     if (status == CELIX_SUCCESS) {
-        // TODO sync issues?
-        target = (bundle_pt) hashMap_remove(framework->installedBundleMap, location);
 
+    	// TODO sync issues?
+        hash_map_entry_pt entry = hashMap_getEntry(framework->installedBundleMap, location);
+        char* entryLocation = hashMapEntry_getKey(entry);
+
+        target = (bundle_pt) hashMap_remove(framework->installedBundleMap, location);
+        free(entryLocation);
         if (target != NULL) {
             status = CELIX_DO_IF(status, bundle_setPersistentStateUninstalled(target));
             // fw_rememberUninstalledBundle(framework, target);
@@ -960,6 +977,7 @@ celix_status_t fw_uninstallBundle(framew
             if (refreshStatus != CELIX_SUCCESS) {
                 printf("Could not refresh bundle");
             } else {
+                bundleArchive_destroy(archive);
                 status = CELIX_DO_IF(status, bundle_destroy(bundle));
             }
 
@@ -1796,7 +1814,7 @@ celix_status_t framework_acquireBundleLo
 	celix_status_t status = CELIX_SUCCESS;
 
 	bool locked;
-	celix_thread_t lockingThread = 0;
+	celix_thread_t lockingThread = celix_thread_default;
 
 	int err = celixThreadMutex_lock(&framework->bundleLock);
 	if (err != CELIX_SUCCESS) {
@@ -1810,7 +1828,7 @@ celix_status_t framework_acquireBundleLo
 		thread_equalsSelf(framework->globalLockThread, &isSelf);
 
 		while (!lockable
-				|| ((framework->globalLockThread != 0)
+				|| (( celixThread_initalized(framework->globalLockThread) == true)
 				&& !isSelf)) {
 			bundle_state_e state;
 			bundle_getState(bundle, &state);
@@ -1820,7 +1838,7 @@ celix_status_t framework_acquireBundleLo
 			} else
 				bundle_getLockingThread(bundle, &lockingThread);
 				if (isSelf
-					&& (lockingThread != 0)
+					&& (celixThread_initalized(lockingThread) == true)
 					&& arrayList_contains(framework->globalLockWaitersList, &lockingThread)) {
 				framework->interrupted = true;
 //				celixThreadCondition_signal_thread_np(&framework->condition, bundle_getLockingThread(bundle));
@@ -1858,7 +1876,7 @@ celix_status_t framework_acquireBundleLo
 
 bool framework_releaseBundleLock(framework_pt framework, bundle_pt bundle) {
     bool unlocked;
-    celix_thread_t lockingThread = 0;
+    celix_thread_t lockingThread = celix_thread_default;
 
     celixThreadMutex_lock(&framework->bundleLock);
 
@@ -1868,7 +1886,7 @@ bool framework_releaseBundleLock(framewo
 		return false;
 	}
 	bundle_getLockingThread(bundle, &lockingThread);
-	if (lockingThread == 0) {
+	if (celixThread_initalized(lockingThread) == false) {
 	    celixThreadCondition_broadcast(&framework->condition);
 	}
 
@@ -1886,7 +1904,7 @@ bool framework_acquireGlobalLock(framewo
 	thread_equalsSelf(framework->globalLockThread, &isSelf);
 
 	while (!interrupted
-			&& (framework->globalLockThread != 0)
+			&& (celixThread_initalized(framework->globalLockThread) == true)
 			&& (!isSelf)) {
 		celix_thread_t currentThread = celixThread_self();
 		arrayList_add(framework->globalLockWaitersList, &currentThread);
@@ -1918,11 +1936,11 @@ celix_status_t framework_releaseGlobalLo
 		return CELIX_FRAMEWORK_EXCEPTION;
 	}
 
-	if (framework->globalLockThread == celixThread_self()) {
+	if (celixThread_equals(framework->globalLockThread, celixThread_self())) {
 		framework->globalLockCount--;
 		if (framework->globalLockCount == 0) {
-			framework->globalLockThread = 0;
-			if (celixThreadCondition_broadcast(&framework->condition) != 0) {
+			framework->globalLockThread = celix_thread_default;
+ 			if (celixThreadCondition_broadcast(&framework->condition) != 0) {
 				fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to broadcast global lock release.");
 				status = CELIX_FRAMEWORK_EXCEPTION;
 				// still need to unlock before returning
@@ -1980,6 +1998,11 @@ static void *framework_shutdown(void *fr
         }
 	}
 
+    hashMapIterator_destroy(iter);
+
+    pthread_cancel(fw->dispatcherThread.thread);
+    celixThread_join(fw->dispatcherThread, NULL);
+
 	err = celixThreadMutex_lock(&fw->mutex);
 	if (err != 0) {
 		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error locking the framework, cannot exit clean.");
@@ -2000,10 +2023,10 @@ static void *framework_shutdown(void *fr
 	}
 	err = celixThreadMutex_unlock(&fw->mutex);
 	if (err != 0) {
-		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking the framework, cannot exit clean.");
+//		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking the framework, cannot exit clean.");
 	}
 
-	fw_log(fw->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Shutdown done\n");
+//	fw_log(fw->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Shutdown done\n");
 	celixThread_exit((void *) CELIX_SUCCESS);
 
 	return NULL;

Modified: celix/branches/celix_config_admin/framework/private/src/module.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/src/module.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/src/module.c (original)
+++ celix/branches/celix_config_admin/framework/private/src/module.c Mon Jan 19 12:26:54 2015
@@ -206,6 +206,10 @@ void module_setWires(module_pt module, l
         module_removeDependentImporter(exporter, module);
     }
 
+    if (module->wires != NULL) {
+    	linkedList_destroy(module->wires);
+    }
+
 	module->wires = wires;
 
 	for (i = 0; (module->wires != NULL) && (i < linkedList_size(module->wires)); i++) {

Modified: celix/branches/celix_config_admin/framework/private/src/service_reference.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/src/service_reference.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/src/service_reference.c (original)
+++ celix/branches/celix_config_admin/framework/private/src/service_reference.c Mon Jan 19 12:26:54 2015
@@ -54,10 +54,11 @@ celix_status_t serviceReference_create(b
 	return status;
 }
 
-celix_status_t serviceReference_destroy(service_reference_pt reference) {
-	reference->bundle = NULL;
-	reference->registration = NULL;
-	free(reference);
+celix_status_t serviceReference_destroy(service_reference_pt *reference) {
+	(*reference)->bundle = NULL;
+	(*reference)->registration = NULL;
+	free(*reference);
+	*reference = NULL;
 	return CELIX_SUCCESS;
 }
 

Modified: celix/branches/celix_config_admin/framework/private/src/service_registration.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/src/service_registration.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/src/service_registration.c (original)
+++ celix/branches/celix_config_admin/framework/private/src/service_registration.c Mon Jan 19 12:26:54 2015
@@ -155,6 +155,14 @@ celix_status_t serviceRegistration_getSe
     return CELIX_SUCCESS;
 }
 
+celix_status_t serviceRegistration_ungetService(service_registration_pt registration, bundle_pt bundle, void **service) {
+    if (registration->isServiceFactory) {
+        service_factory_pt factory = registration->serviceFactory;
+        factory->ungetService(registration->serviceFactory, bundle, registration, service);
+    }
+    return CELIX_SUCCESS;
+}
+
 celix_status_t serviceRegistration_getProperties(service_registration_pt registration, properties_pt *properties) {
 	celix_status_t status = CELIX_SUCCESS;
 

Modified: celix/branches/celix_config_admin/framework/private/src/service_registry.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/src/service_registry.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/src/service_registry.c (original)
+++ celix/branches/celix_config_admin/framework/private/src/service_registry.c Mon Jan 19 12:26:54 2015
@@ -433,7 +433,7 @@ celix_status_t serviceRegistry_ungetServ
     array_list_pt references = hashMap_get(registry->serviceReferences, owner);
     if (references != NULL) {
         arrayList_removeElement(references, reference);
-        serviceReference_destroy(reference);
+        serviceReference_destroy(&reference);
         if (arrayList_size(references) > 0) {
             hashMap_put(registry->serviceReferences, owner, references);
         } else {
@@ -530,6 +530,10 @@ celix_status_t serviceRegistry_ungetServ
 		return CELIX_SUCCESS;
 	}
 
+	if (usage->count == 1) {
+		serviceRegistration_ungetService(registration, bundle, &usage->service);
+	}
+
 	usage->count--;
 
 	if ((!serviceRegistration_isValid(registration)) || (usage->count <= 0)) {

Modified: celix/branches/celix_config_admin/framework/private/src/service_tracker.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/src/service_tracker.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/src/service_tracker.c (original)
+++ celix/branches/celix_config_admin/framework/private/src/service_tracker.c Mon Jan 19 12:26:54 2015
@@ -86,6 +86,13 @@ celix_status_t serviceTracker_destroy(se
 	}
 	arrayList_destroy(tracker->tracked);
 
+	if (tracker->listener != NULL) {
+		free (tracker->listener);
+	}
+
+	free(tracker->filter);
+	free(tracker);
+
 	return CELIX_SUCCESS;
 }
 

Modified: celix/branches/celix_config_admin/framework/private/src/service_tracker_customizer.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/src/service_tracker_customizer.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/src/service_tracker_customizer.c (original)
+++ celix/branches/celix_config_admin/framework/private/src/service_tracker_customizer.c Mon Jan 19 12:26:54 2015
@@ -61,6 +61,8 @@ celix_status_t serviceTrackerCustomizer_
 	customizer->modifiedService = NULL;
 	customizer->removedService = NULL;
 
+	free(customizer);
+
 	return CELIX_SUCCESS;
 }
 

Modified: celix/branches/celix_config_admin/framework/private/test/service_registration_test.cpp
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/test/service_registration_test.cpp?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/test/service_registration_test.cpp (original)
+++ celix/branches/celix_config_admin/framework/private/test/service_registration_test.cpp Mon Jan 19 12:26:54 2015
@@ -79,8 +79,6 @@ TEST(service_registration, create) {
 
 	POINTERS_EQUAL(registry, registration->registry);
 	STRCMP_EQUAL("service", registration->className);
-	CHECK(registration->references);
-	LONGS_EQUAL(0, arrayList_size(registration->references));
 	POINTERS_EQUAL(bundle, registration->bundle);
 	POINTERS_EQUAL(properties, registration->properties);
 	POINTERS_EQUAL(service, registration->svcObj);
@@ -118,8 +116,6 @@ TEST(service_registration, createService
 
 	POINTERS_EQUAL(registry, registration->registry);
 	STRCMP_EQUAL("service", registration->className);
-	CHECK(registration->references);
-	LONGS_EQUAL(0, arrayList_size(registration->references));
 	POINTERS_EQUAL(bundle, registration->bundle);
 	POINTERS_EQUAL(properties, registration->properties);
 	POINTERS_EQUAL(service, registration->svcObj);
@@ -270,7 +266,7 @@ TEST(service_registration, getRegistryIl
 	celix_status_t status = serviceRegistration_getRegistry(registration, &actual);
 	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
 }
-
+ 
 TEST(service_registration, getServiceReferences) {
 	service_registration_pt registration = (service_registration_pt) malloc(sizeof(*registration));
 	array_list_pt references = (array_list_pt) 0x10;

Modified: celix/branches/celix_config_admin/framework/private/test/service_registry_test.cpp
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/test/service_registry_test.cpp?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/test/service_registry_test.cpp (original)
+++ celix/branches/celix_config_admin/framework/private/test/service_registry_test.cpp Mon Jan 19 12:26:54 2015
@@ -337,7 +337,8 @@ TEST(service_registry, getServiceReferen
 		.andReturnValue(CELIX_SUCCESS);
 
 	array_list_pt actual  = NULL;
-	serviceRegistry_getServiceReferences(registry, "test", NULL, &actual);
+
+	serviceRegistry_getServiceReferences(registry, NULL, "test", NULL, &actual);
 	LONGS_EQUAL(1, arrayList_size(actual));
 	POINTERS_EQUAL(reference, arrayList_get(actual, 0));
 }
@@ -584,7 +585,7 @@ TEST(service_registry, createServiceRefe
 		.andReturnValue(CELIX_SUCCESS);
 
 	service_reference_pt actual  = NULL;
-	serviceRegistry_createServiceReference(registry, registration, &actual);
+	serviceRegistry_createServiceReference(registry, NULL, registration, &actual);
 	POINTERS_EQUAL(reference, actual);
 }
 
@@ -622,7 +623,7 @@ TEST(service_registry, getListenerHooks)
 		.andReturnValue(CELIX_SUCCESS);
 
 	array_list_pt hooks = NULL;
-	celix_status_t status = serviceRegistry_getListenerHooks(registry, &hooks);
+	celix_status_t status = serviceRegistry_getListenerHooks(registry, NULL, &hooks);
 	LONGS_EQUAL(1, arrayList_size(hooks));
 	POINTERS_EQUAL(reference, arrayList_get(hooks, 0));
 }

Modified: celix/branches/celix_config_admin/framework/private/test/version_test.cpp
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/private/test/version_test.cpp?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/private/test/version_test.cpp (original)
+++ celix/branches/celix_config_admin/framework/private/test/version_test.cpp Mon Jan 19 12:26:54 2015
@@ -23,6 +23,8 @@
  *  \author     <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
  *  \copyright  Apache License, Version 2.0
  */
+#include <string.h>
+
 #include "CppUTest/TestHarness.h"
 #include "CppUTest/TestHarness_c.h"
 #include "CppUTest/CommandLineTestRunner.h"

Modified: celix/branches/celix_config_admin/framework/public/include/service_factory.h
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/framework/public/include/service_factory.h?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/framework/public/include/service_factory.h (original)
+++ celix/branches/celix_config_admin/framework/public/include/service_factory.h Mon Jan 19 12:26:54 2015
@@ -36,7 +36,7 @@ typedef struct service_factory * service
 struct service_factory {
     void *factory;
     celix_status_t (*getService)(void *factory, bundle_pt bundle, service_registration_pt registration, void **service);
-    celix_status_t (*ungetService)(void *factory, bundle_pt bundle, service_registration_pt registration);
+    celix_status_t (*ungetService)(void *factory, bundle_pt bundle, service_registration_pt registration, void **service);
 };
 
 

Modified: celix/branches/celix_config_admin/log_service/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/log_service/CMakeLists.txt?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/log_service/CMakeLists.txt (original)
+++ celix/branches/celix_config_admin/log_service/CMakeLists.txt Mon Jan 19 12:26:54 2015
@@ -40,6 +40,12 @@ if (LOG_SERVICE)
     install_bundle(log_service
         HEADERS
         	public/include/log_service.h
+        	public/include/log_reader_service.h
+        	public/include/log_listener.h
+        	public/include/log_entry.h
+        	public/include/log_helper.h
+        RESOURCES
+            public/src/log_helper.c
     )
     
     include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")

Modified: celix/branches/celix_config_admin/log_service/private/include/log.h
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/log_service/private/include/log.h?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/log_service/private/include/log.h (original)
+++ celix/branches/celix_config_admin/log_service/private/include/log.h Mon Jan 19 12:26:54 2015
@@ -27,17 +27,16 @@
 #ifndef LOG_H_
 #define LOG_H_
 
-#include <apr_general.h>
-
 #include "linked_list.h"
 #include "log_entry.h"
 #include "log_listener.h"
 
 typedef struct log * log_pt;
 
-celix_status_t log_create(apr_pool_t *pool, log_pt *logger);
+celix_status_t log_create(int max_size, bool store_debug, log_pt *logger);
+celix_status_t log_destroy(log_pt logger);
 celix_status_t log_addEntry(log_pt log, log_entry_pt entry);
-celix_status_t log_getEntries(log_pt log, apr_pool_t *memory_pool, linked_list_pt *list);
+celix_status_t log_getEntries(log_pt log, linked_list_pt *list);
 
 celix_status_t log_bundleChanged(void *listener, bundle_event_pt event);
 celix_status_t log_frameworkEvent(void *listener, framework_event_pt event);

Modified: celix/branches/celix_config_admin/log_service/private/include/log_factory.h
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/log_service/private/include/log_factory.h?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/log_service/private/include/log_factory.h (original)
+++ celix/branches/celix_config_admin/log_service/private/include/log_factory.h Mon Jan 19 12:26:54 2015
@@ -31,9 +31,10 @@
 
 typedef struct log_service_factory * log_service_factory_pt;
 
-celix_status_t logFactory_create(apr_pool_t *pool, log_pt log, service_factory_pt *factory);
+celix_status_t logFactory_create(log_pt log, service_factory_pt *factory);
+celix_status_t logFactory_destroy(service_factory_pt *factory);
 celix_status_t logFactory_getService(void *factory, bundle_pt bundle, service_registration_pt registration, void **service);
-celix_status_t logFactory_ungetService(void *factory, bundle_pt bundle, service_registration_pt registration);
+celix_status_t logFactory_ungetService(void *factory, bundle_pt bundle, service_registration_pt registration, void **service);
 
 
 #endif /* LOG_FACTORY_H_ */

Modified: celix/branches/celix_config_admin/log_service/private/include/log_reader_service_impl.h
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/log_service/private/include/log_reader_service_impl.h?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/log_service/private/include/log_reader_service_impl.h (original)
+++ celix/branches/celix_config_admin/log_service/private/include/log_reader_service_impl.h Mon Jan 19 12:26:54 2015
@@ -30,9 +30,10 @@
 #include "log_reader_service.h"
 #include "log.h"
 
-celix_status_t logReaderService_create(log_pt log, apr_pool_t *pool, log_reader_data_pt *reader);
+celix_status_t logReaderService_create(log_pt log, log_reader_data_pt *reader);
+celix_status_t logReaderService_destroy(log_reader_data_pt *reader);
 
-celix_status_t logReaderService_getLog(log_reader_data_pt reader, apr_pool_t *memory_pool, linked_list_pt *list);
+celix_status_t logReaderService_getLog(log_reader_data_pt reader, linked_list_pt *list);
 
 celix_status_t logReaderService_addLogListener(log_reader_data_pt reader, log_listener_pt listener);
 celix_status_t logReaderService_removeLogListener(log_reader_data_pt reader, log_listener_pt listener);

Modified: celix/branches/celix_config_admin/log_service/private/include/log_service_impl.h
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/log_service/private/include/log_service_impl.h?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/log_service/private/include/log_service_impl.h (original)
+++ celix/branches/celix_config_admin/log_service/private/include/log_service_impl.h Mon Jan 19 12:26:54 2015
@@ -30,7 +30,8 @@
 #include "log_service.h"
 #include "log.h"
 
-celix_status_t logService_create(log_pt log, bundle_pt bundle, apr_pool_t *pool, log_service_data_pt *logger);
+celix_status_t logService_create(log_pt log, bundle_pt bundle, log_service_data_pt *logger);
+celix_status_t logService_destroy(log_service_data_pt *logger);
 celix_status_t logService_log(log_service_data_pt logger, log_level_t level, char * message);
 celix_status_t logService_logSr(log_service_data_pt logger, service_reference_pt reference, log_level_t level, char * message);
 

Modified: celix/branches/celix_config_admin/log_service/private/src/log.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/log_service/private/src/log.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/log_service/private/src/log.c (original)
+++ celix/branches/celix_config_admin/log_service/private/src/log.c Mon Jan 19 12:26:54 2015
@@ -24,127 +24,144 @@
  *  \copyright	Apache License, Version 2.0
  */
 #include <stdlib.h>
-#include <apr_thread_cond.h>
-#include <apr_thread_mutex.h>
-#include <apr_thread_proc.h>
 
 #include "log.h"
 #include "linked_list_iterator.h"
 #include "array_list.h"
 
 struct log {
-    linked_list_pt entries;
-    apr_thread_mutex_t *lock;
+	linked_list_pt entries;
+	celix_thread_mutex_t lock;
 
-    array_list_pt listeners;
-    array_list_pt listenerEntries;
+	array_list_pt listeners;
+	array_list_pt listenerEntries;
 
-    apr_thread_t *listenerThread;
-    bool running;
+	celix_thread_t listenerThread;
+	bool running;
 
-    apr_thread_cond_t *entriesToDeliver;
-    apr_thread_mutex_t *deliverLock;
-    apr_thread_mutex_t *listenerLock;
+	celix_thread_cond_t entriesToDeliver;
+	celix_thread_mutex_t deliverLock;
+	celix_thread_mutex_t listenerLock;
 
-    apr_pool_t *pool;
+	int max_size;
+	bool store_debug;
 };
 
 static celix_status_t log_startListenerThread(log_pt logger);
 static celix_status_t log_stopListenerThread(log_pt logger);
 
-void * APR_THREAD_FUNC log_listenerThread(apr_thread_t *thread, void *data);
-apr_status_t log_destroy(void *logp);
 
-celix_status_t log_create(apr_pool_t *pool, log_pt *logger) {
-    celix_status_t status = CELIX_SUCCESS;
+static void *log_listenerThread(void *data);
 
-    *logger = apr_palloc(pool, sizeof(**logger));
-    if (*logger == NULL) {
-        status = CELIX_ENOMEM;
-    } else {
-        apr_status_t apr_status;
-
-        apr_pool_pre_cleanup_register(pool, *logger, log_destroy);
-        linkedList_create(&(*logger)->entries);
-        apr_thread_mutex_create(&(*logger)->lock, APR_THREAD_MUTEX_UNNESTED, pool);
+celix_status_t log_create(int max_size, bool store_debug, log_pt *logger) {
+	celix_status_t status = CELIX_ENOMEM;
+
+	*logger = calloc(1, sizeof(**logger));
+
+	if (*logger != NULL) {
+		linkedList_create(&(*logger)->entries);
+
+		status = celixThreadMutex_create(&(*logger)->lock, NULL);
+
+		(*logger)->listeners = NULL;
+		(*logger)->listenerEntries = NULL;
+		(*logger)->listenerThread = celix_thread_default;
+		(*logger)->running = false;
+
+		(*logger)->max_size = max_size;
+		(*logger)->store_debug = store_debug;
 
-        (*logger)->pool = pool;
-        (*logger)->listeners = NULL;
 		arrayList_create(&(*logger)->listeners);
-        (*logger)->listenerEntries = NULL;
-        arrayList_create(&(*logger)->listenerEntries);
-        (*logger)->listenerThread = NULL;
-        (*logger)->running = false;
-        apr_status = apr_thread_cond_create(&(*logger)->entriesToDeliver, pool);
-        if (apr_status != APR_SUCCESS) {
-            status = CELIX_INVALID_SYNTAX;
-        } else {
-            apr_status = apr_thread_mutex_create(&(*logger)->deliverLock, 0, pool);
-            if (apr_status != APR_SUCCESS) {
-                status = CELIX_INVALID_SYNTAX;
-            } else {
-                apr_status = apr_thread_mutex_create(&(*logger)->listenerLock, 0, pool);
-                if (apr_status != APR_SUCCESS) {
-                    status = CELIX_INVALID_SYNTAX;
-                } else {
-                    // done
-                }
-            }
-        }
-    }
+		arrayList_create(&(*logger)->listenerEntries);
 
-    return status;
+		if (celixThreadCondition_init(&(*logger)->entriesToDeliver, NULL) != CELIX_SUCCESS) {
+			status = CELIX_INVALID_SYNTAX;
+		}
+		else if (celixThreadMutex_create(&(*logger)->deliverLock, NULL) != CELIX_SUCCESS) {
+			status = CELIX_INVALID_SYNTAX;
+		}
+		else if (celixThreadMutex_create(&(*logger)->listenerLock, NULL) != CELIX_SUCCESS) {
+			status = CELIX_INVALID_SYNTAX;
+		}
+		else {
+			status = CELIX_SUCCESS;
+		}
+	}
+
+	return status;
 }
 
-apr_status_t log_destroy(void *logp) {
-	log_pt log = logp;
-	apr_thread_mutex_destroy(log->listenerLock);
-	apr_thread_mutex_destroy(log->deliverLock);
-	apr_thread_cond_destroy(log->entriesToDeliver);
-	arrayList_destroy(log->listenerEntries);
-	arrayList_destroy(log->listeners);
-	linkedList_destroy(log->entries);
-	apr_thread_mutex_destroy(log->lock);
+celix_status_t log_destroy(log_pt logger) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	celixThreadMutex_destroy(&logger->listenerLock);
+	celixThreadMutex_destroy(&logger->deliverLock);
+	celixThreadCondition_destroy(&logger->entriesToDeliver);
+
+	arrayList_destroy(logger->listenerEntries);
+	arrayList_destroy(logger->listeners);
+	linked_list_iterator_pt iter = linkedListIterator_create(logger->entries, 0);
+	while (linkedListIterator_hasNext(iter)) {
+	    log_entry_pt entry = linkedListIterator_next(iter);
+	    logEntry_destroy(&entry);
+	}
+	linkedListIterator_destroy(iter);
+
+	linkedList_destroy(logger->entries);
 
-	return APR_SUCCESS;
+	celixThreadMutex_destroy(&logger->lock);
+
+	free(logger);
+
+	return status;
 }
 
 celix_status_t log_addEntry(log_pt log, log_entry_pt entry) {
-    apr_thread_mutex_lock(log->lock);
-    linkedList_addElement(log->entries, entry);
+	celixThreadMutex_lock(&log->lock);
 
-    // notify any listeners
-    if (log->listenerThread != NULL)
-    {
-        arrayList_add(log->listenerEntries, entry);
-        apr_thread_cond_signal(log->entriesToDeliver);
-    }
+	if (log->max_size != 0) {
+		if (log->store_debug || entry->level != OSGI_LOGSERVICE_DEBUG) {
+			linkedList_addElement(log->entries, entry);
+		}
+
+		if (log->max_size != -1) {
+			if (linkedList_size(log->entries) > log->max_size) {
+				log_entry_pt entry = linkedList_removeFirst(log->entries);
+				if (entry) {
+					logEntry_destroy(&entry);
+				}
+			}
+		}
+	}
+
+	arrayList_add(log->listenerEntries, entry);
+	celixThreadCondition_signal(&log->entriesToDeliver);
 
-    apr_thread_mutex_unlock(log->lock);
-    return CELIX_SUCCESS;
+	celixThreadMutex_unlock(&log->lock);
+	return CELIX_SUCCESS;
 }
 
-celix_status_t log_getEntries(log_pt log, apr_pool_t *memory_pool, linked_list_pt *list) {
-    linked_list_pt entries = NULL;
-    if (linkedList_create(&entries) == CELIX_SUCCESS) {
-        linked_list_iterator_pt iter = NULL;
+celix_status_t log_getEntries(log_pt log, linked_list_pt *list) {
+	linked_list_pt entries = NULL;
+	if (linkedList_create(&entries) == CELIX_SUCCESS) {
+		linked_list_iterator_pt iter = NULL;
 
-        apr_thread_mutex_lock(log->lock);
+		celixThreadMutex_lock(&log->lock);
 
-        iter = linkedListIterator_create(log->entries, 0);
-        while (linkedListIterator_hasNext(iter)) {
-            linkedList_addElement(entries, linkedListIterator_next(iter));
-        }
+		iter = linkedListIterator_create(log->entries, 0);
+		while (linkedListIterator_hasNext(iter)) {
+			linkedList_addElement(entries, linkedListIterator_next(iter));
+		}
 		linkedListIterator_destroy(iter);
 
-        *list = entries;
+		*list = entries;
 
-        apr_thread_mutex_unlock(log->lock);
+		celixThreadMutex_unlock(&log->lock);
 
-        return CELIX_SUCCESS;
-    } else {
-        return CELIX_ENOMEM;
-    }
+		return CELIX_SUCCESS;
+	} else {
+		return CELIX_ENOMEM;
+	}
 }
 
 celix_status_t log_bundleChanged(void *listener, bundle_event_pt event) {
@@ -175,7 +192,7 @@ celix_status_t log_bundleChanged(void *l
 	}
 
 	if (message != NULL) {
-		status = logEntry_create(event->bundle, NULL, OSGI_LOGSERVICE_INFO, message, 0, logger->pool, &entry);
+		status = logEntry_create(event->bundle, NULL, OSGI_LOGSERVICE_INFO, message, 0, &entry);
 		if (status == CELIX_SUCCESS) {
 			status = log_addEntry(logger, entry);
 		}
@@ -189,7 +206,7 @@ celix_status_t log_frameworkEvent(void *
 	log_pt logger = ((framework_listener_pt) listener)->handle;
 	log_entry_pt entry = NULL;
 
-	status = logEntry_create(event->bundle, NULL, (event->type == OSGI_FRAMEWORK_EVENT_ERROR) ? OSGI_LOGSERVICE_ERROR : OSGI_LOGSERVICE_INFO, event->error, event->errorCode, logger->pool, &entry);
+	status = logEntry_create(event->bundle, NULL, (event->type == OSGI_FRAMEWORK_EVENT_ERROR) ? OSGI_LOGSERVICE_ERROR : OSGI_LOGSERVICE_INFO, event->error, event->errorCode, &entry);
 	if (status == CELIX_SUCCESS) {
 		status = log_addEntry(logger, entry);
 	}
@@ -198,152 +215,135 @@ celix_status_t log_frameworkEvent(void *
 }
 
 celix_status_t log_addLogListener(log_pt logger, log_listener_pt listener) {
-    celix_status_t status = CELIX_SUCCESS;
-    apr_status_t apr_status;
+	celix_status_t status = CELIX_SUCCESS;
 
-    apr_status = apr_thread_mutex_lock(logger->listenerLock);
-    if (apr_status != APR_SUCCESS) {
-        status = CELIX_INVALID_SYNTAX;
-    } else {
-        arrayList_add(logger->listeners, listener);
-
-        if (logger->listenerThread == NULL) {
-            log_startListenerThread(logger);
-        }
-
-        apr_status = apr_thread_mutex_unlock(logger->listenerLock);
-        if (apr_status != APR_SUCCESS) {
-            status = CELIX_INVALID_SYNTAX;
-        }
-    }
+	status = celixThreadMutex_lock(&logger->listenerLock);
+
+	if (status == CELIX_SUCCESS) {
+		arrayList_add(logger->listeners, listener);
+		log_startListenerThread(logger);
+
+		status = celixThreadMutex_unlock(&logger->listenerLock);
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t log_removeLogListener(log_pt logger, log_listener_pt listener) {
-    celix_status_t status = CELIX_SUCCESS;
-    celix_status_t threadStatus = CELIX_SUCCESS;
-	bool last=false;
+	celix_status_t status = CELIX_SUCCESS;
+	bool last = false;
 
-    status = CELIX_DO_IF(status, apr_thread_mutex_lock(logger->deliverLock));
-    status = CELIX_DO_IF(status, apr_thread_mutex_lock(logger->listenerLock));
-    if (status == CELIX_SUCCESS) {
-        arrayList_removeElement(logger->listeners, listener);
-        if (arrayList_size(logger->listeners) == 0) {
-            status = log_stopListenerThread(logger);
-			last=true;
-        }
-
-        status = CELIX_DO_IF(status, apr_thread_mutex_unlock(logger->listenerLock));
-        status = CELIX_DO_IF(status, apr_thread_mutex_unlock(logger->deliverLock));
-
-		if(last){
-        status = CELIX_DO_IF(status, apr_thread_join(&threadStatus, logger->listenerThread));
-		}
-
-        if (status == CELIX_SUCCESS) {
-            logger->listenerThread = NULL;
-        }
-        status = threadStatus;
-    }
+    status = CELIX_DO_IF(status, celixThreadMutex_lock(&logger->deliverLock));
+    status = CELIX_DO_IF(status, celixThreadMutex_lock(&logger->listenerLock));
 
-    if (status != CELIX_SUCCESS) {
-        status = CELIX_SERVICE_EXCEPTION;
-    }
+	if (status == CELIX_SUCCESS) {
+		arrayList_removeElement(logger->listeners, listener);
+		if (arrayList_size(logger->listeners) == 0) {
+			status = log_stopListenerThread(logger);
+			last = true;
+		}
+
+        status = CELIX_DO_IF(status, celixThreadMutex_unlock(&logger->listenerLock));
+        status = CELIX_DO_IF(status, celixThreadMutex_unlock(&logger->deliverLock));
 
-    return status;
+		if (last) {
+		    status = CELIX_DO_IF(status, celixThread_join(logger->listenerThread, NULL));
+		}
+	}
+
+	if (status != CELIX_SUCCESS) {
+		status = CELIX_SERVICE_EXCEPTION;
+	}
+
+	return status;
 }
 
 celix_status_t log_removeAllLogListener(log_pt logger) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    apr_status_t apr_status;
+	celix_status_t status = CELIX_SUCCESS;
 
-    apr_status = apr_thread_mutex_lock(logger->listenerLock);
-    if (apr_status != APR_SUCCESS) {
-        status = CELIX_INVALID_SYNTAX;
-    } else {
-        arrayList_clear(logger->listeners);
+	status = celixThreadMutex_lock(&logger->listenerLock);
 
+    if (status == CELIX_SUCCESS) {
+    	arrayList_clear(logger->listeners);
 
-        apr_status = apr_thread_mutex_unlock(logger->listenerLock);
-        if (apr_status != APR_SUCCESS) {
-            status = CELIX_INVALID_SYNTAX;
-        }
+    	status = celixThreadMutex_unlock(&logger->listenerLock);
     }
 
-    return status;
+	return status;
 }
 
 static celix_status_t log_startListenerThread(log_pt logger) {
-    celix_status_t status = CELIX_SUCCESS;
-    apr_status_t apr_status;
+	celix_status_t status = CELIX_SUCCESS;
 
+	logger->running = true;
     logger->running = true;
-    apr_status = apr_thread_create(&logger->listenerThread, NULL, log_listenerThread, logger, logger->pool);
-    if (apr_status != APR_SUCCESS) {
-        status = CELIX_INVALID_SYNTAX;
-    }
+    status = celixThread_create(&logger->listenerThread, NULL, log_listenerThread, logger);
 
-    return status;
+	return status;
 }
 
 static celix_status_t log_stopListenerThread(log_pt logger) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    logger->running = false;
-	if( apr_thread_cond_signal(logger->entriesToDeliver) != APR_SUCCESS){
-        status = CELIX_SERVICE_EXCEPTION;
-    }
+	logger->running = false;
 
-    return status;
+	status = celixThreadCondition_signal(&logger->entriesToDeliver);
+
+	return status;
 }
 
-void * APR_THREAD_FUNC log_listenerThread(apr_thread_t *thread, void *data) {
-    apr_status_t status = APR_SUCCESS;
+static void * log_listenerThread(void *data) {
+	celix_status_t status = CELIX_SUCCESS;
 
-    log_pt logger = data;
+	log_pt logger = data;
 
-    while (logger->running) {
-        status = apr_thread_mutex_lock(logger->deliverLock);
-        if (status != APR_SUCCESS) {
-            logger->running = false;
-        } else {
-            if (!arrayList_isEmpty(logger->listenerEntries)) {
-                log_entry_pt entry = (log_entry_pt) arrayList_remove(logger->listenerEntries, 0);
-
-                status = apr_thread_mutex_lock(logger->listenerLock);
-                if (status != APR_SUCCESS) {
-                    logger->running = false;
-                    break;
-                } else {
-                    array_list_iterator_pt it = arrayListIterator_create(logger->listeners);
-                    while (arrayListIterator_hasNext(it)) {
-                        log_listener_pt listener = arrayListIterator_next(it);
-                        listener->logged(listener, entry);
-                    }
-					arrayListIterator_destroy(it);
-
-                    status = apr_thread_mutex_unlock(logger->listenerLock);
-                    if (status != APR_SUCCESS) {
-                        logger->running = false;
-                        break;
-                    }
-                }
-            }
-
-            if (arrayList_isEmpty(logger->listenerEntries) && logger->running) {
-                apr_thread_cond_wait(logger->entriesToDeliver, logger->deliverLock);
-            }
-
-            status = apr_thread_mutex_unlock(logger->deliverLock);
-            if (status != APR_SUCCESS) {
-                logger->running = false;
-                break;
-            }
-        }
-    }
+	while (logger->running) {
+
+		status = celixThreadMutex_lock(&logger->deliverLock);
+
+		if ( status != CELIX_SUCCESS) {
+			logger->running = false;
+		}
+		else {
+			if (!arrayList_isEmpty(logger->listenerEntries)) {
+				log_entry_pt entry = (log_entry_pt) arrayList_remove(logger->listenerEntries, 0);
+
+				if (entry) {
+					status = celixThreadMutex_lock(&logger->listenerLock);
+					if (status != CELIX_SUCCESS) {
+						logger->running = false;
+						break;
+					} else {
+						array_list_iterator_pt it = arrayListIterator_create(logger->listeners);
+						while (arrayListIterator_hasNext(it)) {
+							log_listener_pt listener = arrayListIterator_next(it);
+							listener->logged(listener, entry);
+						}
+						arrayListIterator_destroy(it);
+
+						status = celixThreadMutex_unlock(&logger->listenerLock);
+						if (status != CELIX_SUCCESS) {
+							logger->running = false;
+							break;
+						}
+					}
+				}
+			}
+
+			if (arrayList_isEmpty(logger->listenerEntries) && logger->running) {
+				celixThreadCondition_wait(&logger->entriesToDeliver, &logger->deliverLock);
+			}
+
+			status = celixThreadMutex_unlock(&logger->deliverLock);
+
+			if (status != CELIX_SUCCESS) {
+				logger->running = false;
+				break;
+			}
+		}
+
+	}
 
-    apr_thread_exit(thread, status);
+    celixThread_exit(NULL);
     return NULL;
 }

Modified: celix/branches/celix_config_admin/log_service/private/src/log_entry.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/log_service/private/src/log_entry.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/log_service/private/src/log_entry.c (original)
+++ celix/branches/celix_config_admin/log_service/private/src/log_entry.c Mon Jan 19 12:26:54 2015
@@ -25,31 +25,66 @@
  */
 
 #include <stddef.h>
+#include <stdlib.h>
 
+#include "celix_errno.h"
+#include "log_service.h"
 #include "log_entry.h"
 
 celix_status_t logEntry_create(bundle_pt bundle, service_reference_pt reference,
         log_level_t level, char *message, int errorCode,
-        apr_pool_t *pool, log_entry_pt *entry) {
+        log_entry_pt *entry) {
     celix_status_t status = CELIX_SUCCESS;
 
-    *entry = apr_palloc(pool, sizeof(**entry));
-    if (entry == NULL) {
+    *entry = malloc(sizeof(**entry));
+    if (*entry == NULL) {
         status = CELIX_ENOMEM;
     } else {
-        (*entry)->bundle = bundle;
-        (*entry)->reference = reference;
         (*entry)->level = level;
-        (*entry)->message = message;
+        (*entry)->message = strdup(message);
         (*entry)->errorCode = errorCode;
         (*entry)->time = time(NULL);
+
+        (*entry)->bundleSymbolicName = NULL;
+        (*entry)->bundleId = 0;
+    }
+
+    if (status == CELIX_SUCCESS) {
+        status = bundle_getBundleId(bundle, &(*entry)->bundleId);
+    }
+
+    if (status == CELIX_SUCCESS) {
+    	module_pt module = NULL;
+        status = bundle_getCurrentModule(bundle, &module);
+		if (status == CELIX_SUCCESS) {
+			char *symbolicName = NULL;
+			status = module_getSymbolicName(module, &symbolicName);
+			if (status == CELIX_SUCCESS) {
+				(*entry)->bundleSymbolicName = strdup(symbolicName);
+			}
+		}
     }
 
     return status;
 }
 
-celix_status_t logEntry_getBundle(log_entry_pt entry, bundle_pt *bundle) {
-    *bundle = entry->bundle;
+celix_status_t logEntry_destroy(log_entry_pt *entry) {
+    if (*entry) {
+    	free((*entry)->bundleSymbolicName);
+        free((*entry)->message);
+        free(*entry);
+        *entry = NULL;
+    }
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logEntry_getBundleSymbolicName(log_entry_pt entry, char **bundleSymbolicName) {
+    *bundleSymbolicName = entry->bundleSymbolicName;
+    return CELIX_SUCCESS;
+}
+
+celix_status_t logEntry_getBundleId(log_entry_pt entry, long *bundleId) {
+    *bundleId = entry->bundleId;
     return CELIX_SUCCESS;
 }
 
@@ -68,11 +103,6 @@ celix_status_t logEntry_getMessage(log_e
     return CELIX_SUCCESS;
 }
 
-celix_status_t logEntry_getServiceReference(log_entry_pt entry, service_reference_pt *reference) {
-    *reference = entry->reference;
-    return CELIX_SUCCESS;
-}
-
 celix_status_t logEntry_getTime(log_entry_pt entry, time_t *time) {
     *time = entry->time;
     return CELIX_SUCCESS;

Modified: celix/branches/celix_config_admin/log_service/private/src/log_factory.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/log_service/private/src/log_factory.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/log_service/private/src/log_factory.c (original)
+++ celix/branches/celix_config_admin/log_service/private/src/log_factory.c Mon Jan 19 12:26:54 2015
@@ -25,28 +25,28 @@
  */
 
 #include <stddef.h>
+#include <stdlib.h>
+
 
 #include "service_factory.h"
 #include "log_factory.h"
 #include "log_service_impl.h"
 
 struct log_service_factory {
-    apr_pool_t *pool;
     log_pt log;
 };
 
-celix_status_t logFactory_create(apr_pool_t *pool, log_pt log, service_factory_pt *factory) {
+celix_status_t logFactory_create(log_pt log, service_factory_pt *factory) {
     celix_status_t status = CELIX_SUCCESS;
 
-    *factory = apr_palloc(pool, sizeof(**factory));
+    *factory = calloc(1, sizeof(**factory));
     if (*factory == NULL) {
         status = CELIX_ENOMEM;
     } else {
-        log_service_factory_pt factoryData = apr_palloc(pool, sizeof(*factoryData));
+        log_service_factory_pt factoryData = calloc(1, sizeof(*factoryData));
         if (factoryData == NULL) {
             status = CELIX_ENOMEM;
         } else {
-            factoryData->pool = pool;
             factoryData->log = log;
 
             (*factory)->factory = factoryData;
@@ -58,14 +58,27 @@ celix_status_t logFactory_create(apr_poo
     return status;
 }
 
+celix_status_t logFactory_destroy(service_factory_pt *factory) {
+    celix_status_t status = CELIX_SUCCESS;
+
+
+    free((*factory)->factory);
+    free(*factory);
+
+    factory = NULL;
+
+    return status;
+}
+
+
 celix_status_t logFactory_getService(void *factory, bundle_pt bundle, service_registration_pt registration, void **service) {
     log_service_factory_pt log_factory = ((service_factory_pt) factory)->factory;
     log_service_pt log_service = NULL;
     log_service_data_pt log_service_data = NULL;
 
-    logService_create(log_factory->log, bundle, log_factory->pool, &log_service_data);
+    logService_create(log_factory->log, bundle, &log_service_data);
 
-    log_service = apr_palloc(log_factory->pool, sizeof(*log_service));
+    log_service = calloc(1, sizeof(*log_service));
     log_service->logger = log_service_data;
     log_service->log = logService_log;
     log_service->logSr = logService_logSr;
@@ -75,6 +88,13 @@ celix_status_t logFactory_getService(voi
     return CELIX_SUCCESS;
 }
 
-celix_status_t logFactory_ungetService(void *factory, bundle_pt bundle, service_registration_pt registration) {
+celix_status_t logFactory_ungetService(void *factory, bundle_pt bundle, service_registration_pt registration, void **service) {
+	log_service_pt log_service = *service;
+
+	logService_destroy(&log_service->logger);
+
+	free(*service);
+	*service = NULL;
+
     return CELIX_SUCCESS;
 }

Modified: celix/branches/celix_config_admin/log_service/private/src/log_reader_service_impl.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/log_service/private/src/log_reader_service_impl.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/log_service/private/src/log_reader_service_impl.c (original)
+++ celix/branches/celix_config_admin/log_service/private/src/log_reader_service_impl.c Mon Jan 19 12:26:54 2015
@@ -24,6 +24,7 @@
  *  \copyright	Apache License, Version 2.0
  */
 
+#include <stdlib.h>
 #include <stddef.h>
 
 #include "log_reader_service_impl.h"
@@ -31,28 +32,37 @@
 
 struct log_reader_data {
     log_pt log;
-    apr_pool_t *pool;
 };
 
-celix_status_t logReaderService_create(log_pt log, apr_pool_t *pool, log_reader_data_pt *reader) {
-    celix_status_t status = APR_SUCCESS;
+celix_status_t logReaderService_create(log_pt log, log_reader_data_pt *reader) {
+    celix_status_t status = CELIX_SUCCESS;
 
-    *reader = (log_reader_data_pt) apr_palloc(pool, sizeof(**reader));
+    *reader = (log_reader_data_pt) calloc(1, sizeof(**reader));
 
     if (reader == NULL) {
         status = CELIX_ENOMEM;
     } else {
         (*reader)->log = log;
-        (*reader)->pool = pool;
     }
 
     return status;
 }
 
-celix_status_t logReaderService_getLog(log_reader_data_pt reader, apr_pool_t *memory_pool, linked_list_pt *list) {
+celix_status_t logReaderService_destroy(log_reader_data_pt *reader) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    free(*reader);
+    reader = NULL;
+
+    return status;
+}
+
+
+
+celix_status_t logReaderService_getLog(log_reader_data_pt reader, linked_list_pt *list) {
     celix_status_t status = CELIX_SUCCESS;
 
-    status = log_getEntries(reader->log, memory_pool, list);
+    status = log_getEntries(reader->log, list);
 
     return status;
 }

Modified: celix/branches/celix_config_admin/log_service/private/src/log_service_activator.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/log_service/private/src/log_service_activator.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/log_service/private/src/log_service_activator.c (original)
+++ celix/branches/celix_config_admin/log_service/private/src/log_service_activator.c Mon Jan 19 12:26:54 2015
@@ -23,7 +23,7 @@
  *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
  *  \copyright	Apache License, Version 2.0
  */
-#include <apr_general.h>
+
 #include <stdlib.h>
 
 #include "bundle_activator.h"
@@ -34,8 +34,13 @@
 #include "log_reader_service_impl.h"
 #include "service_registration.h"
 
+#define DEFAULT_MAX_SIZE 100
+#define DEFAULT_STORE_DEBUG false
+
+#define MAX_SIZE_PROPERTY "CELIX_LOG_MAX_SIZE"
+#define STORE_DEBUG_PROPERTY "CELIX_LOG_STORE_DEBUG"
+
 struct logActivator {
-    apr_pool_t *pool;
     bundle_context_pt bundleContext;
     service_registration_pt logServiceFactoryReg;
     service_registration_pt logReaderServiceReg;
@@ -43,16 +48,20 @@ struct logActivator {
     bundle_listener_pt bundleListener;
     framework_listener_pt frameworkListener;
 
+    log_pt logger;
+    service_factory_pt factory;
+    log_reader_data_pt reader;
+    log_reader_service_pt reader_service;
 };
 
+static celix_status_t bundleActivator_getMaxSize(struct logActivator *activator, int *max_size);
+static celix_status_t bundleActivator_getStoreDebug(struct logActivator *activator, bool *store_debug);
+
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
     celix_status_t status = CELIX_SUCCESS;
-    apr_pool_t *mp = NULL;
 	struct logActivator * activator = NULL;
 
-    apr_pool_create(&mp, NULL);
-    activator = (struct logActivator *) apr_palloc(mp, sizeof(struct logActivator));
-
+    activator = (struct logActivator *) calloc(1, sizeof(struct logActivator));
 
     if (activator == NULL) {
         status = CELIX_ENOMEM;
@@ -60,7 +69,12 @@ celix_status_t bundleActivator_create(bu
 		activator->bundleContext = context;
 		activator->logServiceFactoryReg = NULL;
 		activator->logReaderServiceReg = NULL;
-		activator->pool = mp;
+
+		activator->logger = NULL;
+		activator->factory = NULL;
+		activator->reader = NULL;
+		activator->reader_service = NULL;
+
         *userData = activator;
     }
 
@@ -70,40 +84,40 @@ celix_status_t bundleActivator_create(bu
 celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
     struct logActivator * activator = (struct logActivator *) userData;
     celix_status_t status = CELIX_SUCCESS;
-    service_factory_pt factory = NULL;
-    log_pt logger = NULL;
 
-    log_reader_data_pt reader = NULL;
-    log_reader_service_pt reader_service = NULL;
+    int max_size = 0;
+    bool store_debug = false;
 
+    bundleActivator_getMaxSize(activator, &max_size);
+    bundleActivator_getStoreDebug(activator, &store_debug);
 
-    log_create(activator->pool, &logger);
+    log_create(max_size, store_debug, &activator->logger);
 
     // Add logger as Bundle- and FrameworkEvent listener
-    activator->bundleListener = apr_palloc(activator->pool, sizeof(*activator->bundleListener));
-    activator->bundleListener->handle = logger;
+    activator->bundleListener = calloc(1, sizeof(*activator->bundleListener));
+    activator->bundleListener->handle = activator->logger;
     activator->bundleListener->bundleChanged = log_bundleChanged;
     bundleContext_addBundleListener(context, activator->bundleListener);
 
-    activator->frameworkListener = apr_palloc(activator->pool, sizeof(*activator->frameworkListener));
-    activator->frameworkListener->handle = logger;
+    activator->frameworkListener = calloc(1, sizeof(*activator->frameworkListener));
+    activator->frameworkListener->handle = activator->logger;
     activator->frameworkListener->frameworkEvent = log_frameworkEvent;
     bundleContext_addFrameworkListener(context, activator->frameworkListener);
 
-    logFactory_create(activator->pool, logger, &factory);
+    logFactory_create(activator->logger, &activator->factory);
 
-    bundleContext_registerServiceFactory(context, (char *) OSGI_LOGSERVICE_NAME, factory, NULL, &activator->logServiceFactoryReg);
+    bundleContext_registerServiceFactory(context, (char *) OSGI_LOGSERVICE_NAME, activator->factory, NULL, &activator->logServiceFactoryReg);
 
-    logReaderService_create(logger, activator->pool, &reader);
+    logReaderService_create(activator->logger, &activator->reader);
 
-    reader_service = apr_palloc(activator->pool, sizeof(*reader_service));
-    reader_service->reader = reader;
-    reader_service->getLog = logReaderService_getLog;
-    reader_service->addLogListener = logReaderService_addLogListener;
-    reader_service->removeLogListener = logReaderService_removeLogListener;
-    reader_service->removeAllLogListener = logReaderService_removeAllLogListener;
+    activator->reader_service = calloc(1, sizeof(*activator->reader_service));
+    activator->reader_service->reader = activator->reader;
+    activator->reader_service->getLog = logReaderService_getLog;
+    activator->reader_service->addLogListener = logReaderService_addLogListener;
+    activator->reader_service->removeLogListener = logReaderService_removeLogListener;
+    activator->reader_service->removeAllLogListener = logReaderService_removeAllLogListener;
 
-    bundleContext_registerService(context, (char *) OSGI_LOGSERVICE_READER_SERVICE_NAME, reader_service, NULL, &activator->logReaderServiceReg);
+    bundleContext_registerService(context, (char *) OSGI_LOGSERVICE_READER_SERVICE_NAME, activator->reader_service, NULL, &activator->logReaderServiceReg);
 
     return status;
 }
@@ -116,12 +130,60 @@ celix_status_t bundleActivator_stop(void
 	serviceRegistration_unregister(activator->logServiceFactoryReg);
 	activator->logServiceFactoryReg = NULL;
 
+    logReaderService_destroy(&activator->reader);
+	free(activator->reader_service);
+
+	logFactory_destroy(&activator->factory);
+
 	bundleContext_removeBundleListener(context, activator->bundleListener);
 	bundleContext_removeFrameworkListener(context, activator->frameworkListener);
 
+	free(activator->bundleListener);
+	free(activator->frameworkListener);
+
+	log_destroy(activator->logger);
+
     return CELIX_SUCCESS;
 }
 
 celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	struct logActivator * activator = (struct logActivator *) userData;
+
+	free(activator);
+
     return CELIX_SUCCESS;
 }
+
+static celix_status_t bundleActivator_getMaxSize(struct logActivator *activator, int *max_size) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	char *max_size_str = NULL;
+
+	*max_size = DEFAULT_MAX_SIZE;
+
+	bundleContext_getProperty(activator->bundleContext, MAX_SIZE_PROPERTY, &max_size_str);
+	if (max_size_str) {
+		*max_size = atoi(max_size_str);
+	}
+
+	return status;
+}
+
+static celix_status_t bundleActivator_getStoreDebug(struct logActivator *activator, bool *store_debug) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	char *store_debug_str = NULL;
+
+	*store_debug = DEFAULT_STORE_DEBUG;
+
+	bundleContext_getProperty(activator->bundleContext, STORE_DEBUG_PROPERTY, &store_debug_str);
+	if (store_debug_str) {
+		if (strcasecmp(store_debug_str, "true") == 0) {
+			*store_debug = true;
+		} else if (strcasecmp(store_debug_str, "false") == 0) {
+			*store_debug = false;
+		}
+	}
+
+	return status;
+}

Modified: celix/branches/celix_config_admin/log_service/private/src/log_service_impl.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/log_service/private/src/log_service_impl.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/log_service/private/src/log_service_impl.c (original)
+++ celix/branches/celix_config_admin/log_service/private/src/log_service_impl.c Mon Jan 19 12:26:54 2015
@@ -32,23 +32,30 @@
 struct log_service_data {
     log_pt log;
     bundle_pt bundle;
-    apr_pool_t *pool;
 };
 
-celix_status_t logService_create(log_pt log, bundle_pt bundle, apr_pool_t *pool, log_service_data_pt *logger) {
+celix_status_t logService_create(log_pt log, bundle_pt bundle, log_service_data_pt *logger) {
     celix_status_t status = CELIX_SUCCESS;
-    *logger = apr_palloc(pool, sizeof(struct log_service_data));
+    *logger = calloc(1, sizeof(struct log_service_data));
     if (*logger == NULL) {
         status = CELIX_ENOMEM;
     } else {
         (*logger)->bundle = bundle;
         (*logger)->log = log;
-        (*logger)->pool = pool;
     }
 
     return status;
 }
 
+celix_status_t logService_destroy(log_service_data_pt *logger) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    free(*logger);
+    logger = NULL;
+
+    return status;
+}
+
 celix_status_t logService_log(log_service_data_pt logger, log_level_t level, char * message) {
     return logService_logSr(logger, NULL, level, message);
 }
@@ -59,7 +66,7 @@ celix_status_t logService_logSr(log_serv
     if (reference != NULL) {
     	serviceReference_getBundle(reference, &bundle);
     }
-    logEntry_create(bundle, reference, level, message, 0, logger->pool, &entry);
+    logEntry_create(bundle, reference, level, message, 0, &entry);
     log_addEntry(logger->log, entry);
 
     return CELIX_SUCCESS;

Modified: celix/branches/celix_config_admin/log_service/public/include/log_entry.h
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/log_service/public/include/log_entry.h?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/log_service/public/include/log_entry.h (original)
+++ celix/branches/celix_config_admin/log_service/public/include/log_entry.h Mon Jan 19 12:26:54 2015
@@ -27,29 +27,29 @@
 #ifndef LOG_ENTRY_H_
 #define LOG_ENTRY_H_
 
-#include <apr_general.h>
-
 #include "log_service.h"
 
 struct log_entry {
-    bundle_pt bundle;
     int errorCode;
     log_level_t level;
     char *message;
-    service_reference_pt reference;
     time_t time;
+
+    char *bundleSymbolicName;
+    long bundleId;
 };
 
 typedef struct log_entry * log_entry_pt;
 
 celix_status_t logEntry_create(bundle_pt bundle, service_reference_pt reference,
         log_level_t level, char *message, int errorCode,
-        apr_pool_t *pool, log_entry_pt *entry);
-celix_status_t logEntry_getBundle(log_entry_pt entry, bundle_pt *bundle);
+        log_entry_pt *entry);
+celix_status_t logEntry_destroy(log_entry_pt *entry);
+celix_status_t logEntry_getBundleSymbolicName(log_entry_pt entry, char **bundleSymbolicName);
+celix_status_t logEntry_getBundleId(log_entry_pt entry, long *bundleId);
 celix_status_t logEntry_getErrorCode(log_entry_pt entry, int *errorCode);
 celix_status_t logEntry_getLevel(log_entry_pt entry, log_level_t *level);
 celix_status_t logEntry_getMessage(log_entry_pt entry, char **message);
-celix_status_t logEntry_getServiceReference(log_entry_pt entry, service_reference_pt *reference);
 celix_status_t logEntry_getTime(log_entry_pt entry, time_t *time);
 
 #endif /* LOG_ENTRY_H_ */

Modified: celix/branches/celix_config_admin/log_service/public/include/log_reader_service.h
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/log_service/public/include/log_reader_service.h?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/log_service/public/include/log_reader_service.h (original)
+++ celix/branches/celix_config_admin/log_service/public/include/log_reader_service.h Mon Jan 19 12:26:54 2015
@@ -27,7 +27,7 @@
 #ifndef LOG_READER_SERVICE_H_
 #define LOG_READER_SERVICE_H_
 
-#include <apr_general.h>
+
 #include "celix_errno.h"
 #include "linked_list.h"
 #include "log_listener.h"
@@ -38,7 +38,7 @@ typedef struct log_reader_data * log_rea
 
 struct log_reader_service {
     log_reader_data_pt reader;
-    celix_status_t (*getLog)(log_reader_data_pt reader, apr_pool_t *memory_pool, linked_list_pt *list);
+    celix_status_t (*getLog)(log_reader_data_pt reader, linked_list_pt *list);
     celix_status_t (*addLogListener)(log_reader_data_pt reader, log_listener_pt listener);
     celix_status_t (*removeLogListener)(log_reader_data_pt reader, log_listener_pt listener);
     celix_status_t (*removeAllLogListener)(log_reader_data_pt reader);

Modified: celix/branches/celix_config_admin/log_writer/log_writer/private/include/log_writer.h
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/log_writer/log_writer/private/include/log_writer.h?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/log_writer/log_writer/private/include/log_writer.h (original)
+++ celix/branches/celix_config_admin/log_writer/log_writer/private/include/log_writer.h Mon Jan 19 12:26:54 2015
@@ -34,14 +34,15 @@
 struct log_writer {
     log_reader_service_pt logReader;
     log_listener_pt logListener;
-    apr_pool_t *pool;
+
     bundle_context_pt context;
     service_tracker_pt tracker;
 };
 
 typedef struct log_writer *log_writer_pt;
 
-celix_status_t logWriter_create(apr_pool_t *pool, bundle_context_pt context, log_writer_pt *writer);
+celix_status_t logWriter_create(bundle_context_pt context, log_writer_pt *writer);
+celix_status_t logWriter_destroy(log_writer_pt *writer);
 celix_status_t logWriter_start(log_writer_pt writer);
 celix_status_t logWriter_stop(log_writer_pt writer);
 

Modified: celix/branches/celix_config_admin/log_writer/log_writer/private/src/log_writer.c
URL: http://svn.apache.org/viewvc/celix/branches/celix_config_admin/log_writer/log_writer/private/src/log_writer.c?rev=1652984&r1=1652983&r2=1652984&view=diff
==============================================================================
--- celix/branches/celix_config_admin/log_writer/log_writer/private/src/log_writer.c (original)
+++ celix/branches/celix_config_admin/log_writer/log_writer/private/src/log_writer.c Mon Jan 19 12:26:54 2015
@@ -34,24 +34,31 @@
 #include "module.h"
 #include "bundle.h"
 
-celix_status_t logWriter_create(apr_pool_t *pool, bundle_context_pt context, log_writer_pt *writer) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    apr_pool_t *mypool;
-    apr_pool_create(&mypool, pool);
+celix_status_t logWriter_create(bundle_context_pt context, log_writer_pt *writer) {
+	celix_status_t status = CELIX_SUCCESS;
 
-    *writer = apr_pcalloc(mypool, sizeof(**writer));
-    (*writer)->logListener = apr_pcalloc(mypool, sizeof(*(*writer)->logListener));
-    (*writer)->logListener->handle = *writer;
-    (*writer)->logListener->logged = logListener_logged;
-    (*writer)->logReader = NULL;
-    (*writer)->pool = mypool;
-    (*writer)->context = context;
-    (*writer)->tracker = NULL;
+	*writer = calloc(1, sizeof(**writer));
+	(*writer)->logListener = calloc(1, sizeof(*(*writer)->logListener));
+	(*writer)->logListener->handle = *writer;
+	(*writer)->logListener->logged = logListener_logged;
+	(*writer)->logReader = NULL;
+	(*writer)->context = context;
+	(*writer)->tracker = NULL;
 
-    return status;
+	return status;
 }
 
+
+celix_status_t logWriter_destroy(log_writer_pt *writer) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	free((*writer)->logListener);
+	free(*writer);
+
+	writer = NULL;
+
+	return status;
+}
 celix_status_t logWriter_start(log_writer_pt writer) {
 	celix_status_t status = CELIX_SUCCESS;
 
@@ -71,7 +78,16 @@ celix_status_t logWriter_start(log_write
 }
 
 celix_status_t logWriter_stop(log_writer_pt writer) {
-	return serviceTracker_close(writer->tracker);
+	celix_status_t status = CELIX_SUCCESS;
+
+	if (serviceTracker_close(writer->tracker) != CELIX_SUCCESS) {
+		status = CELIX_BUNDLE_EXCEPTION;
+	}
+	if (serviceTracker_destroy(writer->tracker) != CELIX_SUCCESS) {
+		status = CELIX_BUNDLE_EXCEPTION;
+	}
+
+	return status;
 }
 
 celix_status_t logWriter_addingServ(void * handle, service_reference_pt ref, void **service) {



Mime
View raw message