You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by ab...@apache.org on 2011/05/21 22:09:21 UTC

svn commit: r1125794 - in /incubator/celix/trunk: ./ dependency_manager/ framework/private/include/ framework/private/src/ hello_world/ hello_world/root/ launcher/ mongoose/ shell/ whiteboard/publisherA/ whiteboard/publisherB/ whiteboard/tracker/ white...

Author: abroekhuis
Date: Sat May 21 20:09:20 2011
New Revision: 1125794

URL: http://svn.apache.org/viewvc?rev=1125794&view=rev
Log:
updated dependency manager, added initial uninstall support

Added:
    incubator/celix/trunk/shell/uninstall_command.c   (with props)
    incubator/celix/trunk/shell/uninstall_command.h   (with props)
Removed:
    incubator/celix/trunk/hello_world/root/
Modified:
    incubator/celix/trunk/.cproject
    incubator/celix/trunk/CMakeLists.txt
    incubator/celix/trunk/WB Service tracker.launch
    incubator/celix/trunk/dependency_manager/dependency_activator_base.c
    incubator/celix/trunk/dependency_manager/service_component.c
    incubator/celix/trunk/framework/private/include/bundle.h
    incubator/celix/trunk/framework/private/src/bundle.c
    incubator/celix/trunk/framework/private/src/bundle_archive.c
    incubator/celix/trunk/framework/private/src/bundle_context.c
    incubator/celix/trunk/framework/private/src/framework.c
    incubator/celix/trunk/hello_world/CMakeLists.txt
    incubator/celix/trunk/launcher/launcher.c
    incubator/celix/trunk/mongoose/activator.c
    incubator/celix/trunk/shell/CMakeLists.txt
    incubator/celix/trunk/shell/shell.c
    incubator/celix/trunk/target.cmake
    incubator/celix/trunk/whiteboard/publisherA/activator.c
    incubator/celix/trunk/whiteboard/publisherB/activator.c
    incubator/celix/trunk/whiteboard/tracker/activator.c
    incubator/celix/trunk/whiteboard/tracker_depman/tracker.c

Modified: incubator/celix/trunk/.cproject
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/.cproject?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/.cproject (original)
+++ incubator/celix/trunk/.cproject Sat May 21 20:09:20 2011
@@ -5,6 +5,9 @@
 	<storageModule moduleId="org.eclipse.cdt.core.settings">
 		<cconfiguration id="cdt.managedbuild.toolchain.gnu.macosx.base.1808592147">
 			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.macosx.base.1808592147" moduleId="org.eclipse.cdt.core.settings" name="Default">
+				<macros>
+					<stringMacro name="std" type="VALUE_TEXT" value="c99"/>
+				</macros>
 				<externalSettings/>
 				<extensions>
 					<extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>

Modified: incubator/celix/trunk/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/CMakeLists.txt?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/CMakeLists.txt (original)
+++ incubator/celix/trunk/CMakeLists.txt Sat May 21 20:09:20 2011
@@ -44,17 +44,14 @@ include_directories(${APR_INCLUDE_DIR})
 
 include_directories("framework/private/include")
 include_directories("framework/public/include")
-#include_directories("/opt/local/include")
-#link_directories("/opt/local/lib")
 
 add_subdirectory(utils)
 add_subdirectory(framework)
 
-#include(CPackConfig.in)
 include(Packaging.cmake)
-#add_subdirectory(dependency_manager)
+add_subdirectory(dependency_manager)
 add_subdirectory(launcher)
-#add_subdirectory(test)
+add_subdirectory(test)
 
 add_subdirectory(shell)
 add_subdirectory(shell_tui)
@@ -63,11 +60,12 @@ add_subdirectory(shell_tui)
 #add_subdirectory(receiver-2.0)
 #add_subdirectory(sender)
 
+add_subdirectory(deployer)
 add_subdirectory(hello_world)
 add_subdirectory(mongoose)
 #add_subdirectory(echo_service/client)
 #add_subdirectory(echo_service/server)
-#add_subdirectory(whiteboard)
+add_subdirectory(whiteboard)
 #add_subdirectory(echo_service)
 
 add_subdirectory(celix_test)

Modified: incubator/celix/trunk/WB Service tracker.launch
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/WB%20Service%20tracker.launch?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/WB Service tracker.launch (original)
+++ incubator/celix/trunk/WB Service tracker.launch Sat May 21 20:09:20 2011
@@ -17,4 +17,5 @@
 <mapAttribute key="org.eclipse.debug.core.environmentVariables">
 <mapEntry key="DYLD_LIBRARY_PATH" value="${workspace_loc:celix/build/framework}:${workspace_loc:celix/build/utils}"/>
 </mapAttribute>
+<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;&#10;"/>
 </launchConfiguration>

Modified: incubator/celix/trunk/dependency_manager/dependency_activator_base.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/dependency_manager/dependency_activator_base.c?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/dependency_manager/dependency_activator_base.c (original)
+++ incubator/celix/trunk/dependency_manager/dependency_activator_base.c Sat May 21 20:09:20 2011
@@ -37,32 +37,46 @@ struct dependencyActivatorBase {
 
 typedef struct dependencyActivatorBase * DEPENDENCY_ACTIVATOR_BASE;
 
-void * bundleActivator_create() {
-	DEPENDENCY_ACTIVATOR_BASE data = (DEPENDENCY_ACTIVATOR_BASE) malloc(sizeof(*data));
-	void * userData = dm_create();
-	data->userData = userData;
+celix_status_t bundleActivator_create(BUNDLE_CONTEXT context, void **userData) {
+	apr_pool_t *pool;
+	celix_status_t status = bundleContext_getMemoryPool(context, &pool);
+	if (status == CELIX_SUCCESS) {
+		*userData = apr_palloc(pool, sizeof(DEPENDENCY_ACTIVATOR_BASE));
+		void * componentData = dm_create();
+		((DEPENDENCY_ACTIVATOR_BASE)(*userData))->userData = componentData;
+	} else {
+		status = CELIX_START_ERROR;
+	}
 
-	return data;
+	return status;
 }
 
-void bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+celix_status_t bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+	celix_status_t status = CELIX_SUCCESS;
+
 	DEPENDENCY_ACTIVATOR_BASE data = (DEPENDENCY_ACTIVATOR_BASE) userData;
 	data->manager = dependencyManager_create(context);
 	data->context = context;
 	dm_init(data->userData, data->context, data->manager);
+
+	return status;
 }
 
-void bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+celix_status_t bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+	celix_status_t status = CELIX_SUCCESS;
+
 	DEPENDENCY_ACTIVATOR_BASE data = (DEPENDENCY_ACTIVATOR_BASE) userData;
 	dm_destroy(data->userData, data->context, data->manager);
 	data->userData = NULL;
 	data->context = NULL;
 	data->manager = NULL;
+
+	return status;
 }
 
-void bundleActivator_destroy(void * userData) {
-	DEPENDENCY_ACTIVATOR_BASE data = (DEPENDENCY_ACTIVATOR_BASE) userData;
-	free(data);
+celix_status_t bundleActivator_destroy(void * userData, BUNDLE_CONTEXT context) {
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
 }
 
 SERVICE dependencyActivatorBase_createService(DEPENDENCY_MANAGER manager) {

Modified: incubator/celix/trunk/dependency_manager/service_component.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/dependency_manager/service_component.c?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/dependency_manager/service_component.c (original)
+++ incubator/celix/trunk/dependency_manager/service_component.c Sat May 21 20:09:20 2011
@@ -63,6 +63,7 @@ SERVICE serviceComponent_create(BUNDLE_C
 
 	service->impl = NULL;
 	service->serviceName = NULL;
+	service->serviceRegistration = NULL;
 	service->dependencies = arrayList_create();
 
 	service->init = service_init;
@@ -242,7 +243,8 @@ void serviceComponent_deactivateService(
 }
 
 void serviceComponent_startTrackingOptional(SERVICE service, STATE state) {
-	ARRAY_LIST_ITERATOR i = arrayListIterator_create(state->dependencies);
+    ARRAY_LIST deps = arrayList_clone(state->dependencies);
+	ARRAY_LIST_ITERATOR i = arrayListIterator_create(deps);
 	while (arrayListIterator_hasNext(i)) {
 		SERVICE_DEPENDENCY dependency = (SERVICE_DEPENDENCY) arrayListIterator_next(i);
 		if (!dependency->required) {
@@ -250,10 +252,12 @@ void serviceComponent_startTrackingOptio
 		}
 	}
 	arrayListIterator_destroy(i);
+	arrayList_destroy(deps);
 }
 
 void serviceComponent_stopTrackingOptional(SERVICE service, STATE state) {
-	ARRAY_LIST_ITERATOR i = arrayListIterator_create(state->dependencies);
+    ARRAY_LIST deps = arrayList_clone(state->dependencies);
+	ARRAY_LIST_ITERATOR i = arrayListIterator_create(deps);
 	while (arrayListIterator_hasNext(i)) {
 		SERVICE_DEPENDENCY dependency = (SERVICE_DEPENDENCY) arrayListIterator_next(i);
 		if (!dependency->required) {
@@ -261,11 +265,13 @@ void serviceComponent_stopTrackingOption
 		}
 	}
 	arrayListIterator_destroy(i);
+	arrayList_destroy(deps);
 }
 
 void serviceComponent_startTrackingRequired(SERVICE service, void * arg) {
 	STATE state = (STATE) arg;
-	ARRAY_LIST_ITERATOR i = arrayListIterator_create(state->dependencies);
+	ARRAY_LIST deps = arrayList_clone(state->dependencies);
+    ARRAY_LIST_ITERATOR i = arrayListIterator_create(deps);
 	while (arrayListIterator_hasNext(i)) {
 		SERVICE_DEPENDENCY dependency = (SERVICE_DEPENDENCY) arrayListIterator_next(i);
 		if (dependency->required) {
@@ -273,11 +279,13 @@ void serviceComponent_startTrackingRequi
 		}
 	}
 	arrayListIterator_destroy(i);
+	arrayList_destroy(deps);
 }
 
 void serviceComponent_stopTrackingRequired(SERVICE service, void * arg) {
 	STATE state = (STATE) arg;
-	ARRAY_LIST_ITERATOR i = arrayListIterator_create(state->dependencies);
+	ARRAY_LIST deps = arrayList_clone(state->dependencies);
+    ARRAY_LIST_ITERATOR i = arrayListIterator_create(deps);
 	while (arrayListIterator_hasNext(i)) {
 		SERVICE_DEPENDENCY dependency = (SERVICE_DEPENDENCY) arrayListIterator_next(i);
 		if (dependency->required) {
@@ -285,6 +293,7 @@ void serviceComponent_stopTrackingRequir
 		}
 	}
 	arrayListIterator_destroy(i);
+	arrayList_destroy(deps);
 }
 
 void serviceComponent_initService(SERVICE service) {

Modified: incubator/celix/trunk/framework/private/include/bundle.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/bundle.h?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/bundle.h (original)
+++ incubator/celix/trunk/framework/private/include/bundle.h Sat May 21 20:09:20 2011
@@ -51,6 +51,7 @@ celix_status_t bundle_getEntry(BUNDLE bu
 void startBundle(BUNDLE bundle, int options);
 celix_status_t bundle_update(BUNDLE bundle, char *inputFile);
 void stopBundle(BUNDLE bundle, int options);
+celix_status_t bundle_uninstall(BUNDLE bundle);
 
 celix_status_t bundle_setPersistentStateInactive(BUNDLE bundle);
 
@@ -70,5 +71,8 @@ pthread_t bundle_getLockingThread(BUNDLE
 bool bundle_lock(BUNDLE bundle);
 bool bundle_unlock(BUNDLE bundle);
 
+celix_status_t bundle_closeAndDelete(BUNDLE bundle);
+celix_status_t bundle_close(BUNDLE bundle);
+
 
 #endif /* BUNDLE_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=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle.c Sat May 21 20:09:20 2011
@@ -35,6 +35,7 @@
 #include "bundle_archive.h"
 
 MODULE bundle_createModule(BUNDLE bundle);
+celix_status_t bundle_closeRevisions(BUNDLE bundle);
 
 celix_status_t bundle_create(BUNDLE * bundle, apr_pool_t *mp) {
 	*bundle = (BUNDLE) malloc(sizeof(**bundle));
@@ -201,6 +202,14 @@ void stopBundle(BUNDLE bundle, int optio
 	fw_stopBundle(bundle->framework, bundle, ((options & 1) == 0));
 }
 
+celix_status_t bundle_uninstall(BUNDLE bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    fw_uninstallBundle(bundle->framework, bundle);
+
+    return status;
+}
+
 celix_status_t bundle_setPersistentStateInactive(BUNDLE bundle) {
 	if (!bundle_isSystemBundle(bundle)) {
 		bundleArchive_setPersistentState(bundle->archive, BUNDLE_INSTALLED);
@@ -208,6 +217,13 @@ celix_status_t bundle_setPersistentState
 	return CELIX_SUCCESS;
 }
 
+celix_status_t bundle_setPersistentStateUninstalled(BUNDLE bundle) {
+    if (!bundle_isSystemBundle(bundle)) {
+        bundleArchive_setPersistentState(bundle->archive, BUNDLE_UNINSTALLED);
+    }
+    return CELIX_SUCCESS;
+}
+
 celix_status_t bundle_isUsed(BUNDLE bundle, bool *used) {
 	bool unresolved = true;
 	ARRAY_LIST_ITERATOR iter = arrayListIterator_create(bundle->modules);
@@ -306,3 +322,32 @@ bool bundle_unlock(BUNDLE bundle) {
 	pthread_mutex_unlock(&bundle->lock);
 	return true;
 }
+
+celix_status_t bundle_close(BUNDLE bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    bundle_closeRevisions(bundle);
+    BUNDLE_ARCHIVE archive = bundle_getArchive(bundle);
+    bundleArchive_close(archive);
+
+    return status;
+}
+
+celix_status_t bundle_closeAndDelete(BUNDLE bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    bundle_closeRevisions(bundle);
+    BUNDLE_ARCHIVE archive = bundle_getArchive(bundle);
+    bundleArchive_closeAndDelete(archive);
+
+    return status;
+}
+
+celix_status_t bundle_closeRevisions(BUNDLE bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    // TODO implement this
+    return status;
+}
+
+

Modified: incubator/celix/trunk/framework/private/src/bundle_archive.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_archive.c?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_archive.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_archive.c Sat May 21 20:09:20 2011
@@ -284,7 +284,7 @@ void bundleArchive_setRefreshCount(BUNDL
 	strcpy(refreshCounter, archive->archiveRoot);
 	strcat(refreshCounter, "/refresh.counter");
 	apr_file_t * refreshCounterFile;
-	apr_file_open(&refreshCounterFile, refreshCounter, APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp);
+	apr_file_open(&refreshCounterFile, refreshCounter, APR_FOPEN_CREATE|APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp);
 
 	apr_file_printf(refreshCounterFile, "%ld", archive->refreshCount);
 	apr_file_close(refreshCounterFile);
@@ -390,7 +390,7 @@ void bundleArchive_setRevisionLocation(B
 	sprintf(revisionLocation, "%s/version%ld.%ld/revision.location", archive->archiveRoot, bundleArchive_getRefreshCount(archive), revNr);
 
 	apr_file_t * revisionLocationFile;
-	apr_file_open(&revisionLocationFile, revisionLocation, APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp);
+	apr_file_open(&revisionLocationFile, revisionLocation, APR_FOPEN_CREATE|APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp);
 	apr_file_printf(revisionLocationFile, "%s", location);
 	apr_file_close(revisionLocationFile);
 }

Modified: incubator/celix/trunk/framework/private/src/bundle_context.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_context.c?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_context.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_context.c Sat May 21 20:09:20 2011
@@ -45,6 +45,7 @@ celix_status_t bundleContext_create(FRAM
 	    context = malloc(sizeof(*context));
 
 		if (context != NULL) {
+            context->pool = NULL;
 			context->framework = framework;
 			context->bundle = bundle;
 

Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Sat May 21 20:09:20 2011
@@ -32,6 +32,7 @@
 #include <pthread.h>
 #include <math.h>
 #include <apr_file_io.h>
+#include <apr_general.h>
 
 #include "framework.h"
 #include "filter.h"
@@ -74,6 +75,9 @@ long framework_getNextBundleId(FRAMEWORK
 
 celix_status_t fw_installBundle2(FRAMEWORK framework, BUNDLE * bundle, long id, char * location, BUNDLE_ARCHIVE archive);
 
+celix_status_t fw_refreshBundles(FRAMEWORK framework, BUNDLE bundles[], int size);
+celix_status_t fw_refreshBundle(FRAMEWORK framework, BUNDLE bundle);
+
 struct fw_serviceListener {
 	BUNDLE bundle;
 	SERVICE_LISTENER listener;
@@ -82,6 +86,12 @@ struct fw_serviceListener {
 
 typedef struct fw_serviceListener * FW_SERVICE_LISTENER;
 
+struct fw_refreshHelper {
+    FRAMEWORK framework;
+    BUNDLE bundle;
+    BUNDLE_STATE oldState;
+};
+
 celix_status_t framework_create(FRAMEWORK *framework) {
 	*framework = (FRAMEWORK) malloc(sizeof(**framework));
 	if (*framework == NULL) {
@@ -416,15 +426,6 @@ celix_status_t fw_startBundle(FRAMEWORK 
 					library,
 					library_extension
 					);
-//			strcpy(libraryPath, root);
-//			strcat(libraryPath, "/version");
-//			strcat(libraryPath, bundleArchive_getRefreshCount(bundle_getArchive(bundle)));
-//			strcat(libraryPath, ".");
-//			strcat(libraryPath, bundleArchive_getCurrentRevisionNumber(bundle_getArchive(bundle)));
-//			strcat(libraryPath, "/");
-//			strcat(libraryPath, library_prefix);
-//			strcat(libraryPath, library);
-//			strcat(libraryPath, library_extension);
 
 			handle = dlopen(libraryPath, RTLD_LAZY|RTLD_LOCAL);
 			if (handle == NULL) {
@@ -566,10 +567,11 @@ void fw_stopBundle(FRAMEWORK framework, 
 		serviceRegistry_unregisterServices(framework->registry, bundle);
 		serviceRegistry_ungetServices(framework->registry, bundle);
 
-		//dlclose(bundle_getHandle(bundle));
+		dlclose(bundle_getHandle(bundle));
 	}
 
 	bundleContext_destroy(bundle_getContext(bundle));
+	bundle_setContext(bundle, NULL);
 	manifest_destroy(bundle_getManifest(bundle));
 
 	framework_setBundleStateAndNotify(framework, bundle, BUNDLE_RESOLVED);
@@ -577,6 +579,155 @@ void fw_stopBundle(FRAMEWORK framework, 
 	framework_releaseBundleLock(framework, bundle);
 }
 
+celix_status_t fw_uninstallBundle(FRAMEWORK framework, BUNDLE bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+    celix_status_t lock = framework_acquireBundleLock(framework, bundle, BUNDLE_INSTALLED|BUNDLE_RESOLVED|BUNDLE_STARTING|BUNDLE_ACTIVE|BUNDLE_STOPPING);
+    if (lock != CELIX_SUCCESS) {
+        printf("Cannot stop bundle");
+        framework_releaseBundleLock(framework, bundle);
+        if (bundle_getState(bundle) == BUNDLE_UNINSTALLED) {
+            status = CELIX_ILLEGAL_STATE;
+        } else {
+            status = CELIX_BUNDLE_EXCEPTION;
+        }
+    } else {
+        fw_stopBundle(framework, bundle, true);
+
+        bool locked = framework_acquireGlobalLock(framework);
+        if (!locked) {
+            printf("Unable to acquire the global lock to install the bundle\n");
+            framework_releaseGlobalLock(framework);
+            status = CELIX_ILLEGAL_STATE;
+        } else {
+            BUNDLE_ARCHIVE archive = bundle_getArchive(bundle);
+            char * location = bundleArchive_getLocation(archive);
+            // TODO sync issues?
+            BUNDLE target = (BUNDLE) hashMap_remove(framework->installedBundleMap, location);
+
+            if (target != NULL) {
+                bundle_setPersistentStateUninstalled(target);
+                // fw_rememberUninstalledBundle(framework, target);
+            }
+
+            framework_releaseGlobalLock(framework);
+
+            if (target == NULL) {
+                printf("Could not remove bundle from installed map");
+            }
+
+            framework_setBundleStateAndNotify(framework, bundle, BUNDLE_INSTALLED);
+            // TODO: fw_fireBundleEvent(framework BUNDLE_EVENT_UNRESOLVED, bundle);
+
+            framework_setBundleStateAndNotify(framework, bundle, BUNDLE_UNINSTALLED);
+            bundleArchive_setLastModified(archive, time(NULL));
+        }
+        framework_releaseBundleLock(framework, bundle);
+
+        // TODO: fw_fireBundleEvent(framework BUNDLE_EVENT_UNINSTALLED, bundle);
+
+        locked = framework_acquireGlobalLock(framework);
+        if (locked) {
+            BUNDLE bundles[] = { bundle };
+            celix_status_t refreshStatus = fw_refreshBundles(framework, bundles, 1);
+            if (refreshStatus != CELIX_SUCCESS) {
+                printf("Could not refresh bundle");
+            }
+
+            framework_releaseGlobalLock(framework);
+        }
+    }
+
+    return status;
+}
+
+celix_status_t fw_refreshBundles(FRAMEWORK framework, BUNDLE bundles[], int size) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    bool locked = framework_acquireGlobalLock(framework);
+    if (!locked) {
+        printf("Unable to acquire the global lock to install the bundle\n");
+        framework_releaseGlobalLock(framework);
+        status = CELIX_ILLEGAL_STATE;
+    } else {
+        bool restart = false;
+        if (bundles != NULL) {
+            int i = 0;
+            for (i = 0; i < size && !restart; i++) {
+                BUNDLE bundle = bundles[i];
+                if (framework->bundle == bundle) {
+                    restart = true;
+                }
+            }
+
+            struct fw_refreshHelper * helpers[size];
+            for (i = 0; i < size && !restart; i++) {
+                BUNDLE bundle = bundles[i];
+                helpers[i] = malloc(sizeof(struct fw_refreshHelper));
+                helpers[i] ->framework = framework;
+                helpers[i]->bundle = bundle;
+            }
+
+            for (i = 0; i < size; i++) {
+                struct fw_refreshHelper * helper = helpers[i];
+                fw_refreshHelper_stop(helper);
+                fw_refreshHelper_refreshOrRemove(helper);
+            }
+
+            for (i = 0; i < size; i++) {
+                struct fw_refreshHelper * helper = helpers[i];
+                fw_refreshHelper_restart(helper);
+            }
+
+            if (restart) {
+                bundle_update(framework->bundle, NULL);
+            }
+        }
+
+        framework_releaseGlobalLock(framework);
+    }
+
+    return status;
+}
+
+celix_status_t fw_refreshBundle(FRAMEWORK framework, BUNDLE bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+    status = framework_acquireBundleLock(framework, bundle, BUNDLE_INSTALLED | BUNDLE_RESOLVED);
+    if (status != CELIX_SUCCESS) {
+        printf("Cannot refresh bundle");
+        framework_releaseBundleLock(framework, bundle);
+    } else {
+        // TODO fire unresolved event
+        // TODO bundle_refresh(bundle);
+        framework_releaseBundleLock(framework, bundle);
+    }
+    return status;
+}
+
+celix_status_t fw_refreshHelper_stop(struct fw_refreshHelper * refreshHelper) {
+    if (bundle_getState(refreshHelper->bundle) == BUNDLE_ACTIVE) {
+        fw_stopBundle(refreshHelper->framework, refreshHelper->bundle, false);
+    }
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t fw_refreshHelper_refreshOrRemove(struct fw_refreshHelper * refreshHelper) {
+    if (bundle_getState(refreshHelper->bundle) == BUNDLE_UNINSTALLED) {
+        bundle_closeAndDelete(refreshHelper->bundle);
+        refreshHelper->bundle = NULL;
+    } else {
+        fw_refreshBundle(refreshHelper->framework, refreshHelper->bundle);
+    }
+    return CELIX_SUCCESS;
+}
+
+celix_status_t fw_refreshHelper_restart(struct fw_refreshHelper * refreshHelper) {
+    if ((refreshHelper->bundle != NULL) && (refreshHelper->oldState == BUNDLE_ACTIVE)) {
+        fw_startBundle(refreshHelper->framework, refreshHelper->bundle, 0);
+    }
+    return CELIX_SUCCESS;
+}
+
 celix_status_t fw_registerService(FRAMEWORK framework, SERVICE_REGISTRATION *registration, BUNDLE bundle, char * serviceName, void * svcObj, PROPERTIES properties) {
 	if (serviceName == NULL) {
 		printf("Service name cannot be null");

Modified: incubator/celix/trunk/hello_world/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/hello_world/CMakeLists.txt?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/hello_world/CMakeLists.txt (original)
+++ incubator/celix/trunk/hello_world/CMakeLists.txt Sat May 21 20:09:20 2011
@@ -19,4 +19,4 @@ add_library(hello_world SHARED activator
 include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
 target_link_libraries(hello_world framework)
 
-bundle(hello_world DIRECTORIES root)
+bundle(hello_world)

Modified: incubator/celix/trunk/launcher/launcher.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/launcher/launcher.c?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/launcher/launcher.c (original)
+++ incubator/celix/trunk/launcher/launcher.c Sat May 21 20:09:20 2011
@@ -82,7 +82,6 @@ int main(void) {
 
     arrayList_destroy(installed);
 
-
     framework_waitForStop(framework);
     framework_destroy(framework);
     properties_destroy(config);

Modified: incubator/celix/trunk/mongoose/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/mongoose/activator.c?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/mongoose/activator.c (original)
+++ incubator/celix/trunk/mongoose/activator.c Sat May 21 20:09:20 2011
@@ -56,7 +56,7 @@ celix_status_t bundleActivator_start(voi
 		};
 		data->ctx = mg_start(NULL, options);
 
-		printf("Mongoose startet on: %s\n", mg_get_option(data->ctx, "listening_ports"));
+		printf("Mongoose started on: %s\n", mg_get_option(data->ctx, "listening_ports"));
 	} else {
 		status = CELIX_START_ERROR;
 	}
@@ -67,7 +67,7 @@ celix_status_t bundleActivator_start(voi
 celix_status_t bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
 	struct userData * data = (struct userData *) userData;
 	mg_stop(data->ctx);
-	printf("Mongoose stopped");
+	printf("Mongoose stopped\n");
 	return CELIX_SUCCESS;
 }
 

Modified: incubator/celix/trunk/shell/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/CMakeLists.txt?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/shell/CMakeLists.txt (original)
+++ incubator/celix/trunk/shell/CMakeLists.txt Sat May 21 20:09:20 2011
@@ -15,7 +15,10 @@
 # specific language governing permissions and limitations
 # under the License.
 
-add_library(shell SHARED shell command ps_command start_command stop_command install_command update_command)
+add_library(shell SHARED shell command
+	ps_command start_command stop_command
+	install_command update_command
+	uninstall_command)
 include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
 target_link_libraries(shell framework curl)
 

Modified: incubator/celix/trunk/shell/shell.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/shell.c?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/shell/shell.c (original)
+++ incubator/celix/trunk/shell/shell.c Sat May 21 20:09:20 2011
@@ -36,6 +36,7 @@
 #include "start_command.h"
 #include "stop_command.h"
 #include "install_command.h"
+#include "uninstall_command.h"
 #include "update_command.h"
 
 #include "utils.h"
@@ -47,15 +48,21 @@ struct shellServiceActivator {
 	SERVICE_LISTENER listener;
 
 	SERVICE_REGISTRATION psCommand;
-	SERVICE_REGISTRATION startCommand;
-	SERVICE_REGISTRATION stopCommand;
-	SERVICE_REGISTRATION installCommand;
-	SERVICE_REGISTRATION updateCommand;
-
 	COMMAND psCmd;
+
+	SERVICE_REGISTRATION startCommand;
 	COMMAND startCmd;
+
+	SERVICE_REGISTRATION stopCommand;
 	COMMAND stopCmd;
+
+	SERVICE_REGISTRATION installCommand;
 	COMMAND installCmd;
+
+	SERVICE_REGISTRATION uninstallCommand;
+    COMMAND uninstallCmd;
+
+	SERVICE_REGISTRATION updateCommand;
 	COMMAND updateCmd;
 };
 
@@ -110,6 +117,8 @@ void shell_executeCommand(SHELL shell, c
 	COMMAND command = shell_getCommand(shell, commandName);
 	if (command != NULL) {
 		command->executeCommand(command, commandLine, out, error);
+	} else {
+	    error("No such command\n");
 	}
 	free(commandName);
 }
@@ -150,6 +159,7 @@ celix_status_t bundleActivator_create(BU
 	((struct shellServiceActivator *) (*userData))->startCommand = NULL;
 	((struct shellServiceActivator *) (*userData))->stopCommand = NULL;
 	((struct shellServiceActivator *) (*userData))->installCommand = NULL;
+	((struct shellServiceActivator *) (*userData))->uninstallCommand = NULL;
 	((struct shellServiceActivator *) (*userData))->updateCommand = NULL;
 	((struct shellServiceActivator *) (*userData))->registration = NULL;
 
@@ -190,6 +200,9 @@ celix_status_t bundleActivator_start(voi
 	activator->installCmd = installCommand_create(context);
 	activator->installCommand = bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->installCmd, NULL);
 
+	activator->uninstallCmd = uninstallCommand_create(context);
+    activator->uninstallCommand = bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->uninstallCmd, NULL);
+
 	activator->updateCmd = updateCommand_create(context);
 	activator->updateCommand = bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->updateCmd, NULL);
 
@@ -203,6 +216,7 @@ celix_status_t bundleActivator_stop(void
 	serviceRegistration_unregister(activator->startCommand);
 	serviceRegistration_unregister(activator->stopCommand);
 	serviceRegistration_unregister(activator->installCommand);
+	serviceRegistration_unregister(activator->uninstallCommand);
 	serviceRegistration_unregister(activator->updateCommand);
 	bundleContext_removeServiceListener(context, activator->listener);
 
@@ -210,6 +224,7 @@ celix_status_t bundleActivator_stop(void
 	startCommand_destroy(activator->startCmd);
 	stopCommand_destroy(activator->stopCmd);
 	installCommand_destroy(activator->installCmd);
+	uninstallCommand_destroy(activator->uninstallCmd);
 	updateCommand_destroy(activator->updateCmd);
 
 	free(activator->shellService);

Added: incubator/celix/trunk/shell/uninstall_command.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/uninstall_command.c?rev=1125794&view=auto
==============================================================================
--- incubator/celix/trunk/shell/uninstall_command.c (added)
+++ incubator/celix/trunk/shell/uninstall_command.c Sat May 21 20:09:20 2011
@@ -0,0 +1,66 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * start_command.c
+ *
+ *  Created on: Aug 20, 2010
+ *      Author: alexanderb
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "command_private.h"
+#include "array_list.h"
+#include "bundle_context.h"
+#include "bundle.h"
+#include "uninstall_command.h"
+
+void uninstallCommand_execute(COMMAND command, char * line, void (*out)(char *), void (*err)(char *));
+
+COMMAND uninstallCommand_create(BUNDLE_CONTEXT context) {
+	COMMAND command = (COMMAND) malloc(sizeof(*command));
+	command->bundleContext = context;
+	command->name = "uninstall";
+	command->shortDescription = "uninstall bundle(s).";
+	command->usage = "uninstall <id> [<id> ...]";
+	command->executeCommand = uninstallCommand_execute;
+	return command;
+}
+
+void uninstallCommand_destroy(COMMAND command) {
+	free(command);
+}
+
+
+void uninstallCommand_execute(COMMAND command, char * line, void (*out)(char *), void (*err)(char *)) {
+	char delims[] = " ";
+	char * sub = NULL;
+	sub = strtok(line, delims);
+	sub = strtok(NULL, delims);
+	while (sub != NULL) {
+		long id = atol(sub);
+		BUNDLE bundle = bundleContext_getBundleById(command->bundleContext, id);
+		if (bundle != NULL) {
+		    bundle_uninstall(bundle);
+		} else {
+			err("Bundle id is invalid.");
+		}
+		sub = strtok(NULL, delims);
+	}
+}

Propchange: incubator/celix/trunk/shell/uninstall_command.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/celix/trunk/shell/uninstall_command.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/uninstall_command.h?rev=1125794&view=auto
==============================================================================
--- incubator/celix/trunk/shell/uninstall_command.h (added)
+++ incubator/celix/trunk/shell/uninstall_command.h Sat May 21 20:09:20 2011
@@ -0,0 +1,32 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * start_command.h
+ *
+ *  Created on: Aug 20, 2010
+ *      Author: alexanderb
+ */
+
+#ifndef UNINSTALL_COMMAND_H_
+#define UNINSTALL_COMMAND_H_
+
+COMMAND uninstallCommand_create(BUNDLE_CONTEXT context);
+void uninstallCommand_destroy(COMMAND command);
+
+#endif /* UNINSTALL_COMMAND_H_ */

Propchange: incubator/celix/trunk/shell/uninstall_command.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/celix/trunk/target.cmake
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/target.cmake?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/target.cmake (original)
+++ incubator/celix/trunk/target.cmake Sat May 21 20:09:20 2011
@@ -18,6 +18,7 @@
 #deploy("name" BUNDLES receiver receiver-2.0 sender shell shell_tui)
 #deploy("shell test" BUNDLES shell)
 deploy("hello_world" BUNDLES shell shell_tui hello_world celix.mongoose)
-#deploy("wb" BUNDLES tracker publisherA publisherB shell shell_tui)
-#deploy("wb_dp" BUNDLES tracker_depman publisherA publisherB shell shell_tui)
+deploy("deployer" BUNDLES shell shell_tui deployer)
+deploy("wb" BUNDLES tracker publisherA publisherB shell shell_tui)
+deploy("wb_dp" BUNDLES tracker_depman publisherA publisherB shell shell_tui)
 #deploy("echo" BUNDLES echo_server echo_client shell shell_tui)
\ No newline at end of file

Modified: incubator/celix/trunk/whiteboard/publisherA/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/publisherA/activator.c?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/whiteboard/publisherA/activator.c (original)
+++ incubator/celix/trunk/whiteboard/publisherA/activator.c Sat May 21 20:09:20 2011
@@ -29,35 +29,45 @@
 #include "publisher_private.h"
 
 struct activatorData {
-	PUBLISHER_SERVICE ps;
-	PUBLISHER pub;
+    PUBLISHER_SERVICE ps;
+    PUBLISHER pub;
 };
 
-void * bundleActivator_create() {
-	struct activatorData * data = (struct activatorData *) malloc(sizeof(*data));
-	return data;
+celix_status_t bundleActivator_create(BUNDLE_CONTEXT context, void **userData) {
+    apr_pool_t *pool;
+    celix_status_t status = bundleContext_getMemoryPool(context, &pool);
+    if (status == CELIX_SUCCESS) {
+        *userData = apr_palloc(pool, sizeof(struct activatorData));
+    } else {
+        status = CELIX_START_ERROR;
+    }
+    return CELIX_SUCCESS;
 }
 
-void bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
-	struct activatorData * data = (struct activatorData *) userData;
-	data->ps = malloc(sizeof(*(data->ps)));
-	data->pub = malloc(sizeof(*(data->pub)));
-	data->ps->invoke = publisher_invoke;
-	data->ps->publisher = data->pub;
-
-	bundleContext_registerService(context, PUBLISHER_NAME, data->ps, NULL);
+celix_status_t bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+    celix_status_t status = CELIX_SUCCESS;
+    apr_pool_t *pool;
+    status = bundleContext_getMemoryPool(context, &pool);
+    if (status == CELIX_SUCCESS) {
+
+        struct activatorData * data = (struct activatorData *) userData;
+        data->ps = apr_pcalloc(pool, sizeof(*(data->ps)));
+        data->pub = apr_pcalloc(pool, sizeof(*(data->pub)));
+        data->ps->invoke = publisher_invoke;
+        data->ps->publisher = data->pub;
+
+        SERVICE_REGISTRATION service_registration = bundleContext_registerService(context, PUBLISHER_NAME, data->ps, NULL);
+    } else {
+        status = CELIX_START_ERROR;
+    }
+    return status;
 }
 
-void bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
-	struct activatorData * data = (struct activatorData *) userData;
-	data->ps->publisher = NULL;
-	data->ps->invoke = NULL;
-	free(data->pub);
-	free(data->ps);
-	data->pub = NULL;
-	data->ps = NULL;
+celix_status_t bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+    celix_status_t status = CELIX_SUCCESS;
+    return status;
 }
 
-void bundleActivator_destroy(void * userData) {
-	free(userData);
+celix_status_t bundleActivator_destroy(void * userData, BUNDLE_CONTEXT context) {
+    return CELIX_SUCCESS;
 }

Modified: incubator/celix/trunk/whiteboard/publisherB/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/publisherB/activator.c?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/whiteboard/publisherB/activator.c (original)
+++ incubator/celix/trunk/whiteboard/publisherB/activator.c Sat May 21 20:09:20 2011
@@ -33,31 +33,40 @@ struct activatorData {
 	PUBLISHER pub;
 };
 
-void * bundleActivator_create() {
-	struct activatorData * data = (struct activatorData *) malloc(sizeof(*data));
-	return data;
+celix_status_t bundleActivator_create(BUNDLE_CONTEXT context, void **userData) {
+    apr_pool_t *pool;
+    celix_status_t status = bundleContext_getMemoryPool(context, &pool);
+    if (status == CELIX_SUCCESS) {
+        *userData = apr_palloc(pool, sizeof(struct activatorData));
+    } else {
+        status = CELIX_START_ERROR;
+    }
+    return CELIX_SUCCESS;
 }
 
-void bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
-	struct activatorData * data = (struct activatorData *) userData;
-	data->ps = malloc(sizeof(*(data->ps)));
-	data->pub = malloc(sizeof(*(data->pub)));
-	data->ps->invoke = publisher_invoke;
-	data->ps->publisher = data->pub;
+celix_status_t bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+    celix_status_t status = CELIX_SUCCESS;
+    apr_pool_t *pool;
+    status = bundleContext_getMemoryPool(context, &pool);
+    if (status == CELIX_SUCCESS) {
+        struct activatorData * data = (struct activatorData *) userData;
+        data->ps = apr_pcalloc(pool, sizeof(*(data->ps)));
+        data->pub = apr_pcalloc(pool, sizeof(*(data->pub)));
+        data->ps->invoke = publisher_invoke;
+        data->ps->publisher = data->pub;
 
-	bundleContext_registerService(context, PUBLISHER_NAME, data->ps, NULL);
+        SERVICE_REGISTRATION service_registration = bundleContext_registerService(context, PUBLISHER_NAME, data->ps, NULL);
+    } else {
+        status = CELIX_START_ERROR;
+    }
+    return status;
 }
 
-void bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
-	struct activatorData * data = (struct activatorData *) userData;
-	data->ps->publisher = NULL;
-	data->ps->invoke = NULL;
-	free(data->pub);
-	free(data->ps);
-	data->pub = NULL;
-	data->ps = NULL;
+celix_status_t bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+    celix_status_t status = CELIX_SUCCESS;
+    return status;
 }
 
-void bundleActivator_destroy(void * userData) {
-	free(userData);
+celix_status_t bundleActivator_destroy(void * userData, BUNDLE_CONTEXT context) {
+    return CELIX_SUCCESS;
 }

Modified: incubator/celix/trunk/whiteboard/tracker/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/tracker/activator.c?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/whiteboard/tracker/activator.c (original)
+++ incubator/celix/trunk/whiteboard/tracker/activator.c Sat May 21 20:09:20 2011
@@ -63,7 +63,7 @@ void * addingServ(void * handle, SERVICE
 void addedServ(void * handle, SERVICE_REFERENCE ref, void * service) {
 	struct data * data = (struct data *) handle;
 	arrayList_add(data->publishers, service);
-	printf("Added\n");
+	printf("Added %p\n", service);
 }
 
 void modifiedServ(void * handle, SERVICE_REFERENCE ref, void * service) {
@@ -74,40 +74,61 @@ void modifiedServ(void * handle, SERVICE
 void removedServ(void * handle, SERVICE_REFERENCE ref, void * service) {
 	struct data * data = (struct data *) handle;
 	arrayList_removeElement(data->publishers, service);
-	printf("Removed\n");
+	printf("Removed %p\n", service);
 }
 
-void * bundleActivator_create() {
-	struct data * data = malloc(sizeof(*data));
-	data->publishers = arrayList_create();
-	return data;
-}
-
-void bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
-	struct data * data = (struct data *) userData;
-	data->context = context;
-
-	SERVICE_TRACKER_CUSTOMIZER cust = (SERVICE_TRACKER_CUSTOMIZER) malloc(sizeof(*cust));
-	cust->handle = data;
-	cust->addedService = addedServ;
-	cust->addingService = addingServ;
-	cust->modifiedService = modifiedServ;
-	cust->removedService = removedServ;
-	SERVICE_TRACKER tracker = tracker_create(context, (char *) PUBLISHER_NAME, cust);
-	data->tracker = tracker;
-
-	tracker_open(tracker);
-
-	data->running = true;
-	pthread_create(&data->sender, NULL, trk_send, data);
-}
-
-void bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
-	struct data * data = (struct data *) userData;
-	tracker_close(data->tracker);
-	data->running = false;
-}
-
-void bundleActivator_destroy(void * userData) {
-
+celix_status_t bundleActivator_create(BUNDLE_CONTEXT context, void **userData) {
+    apr_pool_t *pool;
+    celix_status_t status = bundleContext_getMemoryPool(context, &pool);
+    if (status == CELIX_SUCCESS) {
+        *userData = apr_palloc(pool, sizeof(struct data));
+        ((struct data *) (*userData))->publishers = arrayList_create();
+    } else {
+        status = CELIX_START_ERROR;
+    }
+    return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+    celix_status_t status = CELIX_SUCCESS;
+    apr_pool_t *pool;
+    status = bundleContext_getMemoryPool(context, &pool);
+    if (status == CELIX_SUCCESS) {
+        struct data * data = (struct data *) userData;
+        data->context = context;
+
+        SERVICE_TRACKER_CUSTOMIZER cust = (SERVICE_TRACKER_CUSTOMIZER) apr_palloc(pool, sizeof(*cust));
+        cust->handle = data;
+        cust->addedService = addedServ;
+        cust->addingService = addingServ;
+        cust->modifiedService = modifiedServ;
+        cust->removedService = removedServ;
+        SERVICE_TRACKER tracker = tracker_create(context, (char *) PUBLISHER_NAME, cust);
+        data->tracker = tracker;
+
+        tracker_open(tracker);
+
+        data->running = true;
+        pthread_create(&data->sender, NULL, trk_send, data);
+    } else {
+        status = CELIX_START_ERROR;
+    }
+    return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+    celix_status_t status = CELIX_SUCCESS;
+    printf("Stop\n");
+
+    struct data * data = (struct data *) userData;
+    tracker_close(data->tracker);
+    data->running = false;
+    pthread_join(data->sender, NULL);
+
+    return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, BUNDLE_CONTEXT context) {
+    celix_status_t status = CELIX_SUCCESS;
+    return status;
 }

Modified: incubator/celix/trunk/whiteboard/tracker_depman/tracker.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/tracker_depman/tracker.c?rev=1125794&r1=1125793&r2=1125794&view=diff
==============================================================================
--- incubator/celix/trunk/whiteboard/tracker_depman/tracker.c (original)
+++ incubator/celix/trunk/whiteboard/tracker_depman/tracker.c Sat May 21 20:09:20 2011
@@ -41,6 +41,7 @@ void service_start(void * userData) {
 void service_stop(void * userData) {
 	struct data * data = (struct data *) userData;
 	data->running = false;
+	pthread_join(data->sender, NULL);
 }
 
 void service_destroy(void * userData) {