celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject celix git commit: CELIX-210: Fixed an issue to trigger a state change when required services reapear. Started creating destroy functions for dm info (used in shell command).
Date Thu, 22 Oct 2015 19:05:17 GMT
Repository: celix
Updated Branches:
  refs/heads/feature/CELIX-269_depman 8f279cbcf -> 2de2554ae


CELIX-210: Fixed an issue to trigger a state change when required services reapear. Started
creating destroy functions for dm info (used in shell command).


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

Branch: refs/heads/feature/CELIX-269_depman
Commit: 2de2554aebf9093ed037a23589389542cc7563ec
Parents: 8f279cb
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Thu Oct 22 21:04:06 2015 +0200
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Thu Oct 22 21:04:06 2015 +0200

----------------------------------------------------------------------
 .../private/src/dm_activator_base.c             |  1 +
 .../private/src/dm_component_impl.c             | 42 +++++++++++++++-----
 .../private/src/dm_dependency_manager_impl.c    | 19 +++++++++
 .../private/src/dm_service_dependency.c         |  7 ++++
 .../private/src/dm_shell_list_command.c         |  7 +---
 .../public/include/dm_component.h               |  1 +
 .../public/include/dm_dependency_manager.h      |  1 +
 dependency_manager/public/include/dm_info.h     |  1 +
 .../public/include/dm_service_dependency.h      |  1 +
 9 files changed, 65 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/2de2554a/dependency_manager/private/src/dm_activator_base.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_activator_base.c b/dependency_manager/private/src/dm_activator_base.c
index 2928c25..25065a9 100644
--- a/dependency_manager/private/src/dm_activator_base.c
+++ b/dependency_manager/private/src/dm_activator_base.c
@@ -77,6 +77,7 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt
context)
 	//Create the service
 	dependency_activator->info->handle = dependency_activator->manager;
 	dependency_activator->info->getInfo = (void *)dependencyManager_getInfo;
+    dependency_activator->info->destroyInfo = (void *)dependencyManager_destroyInfo;
 
 	bundleContext_registerService(context, DM_INFO_SERVICE_NAME, dependency_activator->info,
NULL, &(dependency_activator->reg));
 	return status;

http://git-wip-us.apache.org/repos/asf/celix/blob/2de2554a/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 5aeae6b..500d613 100644
--- a/dependency_manager/private/src/dm_component_impl.c
+++ b/dependency_manager/private/src/dm_component_impl.c
@@ -400,21 +400,19 @@ celix_status_t component_handleAdded(dm_component_pt component, dm_service_depen
         case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
             bool instanceBound = false;
             serviceDependency_isInstanceBound(dependency, &instanceBound);
+            bool required = false;
+            serviceDependency_isRequired(dependency, &required);
             if (!instanceBound) {
-                bool required = false;
-                serviceDependency_isRequired(dependency, &required);
                 if (required) {
                     serviceDependency_invokeAdd(dependency, event);
                 }
                 dm_event_pt event = NULL;
                 component_getDependencyEvent(component, dependency, &event);
                 component_updateInstance(component, dependency, event, false, true);
-            } else {
-                bool required = false;
-                serviceDependency_isRequired(dependency, &required);
-                if (required) {
-                    component_handleChange(component);
-                }
+            }
+
+            if (required) {
+                component_handleChange(component);
             }
             break;
         }
@@ -1361,8 +1359,34 @@ celix_status_t component_getComponentInfo(dm_component_pt component,
dm_componen
     if (status == CELIX_SUCCESS) {
         *out = info;
     } else if (info != NULL) {
-        //TODO cleanup
+        component_destroyComponentInfo(info);
     }
 
     return status;
+}
+
+void component_destroyComponentInfo(dm_component_info_pt info) {
+    int i;
+    int size;
+    if (info != NULL) {
+        free(info->state);
+
+        if (info->interfaces != NULL) {
+            size = arrayList_size(info->interfaces);
+            for (i = 0; i < size; i += 1) {
+                char *intf = arrayList_get(info->interfaces, i);
+                free(intf);
+            }
+            arrayList_destroy(info->interfaces);
+        }
+        if (info->dependency_list != NULL) {
+            size = arrayList_size(info->dependency_list);
+            for (i = 0; i < size; i += 1) {
+                dm_service_dependency_info_pt depInfo = arrayList_get(info->dependency_list,
i);
+                dependency_destroyDependencyInfo(depInfo);
+            }
+            arrayList_destroy(info->dependency_list);
+        }
+    }
+    free(info);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/2de2554a/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 59ba677..059ce54 100644
--- a/dependency_manager/private/src/dm_dependency_manager_impl.c
+++ b/dependency_manager/private/src/dm_dependency_manager_impl.c
@@ -109,3 +109,22 @@ celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager,
dm_de
 
 	return status;
 }
+
+void dependencyManager_destroyInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt
info) {
+    return;
+    /*
+     * TODO
+
+    int i;
+    int size;
+    if (info != NULL) {
+        size = arrayList_size(info->components);
+        for (i = 0; i < size; i += 1) {
+            dm_component_info_pt cmpInfo = arrayList_get(info->components, i);
+            component_destroyComponentInfo(cmpInfo);
+        }
+        arrayList_destroy(info->components);
+    }
+    free(info);
+     */
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/2de2554a/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 61daa07..e0bf489 100644
--- a/dependency_manager/private/src/dm_service_dependency.c
+++ b/dependency_manager/private/src/dm_service_dependency.c
@@ -657,4 +657,11 @@ celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_
 	}
 
 	return status;
+}
+
+void dependency_destroyDependencyInfo(dm_service_dependency_info_pt info) {
+    if (info != NULL) {
+        free(info->filter);
+    }
+    free(info);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/2de2554a/dependency_manager/private/src/dm_shell_list_command.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_shell_list_command.c b/dependency_manager/private/src/dm_shell_list_command.c
index 59f748f..1e70513 100644
--- a/dependency_manager/private/src/dm_shell_list_command.c
+++ b/dependency_manager/private/src/dm_shell_list_command.c
@@ -87,9 +87,7 @@ void dmListCommand_execute(command_pt command, char * line, void (*out)(char
*),
                 interface = arrayList_get(compInfo->interfaces, interfCnt);
                 sprintf(outString, "   |- Interface: %s\n", interface);
                 out(outString);
-                free(interface);
             }
-            arrayList_destroy(compInfo->interfaces);
 
             int depCnt;
             sprintf(outString, "|- Dependencies (%d):\n", arrayList_size(compInfo->dependency_list));
@@ -111,12 +109,9 @@ void dmListCommand_execute(command_pt command, char * line, void (*out)(char
*),
                         dependency->filter
                 );
                 out(outString);
-                free(dependency->filter);
-                free(dependency);
             }
 
-            //TODO free compInfo
-            arrayList_destroy(compInfo->dependency_list);
+            infoServ->destroyInfo(infoServ->handle, info);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/2de2554a/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 ab8ac80..c26cc05 100644
--- a/dependency_manager/public/include/dm_component.h
+++ b/dependency_manager/public/include/dm_component.h
@@ -61,5 +61,6 @@ celix_status_t component_setCallbacks(dm_component_pt component, init_fpt
init,
  * returns a dm_component_info_pt. Caller has ownership.
  */
 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_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/2de2554a/dependency_manager/public/include/dm_dependency_manager.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_dependency_manager.h b/dependency_manager/public/include/dm_dependency_manager.h
index ab6e27f..44c1643 100644
--- a/dependency_manager/public/include/dm_dependency_manager.h
+++ b/dependency_manager/public/include/dm_dependency_manager.h
@@ -45,5 +45,6 @@ celix_status_t dependencyManager_remove(dm_dependency_manager_pt manager,
dm_com
  * returns a dm_ of dm_dependency_manager_info. Caller has ownership.
  */
 celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt
*info);
+void dependencyManager_destroyInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt
info);
 
 #endif /* DM_DEPENDENCY_MANAGER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/2de2554a/dependency_manager/public/include/dm_info.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_info.h b/dependency_manager/public/include/dm_info.h
index ee6a4d8..16ee0f8 100644
--- a/dependency_manager/public/include/dm_info.h
+++ b/dependency_manager/public/include/dm_info.h
@@ -56,6 +56,7 @@ struct dm_info_service {
 
     /*Note: dm_caller has the ownership of the result.*/
     celix_status_t (*getInfo)(void *handle, dm_dependency_manager_info_pt *info);
+    void (*destroyInfo)(void *handle, dm_service_dependency_info_pt info);
 };
 
 typedef struct dm_info_service * dm_info_service_pt;

http://git-wip-us.apache.org/repos/asf/celix/blob/2de2554a/dependency_manager/public/include/dm_service_dependency.h
----------------------------------------------------------------------
diff --git a/dependency_manager/public/include/dm_service_dependency.h b/dependency_manager/public/include/dm_service_dependency.h
index 4a9c991..337be01 100644
--- a/dependency_manager/public/include/dm_service_dependency.h
+++ b/dependency_manager/public/include/dm_service_dependency.h
@@ -59,5 +59,6 @@ celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_pt
depen
  * Return a service dependency info. The caller is the owner
  */
 celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_pt, dm_service_dependency_info_pt
*info);
+void dependency_destroyDependencyInfo(dm_service_dependency_info_pt info);
 
 #endif /* DM_SERVICE_DEPENDENCY_H_ */


Mime
View raw message