Skip to content

Commit

Permalink
Merge pull request apache#601 from apache/feature/511-remove-resolver
Browse files Browse the repository at this point in the history
Feature/511 remove resolver
  • Loading branch information
PengZheng authored Aug 2, 2023
2 parents 88bec1d + 4ce9a10 commit 072cba2
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 1,558 deletions.
3 changes: 0 additions & 3 deletions examples/celix-examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ if (EXAMPLES)
add_subdirectory(readme_cxx_examples)
endif ()

#TODO refactor export_import
#add_subdirectory(export_import)

add_subdirectory(http_example)
add_subdirectory(embedding)
add_subdirectory(track_tracker_example)
Expand Down
59 changes: 0 additions & 59 deletions examples/celix-examples/export_import/CMakeLists.txt

This file was deleted.

34 changes: 0 additions & 34 deletions examples/celix-examples/export_import/include/test.h

This file was deleted.

34 changes: 0 additions & 34 deletions examples/celix-examples/export_import/include/test2.h

This file was deleted.

69 changes: 0 additions & 69 deletions examples/celix-examples/export_import/src/activator.c

This file was deleted.

32 changes: 0 additions & 32 deletions examples/celix-examples/export_import/src/test.c

This file was deleted.

32 changes: 0 additions & 32 deletions examples/celix-examples/export_import/src/test2.c

This file was deleted.

2 changes: 1 addition & 1 deletion libs/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (FRAMEWORK)
src/bundle_context.c src/bundle_revision.c
src/framework.c src/manifest.c
src/manifest_parser.c src/module.c
src/requirement.c src/capability.c src/resolver.c src/wire.c
src/requirement.c src/capability.c src/wire.c
src/service_reference.c src/service_registration.c
src/service_registry.c src/service_tracker.c src/service_tracker_customizer.c
src/celix_log.c src/celix_launcher.c
Expand Down
3 changes: 0 additions & 3 deletions libs/framework/src/bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <unistd.h>

#include "framework_private.h"
#include "resolver.h"
#include "utils.h"
#include "celix_file_utils.h"
#include "bundle_archive_private.h"
Expand Down Expand Up @@ -286,7 +285,6 @@ celix_status_t bundle_revise(bundle_pt bundle, const char * location, const char

celix_status_t bundle_addModule(bundle_pt bundle, module_pt module) {
celix_arrayList_add(bundle->modules, module);
resolver_addModule(module);

//free previous module info
free(bundle->symbolicName);
Expand Down Expand Up @@ -363,7 +361,6 @@ celix_status_t bundle_closeModules(const_bundle_pt bundle) {
unsigned int i = 0;
for (i = 0; i < arrayList_size(bundle->modules); i++) {
module_pt module = (module_pt) arrayList_get(bundle->modules, i);
resolver_removeModule(module);
module_setWires(module, NULL);
}

Expand Down
64 changes: 9 additions & 55 deletions libs/framework/src/capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,72 +30,26 @@
#include "attribute.h"
#include "celix_log.h"

//LCOV_EXCL_START
celix_status_t capability_create(module_pt module, hash_map_pt directives, hash_map_pt attributes, capability_pt *capability) {
celix_status_t status;
*capability = (capability_pt) malloc(sizeof(**capability));
if (!*capability) {
status = CELIX_ENOMEM;
} else {
(*capability)->module = module;
(*capability)->attributes = attributes;
(*capability)->directives = directives;
(*capability)->version = NULL;

attribute_pt versionAttribute = NULL;
attribute_pt serviceAttribute = (attribute_pt) hashMap_get(attributes, "service");
status = attribute_getValue(serviceAttribute, &(*capability)->serviceName);
if (status == CELIX_SUCCESS) {
versionAttribute = (attribute_pt) hashMap_get(attributes, "version");
if (versionAttribute != NULL) {
char *versionStr = NULL;
attribute_getValue(versionAttribute, &versionStr);
status = version_createVersionFromString(versionStr, &(*capability)->version);
} else {
status = version_createEmptyVersion(&(*capability)->version);
}
}

}

framework_logIfError(celix_frameworkLogger_globalLogger(), status, NULL, "Failed to create capability");

return status;
celix_status_t status = CELIX_FRAMEWORK_EXCEPTION;
framework_logIfError(celix_frameworkLogger_globalLogger(), status, NULL, "Failed to create capability");
return status;
}

celix_status_t capability_destroy(capability_pt capability) {
hash_map_iterator_pt attrIter = hashMapIterator_create(capability->attributes);
while (hashMapIterator_hasNext(attrIter)) {
attribute_pt attr = hashMapIterator_nextValue(attrIter);
hashMapIterator_remove(attrIter);
attribute_destroy(attr);
}
hashMapIterator_destroy(attrIter);
hashMap_destroy(capability->attributes, false, false);
hashMap_destroy(capability->directives, false, false);

capability->attributes = NULL;
capability->directives = NULL;
capability->module = NULL;

version_destroy(capability->version);
capability->version = NULL;

free(capability);

return CELIX_SUCCESS;
return CELIX_FRAMEWORK_EXCEPTION;
}

celix_status_t capability_getServiceName(capability_pt capability, const char **serviceName) {
*serviceName = capability->serviceName;
return CELIX_SUCCESS;
return CELIX_FRAMEWORK_EXCEPTION;
}

celix_status_t capability_getVersion(capability_pt capability, version_pt *version) {
*version = capability->version;
return CELIX_SUCCESS;
return CELIX_FRAMEWORK_EXCEPTION;
}

celix_status_t capability_getModule(capability_pt capability, module_pt *module) {
*module = capability->module;
return CELIX_SUCCESS;
return CELIX_FRAMEWORK_EXCEPTION;
}
//LCOV_EXCL_STOP
2 changes: 1 addition & 1 deletion libs/framework/src/celix_launcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ static int celixLauncher_createBundleCache(celix_properties_t* embeddedPropertie
return CELIX_LAUNCHER_ERROR_EXIT_CODE;
}
status = celix_framework_utils_createBundleArchivesCache(fw);
status = CELIX_DO_IF(status, framework_destroy(fw));
(void)framework_destroy(fw);
if (status != CELIX_SUCCESS) {
fprintf(stderr, "Failed to create bundle cache\n");
return CELIX_LAUNCHER_ERROR_EXIT_CODE;
Expand Down
Loading

0 comments on commit 072cba2

Please sign in to comment.