incubator-celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1214685 [3/4] - in /incubator/celix/trunk: ./ cmake/ dependency_manager/ deployment_admin/private/src/ examples/osgi-in-action/chapter04-paint-example/paint/private/src/ examples/whiteboard/publisherA/ examples/whiteboard/publisherB/ frame...
Date Thu, 15 Dec 2011 10:12:06 GMT
Modified: incubator/celix/trunk/framework/private/include/wire.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/wire.h?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/wire.h (original)
+++ incubator/celix/trunk/framework/private/include/wire.h Thu Dec 15 10:12:04 2011
@@ -32,13 +32,70 @@
 #include "linkedlist.h"
 #include "headers.h"
 
-WIRE wire_create(MODULE importer, REQUIREMENT requirement,
-		MODULE exporter, CAPABILITY capability);
-void wire_destroy(WIRE wire);
-
-CAPABILITY wire_getCapability(WIRE wire);
-REQUIREMENT wire_getRequirement(WIRE wire);
-MODULE wire_getImporter(WIRE wire);
-MODULE wire_getExporter(WIRE wire);
+/**
+ * @defgroup Version Version
+ * @ingroup framework
+ * @{
+ */
+
+/**
+ * Create a wire between two modules using a requirement and capability.
+ *
+ * @param pool The pool in which the wire is created.
+ * @param importer The importer module of the wire.
+ * @param requirement The requirement of the importer.
+ * @param exporter The exporter module of the wire.
+ * @param capability The capability of the wire.
+ * @param wire The created wire.
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ * 		- CELIX_ENOMEM If allocating memory for <code>wire</code> failed.
+ */
+celix_status_t wire_create(apr_pool_t *pool, MODULE importer, REQUIREMENT requirement,
+		MODULE exporter, CAPABILITY capability, WIRE *wire);
+
+/**
+ * Getter for the capability of the exporting module.
+ *
+ * @param wire The wire to get the capability from.
+ * @param capability The capability
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t wire_getCapability(WIRE wire, CAPABILITY *capability);
+
+/**
+ * Getter for the requirement of the importing module.
+ *
+ * @param wire The wire to get the requirement from.
+ * @param requirement The requirement
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t wire_getRequirement(WIRE wire, REQUIREMENT *requirement);
+
+/**
+ * Getter for the importer of the wire.
+ *
+ * @param wire The wire to get the importer from.
+ * @param importer The importing module.
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t wire_getImporter(WIRE wire, MODULE *importer);
+
+/**
+ * Getter for the exporter of the wire.
+ *
+ * @param wire The wire to get the exporter from.
+ * @param importer The exporting module.
+ * @return Status code indication failure or success:
+ * 		- CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t wire_getExporter(WIRE wire, MODULE *exporter);
+
+/**
+ * @}
+ */
 
 #endif /* WIRE_H_ */

Modified: incubator/celix/trunk/framework/private/src/bundle.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle.c Thu Dec 15 10:12:04 2011
@@ -232,9 +232,13 @@ celix_status_t bundle_createModule(BUNDL
 								status = module_getSymbolicName(mod, &sym);
 
 								VERSION version = module_getVersion(mod);
+								int cmp;
+								version_compareTo(bundleVersion, version, &cmp);
 								if ((symName != NULL) && (sym != NULL) && !strcmp(symName, sym) &&
-										!version_compareTo(bundleVersion, version)) {
-									printf("Bundle symbolic name and version are not unique: %s:%s\n", sym, version_toString(version));
+										!cmp) {
+									char *versionString = NULL;
+									version_toString(version, bundle->memoryPool, &versionString);
+									printf("Bundle symbolic name and version are not unique: %s:%s\n", sym, versionString);
 									status = CELIX_BUNDLE_EXCEPTION;
 									break;
 								}
@@ -518,10 +522,10 @@ celix_status_t bundle_getBundleId(BUNDLE
 	return status;
 }
 
-celix_status_t bundle_getRegisteredServices(BUNDLE bundle, ARRAY_LIST *list) {
+celix_status_t bundle_getRegisteredServices(BUNDLE bundle, apr_pool_t *pool, ARRAY_LIST *list) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	status = fw_getBundleRegisteredServices(bundle->framework, bundle, list);
+	status = fw_getBundleRegisteredServices(bundle->framework, pool, bundle, list);
 
 	return status;
 }

Modified: incubator/celix/trunk/framework/private/src/capability.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/capability.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/capability.c (original)
+++ incubator/celix/trunk/framework/private/src/capability.c Thu Dec 15 10:12:04 2011
@@ -35,25 +35,40 @@ struct capability {
 	HASH_MAP directives;
 };
 
-CAPABILITY capability_create(MODULE module, HASH_MAP directives, HASH_MAP attributes) {
-	CAPABILITY capability = (CAPABILITY) malloc(sizeof(*capability));
+apr_status_t capability_destroy(void *capabilityP);
 
-	capability->module = module;
-	capability->attributes = attributes;
-	capability->directives = directives;
-
-	capability->version = version_createEmptyVersion();
-	ATTRIBUTE versionAttribute = (ATTRIBUTE) hashMap_get(attributes, "version");
-	if (versionAttribute != NULL) {
-		capability->version = version_createVersionFromString(versionAttribute->value);
+celix_status_t capability_create(apr_pool_t *pool, MODULE module, HASH_MAP directives, HASH_MAP attributes, CAPABILITY *capability) {
+	celix_status_t status = CELIX_SUCCESS;
+	*capability = (CAPABILITY) apr_palloc(pool, sizeof(**capability));
+	if (!*capability) {
+		status = CELIX_ENOMEM;
+	} else {
+		apr_pool_pre_cleanup_register(pool, *capability, capability_destroy);
+
+		(*capability)->module = module;
+		(*capability)->attributes = attributes;
+		(*capability)->directives = directives;
+
+		(*capability)->version = NULL;
+		status = version_createEmptyVersion(pool, &(*capability)->version);
+		if (status == CELIX_SUCCESS) {
+			ATTRIBUTE serviceAttribute = (ATTRIBUTE) hashMap_get(attributes, "service");
+			(*capability)->serviceName = serviceAttribute->value;
+
+			ATTRIBUTE versionAttribute = (ATTRIBUTE) hashMap_get(attributes, "version");
+			if (versionAttribute != NULL) {
+				(*capability)->version = NULL;
+				status = version_createVersionFromString(pool, versionAttribute->value, &(*capability)->version);
+			}
+		}
 	}
-	ATTRIBUTE serviceAttribute = (ATTRIBUTE) hashMap_get(attributes, "service");
-	capability->serviceName = serviceAttribute->value;
 
-	return capability;
+	return status;
 }
 
-void capability_destroy(CAPABILITY capability) {
+apr_status_t capability_destroy(void *capabilityP) {
+	CAPABILITY capability = capabilityP;
+
 	HASH_MAP_ITERATOR attrIter = hashMapIterator_create(capability->attributes);
 	while (hashMapIterator_hasNext(attrIter)) {
 		ATTRIBUTE attr = hashMapIterator_nextValue(attrIter);
@@ -62,23 +77,26 @@ void capability_destroy(CAPABILITY capab
 	hashMapIterator_destroy(attrIter);
 	hashMap_destroy(capability->attributes, false, false);
 	hashMap_destroy(capability->directives, false, false);
-	version_destroy(capability->version);
 
 	capability->attributes = NULL;
 	capability->directives = NULL;
 	capability->module = NULL;
 	capability->version = NULL;
 
+	return APR_SUCCESS;
 }
 
-char * capability_getServiceName(CAPABILITY capability) {
-	return capability->serviceName;
+celix_status_t capability_getServiceName(CAPABILITY capability, char **serviceName) {
+	*serviceName = capability->serviceName;
+	return CELIX_SUCCESS;
 }
 
-VERSION capability_getVersion(CAPABILITY capability) {
-	return capability->version;
+celix_status_t capability_getVersion(CAPABILITY capability, VERSION *version) {
+	*version = capability->version;
+	return CELIX_SUCCESS;
 }
 
-MODULE capability_getModule(CAPABILITY capability) {
-	return capability->module;
+celix_status_t capability_getModule(CAPABILITY capability, MODULE *module) {
+	*module = capability->module;
+	return CELIX_SUCCESS;
 }

Modified: incubator/celix/trunk/framework/private/src/filter.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/filter.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/filter.c (original)
+++ incubator/celix/trunk/framework/private/src/filter.c Thu Dec 15 10:12:04 2011
@@ -91,7 +91,7 @@ void filter_destroy(FILTER filter) {
 			arrayList_destroy(filter->value);
 			filter->value = NULL;
 		} else {
-			free(filter->value);
+			// free(filter->value);
 			filter->value = NULL;
 		}
 		free(filter->attribute);

Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Thu Dec 15 10:12:04 2011
@@ -188,7 +188,6 @@ celix_status_t framework_destroy(FRAMEWO
 			while (linkedListIterator_hasNext(iter)) {
 				WIRE wire = linkedListIterator_next(iter);
 				linkedListIterator_remove(iter);
-				wire_destroy(wire);
 			}
 			linkedListIterator_destroy(iter);
 		}
@@ -203,6 +202,9 @@ celix_status_t framework_destroy(FRAMEWO
 
 	serviceRegistry_destroy(framework->registry);
 
+	arrayList_destroy(framework->globalLockWaitersList);
+	arrayList_destroy(framework->serviceListeners);
+
 	//bundleCache_destroy(framework->cache);
 
 	apr_pool_destroy(framework->mp);
@@ -734,7 +736,7 @@ celix_status_t fw_stopBundle(FRAMEWORK f
 			serviceRegistry_unregisterServices(framework->registry, bundle);
 			serviceRegistry_ungetServices(framework->registry, bundle);
 
-			dlclose(bundle_getHandle(bundle));
+//			dlclose(bundle_getHandle(bundle));
 		}
 
 		bundleContext_destroy(context);
@@ -1015,10 +1017,16 @@ celix_status_t fw_registerService(FRAMEW
 			arrayList_add(infos, info);
 		}
 
-		SERVICE_REFERENCE ref = (*registration)->reference;
+		apr_pool_t *subpool;
+		apr_pool_create(&subpool, bundle->memoryPool);
+
+		SERVICE_REFERENCE ref = NULL;
+		serviceRegistry_createServiceReference(framework->registry, subpool, *registration, &ref);
 		listener_hook_service_t hook = fw_getService(framework, framework->bundle, ref);
 		hook->added(hook->handle, infos);
 		serviceRegistry_ungetService(framework->registry, framework->bundle, ref);
+
+		apr_pool_destroy(subpool);
 	}
 
 	return CELIX_SUCCESS;
@@ -1051,7 +1059,7 @@ celix_status_t fw_getServiceReferences(F
 		filter = filter_create(sfilter, bundle->memoryPool);
 	}
 
-	*references = serviceRegistry_getServiceReferences(framework->registry, serviceName, filter);
+	serviceRegistry_getServiceReferences(framework->registry, bundle->memoryPool, serviceName, filter, references);
 
 	if (filter != NULL) {
 		filter_destroy(filter);
@@ -1060,7 +1068,8 @@ celix_status_t fw_getServiceReferences(F
 	int refIdx = 0;
 	for (refIdx = 0; (*references != NULL) && refIdx < arrayList_size(*references); refIdx++) {
 		SERVICE_REFERENCE ref = (SERVICE_REFERENCE) arrayList_get(*references, refIdx);
-		SERVICE_REGISTRATION reg = ref->registration;
+		SERVICE_REGISTRATION reg = NULL;
+		serviceReference_getServiceRegistration(ref, &reg);
 		char * serviceName = properties_get(reg->properties, (char *) OBJECTCLASS);
 		if (!serviceReference_isAssignableTo(ref, bundle, serviceName)) {
 			arrayList_remove(*references, refIdx);
@@ -1075,10 +1084,8 @@ void * fw_getService(FRAMEWORK framework
 	return serviceRegistry_getService(framework->registry, bundle, reference);
 }
 
-celix_status_t fw_getBundleRegisteredServices(FRAMEWORK framework, BUNDLE bundle, ARRAY_LIST *services) {
-	celix_status_t status = CELIX_SUCCESS;
-	*services = serviceRegistry_getRegisteredServices(framework->registry, bundle);
-	return status;
+celix_status_t fw_getBundleRegisteredServices(FRAMEWORK framework, apr_pool_t *pool, BUNDLE bundle, ARRAY_LIST *services) {
+	return serviceRegistry_getRegisteredServices(framework->registry, pool, bundle, services);
 }
 
 celix_status_t fw_getBundleServicesInUse(FRAMEWORK framework, BUNDLE bundle, ARRAY_LIST *services) {
@@ -1092,12 +1099,12 @@ bool framework_ungetService(FRAMEWORK fr
 }
 
 void fw_addServiceListener(FRAMEWORK framework, BUNDLE bundle, SERVICE_LISTENER listener, char * sfilter) {
-	apr_pool_t *pool;
-	apr_pool_t *bpool;
-	BUNDLE_CONTEXT context;
-	bundle_getContext(bundle, &context);
-	bundleContext_getMemoryPool(context, &bpool);
-	apr_pool_create(&pool, bpool);
+//	apr_pool_t *pool;
+//	apr_pool_t *bpool;
+//	BUNDLE_CONTEXT context;
+//	bundle_getContext(bundle, &context);
+//	bundleContext_getMemoryPool(context, &bpool);
+//	apr_pool_create(&pool, bpool);
 
 	FW_SERVICE_LISTENER fwListener = (FW_SERVICE_LISTENER) malloc(sizeof(*fwListener));
 	fwListener->bundle = bundle;
@@ -1110,37 +1117,42 @@ void fw_addServiceListener(FRAMEWORK fra
 	fwListener->listener = listener;
 	arrayList_add(framework->serviceListeners, fwListener);
 
+	apr_pool_t *subpool;
+	apr_pool_create(&subpool, listener->pool);
 	ARRAY_LIST listenerHooks = NULL;
-	serviceRegistry_getListenerHooks(framework->registry, &listenerHooks);
+	serviceRegistry_getListenerHooks(framework->registry, subpool, &listenerHooks);
 
-	listener_hook_info_t info = apr_palloc(pool, sizeof(*info));
+	listener_hook_info_t info = apr_palloc(subpool, sizeof(*info));
 	info->context = bundle->context;
 	info->removed = false;
-	info->filter = sfilter == NULL ? NULL : strdup(sfilter);
+	info->filter = sfilter == NULL ? NULL : apr_pstrdup(subpool, sfilter);
 
 	int i;
 	for (i = 0; i < arrayList_size(listenerHooks); i++) {
 		SERVICE_REFERENCE ref = arrayList_get(listenerHooks, i);
 		listener_hook_service_t hook = fw_getService(framework, framework->bundle, ref);
 		ARRAY_LIST infos = NULL;
-		arrayList_create(bundle->memoryPool, &infos);
+		arrayList_create(subpool, &infos);
 		arrayList_add(infos, info);
 		hook->added(hook->handle, infos);
 		serviceRegistry_ungetService(framework->registry, framework->bundle, ref);
 	}
+
+	arrayList_destroy(listenerHooks);
+	apr_pool_destroy(subpool);
 }
 
 void fw_removeServiceListener(FRAMEWORK framework, BUNDLE bundle, SERVICE_LISTENER listener) {
 	listener_hook_info_t info = NULL;
+	apr_pool_t *pool;
+	BUNDLE_CONTEXT context;
+	bundle_getContext(bundle, &context);
+	bundleContext_getMemoryPool(context, &pool);
 	unsigned int i;
 	FW_SERVICE_LISTENER element;
 	for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
 		element = (FW_SERVICE_LISTENER) arrayList_get(framework->serviceListeners, i);
 		if (element->listener == listener && element->bundle == bundle) {
-			apr_pool_t *pool;
-			BUNDLE_CONTEXT context;
-			bundle_getContext(bundle, &context);
-			bundleContext_getMemoryPool(context, &pool);
 			info = apr_palloc(pool, sizeof(*info));
 			info->context = element->bundle->context;
 			// TODO Filter toString;
@@ -1161,7 +1173,7 @@ void fw_removeServiceListener(FRAMEWORK 
 
 	if (info != NULL) {
 		ARRAY_LIST listenerHooks = NULL;
-		serviceRegistry_getListenerHooks(framework->registry, &listenerHooks);
+		serviceRegistry_getListenerHooks(framework->registry, pool, &listenerHooks);
 
 		int i;
 		for (i = 0; i < arrayList_size(listenerHooks); i++) {
@@ -1173,29 +1185,38 @@ void fw_removeServiceListener(FRAMEWORK 
 			hook->removed(hook->handle, infos);
 			serviceRegistry_ungetService(framework->registry, framework->bundle, ref);
 		}
+
+		arrayList_destroy(listenerHooks);
 	}
 }
 
-void fw_serviceChanged(FRAMEWORK framework, SERVICE_EVENT event, PROPERTIES oldprops) {
+void fw_serviceChanged(FRAMEWORK framework, SERVICE_EVENT_TYPE eventType, SERVICE_REGISTRATION registration, PROPERTIES oldprops) {
 	unsigned int i;
 	FW_SERVICE_LISTENER element;
-	SERVICE_REGISTRATION registration = event->reference->registration;
 	if (arrayList_size(framework->serviceListeners) > 0) {
 		for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
 			int matched = 0;
 			element = (FW_SERVICE_LISTENER) arrayList_get(framework->serviceListeners, i);
 			matched = (element->filter == NULL) || filter_match(element->filter, registration->properties);
 			if (matched) {
-				bool assignable;
-				fw_isServiceAssignable(framework, element->bundle, event->reference, &assignable);
-				if (assignable) {
-					element->listener->serviceChanged(element->listener, event);
-				}
-			} else if (event->type == MODIFIED) {
+				SERVICE_REFERENCE reference = NULL;
+				SERVICE_EVENT event = (SERVICE_EVENT) apr_palloc(element->listener->pool, sizeof(*event));
+
+				serviceRegistry_createServiceReference(framework->registry, element->listener->pool, registration, &reference);
+
+				event->type = eventType;
+				event->reference = reference;
+
+				element->listener->serviceChanged(element->listener, event);
+			} else if (eventType == MODIFIED) {
 				int matched = (element->filter == NULL) || filter_match(element->filter, oldprops);
 				if (matched) {
+					SERVICE_REFERENCE reference = NULL;
 					SERVICE_EVENT endmatch = (SERVICE_EVENT) malloc(sizeof(*endmatch));
-					endmatch->reference = event->reference;
+
+					serviceRegistry_createServiceReference(framework->registry, element->listener->pool, registration, &reference);
+
+					endmatch->reference = reference;
 					endmatch->type = MODIFIED_ENDMATCH;
 					element->listener->serviceChanged(element->listener, endmatch);
 				}
@@ -1204,17 +1225,21 @@ void fw_serviceChanged(FRAMEWORK framewo
 	}
 }
 
-celix_status_t fw_isServiceAssignable(FRAMEWORK fw, BUNDLE requester, SERVICE_REFERENCE reference, bool *assignable) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*assignable = true;
-	char *serviceName = properties_get(reference->registration->properties, (char *) OBJECTCLASS);
-	if (!serviceReference_isAssignableTo(reference, requester, serviceName)) {
-		*assignable = false;
-	}
-
-	return status;
-}
+//celix_status_t fw_isServiceAssignable(FRAMEWORK fw, BUNDLE requester, SERVICE_REFERENCE reference, bool *assignable) {
+//	celix_status_t status = CELIX_SUCCESS;
+//
+//	*assignable = true;
+//	SERVICE_REGISTRATION registration = NULL;
+//	status = serviceReference_getServiceRegistration(reference, &registration);
+//	if (status == CELIX_SUCCESS) {
+//		char *serviceName = properties_get(registration->properties, (char *) OBJECTCLASS);
+//		if (!serviceReference_isAssignableTo(reference, requester, serviceName)) {
+//			*assignable = false;
+//		}
+//	}
+//
+//	return status;
+//}
 
 celix_status_t getManifest(BUNDLE_ARCHIVE archive, MANIFEST *manifest) {
 	celix_status_t status = CELIX_SUCCESS;
@@ -1513,6 +1538,7 @@ celix_status_t framework_waitForStop(FRA
 	}
 	while (!framework->shutdown) {
 		apr_status_t apr_status = apr_thread_cond_wait(framework->shutdownGate, framework->mutex);
+		printf("FRAMEWORK: Gate opened\n");
 		if (apr_status != 0) {
 			celix_log("Error waiting for shutdown gate.");
 			return CELIX_FRAMEWORK_EXCEPTION;
@@ -1530,6 +1556,8 @@ static void *APR_THREAD_FUNC framework_s
 //static void * framework_shutdown(void * framework) {
 	FRAMEWORK fw = (FRAMEWORK) framework;
 
+	printf("FRAMEWORK: Shutdown\n");
+
 	HASH_MAP_ITERATOR iterator = hashMapIterator_create(fw->installedBundleMap);
 	while (hashMapIterator_hasNext(iterator)) {
 		BUNDLE bundle = hashMapIterator_nextValue(iterator);
@@ -1550,8 +1578,12 @@ static void *APR_THREAD_FUNC framework_s
 		return NULL;
 	}
 	fw->shutdown = true;
+	printf("FRAMEWORK: Open gate\n");
 	err = apr_thread_cond_broadcast(fw->shutdownGate);
+	printf("FRAMEWORK: BC send %d\n", err);
+	printf("FRAMEWORK: BC send\n");
 	if (err != 0) {
+		printf("FRAMEWORK: BC send\n");
 		celix_log("Error waking the shutdown gate, cannot exit clean.");
 		err = apr_thread_mutex_unlock(fw->mutex);
 		if (err != 0) {
@@ -1561,13 +1593,17 @@ static void *APR_THREAD_FUNC framework_s
 		apr_thread_exit(thd, APR_ENOLOCK);
 		return NULL;
 	}
+	printf("FRAMEWORK: Unlock\n");
 	err = apr_thread_mutex_unlock(fw->mutex);
 	if (err != 0) {
 		celix_log("Error unlocking the framework, cannot exit clean.");
 	}
 
+	printf("FRAMEWORK: Exit thread\n");
 	apr_thread_exit(thd, APR_SUCCESS);
 
+	printf("FRAMEWORK: Shutdown done\n");
+
 	return NULL;
 }
 
@@ -1584,6 +1620,7 @@ celix_status_t bundleActivator_stop(void
 
 	if (bundleContext_getFramework(context, &framework) == CELIX_SUCCESS) {
 
+		printf("FRAMEWORK: Start shutdownthread\n");
 	    if (apr_thread_create(&shutdownThread, NULL, framework_shutdown, framework, framework->mp) == APR_SUCCESS) {
             //int err = pthread_create(&shutdownThread, NULL, framework_shutdown, framework);
             apr_thread_detach(shutdownThread);

Modified: incubator/celix/trunk/framework/private/src/manifest_parser.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/manifest_parser.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/manifest_parser.c (original)
+++ incubator/celix/trunk/framework/private/src/manifest_parser.c Thu Dec 15 10:12:04 2011
@@ -36,6 +36,16 @@
 #include "celix_errno.h"
 #include "linked_list_iterator.h"
 
+struct manifestParser {
+	MODULE owner;
+	MANIFEST manifest;
+
+	VERSION bundleVersion;
+	char * bundleSymbolicName;
+	LINKED_LIST capabilities;
+	LINKED_LIST requirements;
+};
+
 static LINKED_LIST manifestParser_parseImportHeader(char * header, apr_pool_t *memory_pool);
 static LINKED_LIST manifestParser_parseExportHeader(MODULE module, char * header, apr_pool_t *memory_pool);
 static LINKED_LIST manifestParser_parseDelimitedString(char * value, char * delim, apr_pool_t *memory_pool);
@@ -54,9 +64,11 @@ celix_status_t manifestParser_create(MOD
 
         char * bundleVersion = manifest_getValue(manifest, BUNDLE_VERSION);
         if (bundleVersion != NULL) {
-            parser->bundleVersion = version_createVersionFromString(bundleVersion);
+            parser->bundleVersion = NULL;
+            version_createVersionFromString(memory_pool, bundleVersion, &parser->bundleVersion);
         } else {
-            parser->bundleVersion = version_createEmptyVersion();
+        	parser->bundleVersion = NULL;
+			version_createEmptyVersion(memory_pool, &parser->bundleVersion);
         }
         char * bundleSymbolicName = manifest_getValue(manifest, BUNDLE_SYMBOLICNAME);
         if (bundleSymbolicName != NULL) {
@@ -282,7 +294,7 @@ static LINKED_LIST manifestParser_parseI
                     hashMap_put(attributes, name->key, name);
                 }
 
-                REQUIREMENT req = requirement_create(directives, attributes);
+                REQUIREMENT req = requirement_create(memory_pool, directives, attributes);
                 linkedList_addElement(requirements, req);
             }
         }
@@ -330,7 +342,8 @@ static LINKED_LIST manifestParser_parseE
                 hashMap_put(attributes, name->key, name);
             }
 
-            CAPABILITY cap = capability_create(module, directives, attributes);
+            CAPABILITY cap = NULL;
+            capability_create(memory_pool, module, directives, attributes, &cap);
             linkedList_addElement(capabilities, cap);
         }
     }
@@ -346,3 +359,28 @@ static LINKED_LIST manifestParser_parseE
 
 	return capabilities;
 }
+
+celix_status_t manifestParser_getSymbolicName(MANIFEST_PARSER parser, apr_pool_t *pool, char **symbolicName) {
+	*symbolicName = apr_pstrdup(pool, parser->bundleSymbolicName);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t manifestParser_getBundleVersion(MANIFEST_PARSER parser, apr_pool_t *pool, VERSION *version) {
+	return version_clone(parser->bundleVersion, pool, version);
+}
+
+celix_status_t manifestParser_getCapabilities(MANIFEST_PARSER parser, apr_pool_t *pool, LINKED_LIST *capabilities) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	status = linkedList_clone(parser->capabilities, pool, capabilities);
+
+	return status;
+}
+
+celix_status_t manifestParser_getRequirements(MANIFEST_PARSER parser, apr_pool_t *pool, LINKED_LIST *requirements) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	status = linkedList_clone(parser->requirements, pool, requirements);
+
+	return status;
+}

Modified: incubator/celix/trunk/framework/private/src/module.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/module.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/module.c (original)
+++ incubator/celix/trunk/framework/private/src/module.c Thu Dec 15 10:12:04 2011
@@ -70,10 +70,18 @@ MODULE module_create(MANIFEST headerMap,
 
         if (apr_pool_create(&pool, bundle->memoryPool) == APR_SUCCESS) {
             if (manifestParser_create(module, headerMap, pool, &mp) == CELIX_SUCCESS) {
-                module->symbolicName = apr_pstrdup(bundle->memoryPool, mp->bundleSymbolicName);
-                module->version = mp->bundleVersion;
-                module->capabilities = mp->capabilities;
-                module->requirements = mp->requirements;
+            	module->symbolicName = NULL;
+            	manifestParser_getSymbolicName(mp, bundle->memoryPool, &module->symbolicName);
+
+                module->version = NULL;
+                manifestParser_getBundleVersion(mp, bundle->memoryPool, &module->version);
+
+                module->capabilities = NULL;
+                manifestParser_getCapabilities(mp, bundle->memoryPool, &module->capabilities);
+
+                module->requirements = NULL;
+                manifestParser_getRequirements(mp, bundle->memoryPool, &module->requirements);
+
                 module->wires = NULL;
             } else {
                 apr_pool_destroy(pool);
@@ -97,7 +105,9 @@ MODULE module_createFrameworkModule(BUND
 	            if (apr_pool_create(&dependentImporters_pool, bundle->memoryPool) == APR_SUCCESS) {
                     module->id = apr_pstrdup(bundle->memoryPool, "0");
                     module->symbolicName = apr_pstrdup(bundle->memoryPool, "framework");
-                    module->version = version_createVersion(1, 0, 0, "");
+                    module->version = NULL;
+                    version_createVersion(bundle->memoryPool, 1, 0, 0, "", &module->version);
+
                     linkedList_create(capabilities_pool, &module->capabilities);
                     linkedList_create(requirements_pool, &module->requirements);
                     module->dependentImporters = NULL;
@@ -114,13 +124,6 @@ MODULE module_createFrameworkModule(BUND
 }
 
 void module_destroy(MODULE module) {
-	LINKED_LIST_ITERATOR capIter = linkedListIterator_create(module->capabilities, 0);
-	while (linkedListIterator_hasNext(capIter)) {
-		CAPABILITY cap = linkedListIterator_next(capIter);
-		capability_destroy(cap);
-	}
-	linkedListIterator_destroy(capIter);
-
 	LINKED_LIST_ITERATOR reqIter = linkedListIterator_create(module->requirements, 0);
 	while (linkedListIterator_hasNext(reqIter)) {
 		REQUIREMENT req = linkedListIterator_next(reqIter);
@@ -130,8 +133,6 @@ void module_destroy(MODULE module) {
 
 	arrayList_destroy(module->dependentImporters);
 
-	version_destroy(module->version);
-
 	if (module->headerMap != NULL) {
 		manifest_destroy(module->headerMap);
 	}
@@ -144,7 +145,11 @@ WIRE module_getWire(MODULE module, char 
 		LINKED_LIST_ITERATOR iterator = linkedListIterator_create(module->wires, 0);
 		while (linkedListIterator_hasNext(iterator)) {
 			WIRE next = linkedListIterator_next(iterator);
-			if (strcasecmp(capability_getServiceName(wire_getCapability(next)), serviceName) == 0) {
+			CAPABILITY cap = NULL;
+			wire_getCapability(next, &cap);
+			char *name;
+			capability_getServiceName(cap, &name);
+			if (strcasecmp(name, serviceName) == 0) {
 				wire = next;
 			}
 		}
@@ -181,7 +186,8 @@ void module_setWires(MODULE module, LINK
     int i = 0;
     for (i = 0; (module->wires != NULL) && (i < linkedList_size(module->wires)); i++) {
         WIRE wire = (WIRE) linkedList_get(module->wires, i);
-        MODULE exporter = wire_getExporter(wire);
+        MODULE exporter = NULL;
+        wire_getExporter(wire, &exporter);
         module_removeDependentImporter(exporter, module);
     }
 
@@ -189,7 +195,8 @@ void module_setWires(MODULE module, LINK
 
 	for (i = 0; (module->wires != NULL) && (i < linkedList_size(module->wires)); i++) {
         WIRE wire = (WIRE) linkedList_get(module->wires, i);
-        MODULE exporter = wire_getExporter(wire);
+        MODULE exporter = NULL;
+        wire_getExporter(wire, &exporter);
         module_addDependentImporter(exporter, module);
     }
 }

Modified: incubator/celix/trunk/framework/private/src/requirement.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/requirement.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/requirement.c (original)
+++ incubator/celix/trunk/framework/private/src/requirement.c Thu Dec 15 10:12:04 2011
@@ -35,16 +35,18 @@ struct requirement {
 	HASH_MAP directives;
 };
 
-REQUIREMENT requirement_create(HASH_MAP directives, HASH_MAP attributes) {
+REQUIREMENT requirement_create(apr_pool_t *pool, HASH_MAP directives, HASH_MAP attributes) {
 	REQUIREMENT requirement = (REQUIREMENT) malloc(sizeof(*requirement));
 
 	requirement->attributes = attributes;
 	requirement->directives = directives;
 
-	requirement->versionRange = versionRange_createInfiniteVersionRange();
+	requirement->versionRange = NULL;
+	versionRange_createInfiniteVersionRange(pool, &requirement->versionRange);
 	ATTRIBUTE versionAttribute = (ATTRIBUTE) hashMap_get(attributes, "version");
 	if (versionAttribute != NULL) {
-		requirement->versionRange = versionRange_parse(versionAttribute->value);
+		requirement->versionRange = NULL;
+		versionRange_parse(pool, versionAttribute->value, &requirement->versionRange);
 	}
 	ATTRIBUTE serviceAttribute = (ATTRIBUTE) hashMap_get(attributes, "service");
 	requirement->targetName = serviceAttribute->value;
@@ -61,7 +63,6 @@ void requirement_destroy(REQUIREMENT req
 	hashMapIterator_destroy(attrIter);
 	hashMap_destroy(requirement->attributes, false, false);
 	hashMap_destroy(requirement->directives, false, false);
-	versionRange_destroy(requirement->versionRange);
 
 	requirement->attributes = NULL;
 	requirement->directives = NULL;
@@ -79,5 +80,9 @@ char * requirement_getTargetName(REQUIRE
 }
 
 bool requirement_isSatisfied(REQUIREMENT requirement, CAPABILITY capability) {
-	return versionRange_isInRange(requirement_getVersionRange(requirement), capability_getVersion(capability));
+	bool inRange = false;
+	VERSION version = NULL;
+	capability_getVersion(capability, &version);
+	versionRange_isInRange(requirement_getVersionRange(requirement), version, &inRange);
+	return inRange;
 }

Modified: incubator/celix/trunk/framework/private/src/resolver.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/resolver.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/resolver.c (original)
+++ incubator/celix/trunk/framework/private/src/resolver.c Thu Dec 15 10:12:04 2011
@@ -153,8 +153,10 @@ int resolver_populateCandidatesMap(HASH_
                             LINKED_LIST_ITERATOR iterator = NULL;
                             for (iterator = linkedListIterator_create(candidates, 0); linkedListIterator_hasNext(iterator); ) {
                                 CAPABILITY candidate = (CAPABILITY) linkedListIterator_next(iterator);
-                                if (!module_isResolved(capability_getModule(candidate))) {
-                                    if (resolver_populateCandidatesMap(candidatesMap, capability_getModule(candidate)) != 0) {
+                            	MODULE module = NULL;
+                            	capability_getModule(candidate, &module);
+                                if (!module_isResolved(module)) {
+                                    if (resolver_populateCandidatesMap(candidatesMap, module) != 0) {
                                         linkedListIterator_remove(iterator);
                                     }
                                 }
@@ -207,7 +209,9 @@ void resolver_removeInvalidCandidate(MOD
 				LINKED_LIST_ITERATOR candIter;
 				for (candIter = linkedListIterator_create(set->candidates, 0); linkedListIterator_hasNext(candIter); ) {
 					CAPABILITY candCap = (CAPABILITY) linkedListIterator_next(candIter);
-					if (capability_getModule(candCap) == invalidModule) {
+					MODULE module = NULL;
+					capability_getModule(candCap, &module);
+					if (module == invalidModule) {
 						linkedListIterator_remove(candIter);
 						if (linkedList_size(set->candidates) == 0) {
 							linkedListIterator_remove(itCandSetList);
@@ -257,12 +261,14 @@ void resolver_addModule(MODULE module) {
 
         for (i = 0; i < linkedList_size(module_getCapabilities(module)); i++) {
             cap = (CAPABILITY) linkedList_get(module_getCapabilities(module), i);
-            list = resolver_getCapabilityList(m_unresolvedServices, capability_getServiceName(cap));
+            char *serviceName = NULL;
+			capability_getServiceName(cap, &serviceName);
+            list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
             if (list == NULL) {
                 if (apr_pool_create(&capabilities_pool, module_getBundle(module)->memoryPool) == APR_SUCCESS) {
                     list = (CAPABILITY_LIST) apr_palloc(capabilities_pool, sizeof(*list));
                     if (list != NULL) {
-                        list->serviceName = apr_pstrdup(capabilities_pool, capability_getServiceName(cap));
+                        list->serviceName = apr_pstrdup(capabilities_pool, serviceName);
                         if (linkedList_create(capabilities_pool, &list->capabilities) == APR_SUCCESS) {
                             linkedList_addElement(m_unresolvedServices, list);
                         }
@@ -282,11 +288,13 @@ void resolver_removeModule(MODULE module
         int i = 0;
         for (i = 0; i < linkedList_size(caps); i++) {
             CAPABILITY cap = (CAPABILITY) linkedList_get(caps, i);
-            CAPABILITY_LIST list = resolver_getCapabilityList(m_unresolvedServices, capability_getServiceName(cap));
+            char *serviceName = NULL;
+			capability_getServiceName(cap, &serviceName);
+            CAPABILITY_LIST list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
             if (list != NULL) {
                 linkedList_removeElement(list->capabilities, cap);
             }
-            list = resolver_getCapabilityList(m_resolvedServices, capability_getServiceName(cap));
+            list = resolver_getCapabilityList(m_resolvedServices, serviceName);
             if (list != NULL) {
                 linkedList_removeElement(list->capabilities, cap);
             }
@@ -305,7 +313,9 @@ void resolver_moduleResolved(MODULE modu
 	        if (linkedList_create(capsCopy_pool, &capsCopy) == APR_SUCCESS) {
                 for (capIdx = 0; (module_getCapabilities(module) != NULL) && (capIdx < linkedList_size(module_getCapabilities(module))); capIdx++) {
                     CAPABILITY cap = (CAPABILITY) linkedList_get(module_getCapabilities(module), capIdx);
-                    CAPABILITY_LIST list = resolver_getCapabilityList(m_unresolvedServices, capability_getServiceName(cap));
+                    char *serviceName = NULL;
+					capability_getServiceName(cap, &serviceName);
+                    CAPABILITY_LIST list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
                     linkedList_removeElement(list->capabilities, cap);
 
                     linkedList_addElement(capsCopy, cap);
@@ -318,8 +328,9 @@ void resolver_moduleResolved(MODULE modu
                     int wireIdx = 0;
                     for (wireIdx = 0; (wires != NULL) && (wireIdx < linkedList_size(wires)); wireIdx++) {
                         WIRE wire = (WIRE) linkedList_get(wires, wireIdx);
-
-                        if (requirement_isSatisfied(wire_getRequirement(wire), cap)) {
+                        REQUIREMENT req = NULL;
+                        wire_getRequirement(wire, &req);
+                        if (requirement_isSatisfied(req, cap)) {
                             linkedList_set(capsCopy, capIdx, NULL);
                             break;
                         }
@@ -330,12 +341,15 @@ void resolver_moduleResolved(MODULE modu
                     CAPABILITY cap = linkedList_get(capsCopy, capIdx);
 
                     if (cap != NULL) {
-                        CAPABILITY_LIST list = resolver_getCapabilityList(m_resolvedServices, capability_getServiceName(cap));
+                    	char *serviceName = NULL;
+						capability_getServiceName(cap, &serviceName);
+
+                        CAPABILITY_LIST list = resolver_getCapabilityList(m_resolvedServices, serviceName);
                         if (list == NULL) {
                             if (apr_pool_create(&capabilities_pool, module_getBundle(module)->memoryPool) == APR_SUCCESS) {
                                 list = (CAPABILITY_LIST) apr_palloc(capabilities_pool, sizeof(*list));
                                 if (list != NULL) {
-                                    list->serviceName = apr_pstrdup(capabilities_pool, capability_getServiceName(cap));
+                                    list->serviceName = apr_pstrdup(capabilities_pool, serviceName);
                                     if (linkedList_create(capabilities_pool, &list->capabilities) == APR_SUCCESS) {
                                         linkedList_addElement(m_resolvedServices, list);
                                     }
@@ -389,16 +403,18 @@ HASH_MAP resolver_populateWireMap(HASH_M
                         for (candSetIdx = 0; candSetIdx < linkedList_size(candSetList); candSetIdx++) {
                             CANDIDATE_SET cs = (CANDIDATE_SET) linkedList_get(candSetList, candSetIdx);
 
-
-                            if (importer != capability_getModule(((CAPABILITY) linkedList_get(cs->candidates, 0)))) {
-                                WIRE wire = wire_create(importer, cs->requirement,
-                                        capability_getModule(((CAPABILITY) linkedList_get(cs->candidates, 0))),
-                                        ((CAPABILITY) linkedList_get(cs->candidates, 0)));
+                            MODULE module = NULL;
+                            capability_getModule(((CAPABILITY) linkedList_get(cs->candidates, 0)), &module);
+                            if (importer != module) {
+                                WIRE wire = NULL;
+                                wire_create(serviceWires_pool, importer, cs->requirement,
+                                        module,
+                                        ((CAPABILITY) linkedList_get(cs->candidates, 0)), &wire);
                                 linkedList_addElement(serviceWires, wire);
                             }
 
                             wireMap = resolver_populateWireMap(candidates,
-                                    capability_getModule(((CAPABILITY) linkedList_get(cs->candidates, 0))),
+                                    module,
                                     wireMap);
                         }
 

Modified: incubator/celix/trunk/framework/private/src/service_reference.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_reference.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_reference.c (original)
+++ incubator/celix/trunk/framework/private/src/service_reference.c Thu Dec 15 10:12:04 2011
@@ -25,11 +25,58 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "service_registry.h"
 #include "service_reference.h"
 #include "module.h"
 #include "wire.h"
 #include "bundle.h"
 
+struct serviceReference {
+	BUNDLE bundle;
+	struct serviceRegistration * registration;
+};
+
+apr_status_t serviceReference_destroy(void *referenceP);
+
+celix_status_t serviceReference_create(apr_pool_t *pool, BUNDLE bundle, SERVICE_REGISTRATION registration, SERVICE_REFERENCE *reference) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*reference = apr_palloc(pool, sizeof(**reference));
+	if (!*reference) {
+		status = CELIX_ENOMEM;
+	} else {
+		apr_pool_pre_cleanup_register(pool, *reference, serviceReference_destroy);
+
+		(*reference)->bundle = bundle;
+		(*reference)->registration = registration;
+	}
+
+	return status;
+}
+
+apr_status_t serviceReference_destroy(void *referenceP) {
+	SERVICE_REFERENCE reference = referenceP;
+	printf("SERVICE_REFERENCE: Destroy\n");
+	reference->bundle = NULL;
+	reference->registration = NULL;
+	return APR_SUCCESS;
+}
+
+celix_status_t serviceReference_getBundle(SERVICE_REFERENCE reference, BUNDLE *bundle) {
+	*bundle = reference->bundle;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t serviceReference_getServiceRegistration(SERVICE_REFERENCE reference, SERVICE_REGISTRATION *registration) {
+	*registration = reference->registration;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t serviceReference_invalidate(SERVICE_REFERENCE reference) {
+	reference->registration = NULL;
+	return CELIX_SUCCESS;
+}
+
 bool serviceReference_isAssignableTo(SERVICE_REFERENCE reference, BUNDLE requester, char * serviceName) {
 	bool allow = true;
 
@@ -56,10 +103,13 @@ bool serviceReference_isAssignableTo(SER
 celix_status_t serviceReference_getUsingBundles(SERVICE_REFERENCE reference, apr_pool_t *pool, ARRAY_LIST *bundles) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	ARRAY_LIST bnds = serviceRegistry_getUsingBundles(reference->registration->registry, pool, reference);
-
-	*bundles = bnds;
+	*bundles = serviceRegistry_getUsingBundles(reference->registration->registry, pool, reference);
 
 	return status;
 }
 
+celix_status_t serviceReference_equals(SERVICE_REFERENCE reference, SERVICE_REFERENCE compareTo, bool *equal) {
+	*equal = (reference->registration == compareTo->registration);
+	return CELIX_SUCCESS;
+}
+

Modified: incubator/celix/trunk/framework/private/src/service_registration.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_registration.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registration.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registration.c Thu Dec 15 10:12:04 2011
@@ -29,33 +29,34 @@
 #include "service_registration.h"
 #include "constants.h"
 #include "service_factory.h"
+#include "service_reference.h"
 
-celix_status_t serviceRegistration_createInternal(SERVICE_REGISTRY registry, BUNDLE bundle, char * serviceName, long serviceId,
+celix_status_t serviceRegistration_createInternal(apr_pool_t *pool, SERVICE_REGISTRY registry, BUNDLE bundle, char * serviceName, long serviceId,
         void * serviceObject, PROPERTIES dictionary, bool isFactory, SERVICE_REGISTRATION *registration);
 
-SERVICE_REGISTRATION serviceRegistration_create(SERVICE_REGISTRY registry, BUNDLE bundle, char * serviceName, long serviceId, void * serviceObject, PROPERTIES dictionary) {
+SERVICE_REGISTRATION serviceRegistration_create(apr_pool_t *pool, SERVICE_REGISTRY registry, BUNDLE bundle, char * serviceName, long serviceId, void * serviceObject, PROPERTIES dictionary) {
     SERVICE_REGISTRATION registration = NULL;
-	serviceRegistration_createInternal(registry, bundle, serviceName, serviceId, serviceObject, dictionary, false, &registration);
+	serviceRegistration_createInternal(pool, registry, bundle, serviceName, serviceId, serviceObject, dictionary, false, &registration);
 	return registration;
 }
 
-SERVICE_REGISTRATION serviceRegistration_createServiceFactory(SERVICE_REGISTRY registry, BUNDLE bundle, char * serviceName, long serviceId, void * serviceObject, PROPERTIES dictionary) {
+SERVICE_REGISTRATION serviceRegistration_createServiceFactory(apr_pool_t *pool, SERVICE_REGISTRY registry, BUNDLE bundle, char * serviceName, long serviceId, void * serviceObject, PROPERTIES dictionary) {
     SERVICE_REGISTRATION registration = NULL;
-    serviceRegistration_createInternal(registry, bundle, serviceName, serviceId, serviceObject, dictionary, true, &registration);
+    serviceRegistration_createInternal(pool, registry, bundle, serviceName, serviceId, serviceObject, dictionary, true, &registration);
     return registration;
 }
 
-celix_status_t serviceRegistration_createInternal(SERVICE_REGISTRY registry, BUNDLE bundle, char * serviceName, long serviceId,
+celix_status_t serviceRegistration_createInternal(apr_pool_t *pool, SERVICE_REGISTRY registry, BUNDLE bundle, char * serviceName, long serviceId,
         void * serviceObject, PROPERTIES dictionary, bool isFactory, SERVICE_REGISTRATION *registration) {
     celix_status_t status = CELIX_SUCCESS;
 
-    *registration = (SERVICE_REGISTRATION) malloc(sizeof(**registration));
+    *registration = (SERVICE_REGISTRATION) apr_palloc(pool, sizeof(**registration));
     (*registration)->isServiceFactory = isFactory;
     (*registration)->registry = registry;
     (*registration)->className = serviceName;
     (*registration)->bundle = bundle;
     (*registration)->references = NULL;
-    //arrayList_create(pool, &(*registration)->references);
+    arrayList_create(pool, &(*registration)->references);
 
 	if (dictionary == NULL) {
 		dictionary = properties_create();
@@ -76,11 +77,7 @@ celix_status_t serviceRegistration_creat
 	    (*registration)->serviceFactory = NULL;
 	}
 
-	SERVICE_REFERENCE reference = (SERVICE_REFERENCE) malloc(sizeof(*reference));
-	reference->bundle = bundle;
-	reference->registration = *registration;
-
-	(*registration)->reference = reference;
+//	serviceReference_create(pool, bundle, *registration, &(*registration)->reference);
 
 	(*registration)->isUnregistering = false;
 	pthread_mutex_init(&(*registration)->mutex, NULL);
@@ -92,15 +89,12 @@ void serviceRegistration_destroy(SERVICE
 	registration->className = NULL;
 	registration->registry = NULL;
 
-	registration->reference->bundle = NULL;
-	registration->reference->registration = NULL;
-	free(registration->reference);
-
 	properties_destroy(registration->properties);
+	arrayList_destroy(registration->references);
 
 	pthread_mutex_destroy(&registration->mutex);
 
-	free(registration);
+//	free(registration);
 }
 
 bool serviceRegistration_isValid(SERVICE_REGISTRATION registration) {
@@ -124,7 +118,11 @@ celix_status_t serviceRegistration_unreg
 	}
 	pthread_mutex_unlock(&registration->mutex);
 
-	serviceRegistry_unregisterService(registration->registry, registration->reference->bundle, registration);
+//	BUNDLE bundle = NULL;
+//	status = serviceReference_getBundle(registration->reference, &bundle);
+	if (status == CELIX_SUCCESS) {
+		serviceRegistry_unregisterService(registration->registry, registration->bundle, registration);
+	}
 
 	return status;
 }

Modified: incubator/celix/trunk/framework/private/src/service_registry.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_registry.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registry.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registry.c Thu Dec 15 10:12:04 2011
@@ -31,12 +31,14 @@
 #include "bundle.h"
 #include "listener_hook_service.h"
 #include "constants.h"
+#include "service_reference.h"
 
 struct serviceRegistry {
     FRAMEWORK framework;
 	HASH_MAP serviceRegistrations;
+	HASH_MAP serviceReferences;
 	HASH_MAP inUseMap;
-	void (*serviceChanged)(FRAMEWORK, SERVICE_EVENT, PROPERTIES);
+	void (*serviceChanged)(FRAMEWORK, SERVICE_EVENT_TYPE, SERVICE_REGISTRATION, PROPERTIES);
 	long currentServiceId;
 
 	ARRAY_LIST listenerHooks;
@@ -53,8 +55,10 @@ struct usageCount {
 typedef struct usageCount * USAGE_COUNT;
 
 celix_status_t serviceRegistry_registerServiceInternal(SERVICE_REGISTRY registry, BUNDLE bundle, char * serviceName, void * serviceObject, PROPERTIES dictionary, bool isFactory, SERVICE_REGISTRATION *registration);
-celix_status_t serviceRegistry_addHooks(SERVICE_REGISTRY registry, char *serviceName, void *serviceObject, SERVICE_REFERENCE reference);
-celix_status_t serviceRegistry_removeHook(SERVICE_REGISTRY registry, SERVICE_REFERENCE reference);
+celix_status_t serviceRegistry_addHooks(SERVICE_REGISTRY registry, char *serviceName, void *serviceObject, SERVICE_REGISTRATION registration);
+celix_status_t serviceRegistry_removeHook(SERVICE_REGISTRY registry, SERVICE_REGISTRATION registration);
+
+apr_status_t serviceRegistry_removeReference(void *referenceP);
 
 USAGE_COUNT serviceRegistry_getUsageCount(SERVICE_REGISTRY registry, BUNDLE bundle, SERVICE_REFERENCE reference) {
 	ARRAY_LIST usages = hashMap_get(registry->inUseMap, bundle);
@@ -104,7 +108,7 @@ void serviceRegistry_flushUsageCount(SER
 	}
 }
 
-SERVICE_REGISTRY serviceRegistry_create(FRAMEWORK framework, void (*serviceChanged)(FRAMEWORK, SERVICE_EVENT, PROPERTIES)) {
+SERVICE_REGISTRY serviceRegistry_create(FRAMEWORK framework, void (*serviceChanged)(FRAMEWORK, SERVICE_EVENT_TYPE, SERVICE_REGISTRATION, PROPERTIES)) {
 	SERVICE_REGISTRY registry;
 
 	registry = (SERVICE_REGISTRY) apr_palloc(framework->mp, (sizeof(*registry)));
@@ -130,26 +134,31 @@ SERVICE_REGISTRY serviceRegistry_create(
 celix_status_t serviceRegistry_destroy(SERVICE_REGISTRY registry) {
     hashMap_destroy(registry->inUseMap, false, false);
     hashMap_destroy(registry->serviceRegistrations, false, false);
+    arrayList_destroy(registry->listenerHooks);
     pthread_mutex_destroy(&registry->mutex);
 
     return CELIX_SUCCESS;
 }
 
-ARRAY_LIST serviceRegistry_getRegisteredServices(SERVICE_REGISTRY registry, BUNDLE bundle) {
+celix_status_t serviceRegistry_getRegisteredServices(SERVICE_REGISTRY registry, apr_pool_t *pool, BUNDLE bundle, ARRAY_LIST *services) {
+	celix_status_t status = CELIX_SUCCESS;
+
 	ARRAY_LIST regs = (ARRAY_LIST) hashMap_get(registry->serviceRegistrations, bundle);
 	if (regs != NULL) {
-		ARRAY_LIST refs = NULL;
-		arrayList_create(bundle->memoryPool, &refs);
+		arrayList_create(pool, services);
 		int i;
 		for (i = 0; i < arrayList_size(regs); i++) {
 			SERVICE_REGISTRATION reg = arrayList_get(regs, i);
 			if (serviceRegistration_isValid(reg)) {
-				arrayList_add(refs, reg->reference);
+				// #todo Create SERVICE_REFERECEN for each registration
+				SERVICE_REFERENCE reference = NULL;
+				serviceRegistry_createServiceReference(registry, pool, reg, &reference);
+				arrayList_add(*services, reference);
 			}
 		}
-		return refs;
+		return status;
 	}
-	return NULL;
+	return status;
 }
 
 SERVICE_REGISTRATION serviceRegistry_registerService(SERVICE_REGISTRY registry, BUNDLE bundle, char * serviceName, void * serviceObject, PROPERTIES dictionary) {
@@ -167,13 +176,15 @@ SERVICE_REGISTRATION serviceRegistry_reg
 celix_status_t serviceRegistry_registerServiceInternal(SERVICE_REGISTRY registry, BUNDLE bundle, char * serviceName, void * serviceObject, PROPERTIES dictionary, bool isFactory, SERVICE_REGISTRATION *registration) {
 	pthread_mutex_lock(&registry->mutex);
 
+	apr_pool_t *pool = bundle->memoryPool;
+
 	if (isFactory) {
-	    *registration = serviceRegistration_createServiceFactory(registry, bundle, serviceName, ++registry->currentServiceId, serviceObject, dictionary);
+	    *registration = serviceRegistration_createServiceFactory(pool, registry, bundle, serviceName, ++registry->currentServiceId, serviceObject, dictionary);
 	} else {
-	    *registration = serviceRegistration_create(registry, bundle, serviceName, ++registry->currentServiceId, serviceObject, dictionary);
+	    *registration = serviceRegistration_create(pool, registry, bundle, serviceName, ++registry->currentServiceId, serviceObject, dictionary);
 	}
 
-	serviceRegistry_addHooks(registry, serviceName, serviceObject, (*registration)->reference);
+	serviceRegistry_addHooks(registry, serviceName, serviceObject, *registration);
 
 	ARRAY_LIST regs = (ARRAY_LIST) hashMap_get(registry->serviceRegistrations, bundle);
 	if (regs == NULL) {
@@ -186,12 +197,12 @@ celix_status_t serviceRegistry_registerS
 	pthread_mutex_unlock(&registry->mutex);
 
 	if (registry->serviceChanged != NULL) {
-		SERVICE_EVENT event = (SERVICE_EVENT) malloc(sizeof(*event));
-		event->type = REGISTERED;
-		event->reference = (*registration)->reference;
-		registry->serviceChanged(registry->framework, event, NULL);
-		free(event);
-		event = NULL;
+//		SERVICE_EVENT event = (SERVICE_EVENT) malloc(sizeof(*event));
+//		event->type = REGISTERED;
+//		event->reference = (*registration)->reference;
+		registry->serviceChanged(registry->framework, REGISTERED, *registration, NULL);
+//		free(event);
+//		event = NULL;
 	}
 
 	return CELIX_SUCCESS;
@@ -200,7 +211,7 @@ celix_status_t serviceRegistry_registerS
 void serviceRegistry_unregisterService(SERVICE_REGISTRY registry, BUNDLE bundle, SERVICE_REGISTRATION registration) {
 	pthread_mutex_lock(&registry->mutex);
 
-	serviceRegistry_removeHook(registry, registration->reference);
+	serviceRegistry_removeHook(registry, registration);
 
 	ARRAY_LIST regs = (ARRAY_LIST) hashMap_get(registry->serviceRegistrations, bundle);
 	if (regs != NULL) {
@@ -211,25 +222,27 @@ void serviceRegistry_unregisterService(S
 	pthread_mutex_unlock(&registry->mutex);
 
 	if (registry->serviceChanged != NULL) {
-		SERVICE_EVENT event = (SERVICE_EVENT) malloc(sizeof(*event));
-		event->type = UNREGISTERING;
-		event->reference = registration->reference;
-		registry->serviceChanged(registry->framework, event, NULL);
-		free(event);
+		registry->serviceChanged(registry->framework, UNREGISTERING, registration, NULL);
 	}
 
 	pthread_mutex_lock(&registry->mutex);
 	// unget service
 
-	ARRAY_LIST clients = serviceRegistry_getUsingBundles(registry, registry->framework->mp, registration->reference);
 	int i;
-	for (i = 0; (clients != NULL) && (i < arrayList_size(clients)); i++) {
-		BUNDLE client = arrayList_get(clients, i);
-		while (serviceRegistry_ungetService(registry, client, registration->reference)) {
-			;
+	for (i = 0; i < arrayList_size(registration->references); i++) {
+		SERVICE_REFERENCE reference = arrayList_get(registration->references, i);
+		ARRAY_LIST clients = serviceRegistry_getUsingBundles(registry, registry->framework->mp, reference);
+		int j;
+		for (j = 0; (clients != NULL) && (j < arrayList_size(clients)); j++) {
+			BUNDLE client = arrayList_get(clients, j);
+			while (serviceRegistry_ungetService(registry, client, reference)) {
+				;
+			}
 		}
+		arrayList_destroy(clients);
+
+		serviceReference_invalidate(reference);
 	}
-	arrayList_destroy(clients);
 	serviceRegistration_invalidate(registration);
 
 	serviceRegistration_destroy(registration);
@@ -263,9 +276,25 @@ void serviceRegistry_unregisterServices(
 	pthread_mutex_unlock(&registry->mutex);
 }
 
-ARRAY_LIST serviceRegistry_getServiceReferences(SERVICE_REGISTRY registry, const char * serviceName, FILTER filter) {
-	ARRAY_LIST references = NULL;
-	arrayList_create(registry->framework->mp, &references);
+celix_status_t serviceRegistry_createServiceReference(SERVICE_REGISTRY registry, apr_pool_t *pool, SERVICE_REGISTRATION registration, SERVICE_REFERENCE *reference) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	apr_pool_t *spool = NULL;
+	apr_pool_create(&spool, pool);
+
+	serviceReference_create(spool, registration->bundle, registration, reference);
+
+	apr_pool_pre_cleanup_register(spool, *reference, serviceRegistry_removeReference);
+
+	arrayList_add(registration->references, *reference);
+
+	return status;
+}
+
+celix_status_t serviceRegistry_getServiceReferences(SERVICE_REGISTRY registry, apr_pool_t *pool, const char *serviceName, FILTER filter, ARRAY_LIST *references) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	arrayList_create(pool, references);
 
 	HASH_MAP_VALUES registrations = hashMapValues_create(registry->serviceRegistrations);
 	HASH_MAP_ITERATOR iterator = hashMapValues_iterator(registrations);
@@ -285,7 +314,9 @@ ARRAY_LIST serviceRegistry_getServiceRef
 			}
 			if (matched) {
 				if (serviceRegistration_isValid(registration)) {
-					arrayList_add(references, registration->reference);
+					SERVICE_REFERENCE reference = NULL;
+					serviceRegistry_createServiceReference(registry, pool, registration, &reference);
+					arrayList_add(*references, reference);
 				}
 			}
 		}
@@ -293,9 +324,55 @@ ARRAY_LIST serviceRegistry_getServiceRef
 	hashMapIterator_destroy(iterator);
 	hashMapValues_destroy(registrations);
 
-	return references;
+	return status;
 }
 
+apr_status_t serviceRegistry_removeReference(void *referenceP) {
+	SERVICE_REFERENCE reference = referenceP;
+	SERVICE_REGISTRATION registration = NULL;
+	serviceReference_getServiceRegistration(reference, &registration);
+
+	if (registration != NULL) {
+		printf("SERVICE_REGISTRY: Destroy: %s\n", registration->className);
+		arrayList_removeElement(registration->references, reference);
+	}
+
+	return APR_SUCCESS;
+}
+
+//ARRAY_LIST serviceRegistry_getServiceReferences(SERVICE_REGISTRY registry, const char * serviceName, FILTER filter) {
+//	ARRAY_LIST references = NULL;
+//	arrayList_create(registry->framework->mp, &references);
+//
+//	HASH_MAP_VALUES registrations = hashMapValues_create(registry->serviceRegistrations);
+//	HASH_MAP_ITERATOR iterator = hashMapValues_iterator(registrations);
+//	while (hashMapIterator_hasNext(iterator)) {
+//		ARRAY_LIST regs = (ARRAY_LIST) hashMapIterator_nextValue(iterator);
+//		int regIdx;
+//		for (regIdx = 0; (regs != NULL) && regIdx < arrayList_size(regs); regIdx++) {
+//			SERVICE_REGISTRATION registration = (SERVICE_REGISTRATION) arrayList_get(regs, regIdx);
+//
+//			bool matched = false;
+//			if ((serviceName == NULL) && ((filter == NULL) || filter_match(filter, registration->properties))) {
+//				matched = true;
+//			} else if (serviceName != NULL) {
+//				if ((strcmp(registration->className, serviceName) == 0) && ((filter == NULL) || filter_match(filter, registration->properties))) {
+//					matched = true;
+//				}
+//			}
+//			if (matched) {
+//				if (serviceRegistration_isValid(registration)) {
+//					arrayList_add(references, registration->reference);
+//				}
+//			}
+//		}
+//	}
+//	hashMapIterator_destroy(iterator);
+//	hashMapValues_destroy(registrations);
+//
+//	return references;
+//}
+
 ARRAY_LIST serviceRegistry_getServicesInUse(SERVICE_REGISTRY registry, BUNDLE bundle) {
 	ARRAY_LIST usages = hashMap_get(registry->inUseMap, bundle);
 	if (usages != NULL) {
@@ -312,7 +389,8 @@ ARRAY_LIST serviceRegistry_getServicesIn
 }
 
 void * serviceRegistry_getService(SERVICE_REGISTRY registry, BUNDLE bundle, SERVICE_REFERENCE reference) {
-	SERVICE_REGISTRATION registration = reference->registration;
+	SERVICE_REGISTRATION registration = NULL;
+	serviceReference_getServiceRegistration(reference, &registration);
 	void * service = NULL;
 	USAGE_COUNT usage = NULL;
 
@@ -343,7 +421,8 @@ void * serviceRegistry_getService(SERVIC
 }
 
 bool serviceRegistry_ungetService(SERVICE_REGISTRY registry, BUNDLE bundle, SERVICE_REFERENCE reference) {
-	SERVICE_REGISTRATION registration = reference->registration;
+	SERVICE_REGISTRATION registration = NULL;
+	serviceReference_getServiceRegistration(reference, &registration);
 	USAGE_COUNT usage = NULL;
 
 	pthread_mutex_lock(&registry->mutex);
@@ -413,34 +492,43 @@ ARRAY_LIST serviceRegistry_getUsingBundl
 	return bundles;
 }
 
-celix_status_t serviceRegistry_addHooks(SERVICE_REGISTRY registry, char *serviceName, void *serviceObject, SERVICE_REFERENCE reference) {
+celix_status_t serviceRegistry_addHooks(SERVICE_REGISTRY registry, char *serviceName, void *serviceObject, SERVICE_REGISTRATION registration) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (strcmp(listener_hook_service_name, serviceName) == 0) {
-		arrayList_add(registry->listenerHooks, reference);
+		arrayList_add(registry->listenerHooks, registration);
 	}
 
 	return status;
 }
 
-celix_status_t serviceRegistry_removeHook(SERVICE_REGISTRY registry, SERVICE_REFERENCE reference) {
+celix_status_t serviceRegistry_removeHook(SERVICE_REGISTRY registry, SERVICE_REGISTRATION registration) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	char *serviceName = properties_get(reference->registration->properties, (char *) OBJECTCLASS);
+	char *serviceName = properties_get(registration->properties, (char *) OBJECTCLASS);
 	if (strcmp(listener_hook_service_name, serviceName) == 0) {
-		arrayList_removeElement(registry->listenerHooks, reference);
+		arrayList_removeElement(registry->listenerHooks, registration);
 	}
 
 	return status;
 }
 
-celix_status_t serviceRegistry_getListenerHooks(SERVICE_REGISTRY registry, ARRAY_LIST *hooks) {
+celix_status_t serviceRegistry_getListenerHooks(SERVICE_REGISTRY registry, apr_pool_t *pool, ARRAY_LIST *hooks) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (registry == NULL || *hooks != NULL) {
 		status = CELIX_ILLEGAL_ARGUMENT;
 	} else {
-		*hooks = arrayList_clone(registry->framework->mp, registry->listenerHooks);
+		status = arrayList_create(pool, hooks);
+		if (status == CELIX_SUCCESS) {
+			int i;
+			for (i = 0; i < arrayList_size(registry->listenerHooks); i++) {
+				SERVICE_REGISTRATION registration = arrayList_get(registry->listenerHooks, i);
+				SERVICE_REFERENCE reference = NULL;
+				serviceRegistry_createServiceReference(registry, pool, registration, &reference);
+				arrayList_add(*hooks, reference);
+			}
+		}
 	}
 
 	return status;

Modified: incubator/celix/trunk/framework/private/src/service_tracker.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_tracker.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_tracker.c (original)
+++ incubator/celix/trunk/framework/private/src/service_tracker.c Thu Dec 15 10:12:04 2011
@@ -28,7 +28,9 @@
 #include "service_tracker.h"
 #include "bundle_context.h"
 #include "constants.h"
+#include "service_reference.h"
 
+// #todo: Remove this, make SERVICE_TRACKER an ADT to keep "hidden" information
 ARRAY_LIST m_trackers;
 
 void * addingService(FW_SERVICE_TRACKER, SERVICE_REFERENCE);
@@ -65,7 +67,7 @@ celix_status_t serviceTracker_create(BUN
 }
 
 celix_status_t tracker_createWithFilter(BUNDLE_CONTEXT context, char * filter, SERVICE_TRACKER_CUSTOMIZER customizer, SERVICE_TRACKER *tracker) {
-	*tracker = (SERVICE_TRACKER) malloc(sizeof(*tracker));
+	*tracker = (SERVICE_TRACKER) malloc(sizeof(**tracker));
 	FW_SERVICE_TRACKER fw_tracker = (FW_SERVICE_TRACKER) malloc(sizeof(*fw_tracker));
 	apr_pool_t *pool;
 	bundleContext_getMemoryPool(context, &pool);
@@ -98,6 +100,7 @@ celix_status_t serviceTracker_open(SERVI
 		SERVICE_REFERENCE initial_reference;
 		unsigned int i;
 
+		listener->pool = fwTracker->pool;
 		listener->serviceChanged = (void *) tracker_serviceChanged;
 		status = bundleContext_addServiceListener(tracker->context, listener, tracker->filter);
 		if (status == CELIX_SUCCESS) {
@@ -140,8 +143,11 @@ celix_status_t serviceTracker_close(SERV
 void tracker_destroy(SERVICE_TRACKER tracker) {
 	FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
 	bundleContext_removeServiceListener(tracker->context, fwTracker->listener);
+	arrayList_destroy(m_trackers);
 	free(fwTracker->listener);
+	free(fwTracker);
 	tracker = NULL;
+	free(tracker);
 }
 
 SERVICE_REFERENCE tracker_getServiceReference(SERVICE_TRACKER tracker) {
@@ -202,7 +208,9 @@ void * tracker_getServiceByReference(SER
 	unsigned int i;
 	for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
 		tracked = (TRACKED) arrayList_get(fwTracker->tracked, i);
-		if (tracked->reference == reference) {
+		bool equals;
+		serviceReference_equals(reference, tracked->reference, &equals);
+		if (equals) {
 			return tracked->service;
 		}
 	}
@@ -239,7 +247,9 @@ celix_status_t serviceTracker_track(FW_S
 	unsigned int i;
 	for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
 		tracked = (TRACKED) arrayList_get(fwTracker->tracked, i);
-		if (tracked->reference == reference) {
+		bool equals;
+		serviceReference_equals(reference, tracked->reference, &equals);
+		if (equals) {
 			found = 0;
 			break;
 		}
@@ -286,7 +296,9 @@ celix_status_t serviceTracker_untrack(FW
 
 	for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
 		tracked = (TRACKED) arrayList_get(fwTracker->tracked, i);
-		if (tracked->reference == reference) {
+		bool equals;
+		serviceReference_equals(reference, tracked->reference, &equals);
+		if (equals) {
 			if (tracked != NULL) {
 				arrayList_remove(fwTracker->tracked, i);
 				status = bundleContext_ungetService(fwTracker->tracker->context, reference, &result);

Modified: incubator/celix/trunk/framework/private/src/version.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/version.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/version.c (original)
+++ incubator/celix/trunk/framework/private/src/version.c Thu Dec 15 10:12:04 2011
@@ -24,107 +24,161 @@
  */
 #include <stdlib.h>
 #include <stdio.h>
-#include <string.h>
+#include <apr_strings.h>
 
 #include "version.h"
 #include "celix_errno.h"
+#include "framework_log.h"
+
 
 struct version {
+	apr_pool_t *pool;
+
 	int major;
 	int minor;
 	int micro;
-	char * qualifier;
+	char *qualifier;
 };
 
-VERSION version_createVersion(int major, int minor, int micro, char * qualifier) {
-	VERSION version = (VERSION) malloc(sizeof(*version));
+static apr_status_t version_destroy(void *version);
+
+celix_status_t version_createVersion(apr_pool_t *pool, int major, int minor, int micro, char * qualifier, VERSION *version) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*version = (VERSION) apr_palloc(pool, sizeof(**version));
+	if (!*version) {
+		status = CELIX_ENOMEM;
+	} else {
+		apr_pool_pre_cleanup_register(pool, *version, version_destroy);
+
+		(*version)->pool = pool;
+		(*version)->major = major;
+		(*version)->minor = minor;
+		(*version)->micro = micro;
+		if (qualifier == NULL) {
+			qualifier = "";
+		}
+		(*version)->qualifier = apr_pstrdup(pool, qualifier);
 
-	version->major = major;
-	version->minor = minor;
-	version->micro = micro;
-	if (qualifier == NULL) {
-		qualifier = "";
+		if (major < 0) {
+			celix_log("Negative major");
+		}
+		if (minor < 0) {
+			celix_log("Negative minor");
+		}
+		if (micro < 0) {
+			celix_log("Negative micro");
+		}
+		int i;
+		for (i = 0; i < strlen(qualifier); i++) {
+			char ch = qualifier[i];
+			if (('A' <= ch) && (ch <= 'Z')) {
+				continue;
+			}
+			if (('a' <= ch) && (ch <= 'z')) {
+				continue;
+			}
+			if (('0' <= ch) && (ch <= '9')) {
+				continue;
+			}
+			if ((ch == '_') || (ch == '-')) {
+				continue;
+			}
+			celix_log("Invalid qualifier");
+		}
 	}
-	version->qualifier = qualifier;
 
-	return version;
+	return status;
+}
+
+celix_status_t version_clone(VERSION version, apr_pool_t *pool, VERSION *clone) {
+	return version_createVersion(pool, version->major, version->minor, version->micro, version->qualifier, clone);
+}
+
+apr_status_t version_destroy(void *versionP) {
+	VERSION version = versionP;
+	version->major = 0;
+	version->minor = 0;
+	version->micro = 0;
+	version->qualifier = NULL;
+	return APR_SUCCESS;
 }
 
-VERSION version_createVersionFromString(char * version) {
+celix_status_t version_createVersionFromString(apr_pool_t *pool, char * versionStr, VERSION *version) {
+	celix_status_t status = CELIX_SUCCESS;
+
 	int major = 0;
 	int minor = 0;
 	int micro = 0;
 	char * qualifier = "";
 
 	char delims[] = ".";
-	char * token = NULL;
+	char *token = NULL;
+	char *last;
 
-	token = strtok(version, delims);
+	token = apr_strtok(versionStr, delims, &last);
 	if (token != NULL) {
-		char * majorS = strdup(token);
-		major = atoi(majorS);
-		free(majorS);
-		token = strtok(NULL, delims);
+		major = atoi(token);
+		token = apr_strtok(NULL, delims, &last);
 		if (token != NULL) {
 			minor = atoi(token);
-			token = strtok(NULL, delims);
+			token = apr_strtok(NULL, delims, &last);
 			if (token != NULL) {
 				micro = atoi(token);
-				token = strtok(NULL, delims);
+				token = apr_strtok(NULL, delims, &last);
 				if (token != NULL) {
-					qualifier = strdup(token);
-					token = strtok(NULL, delims);
+					qualifier = apr_pstrdup(pool, token);
+					token = apr_strtok(NULL, delims, &last);
 					if (token != NULL) {
 						printf("invalid format");
-						return NULL;
+						*version = NULL;
+						status = CELIX_ILLEGAL_ARGUMENT;
 					}
 				}
 			}
 		}
 	}
-	return version_createVersion(major, minor, micro, qualifier);
-}
-
-VERSION version_createEmptyVersion() {
-	return version_createVersion(0, 0, 0, "");
+	if (status == CELIX_SUCCESS) {
+		status = version_createVersion(pool, major, minor, micro, qualifier, version);
+	}
+	return status;
 }
 
-celix_status_t version_destroy(VERSION version) {
-	version->major = 0;
-	version->minor = 0;
-	version->micro = 0;
-	free(version);
-	return CELIX_SUCCESS;
+celix_status_t version_createEmptyVersion(apr_pool_t *pool, VERSION *version) {
+	return version_createVersion(pool, 0, 0, 0, "", version);
 }
 
-int version_compareTo(VERSION version, VERSION compare) {
+celix_status_t version_compareTo(VERSION version, VERSION compare, int *result) {
+	celix_status_t status = CELIX_SUCCESS;
 	if (compare == version) {
-		return 0;
-	}
-
-	int result = version->major - compare->major;
-	if (result != 0) {
-		return result;
-	}
-
-	result = version->minor - compare->minor;
-	if (result != 0) {
-		return result;
-	}
-
-	result = version->micro - compare->micro;
-	if (result != 0) {
-		return result;
+		*result = 0;
+	} else {
+		int res = version->major - compare->major;
+		if (res != 0) {
+			*result = res;
+		} else {
+			res = version->minor - compare->minor;
+			if (res != 0) {
+				*result = res;
+			} else {
+				res = version->micro - compare->micro;
+				if (res != 0) {
+					*result = res;
+				} else {
+					*result = strcmp(version->qualifier, compare->qualifier);
+				}
+			}
+		}
 	}
 
-	return strcmp(version->qualifier, compare->qualifier);
+	return status;
 }
 
-char * version_toString(VERSION version) {
-	char result[sizeof(version->major) * 3 + strlen(version->qualifier) + 1];
-	sprintf(result, "%d.%d.%d", version->major, version->minor, version->micro);
+celix_status_t version_toString(VERSION version, apr_pool_t *pool, char **string) {
 	if (strlen(version->qualifier) > 0) {
-		strcat(result, version->qualifier);
+		*string = apr_psprintf(pool, "%d.%d.%d.%s", version->major, version->minor, version->micro, version->qualifier);
+	} else {
+		*string = apr_psprintf(pool, "%d.%d.%d", version->major, version->minor, version->micro);
 	}
-	return strdup(result);
+	return CELIX_SUCCESS;
 }

Modified: incubator/celix/trunk/framework/private/src/version_range.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/version_range.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/version_range.c (original)
+++ incubator/celix/trunk/framework/private/src/version_range.c Thu Dec 15 10:12:04 2011
@@ -36,95 +36,147 @@ struct versionRange {
 
 };
 
-VERSION_RANGE versionRange_createVersionRange(VERSION low, bool isLowInclusive,
-			VERSION high, bool isHighInclusive) {
-	VERSION_RANGE range = (VERSION_RANGE) malloc(sizeof(*range));
-
-	range->low = low;
-	range->isLowInclusive = isLowInclusive;
-	range->high = high;
-	range->isHighInclusive = isHighInclusive;
+apr_status_t versionRange_destroy(void *rangeP);
 
-	return range;
-}
+celix_status_t versionRange_createVersionRange(apr_pool_t *pool, VERSION low, bool isLowInclusive,
+			VERSION high, bool isHighInclusive, VERSION_RANGE *range) {
+	celix_status_t status = CELIX_SUCCESS;
+	*range = (VERSION_RANGE) apr_palloc(pool, sizeof(**range));
+	if (!*range) {
+		status = CELIX_ENOMEM;
+	} else {
+		apr_pool_pre_cleanup_register(pool, *range, versionRange_destroy);
 
-void versionRange_destroy(VERSION_RANGE range) {
-	if (range->high != NULL) {
-		version_destroy(range->high);
-	}
-	if (range->low != NULL) {
-		version_destroy(range->low);
+		(*range)->low = low;
+		(*range)->isLowInclusive = isLowInclusive;
+		(*range)->high = high;
+		(*range)->isHighInclusive = isHighInclusive;
 	}
-	free(range);
-}
 
-VERSION_RANGE versionRange_createInfiniteVersionRange() {
-	VERSION_RANGE range = (VERSION_RANGE) malloc(sizeof(*range));
+	return status;
+}
 
-	range->low = version_createEmptyVersion();
-	range->isLowInclusive = true;
+apr_status_t versionRange_destroy(void *rangeP) {
+	VERSION_RANGE range = rangeP;
 	range->high = NULL;
-	range->isHighInclusive = true;
+	range->isHighInclusive = false;
+	range->low = NULL;
+	range->isLowInclusive = false;
+	return APR_SUCCESS;
+}
+
+celix_status_t versionRange_createInfiniteVersionRange(apr_pool_t *pool, VERSION_RANGE *range) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	VERSION version = NULL;
+	status = version_createEmptyVersion(pool, &version);
+	if (status == CELIX_SUCCESS) {
+		status = versionRange_createVersionRange(pool, version, true, NULL, true, range);
+	}
 
-	return range;
+	return status;
 }
 
-bool versionRange_isInRange(VERSION_RANGE versionRange, VERSION version) {
+celix_status_t versionRange_isInRange(VERSION_RANGE versionRange, VERSION version, bool *inRange) {
+	celix_status_t status = CELIX_SUCCESS;
 	if (versionRange->high == NULL) {
-		return (version_compareTo(version, versionRange->low) >= 0);
+		int cmp;
+		status = version_compareTo(version, versionRange->low, &cmp);
+		if (status == CELIX_SUCCESS) {
+			*inRange = (cmp >= 0);
+		}
 	} else if (versionRange->isLowInclusive && versionRange->isHighInclusive) {
-		return (version_compareTo(version, versionRange->low) >= 0)
-				&& (version_compareTo(version, versionRange->high) <= 0);
+		int low, high;
+		status = version_compareTo(version, versionRange->low, &low);
+		if (status == CELIX_SUCCESS) {
+			status = version_compareTo(version, versionRange->high, &high);
+			if (status == CELIX_SUCCESS) {
+				*inRange = (low >= 0) && (high <= 0);
+			}
+		}
 	} else if (versionRange->isHighInclusive) {
-		return (version_compareTo(version, versionRange->low) > 0)
-				&& (version_compareTo(version, versionRange->high) <= 0);
+		int low, high;
+		status = version_compareTo(version, versionRange->low, &low);
+		if (status == CELIX_SUCCESS) {
+			status = version_compareTo(version, versionRange->high, &high);
+			if (status == CELIX_SUCCESS) {
+				*inRange = (low > 0) && (high <= 0);
+			}
+		}
 	} else if (versionRange->isLowInclusive) {
-		return (version_compareTo(version, versionRange->low) >= 0)
-				&& (version_compareTo(version, versionRange->high) < 0);
+		int low, high;
+		status = version_compareTo(version, versionRange->low, &low);
+		if (status == CELIX_SUCCESS) {
+			status = version_compareTo(version, versionRange->high, &high);
+			if (status == CELIX_SUCCESS) {
+				*inRange = (low >= 0) && (high < 0);
+			}
+		}
 	} else {
-		return (version_compareTo(version, versionRange->low) > 0)
-				&& (version_compareTo(version, versionRange->high) < 0);
-	}
-}
-
-bool versionRange_intersects(VERSION_RANGE versionRange, VERSION_RANGE toCompare) {
-	bool isFloorLessThanCeiling = false;
-	if ((versionRange->high == NULL)
-			|| (version_compareTo(versionRange->high, toCompare->low) > 0)
-			|| ((version_compareTo(versionRange->high, toCompare->low) == 0)
-				&& versionRange->isHighInclusive && toCompare->isLowInclusive)) {
-		isFloorLessThanCeiling = true;
-	}
-	bool isCeilingGreaterThanFloor = false;
-	if ((toCompare->high == NULL)
-			|| (version_compareTo(versionRange->low, toCompare->high) < 0)
-			|| ((version_compareTo(versionRange->low, toCompare->high) == 0)
-				&& versionRange->isLowInclusive && toCompare->isHighInclusive)) {
-		isCeilingGreaterThanFloor = true;
-	}
-	return isFloorLessThanCeiling && isCeilingGreaterThanFloor;
-}
-
-VERSION_RANGE versionRange_parse(char * range) {
-	if (strchr(range, ',') != NULL) {
-		int vlowL = strcspn(range+1, ",");
-		char * vlow = (char *) malloc(sizeof(*vlow * vlowL));
-		vlow = strncpy(vlow, range+1, vlowL);
-		int vhighL = strlen(range+1) - vlowL - 2;
-		char * vhigh = (char *) malloc(sizeof(*vhigh * vhighL));
-		vhigh = strncpy(vhigh, range+vlowL+2, vhighL);
-
-		int rangeL = strlen(range);
-		char start = range[0];
-		char end = range[rangeL-1];
-
-		return versionRange_createVersionRange(
-				version_createVersionFromString(vlow),
-				start == '[',
-				version_createVersionFromString(vhigh),
-				end ==']'
-			);
+		int low, high;
+		status = version_compareTo(version, versionRange->low, &low);
+		if (status == CELIX_SUCCESS) {
+			status = version_compareTo(version, versionRange->high, &high);
+			if (status == CELIX_SUCCESS) {
+				*inRange = (low > 0) && (high < 0);
+			}
+		}
+	}
+
+	return status;
+}
+
+celix_status_t versionRange_parse(apr_pool_t *pool, char * rangeStr, VERSION_RANGE *range) {
+	celix_status_t status = CELIX_SUCCESS;
+	if (strchr(rangeStr, ',') != NULL) {
+		apr_pool_t *spool;
+		apr_status_t aprStatus = apr_pool_create(&spool, pool);
+		if (aprStatus != APR_SUCCESS) {
+			status = CELIX_ILLEGAL_STATE;
+		} else {
+			int vlowL = strcspn(rangeStr+1, ",");
+			char * vlow = (char *) apr_palloc(spool, sizeof(*vlow * vlowL));
+			if (!vlow) {
+				status = CELIX_ENOMEM;
+			} else {
+				vlow = strncpy(vlow, rangeStr+1, vlowL);
+				int vhighL = strlen(rangeStr+1) - vlowL - 2;
+				char * vhigh = (char *) apr_palloc(spool, sizeof(*vhigh * vhighL));
+				if (!vhigh) {
+					status = CELIX_ENOMEM;
+				} else {
+					vhigh = strncpy(vhigh, rangeStr+vlowL+2, vhighL);
+
+					int rangeL = strlen(rangeStr);
+					char start = rangeStr[0];
+					char end = rangeStr[rangeL-1];
+
+					VERSION versionLow = NULL;
+					status = version_createVersionFromString(pool, vlow, &versionLow);
+					if (status == CELIX_SUCCESS) {
+						VERSION versionHigh = NULL;
+						status = version_createVersionFromString(pool, vhigh, &versionHigh);
+						if (status == CELIX_SUCCESS) {
+							status = versionRange_createVersionRange(pool,
+									versionLow,
+									start == '[',
+									versionHigh,
+									end ==']',
+									range
+								);
+						}
+					}
+				}
+			}
+			apr_pool_destroy(spool);
+		}
 	} else {
-		return versionRange_createVersionRange(version_createVersionFromString(range), true, NULL, false);
+		VERSION version = NULL;
+		status = version_createVersionFromString(pool, rangeStr, &version);
+		if (status == CELIX_SUCCESS) {
+			status = versionRange_createVersionRange(pool, version, true, NULL, false, range);
+		}
 	}
+
+	return status;
 }

Modified: incubator/celix/trunk/framework/private/src/wire.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/wire.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/wire.c (original)
+++ incubator/celix/trunk/framework/private/src/wire.c Thu Dec 15 10:12:04 2011
@@ -34,37 +34,52 @@ struct wire {
 	CAPABILITY capability;
 };
 
-WIRE wire_create(MODULE importer, REQUIREMENT requirement,
-		MODULE exporter, CAPABILITY capability) {
-	WIRE wire = (WIRE) malloc(sizeof(*wire));
-	wire->importer = importer;
-	wire->requirement = requirement;
-	wire->exporter = exporter;
-	wire->capability = capability;
+apr_status_t wire_destroy(void *wireP);
 
-	return wire;
+celix_status_t wire_create(apr_pool_t *pool, MODULE importer, REQUIREMENT requirement,
+		MODULE exporter, CAPABILITY capability, WIRE *wire) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	(*wire) = (WIRE) apr_palloc(pool, sizeof(**wire));
+	if (!*wire) {
+		status = CELIX_ENOMEM;
+	} else {
+		apr_pool_pre_cleanup_register(pool, *wire, wire_destroy);
+
+		(*wire)->importer = importer;
+		(*wire)->requirement = requirement;
+		(*wire)->exporter = exporter;
+		(*wire)->capability = capability;
+	}
+
+	return status;
 }
 
-void wire_destroy(WIRE wire) {
+apr_status_t wire_destroy(void *wireP) {
+	WIRE wire = wireP;
 	wire->importer = NULL;
 	wire->requirement = NULL;
 	wire->exporter = NULL;
 	wire->capability = NULL;
-	free(wire);
+	return APR_SUCCESS;
 }
 
-CAPABILITY wire_getCapability(WIRE wire) {
-	return wire->capability;
+celix_status_t wire_getCapability(WIRE wire, CAPABILITY *capability) {
+	*capability = wire->capability;
+	return CELIX_SUCCESS;
 }
 
-REQUIREMENT wire_getRequirement(WIRE wire) {
-	return wire->requirement;
+celix_status_t wire_getRequirement(WIRE wire, REQUIREMENT *requirement) {
+	*requirement = wire->requirement;
+	return CELIX_SUCCESS;
 }
 
-MODULE wire_getImporter(WIRE wire) {
-	return wire->importer;
+celix_status_t wire_getImporter(WIRE wire, MODULE *importer) {
+	*importer = wire->importer;
+	return CELIX_SUCCESS;
 }
 
-MODULE wire_getExporter(WIRE wire) {
-	return wire->exporter;
+celix_status_t wire_getExporter(WIRE wire, MODULE *exporter) {
+	*exporter = wire->exporter;
+	return CELIX_SUCCESS;
 }

Modified: incubator/celix/trunk/launcher/launcher.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/launcher/launcher.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/launcher/launcher.c (original)
+++ incubator/celix/trunk/launcher/launcher.c Thu Dec 15 10:12:04 2011
@@ -111,6 +111,7 @@ int main(void) {
     apr_pool_destroy(memoryPool);
     apr_terminate();
 
+    printf("LAUNCHER: Exit\n");
     return 0;
 }
 

Modified: incubator/celix/trunk/log_service/private/src/log.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/log_service/private/src/log.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/log_service/private/src/log.c (original)
+++ incubator/celix/trunk/log_service/private/src/log.c Thu Dec 15 10:12:04 2011
@@ -52,6 +52,7 @@ celix_status_t log_startListenerThread(l
 celix_status_t log_stopListenerThread(log_t 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_t *logger) {
     celix_status_t status = CELIX_SUCCESS;
@@ -62,6 +63,7 @@ celix_status_t log_create(apr_pool_t *po
     } else {
         apr_status_t apr_status;
 
+        apr_pool_pre_cleanup_register(pool, *logger, log_destroy);
         linkedList_create(pool, &(*logger)->entries);
         apr_thread_mutex_create(&(*logger)->lock, APR_THREAD_MUTEX_UNNESTED, pool);
 
@@ -93,6 +95,18 @@ celix_status_t log_create(apr_pool_t *po
     return status;
 }
 
+apr_status_t log_destroy(void *logp) {
+	log_t 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);
+	apr_thread_mutex_destroy(log->lock);
+
+	return APR_SUCCESS;
+}
+
 celix_status_t log_addEntry(log_t log, log_entry_t entry) {
     apr_thread_mutex_lock(log->lock);
     linkedList_addElement(log->entries, entry);

Modified: incubator/celix/trunk/log_service/private/src/log_service_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/log_service/private/src/log_service_activator.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/log_service/private/src/log_service_activator.c (original)
+++ incubator/celix/trunk/log_service/private/src/log_service_activator.c Thu Dec 15 10:12:04 2011
@@ -47,11 +47,13 @@ celix_status_t bundleActivator_create(BU
     bundleContext_getMemoryPool(context, &mp);
     struct logActivator * activator = apr_palloc(mp, sizeof(struct logActivator));
 
-    activator->bundleContext = context;
 
     if (activator == NULL) {
         status = CELIX_ENOMEM;
     } else {
+		activator->bundleContext = context;
+		activator->logServiceFactoryReg = NULL;
+		activator->logReaderServiceReg = NULL;
         *userData = activator;
     }
 

Modified: incubator/celix/trunk/log_service/private/src/log_service_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/log_service/private/src/log_service_impl.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/log_service/private/src/log_service_impl.c (original)
+++ incubator/celix/trunk/log_service/private/src/log_service_impl.c Thu Dec 15 10:12:04 2011
@@ -22,6 +22,7 @@
  *  Created on: Jun 22, 2011
  *      Author: alexander
  */
+#include <stdlib.h>
 
 #include "log_service_impl.h"
 #include "module.h"
@@ -55,7 +56,7 @@ celix_status_t logService_logSr(log_serv
     log_entry_t entry = NULL;
     BUNDLE bundle = logger->bundle;
     if (reference != NULL) {
-        bundle = reference->bundle;
+    	serviceReference_getBundle(reference, &bundle);
     }
     logEntry_create(bundle, reference, level, message, 0, logger->pool, &entry);
     log_addEntry(logger->log, entry);

Modified: incubator/celix/trunk/log_writer/dependency_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/log_writer/dependency_activator.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/log_writer/dependency_activator.c (original)
+++ incubator/celix/trunk/log_writer/dependency_activator.c Thu Dec 15 10:12:04 2011
@@ -48,11 +48,11 @@ void dm_init(void * userData, BUNDLE_CON
 	SERVICE service = dependencyActivatorBase_createService(manager);
 	serviceComponent_setImplementation(service, data);
 
-	SERVICE_DEPENDENCY dep = dependencyActivatorBase_createServiceDependency(manager);
-	serviceDependency_setRequired(dep, true);
-	serviceDependency_setAutoConfigure(dep, (void**) &(data->logReader));
-	serviceDependency_setService(dep, (char *) LOG_READER_SERVICE_NAME, NULL);
-	serviceComponent_addServiceDependency(service, dep);
+	data->dep = dependencyActivatorBase_createServiceDependency(manager);
+	serviceDependency_setRequired(data->dep, false);
+	serviceDependency_setAutoConfigure(data->dep, (void**) &(data->logReader));
+	serviceDependency_setService(data->dep, (char *) LOG_READER_SERVICE_NAME, NULL);
+	serviceComponent_addServiceDependency(service, data->dep);
 
 	data->service = service;
 	dependencyManager_add(manager, service);
@@ -60,6 +60,7 @@ void dm_init(void * userData, BUNDLE_CON
 
 void dm_destroy(void * userData, BUNDLE_CONTEXT context, DEPENDENCY_MANAGER manager) {
     log_writer_t data = (log_writer_t) userData;
+//    serviceComponent_removeServiceDependency(data->service, data->dep);
 	dependencyManager_remove(manager, data->service);
 	//free(data);
 }

Modified: incubator/celix/trunk/log_writer/log_writer.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/log_writer/log_writer.c?rev=1214685&r1=1214684&r2=1214685&view=diff
==============================================================================
--- incubator/celix/trunk/log_writer/log_writer.c (original)
+++ incubator/celix/trunk/log_writer/log_writer.c Thu Dec 15 10:12:04 2011
@@ -55,14 +55,17 @@ void service_init(void * userData) {
 
 void service_start(void * userData) {
     log_writer_t writer = (log_writer_t) userData;
-
-    writer->logReader->addLogListener(writer->logReader->reader, writer->logListener);
+    if (writer->logReader != NULL) {
+    	writer->logReader->addLogListener(writer->logReader->reader, writer->logListener);
+    }
 }
 
 void service_stop(void * userData) {
     log_writer_t writer = (log_writer_t) userData;
 
-    writer->logReader->removeLogListener(writer->logReader->reader, writer->logListener);
+    if (writer->logReader != NULL) {
+    	writer->logReader->removeLogListener(writer->logReader->reader, writer->logListener);
+    }
 }
 
 void service_destroy(void * userData) {



Mime
View raw message