Repository: celix
Updated Branches:
  refs/heads/develop 367fc69a4 -> fe59e3e90


CELIX-269: Some naming/style refactoring for the dependency manager


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/a369efdf
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/a369efdf
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/a369efdf

Branch: refs/heads/develop
Commit: a369efdf6e0a7e69b4393e4b22adb241cb3ed779
Parents: 93b7e5f
Author: Pepijn Noltes <[email protected]>
Authored: Wed Nov 4 12:57:28 2015 +0100
Committer: Pepijn Noltes <[email protected]>
Committed: Wed Nov 4 12:57:28 2015 +0100

----------------------------------------------------------------------
 .../private/include/dm_component_impl.h         |  41 ---
 .../private/src/dm_component_impl.c             | 258 ++++++++++---------
 .../private/src/dm_dependency_manager_impl.c    |   2 +-
 .../private/src/dm_service_dependency.c         |  20 +-
 .../private/src/dm_shell_activator.c            |   2 +-
 .../public/include/dm_component.h               |  16 +-
 6 files changed, 156 insertions(+), 183 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/a369efdf/dependency_manager/private/include/dm_component_impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_component_impl.h 
b/dependency_manager/private/include/dm_component_impl.h
index 4963b44..418b022 100644
--- a/dependency_manager/private/include/dm_component_impl.h
+++ b/dependency_manager/private/include/dm_component_impl.h
@@ -33,47 +33,6 @@
 
 #include "dm_event.h"
 
-typedef enum dm_component_state {
-    DM_CMP_STATE_INACTIVE = 1,
-    DM_CMP_STATE_WAITING_FOR_REQUIRED = 2,
-    DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED = 3,
-    DM_CMP_STATE_TRACKING_OPTIONAL = 4,
-} dm_component_state_t;
-
-typedef struct dm_executor * dm_executor_pt;
-
-typedef struct dm_interface_struct {
-    char *serviceName;
-    void *service;
-    properties_pt properties;
-    service_registration_pt registration;
-} dm_interface;
-
-struct dm_component {
-    char id[DM_COMPONENT_MAX_ID_LENGTH];
-    char name[DM_COMPONENT_MAX_NAME_LENGTH];
-    bundle_context_pt context;
-    array_list_pt dm_interface;
-
-    void *implementation;
-
-    init_fpt callbackInit;
-    start_fpt callbackStart;
-    stop_fpt callbackStop;
-    deinit_fpt callbackDeinit;
-
-    array_list_pt dependencies;
-    pthread_mutex_t mutex;
-
-    dm_component_state_t state;
-    bool isStarted;
-    bool active;
-
-    hash_map_pt dependencyEvents;
-
-    dm_executor_pt executor;
-};
-
 celix_status_t component_start(dm_component_pt component);
 celix_status_t component_stop(dm_component_pt component);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/a369efdf/dependency_manager/private/src/dm_component_impl.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_component_impl.c 
b/dependency_manager/private/src/dm_component_impl.c
index fb89b05..127d984 100644
--- a/dependency_manager/private/src/dm_component_impl.c
+++ b/dependency_manager/private/src/dm_component_impl.c
@@ -27,41 +27,70 @@
 #include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
-#include <limits.h>
 
-#include "constants.h"
 #include "filter.h"
 #include "dm_component_impl.h"
-#include "../../../framework/private/include/framework_private.h"
 
-struct dm_executor {
+
+typedef struct dm_executor_struct * dm_executor_pt;
+
+struct dm_component_struct {
+    char id[DM_COMPONENT_MAX_ID_LENGTH];
+    char name[DM_COMPONENT_MAX_NAME_LENGTH];
+    bundle_context_pt context;
+    array_list_pt dm_interfaces;
+
+    void *implementation;
+
+    init_fpt callbackInit;
+    start_fpt callbackStart;
+    stop_fpt callbackStop;
+    deinit_fpt callbackDeinit;
+
+    array_list_pt dependencies; //protected by mutex
+    pthread_mutex_t mutex;
+
+    dm_component_state_t state;
+    bool isStarted;
+    bool active;
+
+    hash_map_pt dependencyEvents; //protected by mutex
+
+    dm_executor_pt executor;
+};
+
+typedef struct dm_interface_struct {
+    char *serviceName;
+    void *service;
+    properties_pt properties;
+    service_registration_pt registration;
+} dm_interface_t;
+
+struct dm_executor_struct {
     pthread_t runningThread;
     bool runningThreadSet;
     linked_list_pt workQueue;
-
     pthread_mutex_t mutex;
 };
 
-struct dm_executor_task {
+typedef struct dm_executor_task_struct {
     dm_component_pt component;
     void (*command)(void *command_ptr, void *data);
     void *data;
-};
+} dm_executor_task_t;
 
-struct dm_handle_event_type {
+typedef struct dm_handle_event_type_struct {
        dm_service_dependency_pt dependency;
        dm_event_pt event;
        dm_event_pt newEvent;
-};
-
-typedef struct dm_handle_event_type *dm_handle_event_type_pt;
+} *dm_handle_event_type_pt;
 
 static celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t  
currentThread __attribute__((unused)));
 static celix_status_t executor_execute(dm_executor_pt executor);
 static celix_status_t executor_executeTask(dm_executor_pt executor, 
dm_component_pt component, void (*command), void *data);
 static celix_status_t executor_schedule(dm_executor_pt executor, 
dm_component_pt component, void (*command), void *data);
 static celix_status_t executor_create(dm_component_pt component 
__attribute__((unused)), dm_executor_pt *executor);
-static celix_status_t executor_destroy(dm_executor_pt *executor);
+static void executor_destroy(dm_executor_pt executor);
 
 static celix_status_t 
component_invokeRemoveRequiredDependencies(dm_component_pt component);
 static celix_status_t 
component_invokeRemoveInstanceBoundDependencies(dm_component_pt component);
@@ -83,7 +112,7 @@ static celix_status_t 
component_startDependencies(dm_component_pt component __at
 static celix_status_t component_getDependencyEvent(dm_component_pt component, 
dm_service_dependency_pt dependency, dm_event_pt *event_pptr);
 static celix_status_t component_updateInstance(dm_component_pt component, 
dm_service_dependency_pt dependency, dm_event_pt event, bool update, bool add);
 
-static celix_status_t component_addTask(dm_component_pt component, 
array_list_pt dependencies);
+static celix_status_t component_addTask(dm_component_pt component, 
dm_service_dependency_pt dep);
 static celix_status_t component_startTask(dm_component_pt component, void * 
data __attribute__((unused)));
 static celix_status_t component_stopTask(dm_component_pt component, void * 
data __attribute__((unused)));
 static celix_status_t component_removeTask(dm_component_pt component, 
dm_service_dependency_pt dependency);
@@ -94,140 +123,124 @@ static celix_status_t 
component_handleChanged(dm_component_pt component, dm_serv
 static celix_status_t component_handleRemoved(dm_component_pt component, 
dm_service_dependency_pt dependency, dm_event_pt event);
 static celix_status_t component_handleSwapped(dm_component_pt component, 
dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent);
 
-celix_status_t component_create(bundle_context_pt context, const char *name, 
dm_component_pt *component) {
+celix_status_t component_create(bundle_context_pt context, const char *name, 
dm_component_pt *out) {
     celix_status_t status = CELIX_SUCCESS;
 
-    *component = malloc(sizeof(**component));
-    if (!*component) {
+    dm_component_pt component = calloc(1, sizeof(*component));
+
+    if (!component) {
         status = CELIX_ENOMEM;
     } else {
-        snprintf((*component)->id, DM_COMPONENT_MAX_ID_LENGTH, "%p", 
*component);
-        if (name == NULL) {
-            snprintf((*component)->name, DM_COMPONENT_MAX_NAME_LENGTH, "%s", 
"n/a");
-        } else {
-            snprintf((*component)->name, DM_COMPONENT_MAX_NAME_LENGTH, "%s", 
name);
-        }
-        (*component)->context = context;
+        snprintf(component->id, DM_COMPONENT_MAX_ID_LENGTH, "%p", component);
+        snprintf(component->name, DM_COMPONENT_MAX_NAME_LENGTH, "%s", name == 
NULL ? "n/a" : name);
 
-       arrayList_create(&((*component)->dm_interface));
+        component->context = context;
 
-        (*component)->implementation = NULL;
+           arrayList_create(&component->dm_interfaces);
+        arrayList_create(&(component)->dependencies);
+        pthread_mutex_init(&(component)->mutex, NULL);
 
-        (*component)->callbackInit = NULL;
-        (*component)->callbackStart = NULL;
-        (*component)->callbackStop = NULL;
-        (*component)->callbackDeinit = NULL;
+        component->implementation = NULL;
 
+        component->callbackInit = NULL;
+        component->callbackStart = NULL;
+        component->callbackStop = NULL;
+        component->callbackDeinit = NULL;
 
-        arrayList_create(&(*component)->dependencies);
-        pthread_mutex_init(&(*component)->mutex, NULL);
+        component->state = DM_CMP_STATE_INACTIVE;
+        component->isStarted = false;
+        component->active = false;
 
-        (*component)->state = DM_CMP_STATE_INACTIVE;
-        (*component)->isStarted = false;
-        (*component)->active = false;
+        component->dependencyEvents = hashMap_create(NULL, NULL, NULL, NULL);
 
-        (*component)->dependencyEvents = hashMap_create(NULL, NULL, NULL, 
NULL);
+        component->executor = NULL;
+        executor_create(component, &component->executor);
+    }
 
-        (*component)->executor = NULL;
-        executor_create(*component, &(*component)->executor);
+    if (status == CELIX_SUCCESS) {
+        *out = component;
     }
 
     return status;
 }
 
-celix_status_t component_destroy(dm_component_pt *component_ptr) {
-       celix_status_t status = CELIX_SUCCESS;
-
-       if (!*component_ptr) {
-               status = CELIX_ILLEGAL_ARGUMENT;
-       }
-
-       if (status == CELIX_SUCCESS) {
+void component_destroy(dm_component_pt component) {
+       if (component) {
                unsigned int i;
 
-               for (i = 0; i < arrayList_size((*component_ptr)->dm_interface); 
i++) {
-                   dm_interface *interface = 
arrayList_get((*component_ptr)->dm_interface, i);
+               for (i = 0; i < arrayList_size(component->dm_interfaces); i++) {
+                   dm_interface_t *interface = 
arrayList_get(component->dm_interfaces, i);
 
                    free (interface->serviceName);
+            free (interface);
                }
-               arrayList_destroy((*component_ptr)->dm_interface);
+               arrayList_destroy(component->dm_interfaces);
 
-               // #TODO destroy dependencies?
-               executor_destroy(&(*component_ptr)->executor);
-               hashMap_destroy((*component_ptr)->dependencyEvents, false, 
false);
-               pthread_mutex_destroy(&(*component_ptr)->mutex);
-               arrayList_destroy((*component_ptr)->dependencies);
+               // #TODO destroy dependencies
 
-               free(*component_ptr);
-               *component_ptr = NULL;
-       }
+               executor_destroy(component->executor);
+        //TODO free events
+               hashMap_destroy(component->dependencyEvents, false, false);
+               pthread_mutex_destroy(&component->mutex);
+               arrayList_destroy(component->dependencies);
 
-       return status;
+               free(component);
+       }
 }
 
 celix_status_t component_addServiceDependency(dm_component_pt component, 
dm_service_dependency_pt dep) {
     celix_status_t status = CELIX_SUCCESS;
 
-    array_list_pt dependenciesList = NULL;
-    arrayList_create(&dependenciesList);
-    arrayList_add(dependenciesList, dep);
-
-    /*
-    va_list dependencies;
-    va_start(dependencies, component);
-    dm_service_dependency_pt dependency = va_arg(dependencies, 
dm_service_dependency_pt);
-    while (dependency != NULL) {
-        arrayList_add(dependenciesList, dependency);
-
-        dependency = va_arg(dependencies, dm_service_dependency_pt);
-    }
-
-    va_end(dependencies);
-     */
-
-       executor_executeTask(component->executor, component, component_addTask, 
dependenciesList);
-//    component_addTask(component, dependenciesList);
+       executor_executeTask(component->executor, component, component_addTask, 
dep);
 
     return status;
 }
 
 
-celix_status_t component_addTask(dm_component_pt component, array_list_pt 
dependencies) {
+static celix_status_t component_addTask(dm_component_pt component, 
dm_service_dependency_pt dep) {
     celix_status_t status = CELIX_SUCCESS;
 
     array_list_pt bounds = NULL;
     arrayList_create(&bounds);
-    for (unsigned int i = 0; i < arrayList_size(dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(dependencies, i);
 
-        pthread_mutex_lock(&component->mutex);
-        array_list_pt events = NULL;
-        arrayList_createWithEquals(event_equals, &events);
-        hashMap_put(component->dependencyEvents, dependency, events);
+    array_list_pt events = NULL;
+    arrayList_createWithEquals(event_equals, &events);
 
-        arrayList_add(component->dependencies, dependency);
-        pthread_mutex_unlock(&component->mutex);
+    pthread_mutex_lock(&component->mutex);
+    hashMap_put(component->dependencyEvents, dep, events);
+    arrayList_add(component->dependencies, dep);
+    pthread_mutex_unlock(&component->mutex);
 
-        serviceDependency_setComponent(dependency, component);
-        if (component->state != DM_CMP_STATE_INACTIVE) {
-            serviceDependency_setInstanceBound(dependency, true);
-            arrayList_add(bounds, dependency);
-        }
-        component_startDependencies(component, bounds);
-        component_handleChange(component);
+    serviceDependency_setComponent(dep, component);
+
+    if (component->state != DM_CMP_STATE_INACTIVE) {
+        serviceDependency_setInstanceBound(dep, true);
+        arrayList_add(bounds, dep);
     }
+    component_startDependencies(component, bounds);
+    component_handleChange(component);
 
     arrayList_destroy(bounds);
-    arrayList_destroy(dependencies);
 
     return status;
 }
 
+dm_component_state_t component_currentState(dm_component_pt cmp) {
+    return cmp->state;
+}
+
+void * component_getImplementation(dm_component_pt cmp) {
+    return cmp->implementation;
+}
+
+const char * component_getName(dm_component_pt cmp) {
+    return cmp->name;
+}
+
 celix_status_t component_removeServiceDependency(dm_component_pt component, 
dm_service_dependency_pt dependency) {
     celix_status_t status = CELIX_SUCCESS;
 
     executor_executeTask(component->executor, component, component_removeTask, 
dependency);
-//    component_removeTask(component, dependency);
 
     return status;
 }
@@ -245,12 +258,13 @@ celix_status_t component_removeTask(dm_component_pt 
component, dm_service_depend
 
     pthread_mutex_lock(&component->mutex);
     array_list_pt events = hashMap_remove(component->dependencyEvents, 
dependency);
-    for (unsigned int i = arrayList_size(events); i > 0; i--) {
-       dm_event_pt event = arrayList_remove(events, i - 1);
+    pthread_mutex_unlock(&component->mutex);
+
+    while (!arrayList_isEmpty(events)) {
+       dm_event_pt event = arrayList_remove(events, 0);
        event_destroy(&event);
     }
     arrayList_destroy(events);
-    pthread_mutex_unlock(&component->mutex);
 
     component_handleChange(component);
 
@@ -262,7 +276,6 @@ celix_status_t component_start(dm_component_pt component) {
 
     component->active = true;
     executor_executeTask(component->executor, component, component_startTask, 
NULL);
-//    component_startTask(component, NULL);
 
     return status;
 }
@@ -281,7 +294,6 @@ celix_status_t component_stop(dm_component_pt component) {
 
     component->active = false;
     executor_executeTask(component->executor, component, component_stopTask, 
NULL);
-//    component_stopTask(component, NULL);
 
     return status;
 }
@@ -302,7 +314,7 @@ celix_status_t component_addInterface(dm_component_pt 
component, char *serviceNa
     if (component->active) {
         return CELIX_ILLEGAL_STATE;
     } else {
-       dm_interface *interface = (dm_interface *) malloc (sizeof 
(dm_interface));
+       dm_interface_t *interface = (dm_interface_t *) calloc(1, 
sizeof(*interface));
        char *name = strdup (serviceName);
 
        if (interface && name) {
@@ -310,7 +322,7 @@ celix_status_t component_addInterface(dm_component_pt 
component, char *serviceNa
             interface->service = service;
             interface->properties = properties;
             interface->registration = NULL;
-           arrayList_add(component->dm_interface, interface);
+           arrayList_add(component->dm_interfaces, interface);
        }
        else {
           free (interface);
@@ -327,10 +339,10 @@ celix_status_t component_getInterfaces(dm_component_pt 
component, array_list_pt
     array_list_pt names = NULL;
     arrayList_create(&names);
     celixThreadMutex_lock(&component->mutex);
-    int size = arrayList_size(component->dm_interface);
+    int size = arrayList_size(component->dm_interfaces);
     int i;
     for (i = 0; i < size; i += 1) {
-        dm_interface *interface = arrayList_get(component->dm_interface, i);
+        dm_interface_t *interface = arrayList_get(component->dm_interfaces, i);
         arrayList_add(names, strdup(interface->serviceName));
     }
     celixThreadMutex_unlock(&component->mutex);
@@ -1086,8 +1098,8 @@ celix_status_t component_registerServices(dm_component_pt 
component) {
     if (component->context) {
        unsigned int i;
 
-       for (i = 0; i < arrayList_size(component->dm_interface); i++) {
-           dm_interface *interface = arrayList_get(component->dm_interface, i);
+       for (i = 0; i < arrayList_size(component->dm_interfaces); i++) {
+           dm_interface_t *interface = arrayList_get(component->dm_interfaces, 
i);
 
             bundleContext_registerService(component->context, 
interface->serviceName, interface->service, interface->properties, 
&interface->registration);
        }
@@ -1101,8 +1113,8 @@ celix_status_t 
component_unregisterServices(dm_component_pt component) {
 
     unsigned int i;
 
-    for (i = 0; i < arrayList_size(component->dm_interface); i++) {
-       dm_interface *interface = arrayList_get(component->dm_interface, i);
+    for (i = 0; i < arrayList_size(component->dm_interfaces); i++) {
+       dm_interface_t *interface = arrayList_get(component->dm_interfaces, i);
 
        serviceRegistration_unregister(interface->registration);
        interface->registration = NULL;
@@ -1147,7 +1159,7 @@ celix_status_t component_getBundleContext(dm_component_pt 
component, bundle_cont
 }
 
 
-celix_status_t executor_create(dm_component_pt component 
__attribute__((unused)), dm_executor_pt *executor) {
+static celix_status_t executor_create(dm_component_pt component 
__attribute__((unused)), dm_executor_pt *executor) {
     celix_status_t status = CELIX_SUCCESS;
 
     *executor = malloc(sizeof(**executor));
@@ -1162,28 +1174,20 @@ celix_status_t executor_create(dm_component_pt 
component __attribute__((unused))
     return status;
 }
 
-celix_status_t executor_destroy(dm_executor_pt *executor) {
-       celix_status_t status = CELIX_SUCCESS;
+static void executor_destroy(dm_executor_pt executor) {
 
-       if (!*executor) {
-               status = CELIX_ILLEGAL_ARGUMENT;
-       }
+       if (executor) {
+               pthread_mutex_destroy(&executor->mutex);
+               linkedList_destroy(executor->workQueue);
 
-       if (status == CELIX_SUCCESS) {
-               pthread_mutex_destroy(&(*executor)->mutex);
-               linkedList_destroy((*executor)->workQueue);
-
-               free(*executor);
-               *executor = NULL;
+               free(executor);
        }
-
-       return status;
 }
 
-celix_status_t executor_schedule(dm_executor_pt executor, dm_component_pt 
component, void (*command), void *data) {
+static celix_status_t executor_schedule(dm_executor_pt executor, 
dm_component_pt component, void (*command), void *data) {
     celix_status_t status = CELIX_SUCCESS;
 
-    struct dm_executor_task *task = NULL;
+    dm_executor_task_t *task = NULL;
     task = malloc(sizeof(*task));
     if (!task) {
         status = CELIX_ENOMEM;
@@ -1200,7 +1204,7 @@ celix_status_t executor_schedule(dm_executor_pt executor, 
dm_component_pt compon
     return status;
 }
 
-celix_status_t executor_executeTask(dm_executor_pt executor, dm_component_pt 
component, void (*command), void *data) {
+static celix_status_t executor_executeTask(dm_executor_pt executor, 
dm_component_pt component, void (*command), void *data) {
     celix_status_t status = CELIX_SUCCESS;
 
     // Check thread and executor thread, if the same, execute immediately.
@@ -1219,7 +1223,7 @@ celix_status_t executor_executeTask(dm_executor_pt 
executor, dm_component_pt com
     return status;
 }
 
-celix_status_t executor_execute(dm_executor_pt executor) {
+static celix_status_t executor_execute(dm_executor_pt executor) {
     celix_status_t status = CELIX_SUCCESS;
     pthread_t currentThread = pthread_self();
 
@@ -1238,12 +1242,12 @@ celix_status_t executor_execute(dm_executor_pt 
executor) {
     return status;
 }
 
-celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t 
currentThread __attribute__((unused))) {
+static celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t 
currentThread __attribute__((unused))) {
     celix_status_t status = CELIX_SUCCESS;
 //    bool execute = false;
 
     do {
-        struct dm_executor_task *entry = NULL;
+        dm_executor_task_t *entry = NULL;
         pthread_mutex_lock(&executor->mutex);
         while ((entry = linkedList_removeFirst(executor->workQueue)) != NULL) {
             pthread_mutex_unlock(&executor->mutex);

http://git-wip-us.apache.org/repos/asf/celix/blob/a369efdf/dependency_manager/private/src/dm_dependency_manager_impl.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_dependency_manager_impl.c 
b/dependency_manager/private/src/dm_dependency_manager_impl.c
index 7636121..7ee9287 100644
--- a/dependency_manager/private/src/dm_dependency_manager_impl.c
+++ b/dependency_manager/private/src/dm_dependency_manager_impl.c
@@ -73,7 +73,7 @@ celix_status_t 
depedencyManager_removeAllComponents(dm_dependency_manager_pt man
 
        while (!arrayList_isEmpty(manager->components)) {
                dm_component_pt cmp = arrayList_remove(manager->components, 0);
-        printf("Removing comp %s\n", cmp->name);
+        printf("Removing comp %s\n", component_getName(cmp));
         status = component_stop(cmp);
         //TODO component_destroy(&cmp);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/a369efdf/dependency_manager/private/src/dm_service_dependency.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_service_dependency.c 
b/dependency_manager/private/src/dm_service_dependency.c
index b88f21d..d29a8fe 100644
--- a/dependency_manager/private/src/dm_service_dependency.c
+++ b/dependency_manager/private/src/dm_service_dependency.c
@@ -367,10 +367,10 @@ celix_status_t 
serviceDependency_invokeSet(dm_service_dependency_pt dependency,
        }
 
        if (dependency->set) {
-               dependency->set(dependency->component->implementation, service);
+               
dependency->set(component_getImplementation(dependency->component), service);
        }
        if (dependency->set_with_ref) {
-               dependency->set_with_ref(dependency->component->implementation, 
curServRef, service);
+               
dependency->set_with_ref(component_getImplementation(dependency->component), 
curServRef, service);
        }
 
        return status;
@@ -385,10 +385,10 @@ celix_status_t 
serviceDependency_invokeAdd(dm_service_dependency_pt dependency,
 
        if (status == CELIX_SUCCESS) {
                if (dependency->add) {
-                       dependency->add(dependency->component->implementation, 
event->service);
+                       
dependency->add(component_getImplementation(dependency->component), 
event->service);
                }
                if (dependency->add_with_ref) {
-                       
dependency->add_with_ref(dependency->component->implementation, 
event->reference, event->service);
+                       
dependency->add_with_ref(component_getImplementation(dependency->component), 
event->reference, event->service);
                }
        }
 
@@ -404,10 +404,10 @@ celix_status_t 
serviceDependency_invokeChange(dm_service_dependency_pt dependenc
 
        if (status == CELIX_SUCCESS) {
                if (dependency->change) {
-                       
dependency->change(dependency->component->implementation, event->service);
+                       
dependency->change(component_getImplementation(dependency->component), 
event->service);
                }
                if (dependency->change_with_ref) {
-                       
dependency->change_with_ref(dependency->component->implementation, 
event->reference, event->service);
+                       
dependency->change_with_ref(component_getImplementation(dependency->component), 
event->reference, event->service);
                }
        }
 
@@ -423,10 +423,10 @@ celix_status_t 
serviceDependency_invokeRemove(dm_service_dependency_pt dependenc
 
        if (status == CELIX_SUCCESS) {
                if (dependency->remove) {
-                       
dependency->remove(dependency->component->implementation, event->service);
+                       
dependency->remove(component_getImplementation(dependency->component), 
event->service);
                }
                if (dependency->remove_with_ref) {
-                       
dependency->remove_with_ref(dependency->component->implementation, 
event->reference, event->service);
+                       
dependency->remove_with_ref(component_getImplementation(dependency->component), 
event->reference, event->service);
                }
        }
 
@@ -442,10 +442,10 @@ celix_status_t 
serviceDependency_invokeSwap(dm_service_dependency_pt dependency,
 
        if (status == CELIX_SUCCESS) {
                if (dependency->swap) {
-                       dependency->swap(dependency->component->implementation, 
event->service, newEvent->service);
+                       
dependency->swap(component_getImplementation(dependency->component), 
event->service, newEvent->service);
                }
                if (dependency->swap_with_ref) {
-                       
dependency->swap_with_ref(dependency->component->implementation, 
event->reference, event->service, newEvent->reference, newEvent->service);
+                       
dependency->swap_with_ref(component_getImplementation(dependency->component), 
event->reference, event->service, newEvent->reference, newEvent->service);
                }
        }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/a369efdf/dependency_manager/private/src/dm_shell_activator.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_shell_activator.c 
b/dependency_manager/private/src/dm_shell_activator.c
index 178b460..fcb42cd 100644
--- a/dependency_manager/private/src/dm_shell_activator.c
+++ b/dependency_manager/private/src/dm_shell_activator.c
@@ -68,7 +68,7 @@ celix_status_t bundleActivator_start(void * userData, 
bundle_context_pt context)
 
     if (commandService != NULL) {
         commandService->handle = context;
-        commandService->executeCommand = dmListCommand_execute;
+        commandService->executeCommand = (void *)dmListCommand_execute;
 
         properties_pt props = properties_create();
         properties_set(props, OSGI_SHELL_COMMAND_NAME, "dm");

http://git-wip-us.apache.org/repos/asf/celix/blob/a369efdf/dependency_manager/public/include/dm_component.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_component.h 
b/dependency_manager/public/include/dm_component.h
index b558aea..014247e 100644
--- a/dependency_manager/public/include/dm_component.h
+++ b/dependency_manager/public/include/dm_component.h
@@ -32,9 +32,14 @@
 
 #include "dm_service_dependency.h"
 
-typedef struct dm_component *dm_component_pt;
+typedef struct dm_component_struct *dm_component_pt;
 
-#include "dm_component.h"
+typedef enum dm_component_state_enum {
+    DM_CMP_STATE_INACTIVE = 1,
+    DM_CMP_STATE_WAITING_FOR_REQUIRED = 2,
+    DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED = 3,
+    DM_CMP_STATE_TRACKING_OPTIONAL = 4,
+} dm_component_state_t;
 
 #define DM_COMPONENT_MAX_ID_LENGTH 64
 #define DM_COMPONENT_MAX_NAME_LENGTH 128
@@ -45,7 +50,7 @@ typedef int (*stop_fpt)(void *userData);
 typedef int (*deinit_fpt)(void *userData);
 
 celix_status_t component_create(bundle_context_pt context, const char *name, 
dm_component_pt *component);
-celix_status_t component_destroy(dm_component_pt *component);
+void component_destroy(dm_component_pt component);
 
 celix_status_t component_addInterface(dm_component_pt component, char 
*serviceName, void *service, properties_pt properties);
 celix_status_t component_setImplementation(dm_component_pt component, void 
*implementation);
@@ -58,6 +63,10 @@ celix_status_t component_getInterfaces(dm_component_pt 
component, array_list_pt
 celix_status_t component_addServiceDependency(dm_component_pt component, 
dm_service_dependency_pt dep);
 celix_status_t component_removeServiceDependency(dm_component_pt component, 
dm_service_dependency_pt dependency);
 
+dm_component_state_t component_currentState(dm_component_pt cmp);
+void * component_getImplementation(dm_component_pt cmp);
+const char * component_getName(dm_component_pt cmp);
+
 #define component_setCallbacksSafe(dmCmp, type, init, start, stop, deinit) \
     do {  \
         int (*tmp_init)(type)   = (init); \
@@ -75,4 +84,5 @@ celix_status_t component_setCallbacks(dm_component_pt 
component, init_fpt init,
 celix_status_t component_getComponentInfo(dm_component_pt component, 
dm_component_info_pt *info);
 void component_destroyComponentInfo(dm_component_info_pt info);
 
+
 #endif /* COMPONENT_H_ */

Reply via email to