Author: abroekhuis
Date: Mon May 23 12:24:58 2011
New Revision: 1126469
URL: http://svn.apache.org/viewvc?rev=1126469&view=rev
Log:
Updated the uninstall to refresh the bundle correctly and remove the cache.
Modified:
incubator/celix/trunk/celix_test/array_list_test.c
incubator/celix/trunk/celix_test/hash_map_test.c
incubator/celix/trunk/framework/private/include/bundle.h
incubator/celix/trunk/framework/private/include/module.h
incubator/celix/trunk/framework/private/include/resolver.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_cache.c
incubator/celix/trunk/framework/private/src/framework.c
incubator/celix/trunk/framework/private/src/module.c
incubator/celix/trunk/framework/private/src/resolver.c
incubator/celix/trunk/target.cmake
incubator/celix/trunk/test/main.c
incubator/celix/trunk/utils/private/src/array_list.c
incubator/celix/trunk/utils/private/src/hash_map.c
incubator/celix/trunk/utils/public/include/hash_map.h
Modified: incubator/celix/trunk/celix_test/array_list_test.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/celix_test/array_list_test.c?rev=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/celix_test/array_list_test.c (original)
+++ incubator/celix/trunk/celix_test/array_list_test.c Mon May 23 12:24:58 2011
@@ -196,6 +196,32 @@ void test_arrayList_add(void) {
CU_ASSERT_EQUAL(entry2, get);
}
+void test_arrayList_addAll(void) {
+ arrayList_clear(list);
+
+ ARRAY_LIST toAdd = arrayList_create();
+ char * entry = "entry";
+ arrayList_add(toAdd, entry);
+ char * entry2 = "entry2";
+ arrayList_add(toAdd, entry2);
+
+ char * entry3 = "entry3";
+ arrayList_add(list, entry3);
+
+ char * get = arrayList_get(list, 0);
+ CU_ASSERT_EQUAL(entry3, get);
+
+ bool changed = arrayList_addAll(list, toAdd);
+ CU_ASSERT_TRUE(changed);
+ CU_ASSERT_EQUAL(arrayList_size(list), 3);
+
+ get = arrayList_get(list, 1);
+ CU_ASSERT_EQUAL(entry, get);
+
+ get = arrayList_get(list, 2);
+ CU_ASSERT_EQUAL(entry2, get);
+}
+
void test_arrayList_remove(void) {
arrayList_clear(list);
@@ -289,6 +315,7 @@ int main (int argc, char** argv) {
|| NULL == CU_add_test(pSuite, "Array List Remove Test",
test_arrayList_remove)
|| NULL == CU_add_test(pSuite, "Array List Remove Element
Test", test_arrayList_removeElement)
|| NULL == CU_add_test(pSuite, "Array List Clear Test",
test_arrayList_clear)
+ || NULL == CU_add_test(pSuite, "Array List Add All",
test_arrayList_addAll)
)
{
CU_cleanup_registry();
Modified: incubator/celix/trunk/celix_test/hash_map_test.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/celix_test/hash_map_test.c?rev=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/celix_test/hash_map_test.c (original)
+++ incubator/celix/trunk/celix_test/hash_map_test.c Mon May 23 12:24:58 2011
@@ -384,6 +384,28 @@ void test_hashMap_containsValue(void) {
CU_ASSERT_TRUE(hashMap_containsValue(map, value3));
}
+void test_hashMapValues_toArray(void) {
+ hashMap_clear(map, false, false);
+
+ // Add one entry
+ char * key = "key";
+ char * value = "value";
+ hashMap_put(map, key, value);
+
+ // Add second entry
+ char * key2 = "key2";
+ char * value2 = "value2";
+ hashMap_put(map, key2, value2);
+
+ char **array;
+ int size;
+ HASH_MAP_VALUES values = hashMapValues_create(map);
+ hashMapValues_toArray(values, (void*)&array, &size);
+ CU_ASSERT_EQUAL(size, 2);
+ CU_ASSERT_TRUE(hashMapValues_contains(values, array[0]));
+ CU_ASSERT_TRUE(hashMapValues_contains(values, array[1]));
+}
+
int main (int argc, char** argv) {
CU_pSuite pSuite = NULL;
@@ -411,6 +433,7 @@ int main (int argc, char** argv) {
|| NULL == CU_add_test(pSuite, "Map Remove Mapping Test",
test_hashMap_removeMapping)
|| NULL == CU_add_test(pSuite, "Map Clear Test",
test_hashMap_clear)
|| NULL == CU_add_test(pSuite, "Map Contains Value Test",
test_hashMap_containsValue)
+ || NULL == CU_add_test(pSuite, "Map To Array Test",
test_hashMapValues_toArray)
)
Modified: incubator/celix/trunk/framework/private/include/bundle.h
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/bundle.h?rev=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/bundle.h (original)
+++ incubator/celix/trunk/framework/private/include/bundle.h Mon May 23
12:24:58 2011
@@ -38,6 +38,7 @@ celix_status_t bundle_destroy(BUNDLE bun
bool bundle_isSystemBundle(BUNDLE bundle);
BUNDLE_ARCHIVE bundle_getArchive(BUNDLE bundle);
MODULE bundle_getCurrentModule(BUNDLE bundle);
+ARRAY_LIST bundle_getModules(BUNDLE bundle);
void * bundle_getHandle(BUNDLE bundle);
void bundle_setHandle(BUNDLE bundle, void * handle);
ACTIVATOR bundle_getActivator(BUNDLE bundle);
@@ -74,5 +75,6 @@ bool bundle_unlock(BUNDLE bundle);
celix_status_t bundle_closeAndDelete(BUNDLE bundle);
celix_status_t bundle_close(BUNDLE bundle);
+celix_status_t bundle_refresh(BUNDLE bundle);
#endif /* BUNDLE_H_ */
Modified: incubator/celix/trunk/framework/private/include/module.h
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/module.h?rev=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/module.h (original)
+++ incubator/celix/trunk/framework/private/include/module.h Mon May 23
12:24:58 2011
@@ -52,4 +52,14 @@ BUNDLE module_getBundle(MODULE module);
LINKED_LIST module_getRequirements(MODULE module);
LINKED_LIST module_getCapabilities(MODULE module);
+ARRAY_LIST module_getDependentImporters(MODULE module);
+void module_addDependentImporter(MODULE module, MODULE importer);
+void module_removeDependentImporter(MODULE module, MODULE importer);
+
+ARRAY_LIST module_getDependentRequirers(MODULE module);
+void module_addDependentRequirer(MODULE module, MODULE requirer);
+void module_removeDependentRequirer(MODULE module, MODULE requirer);
+
+ARRAY_LIST module_getDependents(MODULE module);
+
#endif /* MODULE_H_ */
Modified: incubator/celix/trunk/framework/private/include/resolver.h
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/resolver.h?rev=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/resolver.h (original)
+++ incubator/celix/trunk/framework/private/include/resolver.h Mon May 23
12:24:58 2011
@@ -33,5 +33,6 @@
HASH_MAP resolver_resolve(MODULE root);
void resolver_moduleResolved(MODULE module);
void resolver_addModule(MODULE module);
+void resolver_removeModule(MODULE module);
#endif /* RESOLVER_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=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle.c Mon May 23 12:24:58
2011
@@ -112,6 +112,10 @@ MODULE bundle_getCurrentModule(BUNDLE bu
return arrayList_get(bundle->modules, arrayList_size(bundle->modules) -
1);
}
+ARRAY_LIST bundle_getModules(BUNDLE bundle) {
+ return bundle->modules;
+}
+
void * bundle_getHandle(BUNDLE bundle) {
return bundle->handle;
}
@@ -326,6 +330,7 @@ bool bundle_unlock(BUNDLE bundle) {
celix_status_t bundle_close(BUNDLE bundle) {
celix_status_t status = CELIX_SUCCESS;
+ bundle_closeModules(bundle);
bundle_closeRevisions(bundle);
BUNDLE_ARCHIVE archive = bundle_getArchive(bundle);
bundleArchive_close(archive);
@@ -336,6 +341,7 @@ celix_status_t bundle_close(BUNDLE bundl
celix_status_t bundle_closeAndDelete(BUNDLE bundle) {
celix_status_t status = CELIX_SUCCESS;
+ bundle_closeModules(bundle);
bundle_closeRevisions(bundle);
BUNDLE_ARCHIVE archive = bundle_getArchive(bundle);
bundleArchive_closeAndDelete(archive);
@@ -350,4 +356,26 @@ celix_status_t bundle_closeRevisions(BUN
return status;
}
+celix_status_t bundle_closeModules(BUNDLE bundle) {
+ celix_status_t status = CELIX_SUCCESS;
+
+ int i = 0;
+ for (i = 0; i < arrayList_size(bundle->modules); i++) {
+ MODULE module = arrayList_get(bundle->modules, i);
+ resolver_removeModule(module);
+ module_setWires(module, NULL);
+ }
+
+ return status;
+}
+
+celix_status_t bundle_refresh(BUNDLE bundle) {
+ bundle_closeModules(bundle);
+ arrayList_clear(bundle->modules);
+ MODULE module = bundle_createModule(bundle);
+ bundle_addModule(bundle, module);
+ bundle->state = BUNDLE_INSTALLED;
+ return CELIX_SUCCESS;
+}
+
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=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_archive.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_archive.c Mon May 23
12:24:58 2011
@@ -132,7 +132,7 @@ BUNDLE_ARCHIVE bundleArchive_recreate(ch
apr_dir_t *dir;
apr_status_t status = apr_dir_open(&dir, archiveRoot, mp);
apr_finfo_t dp;
- while ((apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir))) {
+ while ((apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir)) ==
APR_SUCCESS) {
if (dp.filetype == APR_DIR && (strncmp(dp.name, "version", 7)
== 0)) {
long idx;
sscanf(dp.name, "version%*d.%ld", &idx);
@@ -434,9 +434,14 @@ void bundleArchive_initialize(BUNDLE_ARC
void bundleArchive_deleteTree(char * directory, apr_pool_t *mp) {
apr_dir_t *dir;
- apr_dir_open(&dir, directory, mp);
+ apr_status_t stat = apr_dir_open(&dir, directory, mp);
+ if (stat != APR_SUCCESS) {
+ printf("ERROR opening: %d\n", stat);
+ }
apr_finfo_t dp;
- while (apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir)) {
+ while ((apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir)) ==
APR_SUCCESS) {
+ printf("Stat: %d\n", stat);
+ printf("File: %s\n", dp.name);
if ((strcmp((dp.name), ".") != 0) && (strcmp((dp.name), "..")
!= 0)) {
char subdir[strlen(directory) + strlen(dp.name) + 2];
strcpy(subdir, directory);
Modified: incubator/celix/trunk/framework/private/src/bundle_cache.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_cache.c?rev=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_cache.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_cache.c Mon May 23
12:24:58 2011
@@ -65,7 +65,7 @@ void bundleCache_deleteTree(char * direc
apr_dir_t *dir;
apr_dir_open(&dir, directory, mp);
apr_finfo_t dp;
- while (apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir)) {
+ while ((apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir)) ==
APR_SUCCESS) {
if ((strcmp((dp.name), ".") != 0) && (strcmp((dp.name), "..")
!= 0)) {
char subdir[strlen(directory) + strlen(dp.name) + 2];
strcpy(subdir, directory);
@@ -93,7 +93,7 @@ ARRAY_LIST bundleCache_getArchives(BUNDL
ARRAY_LIST list = arrayList_create();
apr_finfo_t dp;
- while ((apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir))) {
+ while ((apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir)) ==
APR_SUCCESS) {
char archiveRoot[strlen(cache->cacheDir) + strlen(dp.name) + 2];
strcpy(archiveRoot, cache->cacheDir);
strcat(archiveRoot, "/");
Modified: incubator/celix/trunk/framework/private/src/framework.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Mon May 23 12:24:58
2011
@@ -203,7 +203,7 @@ celix_status_t fw_init(FRAMEWORK framewo
int arcIdx;
for (arcIdx = 0; arcIdx < arrayList_size(archives); arcIdx++) {
BUNDLE_ARCHIVE archive = (BUNDLE_ARCHIVE)
arrayList_get(archives, arcIdx);
-// framework->nextBundleId = fmaxl(framework->nextBundleId,
bundleArchive_getId(archive) + 1);
+ framework->nextBundleId = fmaxl(framework->nextBundleId,
bundleArchive_getId(archive) + 1);
if (bundleArchive_getPersistentState(archive) ==
BUNDLE_UNINSTALLED) {
bundleArchive_closeAndDelete(archive);
@@ -388,13 +388,15 @@ celix_status_t fw_startBundle(FRAMEWORK
framework_releaseBundleLock(framework, bundle);
return CELIX_SUCCESS;
case BUNDLE_INSTALLED:
- wires =
resolver_resolve(bundle_getCurrentModule(bundle));
- if (wires == NULL) {
- framework_releaseBundleLock(framework, bundle);
- return CELIX_BUNDLE_EXCEPTION;
- }
- framework_markResolvedModules(framework, wires);
- hashMap_destroy(wires, false, false);
+ if (!module_isResolved(bundle_getCurrentModule(bundle))) {
+ wires = resolver_resolve(bundle_getCurrentModule(bundle));
+ if (wires == NULL) {
+ framework_releaseBundleLock(framework, bundle);
+ return CELIX_BUNDLE_EXCEPTION;
+ }
+ framework_markResolvedModules(framework, wires);
+ }
+ //hashMap_destroy(wires, false, false);
// no break
case BUNDLE_RESOLVED:
if (bundleContext_create(framework, bundle, &context)
!= CELIX_SUCCESS) {
@@ -649,31 +651,44 @@ celix_status_t fw_refreshBundles(FRAMEWO
framework_releaseGlobalLock(framework);
status = CELIX_ILLEGAL_STATE;
} else {
+ HASH_MAP map = hashMap_create(NULL, NULL, NULL, NULL);
+ int targetIdx = 0;
+ for (targetIdx = 0; targetIdx < size; targetIdx++) {
+ BUNDLE bundle = bundles[targetIdx];
+ hashMap_put(map, bundle, bundle);
+ fw_populateDependentGraph(framework, bundle, &map);
+ }
+ HASH_MAP_VALUES values = hashMapValues_create(map);
+ BUNDLE *newTargets;
+ int nrofvalues;
+ hashMapValues_toArray(values, (void *) &newTargets, &nrofvalues);
+
bool restart = false;
- if (bundles != NULL) {
+ if (newTargets != NULL) {
int i = 0;
- for (i = 0; i < size && !restart; i++) {
- BUNDLE bundle = bundles[i];
+ for (i = 0; i < nrofvalues && !restart; i++) {
+ BUNDLE bundle = (BUNDLE) newTargets[i];
if (framework->bundle == bundle) {
restart = true;
}
}
- struct fw_refreshHelper * helpers[size];
- for (i = 0; i < size && !restart; i++) {
- BUNDLE bundle = bundles[i];
+ struct fw_refreshHelper * helpers[nrofvalues];
+ for (i = 0; i < nrofvalues && !restart; i++) {
+ BUNDLE bundle = (BUNDLE) newTargets[i];
helpers[i] = malloc(sizeof(struct fw_refreshHelper));
helpers[i] ->framework = framework;
helpers[i]->bundle = bundle;
+ helpers[i]->oldState = BUNDLE_INSTALLED;
}
- for (i = 0; i < size; i++) {
+ for (i = 0; i < nrofvalues; i++) {
struct fw_refreshHelper * helper = helpers[i];
fw_refreshHelper_stop(helper);
fw_refreshHelper_refreshOrRemove(helper);
}
- for (i = 0; i < size; i++) {
+ for (i = 0; i < nrofvalues; i++) {
struct fw_refreshHelper * helper = helpers[i];
fw_refreshHelper_restart(helper);
}
@@ -696,8 +711,13 @@ celix_status_t fw_refreshBundle(FRAMEWOR
printf("Cannot refresh bundle");
framework_releaseBundleLock(framework, bundle);
} else {
- // TODO fire unresolved event
- // TODO bundle_refresh(bundle);
+ bool fire = (bundle_getState(bundle) != BUNDLE_INSTALLED);
+ bundle_refresh(bundle);
+
+ if (fire) {
+ framework_setBundleStateAndNotify(framework, bundle,
BUNDLE_INSTALLED);
+ }
+
framework_releaseBundleLock(framework, bundle);
}
return status;
@@ -705,6 +725,7 @@ celix_status_t fw_refreshBundle(FRAMEWOR
celix_status_t fw_refreshHelper_stop(struct fw_refreshHelper * refreshHelper) {
if (bundle_getState(refreshHelper->bundle) == BUNDLE_ACTIVE) {
+ refreshHelper->oldState = BUNDLE_ACTIVE;
fw_stopBundle(refreshHelper->framework, refreshHelper->bundle, false);
}
@@ -728,6 +749,51 @@ celix_status_t fw_refreshHelper_restart(
return CELIX_SUCCESS;
}
+celix_status_t fw_getDependentBundles(FRAMEWORK framework, BUNDLE exporter,
ARRAY_LIST *list) {
+ celix_status_t status = CELIX_SUCCESS;
+
+ if (*list == NULL && exporter != NULL && framework != NULL) {
+ *list = arrayList_create();
+
+ ARRAY_LIST modules = bundle_getModules(exporter);
+ int modIdx = 0;
+ for (modIdx = 0; modIdx < arrayList_size(modules); modIdx++) {
+ MODULE module = arrayList_get(modules, modIdx);
+ ARRAY_LIST dependents = module_getDependents(module);
+ int depIdx = 0;
+ for (depIdx = 0; (dependents != NULL) && (depIdx <
arrayList_size(dependents)); depIdx++) {
+ MODULE dependent = arrayList_get(dependents, depIdx);
+ arrayList_add(*list, module_getBundle(dependent));
+ }
+ }
+ } else {
+ status = CELIX_ILLEGAL_ARGUMENT;
+ }
+
+ return status;
+}
+
+celix_status_t fw_populateDependentGraph(FRAMEWORK framework, BUNDLE exporter,
HASH_MAP *map) {
+ celix_status_t status = CELIX_SUCCESS;
+
+ if (exporter != NULL && framework != NULL) {
+ ARRAY_LIST dependents = NULL;
+ if ((status = fw_getDependentBundles(framework, exporter,
&dependents)) == CELIX_SUCCESS) {
+ int depIdx = 0;
+ for (depIdx = 0; (dependents != NULL) && (depIdx <
arrayList_size(dependents)); depIdx++) {
+ if (!hashMap_containsKey(*map, arrayList_get(dependents,
depIdx))) {
+ hashMap_put(*map, arrayList_get(dependents, depIdx),
arrayList_get(dependents, depIdx));
+ fw_populateDependentGraph(framework,
arrayList_get(dependents, depIdx), map);
+ }
+ }
+ }
+ } else {
+ status = CELIX_ILLEGAL_ARGUMENT;
+ }
+
+ return status;
+}
+
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/framework/private/src/module.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/module.c?rev=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/module.c (original)
+++ incubator/celix/trunk/framework/private/src/module.c Mon May 23 12:24:58
2011
@@ -37,6 +37,8 @@ struct module {
LINKED_LIST requirements;
LINKED_LIST wires;
+ ARRAY_LIST dependentImporters;
+
VERSION version;
char * symbolicName;
bool resolved;
@@ -54,6 +56,8 @@ MODULE module_create(MANIFEST headerMap,
module->bundle = bundle;
module->resolved = false;
+ module->dependentImporters = arrayList_create();
+
MANIFEST_PARSER mp = manifestParser_createManifestParser(module,
headerMap);
module->symbolicName = mp->bundleSymbolicName;
module->version = mp->bundleVersion;
@@ -141,7 +145,20 @@ LINKED_LIST module_getWires(MODULE modul
}
void module_setWires(MODULE module, LINKED_LIST wires) {
+ int i = 0;
+ for (i = 0; (module->wires != NULL) && (i <
linkedList_size(module->wires)); i++) {
+ WIRE wire = (WIRE) linkedList_get(module->wires, i);
+ MODULE exporter = wire_getExporter(wire);
+ module_removeDependentImporter(exporter, module);
+ }
+
module->wires = wires;
+
+ for (i = 0; (module->wires != NULL) && (i <
linkedList_size(module->wires)); i++) {
+ WIRE wire = (WIRE) linkedList_get(module->wires, i);
+ MODULE exporter = wire_getExporter(wire);
+ module_addDependentImporter(exporter, module);
+ }
}
bool module_isResolved(MODULE module) {
@@ -163,3 +180,25 @@ LINKED_LIST module_getRequirements(MODUL
LINKED_LIST module_getCapabilities(MODULE module) {
return module->capabilities;
}
+
+ARRAY_LIST module_getDependentImporters(MODULE module) {
+ return module->dependentImporters;
+}
+
+void module_addDependentImporter(MODULE module, MODULE importer) {
+ if (!arrayList_contains(module->dependentImporters, importer)) {
+ arrayList_add(module->dependentImporters, importer);
+ }
+}
+
+void module_removeDependentImporter(MODULE module, MODULE importer) {
+ arrayList_removeElement(module->dependentImporters, importer);
+}
+
+ARRAY_LIST module_getDependents(MODULE module) {
+ ARRAY_LIST dependents = arrayList_create();
+
+ arrayList_addAll(dependents, module->dependentImporters);
+
+ return dependents;
+}
Modified: incubator/celix/trunk/framework/private/src/resolver.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/resolver.c?rev=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/resolver.c (original)
+++ incubator/celix/trunk/framework/private/src/resolver.c Mon May 23 12:24:58
2011
@@ -58,6 +58,7 @@ HASH_MAP resolver_populateWireMap(HASH_M
HASH_MAP resolver_resolve(MODULE root) {
if (module_isResolved(root)) {
+ printf("already resolved\n");
return NULL;
}
@@ -241,6 +242,26 @@ void resolver_addModule(MODULE module) {
}
}
+void resolver_removeModule(MODULE module) {
+ linkedList_removeElement(m_modules, module);
+ LINKED_LIST caps = module_getCapabilities(module);
+ if (caps != NULL)
+ {
+ int i = 0;
+ for (i = 0; i < linkedList_size(caps); i++) {
+ CAPABILITY cap = (CAPABILITY) linkedList_get(caps, i);
+ CAPABILITY_LIST list =
resolver_getCapabilityList(m_unresolvedServices,
capability_getServiceName(cap));
+ if (list != NULL) {
+ linkedList_removeElement(list->capabilities, cap);
+ }
+ list = resolver_getCapabilityList(m_resolvedServices,
capability_getServiceName(cap));
+ if (list != NULL) {
+ linkedList_removeElement(list->capabilities, cap);
+ }
+ }
+ }
+}
+
void resolver_moduleResolved(MODULE module) {
if (module_isResolved(module)) {
int capIdx;
Modified: incubator/celix/trunk/target.cmake
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/target.cmake?rev=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/target.cmake (original)
+++ incubator/celix/trunk/target.cmake Mon May 23 12:24:58 2011
@@ -18,7 +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("deployer" BUNDLES shell shell_tui deployer)
+#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/test/main.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/test/main.c?rev=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/test/main.c (original)
+++ incubator/celix/trunk/test/main.c Mon May 23 12:24:58 2011
@@ -48,12 +48,13 @@
#include "bundle_cache.h"
#include "constants.h"
-void test(void ** ptr) {
- ARRAY_LIST l;
- ARRAY_LIST list = arrayList_create();
- *ptr = list;
+struct bla {
+ int idx;
+};
-}
+typedef struct bla * bla_t;
+
+void main_arrayTest(ARRAY_LIST list, void* *array[], int *size);
int main( int argc, const char* argv[] )
{
@@ -76,9 +77,31 @@ int main( int argc, const char* argv[] )
// framework_stop(framework);
- ARRAY_LIST l;
- test((void**)&l);
- printf("Size: %d\n", arrayList_size(l));
+ ARRAY_LIST list = arrayList_create();
+ int i = 0;
+ for (i = 0; i < 10; i++) {
+ bla_t bl = malloc(sizeof(*bl));
+ bl->idx = i;
+ arrayList_add(list, bl);
+ }
+ bla_t *array;
+ int size;
+ main_arrayTest(list, (void*) &array, &size);
+ printf("Idx: %d\n", array[2]->idx);
+ printf("Idx: %d\n", array[9]->idx);
+ printf("Idx: %d\n", array[0]->idx);
+
return 0;
}
+
+void main_arrayTest(ARRAY_LIST list, void* *array[], int *size) {
+ int asize = arrayList_size(list);
+ *array = malloc(asize * sizeof(*array));
+ int i = 0;
+ for (i = 0; i < arrayList_size(list); i++) {
+ void *val = arrayList_get(list, i);
+ (*array)[i] = val;
+ }
+
+}
Modified: incubator/celix/trunk/utils/private/src/array_list.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/utils/private/src/array_list.c?rev=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/utils/private/src/array_list.c (original)
+++ incubator/celix/trunk/utils/private/src/array_list.c Mon May 23 12:24:58
2011
@@ -157,6 +157,7 @@ int arrayList_addIndex(ARRAY_LIST list,
list->elementData[index] = element;
list->size++;
+ return 0;
}
void * arrayList_remove(ARRAY_LIST list, unsigned int index) {
@@ -213,6 +214,18 @@ void arrayList_clear(ARRAY_LIST list) {
list->size = 0;
}
+bool arrayList_addAll(ARRAY_LIST list, ARRAY_LIST toAdd) {
+ int size = arrayList_size(toAdd);
+ arrayList_ensureCapacity(list, list->size + size);
+// memcpy(list->elementData+list->size, *toAdd->elementData, size);
+// list->size += size;
+ int i;
+ for (i = 0; i < arrayList_size(toAdd); i++) {
+ arrayList_add(list, arrayList_get(toAdd, i));
+ }
+ return size != 0;
+}
+
ARRAY_LIST arrayList_clone(ARRAY_LIST list) {
ARRAY_LIST new = arrayList_create();
// arrayList_ensureCapacity(new, list->size);
Modified: incubator/celix/trunk/utils/private/src/hash_map.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/utils/private/src/hash_map.c?rev=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/utils/private/src/hash_map.c (original)
+++ incubator/celix/trunk/utils/private/src/hash_map.c Mon May 23 12:24:58 2011
@@ -471,6 +471,20 @@ bool hashMapValues_contains(HASH_MAP_VAL
return hashMap_containsValue(values->map, value);
}
+void hashMapValues_toArray(HASH_MAP_VALUES values, void* *array[], unsigned
int *size) {
+ int vsize = hashMapValues_size(values);
+ *size = vsize;
+ *array = malloc(vsize * sizeof(*array));
+ HASH_MAP_ITERATOR it = hashMapValues_iterator(values);
+ int i = 0;
+ for (i = 0; i < vsize; i++) {
+ if (!hashMapIterator_hasNext(it)) {
+ return;
+ }
+ (*array)[i] = hashMapIterator_nextValue(it);
+ }
+}
+
bool hashMapValues_remove(HASH_MAP_VALUES values, void * value) {
HASH_MAP_ITERATOR iterator = hashMapValues_iterator(values);
if (value == NULL) {
Modified: incubator/celix/trunk/utils/public/include/hash_map.h
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/utils/public/include/hash_map.h?rev=1126469&r1=1126468&r2=1126469&view=diff
==============================================================================
--- incubator/celix/trunk/utils/public/include/hash_map.h (original)
+++ incubator/celix/trunk/utils/public/include/hash_map.h Mon May 23 12:24:58
2011
@@ -70,6 +70,7 @@ void hashMapValues_destroy(HASH_MAP_VALU
HASH_MAP_ITERATOR hashMapValues_iterator(HASH_MAP_VALUES values);
int hashMapValues_size(HASH_MAP_VALUES values);
bool hashMapValues_contains(HASH_MAP_VALUES values, void * o);
+void hashMapValues_toArray(HASH_MAP_VALUES values, void* *array[], unsigned
int *size);
bool hashMapValues_remove(HASH_MAP_VALUES values, void * o);
void hashMapValues_clear(HASH_MAP_VALUES values);
bool hashMapValues_isEmpty(HASH_MAP_VALUES values);