Skip to content

Commit

Permalink
gh-685: Update usage of manifest to celix_bundle_manifest and removes…
Browse files Browse the repository at this point in the history
… some usage of deprecated api
  • Loading branch information
pnoltes committed Jul 21, 2024
1 parent f79f229 commit 3759c1d
Show file tree
Hide file tree
Showing 72 changed files with 753 additions and 1,473 deletions.
3 changes: 0 additions & 3 deletions bundles/http_admin/http_admin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ target_include_directories(http_admin PRIVATE src)

target_link_libraries(http_admin PUBLIC Celix::http_admin_api)

celix_deprecated_utils_headers(http_admin)


install_celix_bundle(http_admin EXPORT celix COMPONENT http_admin)
#Setup target aliases to match external usage
add_library(Celix::http_admin ALIAS http_admin)
2 changes: 1 addition & 1 deletion bundles/http_admin/http_admin/src/http_admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

#include "civetweb.h"

#include "celix_utils_api.h"
#include "celix_compiler.h"
#include "celix_threads.h"


struct http_admin_manager {
Expand Down
2 changes: 1 addition & 1 deletion bundles/http_admin/http_admin/src/websocket_admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "celix_compiler.h"
#include "celix_stdlib_cleanup.h"
#include "celix_utils_api.h"
#include "celix_threads.h"

struct websocket_admin_manager {
bundle_context_pt context;
Expand Down
2 changes: 0 additions & 2 deletions bundles/logging/log_helper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ if (LOG_HELPER)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_helper COMPONENT logging)

celix_target_hide_symbols(log_helper)
celix_deprecated_utils_headers(log_helper)
celix_deprecated_framework_headers(log_helper)

add_library(Celix::log_helper ALIAS log_helper)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,26 +156,9 @@ extern "C" {
}

static void testBundles(void) {
celix_array_list_t* bundles = nullptr;

int rc = bundleContext_getBundles(context, &bundles);
ASSERT_EQ(0, rc);
celix_array_list_t* bundles = celix_bundleContext_listBundles(context);
ASSERT_NE(nullptr, bundles);
ASSERT_EQ(3, celix_arrayList_size(bundles)); //framework, rsa_dfi & calc

/*
int size = arrayList_size(bundles);
int i;
for (i = 0; i < size; i += 1) {
celix_bundle_t *bundle = nullptr;
module_pt module = nullptr;
char *name = nullptr;
bundle = (celix_bundle_t *) arrayList_get(bundles, i);
bundle_getCurrentModule(bundle, &module);
module_getSymbolicName(module, &name);
printf("got bundle with symbolic name '%s'", name);
}*/

celix_arrayList_destroy(bundles);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "export_registration_dfi.h"
#include "dfi_utils.h"
#include "remote_interceptors_handler.h"
#include "celix_threads.h"

#include <string.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "remote_interceptors_handler.h"
#include "remote_service_admin_dfi.h"
#include "remote_service_admin_dfi_constants.h"
#include "hash_map.h"
#include "celix_threads.h"

struct import_registration {
celix_bundle_context_t *context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "utils.h"
#include "celix_utils.h"
#include "celix_ref.h"
#include "hash_map.h"

#include "import_registration_dfi.h"
#include "export_registration_dfi.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "export_registration_impl.h"
#include "remote_service_admin_impl.h"
#include "bundle.h"


struct export_reference {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include "import_registration_impl.h"
#include "remote_service_admin_impl.h"
#include "bundle.h"

struct import_reference {
endpoint_description_t *endpoint;
Expand Down
1 change: 1 addition & 0 deletions bundles/remote_services/rsa_spi/include/remote_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "endpoint_listener.h"
#include "remote_service_admin.h"
#include "hash_map.h"

#define CELIX_RSA_REMOTE_PROXY_FACTORY "remote_proxy_factory"
#define CELIX_RSA_REMOTE_PROXY_TIMEOUT "remote_proxy_timeout"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "bundle_context.h"
#include "celix_compiler.h"
#include "celix_constants.h"
#include "bundle.h"
#include "celix_bundle.h"
#include "remote_service_admin.h"
#include "remote_constants.h"
#include "filter.h"
Expand Down
20 changes: 10 additions & 10 deletions bundles/remote_services/topology_manager/tms_tst/tms_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,18 @@ extern "C" {
static endpoint_listener_t *eplService = nullptr; // actually this is the topology manager

static void setupFm() {
celix_status_t rc;
celix_properties_t* config;
ASSERT_EQ(CELIX_SUCCESS, celix_properties_load("config.properties", 0, &config));

framework = celix_frameworkFactory_createFramework(config);
ASSERT_NE(nullptr, framework);

celix_bundle_t *bundle = nullptr;
celix_status_t rc = framework_getFrameworkBundle(framework, &bundle);
EXPECT_EQ(CELIX_SUCCESS, rc);
celix_bundle_t *bundle = celix_framework_getFrameworkBundle(framework);
EXPECT_NE(nullptr, bundle);

rc = bundle_getContext(bundle, &context);
EXPECT_EQ(CELIX_SUCCESS, rc);
context = celix_framework_getFrameworkContext(framework);
EXPECT_NE(nullptr, context);

rc = bundleContext_getServiceReference(context, (char *)CELIX_RSA_REMOTE_SERVICE_ADMIN, &rsaRef);
EXPECT_EQ(CELIX_SUCCESS, rc);
Expand Down Expand Up @@ -172,18 +172,18 @@ extern "C" {
}

static void setupFmImport() {
celix_status_t rc;
celix_properties_t* config;
ASSERT_EQ(CELIX_SUCCESS, celix_properties_load("config_import.properties", 0, &config));

framework = celix_frameworkFactory_createFramework(config);
ASSERT_NE(nullptr, framework);

celix_bundle_t *bundle = nullptr;
celix_status_t rc = framework_getFrameworkBundle(framework, &bundle);
EXPECT_EQ(CELIX_SUCCESS, rc);
celix_bundle_t *bundle = celix_framework_getFrameworkBundle(framework);
ASSERT_NE(nullptr, bundle);

rc = bundle_getContext(bundle, &context);
EXPECT_EQ(CELIX_SUCCESS, rc);
context = celix_framework_getFrameworkContext(framework);
ASSERT_NE(nullptr, context);

celix_array_list_t* bundles = celix_bundleContext_listBundles(context);
EXPECT_EQ(celix_arrayList_size(bundles), 4); //rsa, calculator, topman, test bundle
Expand Down
2 changes: 1 addition & 1 deletion bundles/shell/remote_shell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if (REMOTE_SHELL)
include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")

target_link_libraries(remote_shell PRIVATE Celix::shell_api)
celix_deprecated_utils_headers(remote_shell)
#celix_deprecated_utils_headers(remote_shell)
celix_deprecated_framework_headers(remote_shell)

install_celix_bundle(remote_shell EXPORT celix COMPONENT remote_shell)
Expand Down
9 changes: 0 additions & 9 deletions bundles/shell/remote_shell/src/remote_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
/**
* remote_shell.c
*
* \date Nov 4, 2012
* \author <a href="mailto:[email protected]">Apache Celix Project Team</a>
* \copyright Apache License, Version 2.0
*/

#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <utils.h>
#include <sys/socket.h>

#include "celix_log_helper.h"
Expand Down
148 changes: 69 additions & 79 deletions bundles/shell/remote_shell/src/shell_mediator.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,120 +16,110 @@
* specific language governing permissions and limitations
* under the License.
*/
/**
* shell_mediator.c
*
* \date Nov 4, 2012
* \author <a href="mailto:[email protected]">Apache Celix Project Team</a>
* \copyright Apache License, Version 2.0
*/

#include <stdlib.h>
#include <string.h>
#include <utils.h>
#include <celix_shell.h>
#include <service_tracker.h>
#include <sys/socket.h>

#include "celix_log_helper.h"
#include "celix_shell.h"
#include "service_tracker.h"
#include "shell_mediator.h"

static celix_status_t shellMediator_addedService(void *handler, service_reference_pt reference, void * service);
static celix_status_t shellMediator_removedService(void *handler, service_reference_pt reference, void * service);

celix_status_t shellMediator_create(bundle_context_pt context, shell_mediator_pt *instance) {
celix_status_t status = CELIX_SUCCESS;
service_tracker_customizer_pt customizer = NULL;
static celix_status_t shellMediator_addedService(void* handler, service_reference_pt reference, void* service);
static celix_status_t shellMediator_removedService(void* handler, service_reference_pt reference, void* service);

(*instance) = (shell_mediator_pt) calloc(1, sizeof(**instance));
if ((*instance) != NULL) {
celix_status_t shellMediator_create(bundle_context_pt context, shell_mediator_pt* instance) {
celix_status_t status = CELIX_SUCCESS;
service_tracker_customizer_pt customizer = NULL;

(*instance)->context = context;
(*instance)->tracker = NULL;
(*instance)->shellService = NULL;
(*instance) = (shell_mediator_pt)calloc(1, sizeof(**instance));
if ((*instance) != NULL) {
(*instance)->context = context;
(*instance)->tracker = NULL;
(*instance)->shellService = NULL;

(*instance)->loghelper = celix_logHelper_create(context, "celix_shell");

status = CELIX_DO_IF(status, celixThreadMutex_create(&(*instance)->mutex, NULL));

status = CELIX_DO_IF(status, serviceTrackerCustomizer_create((*instance), NULL, shellMediator_addedService,
NULL, shellMediator_removedService, &customizer));
status = CELIX_DO_IF(status, serviceTracker_create(context, (char * )CELIX_SHELL_SERVICE_NAME, customizer, &(*instance)->tracker));

if (status == CELIX_SUCCESS) {
serviceTracker_open((*instance)->tracker);
}
} else {
status = CELIX_ENOMEM;
}

if ((status != CELIX_SUCCESS) && ((*instance) != NULL)){
celix_logHelper_log((*instance)->loghelper, CELIX_LOG_LEVEL_ERROR, "Error creating shell_mediator, error code is %i\n", status);
}
return status;
status = CELIX_DO_IF(status, celixThreadMutex_create(&(*instance)->mutex, NULL));

status = CELIX_DO_IF(
status,
serviceTrackerCustomizer_create(
(*instance), NULL, shellMediator_addedService, NULL, shellMediator_removedService, &customizer));
status = CELIX_DO_IF(
status, serviceTracker_create(context, (char*)CELIX_SHELL_SERVICE_NAME, customizer, &(*instance)->tracker));

if (status == CELIX_SUCCESS) {
serviceTracker_open((*instance)->tracker);
}
} else {
status = CELIX_ENOMEM;
}

if ((status != CELIX_SUCCESS) && ((*instance) != NULL)) {
celix_logHelper_log(
(*instance)->loghelper, CELIX_LOG_LEVEL_ERROR, "Error creating shell_mediator, error code is %i\n", status);
}
return status;
}

celix_status_t shellMediator_stop(shell_mediator_pt instance) {
service_tracker_pt tracker;
celixThreadMutex_lock(&instance->mutex);
tracker = instance->tracker;
celixThreadMutex_unlock(&instance->mutex);
service_tracker_pt tracker;
celixThreadMutex_lock(&instance->mutex);
tracker = instance->tracker;
celixThreadMutex_unlock(&instance->mutex);

if (tracker != NULL) {
serviceTracker_close(tracker);
}
if (tracker != NULL) {
serviceTracker_close(tracker);
}

return CELIX_SUCCESS;
}

celix_status_t shellMediator_destroy(shell_mediator_pt instance) {
celix_status_t status = CELIX_SUCCESS;
celix_status_t status = CELIX_SUCCESS;

celixThreadMutex_lock(&instance->mutex);
celixThreadMutex_lock(&instance->mutex);

instance->shellService = NULL;
serviceTracker_destroy(instance->tracker);
instance->shellService = NULL;
serviceTracker_destroy(instance->tracker);
celix_logHelper_destroy(instance->loghelper);
celixThreadMutex_destroy(&instance->mutex);
celixThreadMutex_destroy(&instance->mutex);

free(instance);

free(instance);


return status;
return status;
}

celix_status_t shellMediator_executeCommand(shell_mediator_pt instance, char *command, FILE *out, FILE *err) {
celix_status_t status = CELIX_SUCCESS;

celixThreadMutex_lock(&instance->mutex);
celix_status_t shellMediator_executeCommand(shell_mediator_pt instance, char* command, FILE* out, FILE* err) {
celix_status_t status = CELIX_SUCCESS;

celixThreadMutex_lock(&instance->mutex);

if (instance->shellService != NULL) {
instance->shellService->executeCommand(instance->shellService->handle, command, out, err);
}
if (instance->shellService != NULL) {
instance->shellService->executeCommand(instance->shellService->handle, command, out, err);
}

celixThreadMutex_unlock(&instance->mutex);
celixThreadMutex_unlock(&instance->mutex);

return status;
return status;
}

static celix_status_t shellMediator_addedService(void *handler, service_reference_pt reference, void * service) {
celix_status_t status = CELIX_SUCCESS;
shell_mediator_pt instance = (shell_mediator_pt) handler;
celixThreadMutex_lock(&instance->mutex);
instance->shellService = (celix_shell_t*) service;
celixThreadMutex_unlock(&instance->mutex);
return status;
static celix_status_t shellMediator_addedService(void* handler, service_reference_pt reference, void* service) {
celix_status_t status = CELIX_SUCCESS;
shell_mediator_pt instance = (shell_mediator_pt)handler;
celixThreadMutex_lock(&instance->mutex);
instance->shellService = (celix_shell_t*)service;
celixThreadMutex_unlock(&instance->mutex);
return status;
}


static celix_status_t shellMediator_removedService(void *handler, service_reference_pt reference, void * service) {
celix_status_t status = CELIX_SUCCESS;
shell_mediator_pt instance = (shell_mediator_pt) handler;
celixThreadMutex_lock(&instance->mutex);
instance->shellService = NULL;
celixThreadMutex_unlock(&instance->mutex);
return status;
static celix_status_t shellMediator_removedService(void* handler, service_reference_pt reference, void* service) {
celix_status_t status = CELIX_SUCCESS;
shell_mediator_pt instance = (shell_mediator_pt)handler;
celixThreadMutex_lock(&instance->mutex);
instance->shellService = NULL;
celixThreadMutex_unlock(&instance->mutex);
return status;
}

Loading

0 comments on commit 3759c1d

Please sign in to comment.