Author: abroekhuis
Date: Sat May 21 20:41:08 2011
New Revision: 1125808

URL: http://svn.apache.org/viewvc?rev=1125808&view=rev
Log:
Applied the patch from CELIX-2

Modified:
    incubator/celix/trunk/dependency_manager/service_component.c
    incubator/celix/trunk/dependency_manager/service_dependency.c
    incubator/celix/trunk/echo_service/server/echo_server_activator.c
    incubator/celix/trunk/framework/private/include/bundle_context.h
    incubator/celix/trunk/framework/private/src/bundle_context.c
    incubator/celix/trunk/framework/private/src/service_tracker.c
    incubator/celix/trunk/hello_world/activator.c
    incubator/celix/trunk/receiver/activator.c
    incubator/celix/trunk/sender/test_activator.c
    incubator/celix/trunk/shell/shell.c
    incubator/celix/trunk/shell/start_command.c
    incubator/celix/trunk/shell/stop_command.c
    incubator/celix/trunk/shell/uninstall_command.c
    incubator/celix/trunk/shell/update_command.c
    incubator/celix/trunk/shell_tui/shell_tui.c
    incubator/celix/trunk/whiteboard/publisherA/activator.c
    incubator/celix/trunk/whiteboard/publisherB/activator.c
    incubator/celix/trunk/whiteboard/tracker/activator.c

Modified: incubator/celix/trunk/dependency_manager/service_component.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/dependency_manager/service_component.c?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/dependency_manager/service_component.c (original)
+++ incubator/celix/trunk/dependency_manager/service_component.c Sat May 21 
20:41:08 2011
@@ -188,7 +188,7 @@ void serviceComponent_dependencyUnavaila
 }
 
 void serviceComponent_start(SERVICE service) {
-       service->serviceRegistration = 
bundleContext_registerService(service->context, SERVICE_COMPONENT_NAME, 
service, NULL);
+       bundleContext_registerService(service->context, SERVICE_COMPONENT_NAME, 
service, NULL, &service->serviceRegistration);
        STATE old, new;
        pthread_mutex_lock(&service->mutex);
        old = service->state;
@@ -326,7 +326,7 @@ void serviceComponent_destroyService(SER
 
 void serviceComponent_registerService(SERVICE service) {
        if (service->serviceName != NULL) {
-               service->registration = 
bundleContext_registerService(service->context, service->serviceName, 
service->impl, service->properties);
+               bundleContext_registerService(service->context, 
service->serviceName, service->impl, service->properties, 
&service->registration);
        }
 }
 

Modified: incubator/celix/trunk/dependency_manager/service_dependency.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/dependency_manager/service_dependency.c?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/dependency_manager/service_dependency.c (original)
+++ incubator/celix/trunk/dependency_manager/service_dependency.c Sat May 21 
20:41:08 2011
@@ -76,7 +76,8 @@ void serviceDependency_stop(SERVICE_DEPE
 
 void * serviceDependency_addingService(void * handle, SERVICE_REFERENCE 
reference) {
        SERVICE_DEPENDENCY dependency = (SERVICE_DEPENDENCY) handle;
-       void * service = bundleContext_getService(dependency->context, 
reference);
+       void * service = NULL;
+       bundleContext_getService(dependency->context, reference, &service);
        dependency->reference = reference;
        dependency->serviceInstance = service;
        return service;
@@ -123,7 +124,8 @@ void serviceDependency_removedService(vo
                dependency->removed(dependency->service->impl, reference, 
service);
        }
 
-       bundleContext_ungetService(dependency->context, reference);
+       bool result;
+       bundleContext_ungetService(dependency->context, reference, &result);
 }
 
 void serviceDependency_invokeRemoved(SERVICE_DEPENDENCY dependency) {

Modified: incubator/celix/trunk/echo_service/server/echo_server_activator.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/echo_service/server/echo_server_activator.c?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/echo_service/server/echo_server_activator.c (original)
+++ incubator/celix/trunk/echo_service/server/echo_server_activator.c Sat May 
21 20:41:08 2011
@@ -50,8 +50,7 @@ void bundleActivator_start(void * userDa
 
        act->es = es;
 
-       SERVICE_REGISTRATION reg = bundleContext_registerService(context, 
ECHO_SERVICE_NAME, es, NULL);
-       act->reg = reg;
+    bundleContext_registerService(context, ECHO_SERVICE_NAME, es, NULL, 
&act->reg);
 }
 
 void bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {

Modified: incubator/celix/trunk/framework/private/include/bundle_context.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/bundle_context.h?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/bundle_context.h (original)
+++ incubator/celix/trunk/framework/private/include/bundle_context.h Sat May 21 
20:41:08 2011
@@ -37,19 +37,20 @@ celix_status_t bundleContext_getMemoryPo
 
 celix_status_t bundleContext_installBundle(BUNDLE_CONTEXT context, char * 
location, BUNDLE *bundle);
 
-SERVICE_REGISTRATION bundleContext_registerService(BUNDLE_CONTEXT context, 
char * serviceName, void * svcObj, PROPERTIES properties);
+celix_status_t bundleContext_registerService(BUNDLE_CONTEXT context, char * 
serviceName, void * svcObj,
+        PROPERTIES properties, SERVICE_REGISTRATION *service_registration);
 
-ARRAY_LIST bundleContext_getServiceReferences(BUNDLE_CONTEXT context, char * 
serviceName, char * filter);
-SERVICE_REFERENCE bundleContext_getServiceReference(BUNDLE_CONTEXT context, 
char * serviceName);
+celix_status_t bundleContext_getServiceReferences(BUNDLE_CONTEXT context, char 
* serviceName, char * filter, ARRAY_LIST *service_references);
+celix_status_t bundleContext_getServiceReference(BUNDLE_CONTEXT context, char 
* serviceName, SERVICE_REFERENCE *service_reference);
 
-void * bundleContext_getService(BUNDLE_CONTEXT context, SERVICE_REFERENCE 
reference);
-bool bundleContext_ungetService(BUNDLE_CONTEXT context, SERVICE_REFERENCE 
reference);
+celix_status_t bundleContext_getService(BUNDLE_CONTEXT context, 
SERVICE_REFERENCE reference, void **service_instance);
+celix_status_t bundleContext_ungetService(BUNDLE_CONTEXT context, 
SERVICE_REFERENCE reference, bool *result);
 
 celix_status_t bundleContext_getBundles(BUNDLE_CONTEXT context, ARRAY_LIST 
*bundles);
-BUNDLE bundleContext_getBundleById(BUNDLE_CONTEXT context, long id);
+celix_status_t bundleContext_getBundleById(BUNDLE_CONTEXT context, long id, 
BUNDLE *bundle);
 
-void bundleContext_addServiceListener(BUNDLE_CONTEXT context, SERVICE_LISTENER 
listener, char * filter);
-void bundleContext_removeServiceListener(BUNDLE_CONTEXT context, 
SERVICE_LISTENER listener);
+celix_status_t bundleContext_addServiceListener(BUNDLE_CONTEXT context, 
SERVICE_LISTENER listener, char * filter);
+celix_status_t bundleContext_removeServiceListener(BUNDLE_CONTEXT context, 
SERVICE_LISTENER listener);
 
 
 #endif /* BUNDLE_CONTEXT_H_ */

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=1125808&r1=1125807&r2=1125808&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:41:08 2011
@@ -19,8 +19,6 @@
 /*
  * bundle_context.c
  *
- *Some change to test hudson
- *
  *  Created on: Mar 26, 2010
  *      Author: alexanderb
  */
@@ -123,7 +121,7 @@ celix_status_t bundleContext_installBund
        celix_status_t status = CELIX_SUCCESS;
        BUNDLE b = NULL;
 
-       if (*bundle == NULL) {
+       if (context != NULL && *bundle == NULL) {
                if (fw_installBundle(context->framework, &b, location) != 
CELIX_SUCCESS) {
             status = CELIX_FRAMEWORK_EXCEPTION;
                } else {
@@ -136,37 +134,83 @@ celix_status_t bundleContext_installBund
        return status;
 }
 
-SERVICE_REGISTRATION bundleContext_registerService(BUNDLE_CONTEXT context, 
char * serviceName, void * svcObj, PROPERTIES properties) {
+celix_status_t bundleContext_registerService(BUNDLE_CONTEXT context, char * 
serviceName, void * svcObj,
+        PROPERTIES properties, SERVICE_REGISTRATION *service_registration) {
        SERVICE_REGISTRATION registration = NULL;
-       fw_registerService(context->framework, &registration, context->bundle, 
serviceName, svcObj, properties);
-       return registration;
+       celix_status_t status = CELIX_SUCCESS;
+
+       if (context != NULL && *service_registration == NULL) {
+           fw_registerService(context->framework, &registration, 
context->bundle, serviceName, svcObj, properties);
+           *service_registration = registration;
+       } else {
+           status = CELIX_ILLEGAL_ARGUMENT;
+       }
+
+       return status;
 }
 
-ARRAY_LIST bundleContext_getServiceReferences(BUNDLE_CONTEXT context, char * 
serviceName, char * filter) {
-       ARRAY_LIST references = NULL;
-       fw_getServiceReferences(context->framework, &references, 
context->bundle, serviceName, filter);
-       return references;
+celix_status_t bundleContext_getServiceReferences(BUNDLE_CONTEXT context, char 
* serviceName, char * filter, ARRAY_LIST *service_references) {
+    ARRAY_LIST references = NULL;
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && *service_references == NULL) {
+        fw_getServiceReferences(context->framework, &references, 
context->bundle, serviceName, filter);
+        *service_references = references;
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+       return status;
 }
 
-SERVICE_REFERENCE bundleContext_getServiceReference(BUNDLE_CONTEXT context, 
char * serviceName) {
-       ARRAY_LIST services = bundleContext_getServiceReferences(context, 
serviceName, NULL);
-       SERVICE_REFERENCE reference = (arrayList_size(services) > 0) ? 
arrayList_get(services, 0) : NULL;
-       arrayList_destroy(services);
-       return reference;
+celix_status_t bundleContext_getServiceReference(BUNDLE_CONTEXT context, char 
* serviceName, SERVICE_REFERENCE *service_reference) {
+    SERVICE_REFERENCE reference = NULL;
+    ARRAY_LIST services = NULL;
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (serviceName != NULL) {
+        if (bundleContext_getServiceReferences(context, serviceName, NULL, 
&services) == CELIX_SUCCESS) {
+            reference = (arrayList_size(services) > 0) ? 
arrayList_get(services, 0) : NULL;
+            arrayList_destroy(services);
+            *service_reference = reference;
+        } else {
+            status = CELIX_ILLEGAL_ARGUMENT;
+        }
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+       return status;
 }
 
-void * bundleContext_getService(BUNDLE_CONTEXT context, SERVICE_REFERENCE 
reference) {
-       return fw_getService(context->framework, context->bundle, reference);
+celix_status_t bundleContext_getService(BUNDLE_CONTEXT context, 
SERVICE_REFERENCE reference, void **service_instance) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && reference != NULL && *service_instance == NULL) {
+           *service_instance = fw_getService(context->framework, 
context->bundle, reference);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    return status;
 }
 
-bool bundleContext_ungetService(BUNDLE_CONTEXT context, SERVICE_REFERENCE 
reference) {
-       return framework_ungetService(context->framework, context->bundle, 
reference);
+celix_status_t bundleContext_ungetService(BUNDLE_CONTEXT context, 
SERVICE_REFERENCE reference, bool *result) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && reference != NULL) {
+        *result = framework_ungetService(context->framework, context->bundle, 
reference);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    return status;
 }
 
 celix_status_t bundleContext_getBundles(BUNDLE_CONTEXT context, ARRAY_LIST 
*bundles) {
        celix_status_t status = CELIX_SUCCESS;
 
-       if (context == NULL) {
+       if (context == NULL || *bundles != NULL) {
                status = CELIX_ILLEGAL_ARGUMENT;
        } else {
                *bundles = framework_getBundles(context->framework);
@@ -175,14 +219,38 @@ celix_status_t bundleContext_getBundles(
        return status;
 }
 
-BUNDLE bundleContext_getBundleById(BUNDLE_CONTEXT context, long id) {
-       return framework_getBundleById(context->framework, id);
+celix_status_t bundleContext_getBundleById(BUNDLE_CONTEXT context, long id, 
BUNDLE *bundle) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context == NULL || *bundle != NULL) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    } else {
+        *bundle = framework_getBundleById(context->framework, id);
+    }
+
+       return status;
 }
 
-void bundleContext_addServiceListener(BUNDLE_CONTEXT context, SERVICE_LISTENER 
listener, char * filter) {
-       fw_addServiceListener(context->bundle, listener, filter);
+celix_status_t bundleContext_addServiceListener(BUNDLE_CONTEXT context, 
SERVICE_LISTENER listener, char * filter) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && listener != NULL) {
+        fw_addServiceListener(context->bundle, listener, filter);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    return status;
 }
 
-void bundleContext_removeServiceListener(BUNDLE_CONTEXT context, 
SERVICE_LISTENER listener) {
-       fw_removeServiceListener(context->bundle, listener);
+celix_status_t bundleContext_removeServiceListener(BUNDLE_CONTEXT context, 
SERVICE_LISTENER listener) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    if (context != NULL && listener != NULL) {
+        fw_removeServiceListener(context->bundle, listener);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    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=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_tracker.c (original)
+++ incubator/celix/trunk/framework/private/src/service_tracker.c Sat May 21 
20:41:08 2011
@@ -58,8 +58,9 @@ SERVICE_TRACKER tracker_create(BUNDLE_CO
 void tracker_open(SERVICE_TRACKER tracker) {
        SERVICE_LISTENER listener = (SERVICE_LISTENER) 
malloc(sizeof(*listener));
        FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
+       ARRAY_LIST initial = NULL;
 
-       ARRAY_LIST initial = 
bundleContext_getServiceReferences(tracker->context, tracker->className, NULL);
+       bundleContext_getServiceReferences(tracker->context, 
tracker->className, NULL, &initial);
        SERVICE_REFERENCE initial_reference;
        unsigned int i;
        int len = strlen(tracker->className);
@@ -226,27 +227,33 @@ void track(FW_SERVICE_TRACKER fwTracker,
 }
 
 void * addingService(FW_SERVICE_TRACKER fwTracker, SERVICE_REFERENCE 
reference) {
-       if (fwTracker->customizer != NULL) {
-               return 
fwTracker->customizer->addingService(fwTracker->customizer->handle, reference);
+    void *svc = NULL;
+
+    if (fwTracker->customizer != NULL) {
+               svc = 
fwTracker->customizer->addingService(fwTracker->customizer->handle, reference);
        } else {
-               return bundleContext_getService(fwTracker->tracker->context, 
reference);
+               bundleContext_getService(fwTracker->tracker->context, 
reference, &svc);
        }
+
+    return svc;
 }
 
 void untrack(FW_SERVICE_TRACKER fwTracker, SERVICE_REFERENCE reference, 
SERVICE_EVENT event ATTRIBUTE_UNUSED) {
        TRACKED tracked = NULL;
        unsigned int i;
+       bool result = NULL;
+
        for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
                tracked = (TRACKED) arrayList_get(fwTracker->tracked, i);
                if (tracked->reference == reference) {
                        if (tracked != NULL) {
                                arrayList_remove(fwTracker->tracked, i);
-                               
bundleContext_ungetService(fwTracker->tracker->context, reference);
+                               
bundleContext_ungetService(fwTracker->tracker->context, reference, &result);
                        }
                        if (fwTracker->customizer != NULL) {
                                
fwTracker->customizer->removedService(fwTracker->customizer->handle, reference, 
tracked->service);
                        } else {
-                               
bundleContext_ungetService(fwTracker->tracker->context, reference);
+                               
bundleContext_ungetService(fwTracker->tracker->context, reference, &result);
                        }
                        free(tracked);
                        break;

Modified: incubator/celix/trunk/hello_world/activator.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/hello_world/activator.c?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/hello_world/activator.c (original)
+++ incubator/celix/trunk/hello_world/activator.c Sat May 21 20:41:08 2011
@@ -46,13 +46,10 @@ celix_status_t bundleActivator_create(BU
 }
 
 celix_status_t bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
-       BUNDLE bundle;
-       celix_status_t status = CELIX_SUCCESS;
-
        struct userData * data = (struct userData *) userData;
        printf("Hello %s\n", data->word);
 
-       return status;
+       return CELIX_SUCCESS;
 }
 
 celix_status_t bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {

Modified: incubator/celix/trunk/receiver/activator.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/receiver/activator.c?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/receiver/activator.c (original)
+++ incubator/celix/trunk/receiver/activator.c Sat May 21 20:41:08 2011
@@ -41,7 +41,7 @@ void bundleActivator_start(void * userDa
        m_test->handle = serviceTest_construct();
        m_test->doo = doo;
 
-       reg = bundleContext_registerService(context, SERVICE_TEST_NAME, m_test, 
props);
+       bundleContext_registerService(context, SERVICE_TEST_NAME, m_test, 
props, &reg);
        //reg2 = register_service(context, SERVICE_TEST_NAME, test, NULL);
 }
 

Modified: incubator/celix/trunk/sender/test_activator.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/sender/test_activator.c?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/sender/test_activator.c (original)
+++ incubator/celix/trunk/sender/test_activator.c Sat May 21 20:41:08 2011
@@ -127,8 +127,12 @@ void service_destroy(void * userData) {
 //}
 
 void * addingServ(void * handle, SERVICE_REFERENCE ref) {
+    void *service_instance = NULL;
+
        printf("Adding\n");
-       return bundleContext_getService(m_context, ref);
+       bundleContext_getService(m_context, ref, &service_instance);
+
+       return service_instance;
 }
 
 void addedServ(void * handle, SERVICE_REFERENCE ref, void * service) {

Modified: incubator/celix/trunk/shell/shell.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/shell/shell.c?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/shell/shell.c (original)
+++ incubator/celix/trunk/shell/shell.c Sat May 21 20:41:08 2011
@@ -129,7 +129,8 @@ COMMAND shell_getCommand(SHELL shell, ch
 }
 
 void shell_addCommand(SHELL shell, SERVICE_REFERENCE reference) {
-       void * cmd = bundleContext_getService(shell->bundleContext, reference);
+    void *cmd = NULL;
+       bundleContext_getService(shell->bundleContext, reference, &cmd);
        COMMAND command = (COMMAND) cmd;
        hashMap_put(shell->commandNameMap, command->name, command);
        hashMap_put(shell->commandReferenceMap, reference, command);
@@ -169,6 +170,8 @@ celix_status_t bundleActivator_create(BU
 }
 
 celix_status_t bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+    celix_status_t status;
+
        struct shellServiceActivator * activator = (struct 
shellServiceActivator *) userData;
        activator->shell->bundleContext = context;
 
@@ -180,36 +183,41 @@ celix_status_t bundleActivator_start(voi
        activator->shellService->getCommandReference = 
shell_getCommandReference;
        activator->shellService->executeCommand = shell_executeCommand;
 
-       activator->registration = bundleContext_registerService(context, (char 
*) SHELL_SERVICE_NAME, activator->shellService, NULL);
-
-       SERVICE_LISTENER listener = (SERVICE_LISTENER) 
malloc(sizeof(*listener));
-       activator->listener = listener;
-       listener->handle = activator->shell;
-       listener->serviceChanged = (void *) shell_serviceChanged;
-       bundleContext_addServiceListener(context, listener, 
"(objectClass=commandService)");
-
-       activator->psCmd = psCommand_create(context);
-       activator->psCommand = bundleContext_registerService(context, (char *) 
COMMAND_SERVICE_NAME, activator->psCmd, NULL);
-
-       activator->startCmd = startCommand_create(context);
-       activator->startCommand = bundleContext_registerService(context, (char 
*) COMMAND_SERVICE_NAME, activator->startCmd, NULL);
-
-       activator->stopCmd = stopCommand_create(context);
-       activator->stopCommand = bundleContext_registerService(context, (char 
*) COMMAND_SERVICE_NAME, activator->stopCmd, NULL);
-
-       activator->installCmd = installCommand_create(context);
-       activator->installCommand = bundleContext_registerService(context, 
(char *) COMMAND_SERVICE_NAME, activator->installCmd, NULL);
+       status = bundleContext_registerService(context, (char *) 
SHELL_SERVICE_NAME, activator->shellService, NULL, &activator->registration);
 
-       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);
+       if (status == CELIX_SUCCESS) {
+           SERVICE_LISTENER listener = (SERVICE_LISTENER) 
malloc(sizeof(*listener));
+           activator->listener = listener;
+           listener->handle = activator->shell;
+           listener->serviceChanged = (void *) shell_serviceChanged;
+           status = bundleContext_addServiceListener(context, listener, 
"(objectClass=commandService)");
+
+           if (status == CELIX_SUCCESS) {
+               activator->psCmd = psCommand_create(context);
+               bundleContext_registerService(context, (char *) 
COMMAND_SERVICE_NAME, activator->psCmd, NULL, &activator->psCommand);
+
+               activator->startCmd = startCommand_create(context);
+               bundleContext_registerService(context, (char *) 
COMMAND_SERVICE_NAME, activator->startCmd, NULL, &activator->startCommand);
+
+               activator->stopCmd = stopCommand_create(context);
+               bundleContext_registerService(context, (char *) 
COMMAND_SERVICE_NAME, activator->stopCmd, NULL, &activator->stopCommand);
+
+               activator->installCmd = installCommand_create(context);
+               bundleContext_registerService(context, (char *) 
COMMAND_SERVICE_NAME, activator->installCmd, NULL, &activator->installCommand);
+
+               activator->uninstallCmd = uninstallCommand_create(context);
+               bundleContext_registerService(context, (char *) 
COMMAND_SERVICE_NAME, activator->uninstallCmd, NULL, 
&activator->uninstallCommand);
+
+               activator->updateCmd = updateCommand_create(context);
+               bundleContext_registerService(context, (char *) 
COMMAND_SERVICE_NAME, activator->updateCmd, NULL, &activator->updateCommand);
+           }
+       }
 
-       return CELIX_SUCCESS;
+       return status;
 }
 
 celix_status_t bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+    celix_status_t status = CELIX_SUCCESS;
        struct shellServiceActivator * activator = (struct 
shellServiceActivator *) userData;
        serviceRegistration_unregister(activator->registration);
        serviceRegistration_unregister(activator->psCommand);
@@ -218,22 +226,23 @@ celix_status_t bundleActivator_stop(void
        serviceRegistration_unregister(activator->installCommand);
        serviceRegistration_unregister(activator->uninstallCommand);
        serviceRegistration_unregister(activator->updateCommand);
-       bundleContext_removeServiceListener(context, activator->listener);
+       status = bundleContext_removeServiceListener(context, 
activator->listener);
 
-       psCommand_destroy(activator->psCmd);
-       startCommand_destroy(activator->startCmd);
-       stopCommand_destroy(activator->stopCmd);
-       installCommand_destroy(activator->installCmd);
-       uninstallCommand_destroy(activator->uninstallCmd);
-       updateCommand_destroy(activator->updateCmd);
+       if (status == CELIX_SUCCESS) {
+        psCommand_destroy(activator->psCmd);
+        startCommand_destroy(activator->startCmd);
+        stopCommand_destroy(activator->stopCmd);
+        installCommand_destroy(activator->installCmd);
+        updateCommand_destroy(activator->updateCmd);
 
-       free(activator->shellService);
-       activator->shellService = NULL;
+        free(activator->shellService);
+        activator->shellService = NULL;
 
-       free(activator->listener);
-       activator->listener = NULL;
+        free(activator->listener);
+        activator->listener = NULL;
+       }
 
-       return CELIX_SUCCESS;
+       return status;
 }
 
 celix_status_t bundleActivator_destroy(void * userData, BUNDLE_CONTEXT 
context) {

Modified: incubator/celix/trunk/shell/start_command.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/shell/start_command.c?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/shell/start_command.c (original)
+++ incubator/celix/trunk/shell/start_command.c Sat May 21 20:41:08 2011
@@ -54,7 +54,8 @@ void startCommand_execute(COMMAND comman
        sub = strtok(NULL, delims);
        while (sub != NULL) {
                long id = atol(sub);
-               BUNDLE bundle = 
bundleContext_getBundleById(command->bundleContext, id);
+        BUNDLE bundle = NULL;
+               bundleContext_getBundleById(command->bundleContext, id, 
&bundle);
                if (bundle != NULL) {
                        startBundle(bundle, 0);
                } else {

Modified: incubator/celix/trunk/shell/stop_command.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/shell/stop_command.c?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/shell/stop_command.c (original)
+++ incubator/celix/trunk/shell/stop_command.c Sat May 21 20:41:08 2011
@@ -47,13 +47,14 @@ void stopCommand_destroy(COMMAND command
 }
 
 void stopCommand_execute(COMMAND command, char * line, void (*out)(char *), 
void (*err)(char *)) {
-       char delims[] = " ";
+    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);
+               BUNDLE bundle = NULL;
+               bundleContext_getBundleById(command->bundleContext, id, 
&bundle);
                if (bundle != NULL) {
                        stopBundle(bundle, 0);
                } else {

Modified: incubator/celix/trunk/shell/uninstall_command.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/shell/uninstall_command.c?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/shell/uninstall_command.c (original)
+++ incubator/celix/trunk/shell/uninstall_command.c Sat May 21 20:41:08 2011
@@ -55,7 +55,8 @@ void uninstallCommand_execute(COMMAND co
        sub = strtok(NULL, delims);
        while (sub != NULL) {
                long id = atol(sub);
-               BUNDLE bundle = 
bundleContext_getBundleById(command->bundleContext, id);
+               BUNDLE bundle = NULL;
+               bundleContext_getBundleById(command->bundleContext, id, 
&bundle);
                if (bundle != NULL) {
                    bundle_uninstall(bundle);
                } else {

Modified: incubator/celix/trunk/shell/update_command.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/shell/update_command.c?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/shell/update_command.c (original)
+++ incubator/celix/trunk/shell/update_command.c Sat May 21 20:41:08 2011
@@ -56,6 +56,7 @@ void updateCommand_destroy(COMMAND comma
 
 
 void updateCommand_execute(COMMAND command, char * line, void (*out)(char *), 
void (*err)(char *)) {
+    BUNDLE bundle = NULL;
        char delims[] = " ";
        char * sub = NULL;
        sub = strtok(line, delims);
@@ -63,7 +64,7 @@ void updateCommand_execute(COMMAND comma
        sub = strtok(NULL, delims);
        if (sub != NULL) {
                long id = atol(sub);
-               BUNDLE bundle = 
bundleContext_getBundleById(command->bundleContext, id);
+               bundleContext_getBundleById(command->bundleContext, id, 
&bundle);
                if (bundle != NULL) {
                        sub = strtok(NULL, delims);
                        char inputFile[MAXNAMLEN];

Modified: incubator/celix/trunk/shell_tui/shell_tui.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/shell_tui/shell_tui.c?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/shell_tui/shell_tui.c (original)
+++ incubator/celix/trunk/shell_tui/shell_tui.c Sat May 21 20:41:08 2011
@@ -76,19 +76,23 @@ void * shellTui_runnable(void * data) {
 
 void shellTui_initializeService(SHELL_TUI_ACTIVATOR activator) {
        if (activator->shell == NULL) {
-               activator->reference = 
bundleContext_getServiceReference(activator->context, (char *) 
SHELL_SERVICE_NAME);
+               bundleContext_getServiceReference(activator->context, (char *) 
SHELL_SERVICE_NAME, &activator->reference);
                if (activator->reference != NULL) {
-                       activator->shell = (SHELL_SERVICE) 
bundleContext_getService(activator->context, activator->reference);
+                   void *shell_svc = NULL;
+                   bundleContext_getService(activator->context, 
activator->reference, &shell_svc);
+                   activator->shell = (SHELL_SERVICE) shell_svc;
                }
        }
 }
 
 void shellTui_serviceChanged(SERVICE_LISTENER listener, SERVICE_EVENT event) {
-       SHELL_TUI_ACTIVATOR act = (SHELL_TUI_ACTIVATOR) listener->handle;
+       bool result = NULL;
+    SHELL_TUI_ACTIVATOR act = (SHELL_TUI_ACTIVATOR) listener->handle;
+
        if ((event->type == REGISTERED) && (act->reference == NULL)) {
                shellTui_initializeService(act);
        } else if ((event->type == UNREGISTERING) && (act->reference == 
event->reference)) {
-               bundleContext_ungetService(act->context, act->reference);
+               bundleContext_ungetService(act->context, act->reference, 
&result);
                act->reference = NULL;
                act->shell = NULL;
 
@@ -107,6 +111,7 @@ celix_status_t bundleActivator_create(BU
 }
 
 celix_status_t bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+    celix_status_t status;
        SHELL_TUI_ACTIVATOR act = (SHELL_TUI_ACTIVATOR) userData;
        act->context = context;
        act->running = true;
@@ -115,22 +120,30 @@ celix_status_t bundleActivator_start(voi
        act->listener = listener;
        act->listener->handle = act;
        act->listener->serviceChanged = (void *) shellTui_serviceChanged;
-       bundleContext_addServiceListener(context, act->listener, 
"(objectClass=shellService)");
+       status = bundleContext_addServiceListener(context, act->listener, 
"(objectClass=shellService)");
 
-       shellTui_initializeService(act);
-       pthread_create(&act->runnable, NULL, shellTui_runnable, act);
-       return CELIX_SUCCESS;
+       if (status == CELIX_SUCCESS) {
+        shellTui_initializeService(act);
+        pthread_create(&act->runnable, NULL, shellTui_runnable, act);
+       }
+
+       return status;
 }
 
 celix_status_t bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+    celix_status_t status;
        SHELL_TUI_ACTIVATOR act = (SHELL_TUI_ACTIVATOR) userData;
-       bundleContext_removeServiceListener(context, act->listener);
-       free(act->listener);
-       act->listener = NULL;
-       act->context = NULL;
-       act->running = false;
-       pthread_detach(act->runnable);
-       return CELIX_SUCCESS;
+       status = bundleContext_removeServiceListener(context, act->listener);
+
+       if (status == CELIX_SUCCESS) {
+        free(act->listener);
+        act->listener = NULL;
+        act->context = NULL;
+        act->running = false;
+        pthread_detach(act->runnable);
+       }
+
+       return status;
 }
 
 celix_status_t bundleActivator_destroy(void * userData, BUNDLE_CONTEXT 
context) {

Modified: incubator/celix/trunk/whiteboard/publisherA/activator.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/publisherA/activator.c?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/whiteboard/publisherA/activator.c (original)
+++ incubator/celix/trunk/whiteboard/publisherA/activator.c Sat May 21 20:41:08 
2011
@@ -56,7 +56,8 @@ celix_status_t bundleActivator_start(voi
         data->ps->invoke = publisher_invoke;
         data->ps->publisher = data->pub;
 
-        SERVICE_REGISTRATION service_registration = 
bundleContext_registerService(context, PUBLISHER_NAME, data->ps, NULL);
+        SERVICE_REGISTRATION service_registration = NULL;
+        bundleContext_registerService(context, PUBLISHER_NAME, data->ps, NULL, 
&service_registration);
     } else {
         status = CELIX_START_ERROR;
     }

Modified: incubator/celix/trunk/whiteboard/publisherB/activator.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/publisherB/activator.c?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/whiteboard/publisherB/activator.c (original)
+++ incubator/celix/trunk/whiteboard/publisherB/activator.c Sat May 21 20:41:08 
2011
@@ -55,7 +55,8 @@ celix_status_t bundleActivator_start(voi
         data->ps->invoke = publisher_invoke;
         data->ps->publisher = data->pub;
 
-        SERVICE_REGISTRATION service_registration = 
bundleContext_registerService(context, PUBLISHER_NAME, data->ps, NULL);
+       SERVICE_REGISTRATION service_registration = NULL;
+       bundleContext_registerService(context, PUBLISHER_NAME, data->ps, NULL, 
&service_registration);
     } else {
         status = CELIX_START_ERROR;
     }

Modified: incubator/celix/trunk/whiteboard/tracker/activator.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/tracker/activator.c?rev=1125808&r1=1125807&r2=1125808&view=diff
==============================================================================
--- incubator/celix/trunk/whiteboard/tracker/activator.c (original)
+++ incubator/celix/trunk/whiteboard/tracker/activator.c Sat May 21 20:41:08 
2011
@@ -55,9 +55,13 @@ void * trk_send(void * handle) {
 }
 
 void * addingServ(void * handle, SERVICE_REFERENCE ref) {
-       struct data * data = (struct data *) handle;
-       printf("Adding\n");
-       return bundleContext_getService(data->context, ref);
+    void *service_instance = NULL;
+    struct data * data = (struct data *) handle;
+
+    printf("Adding\n");
+       bundleContext_getService(data->context, ref, &service_instance);
+
+       return service_instance;
 }
 
 void addedServ(void * handle, SERVICE_REFERENCE ref, void * service) {


Reply via email to