Repository: celix Updated Branches: refs/heads/develop 9b5bca43d -> b8b16fd67
CELIX-386: Removes source files for the C++ dependency manager. This makes the C++ dep man a pure header file implementation. This is done the prevent ABI compatibility issues (e.g. from gcc 4 -> 5). Although the C++ dependency manager was already considered only source backwards compatible, because is removes the dependency_manager_cxx_static lib it now also not possible anymore. Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/b8b16fd6 Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/b8b16fd6 Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/b8b16fd6 Branch: refs/heads/develop Commit: b8b16fd67b062506112c9f97c13e7745d3971a6f Parents: 9b5bca4 Author: Pepijn Noltes <[email protected]> Authored: Wed Jun 7 21:02:30 2017 +0200 Committer: Pepijn Noltes <[email protected]> Committed: Wed Jun 7 21:02:30 2017 +0200 ---------------------------------------------------------------------- .gitignore | 1 + dependency_manager/CMakeLists.txt | 5 +- .../private/src/dm_activator_base.c | 135 ------------------- .../public/include/dm_activator.h | 6 + .../public/include/dm_activator_impl.h | 119 ++++++++++++++++ dependency_manager_cxx/CMakeLists.txt | 38 +----- .../include/celix/dm/DependencyManager.h | 34 ++--- .../include/celix/dm/DependencyManager_Impl.h | 75 +++++++++++ .../include/celix/dm/DmActivator.h | 31 ++++- .../include/celix/dm/DmActivator_Impl.h | 125 +++++++++++++++++ .../include/celix/dm/ServiceDependency.h | 54 ++++---- .../include/celix/dm/ServiceDependency_Impl.h | 21 +++ dependency_manager_cxx/src/DependencyManager.cc | 54 -------- dependency_manager_cxx/src/ServiceDependency.cc | 44 ------ .../src/dm_activator_base_cxx.cc | 130 ------------------ examples/dm_example_cxx/phase1/CMakeLists.txt | 6 +- examples/dm_example_cxx/phase2a/CMakeLists.txt | 6 +- examples/dm_example_cxx/phase2b/CMakeLists.txt | 6 +- examples/dm_example_cxx/phase3/CMakeLists.txt | 6 +- .../phase3_locking/CMakeLists.txt | 6 +- .../services_example_cxx/bar/CMakeLists.txt | 6 +- .../services_example_cxx/baz/CMakeLists.txt | 6 +- .../services_example_cxx/foo/CMakeLists.txt | 4 +- framework/private/src/bundle_archive.c | 4 +- framework/private/src/celix_errorcodes.c | 47 ++++--- 25 files changed, 460 insertions(+), 509 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index 50221c0..cb42137 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ .DS_Store .idea build +cmake-build* *~ *.swp .idea http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/dependency_manager/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/dependency_manager/CMakeLists.txt b/dependency_manager/CMakeLists.txt index d849aa8..f2e8342 100644 --- a/dependency_manager/CMakeLists.txt +++ b/dependency_manager/CMakeLists.txt @@ -42,8 +42,7 @@ if (DEPENDENCY_MANAGER) add_library(dependency_manager_static STATIC - private/src/dm_activator_base - private/src/dm_component_impl + private/src/dm_component_impl private/src/dm_service_dependency private/src/dm_event private/src/dm_dependency_manager_impl @@ -51,7 +50,6 @@ if (DEPENDENCY_MANAGER) set_target_properties(dependency_manager_static PROPERTIES SOVERSION 1) add_library(dependency_manager_so SHARED - private/src/dm_activator_base private/src/dm_component_impl private/src/dm_service_dependency private/src/dm_event @@ -86,4 +84,5 @@ if (DEPENDENCY_MANAGER) install_bundle(dm_shell) install(TARGETS dependency_manager_static DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dependency_manager) install(TARGETS dependency_manager_so DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dependency_manager) + endif (DEPENDENCY_MANAGER) http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/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 deleted file mode 100644 index cbd1762..0000000 --- a/dependency_manager/private/src/dm_activator_base.c +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * dm_activator_base.c - * - * \date 26 Jul 2014 - * \author <a href="mailto:[email protected]">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ - - -#include <stdlib.h> - -#include "bundle_context.h" -#include "celix_errno.h" -#include "dm_dependency_manager.h" -#include "bundle_activator.h" -#include "dm_info.h" - -#include "dm_activator.h" - -struct dm_dependency_activator_base { - dm_dependency_manager_pt manager; - bundle_context_pt context; - service_registration_pt reg; - dm_info_service_pt info; - void* userData; -}; - -typedef struct dm_dependency_activator_base * dependency_activator_base_pt; - - -celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) { - celix_status_t status = CELIX_ENOMEM; - - dependency_activator_base_pt dependency_activator = calloc(1, sizeof(struct dm_dependency_activator_base)); - dm_info_service_pt serv = calloc(1, sizeof(*serv)); - - if (dependency_activator != NULL && serv != NULL) { - dependency_activator->context = context; - dm_create(context, &dependency_activator->userData); - dependency_activator->info = serv; - - status = dependencyManager_create(dependency_activator->context, &dependency_activator->manager); - } else { - status = CELIX_ENOMEM; - - } - - if (status == CELIX_SUCCESS) { - *userData = dependency_activator; - } else { - if (dependency_activator != NULL) { - dependencyManager_destroy(dependency_activator->manager); - } - free(dependency_activator); - free(serv); - } - - return status; -} - -celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) { - celix_status_t status; - dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData; - - - status = dm_init(dependency_activator->userData, context, dependency_activator->manager); - - if (status == CELIX_SUCCESS) { - //Create the service - dependency_activator->info->handle = dependency_activator->manager; - dependency_activator->info->getInfo = (void *) dependencyManager_getInfo; - dependency_activator->info->destroyInfo = (void *) dependencyManager_destroyInfo; - - status = bundleContext_registerService(context, DM_INFO_SERVICE_NAME, dependency_activator->info, NULL, - &(dependency_activator->reg)); - } - - return status; -} - -celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context __attribute__((unused))) { - celix_status_t status = CELIX_SUCCESS; - dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData; - - // Remove the service - status = serviceRegistration_unregister(dependency_activator->reg); - dependencyManager_removeAllComponents(dependency_activator->manager); - - return status; -} - -celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context __attribute__((unused))) { - celix_status_t status = CELIX_SUCCESS; - dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData; - - if(dependency_activator==NULL){ - return CELIX_ILLEGAL_ARGUMENT; - } - - status = dm_destroy(dependency_activator->userData, dependency_activator->context, - dependency_activator->manager); - - if (status == CELIX_SUCCESS) { - dependencyManager_destroy(dependency_activator->manager); - } - - dependency_activator->userData = NULL; - dependency_activator->manager = NULL; - - if (dependency_activator != NULL) { - free(dependency_activator->info); - } - free(dependency_activator); - - return status; -} http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/dependency_manager/public/include/dm_activator.h ---------------------------------------------------------------------- diff --git a/dependency_manager/public/include/dm_activator.h b/dependency_manager/public/include/dm_activator.h index a97680c..1b2b018 100644 --- a/dependency_manager/public/include/dm_activator.h +++ b/dependency_manager/public/include/dm_activator.h @@ -57,6 +57,12 @@ celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency */ celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager); +/** + * Includes the header implementation of the bundle activator functions. The header impl is used to prevent + * source dependency to bundle activator symbols. + */ +#include "dm_activator_impl.h" + #ifdef __cplusplus } #endif http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/dependency_manager/public/include/dm_activator_impl.h ---------------------------------------------------------------------- diff --git a/dependency_manager/public/include/dm_activator_impl.h b/dependency_manager/public/include/dm_activator_impl.h new file mode 100644 index 0000000..878af0b --- /dev/null +++ b/dependency_manager/public/include/dm_activator_impl.h @@ -0,0 +1,119 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include <stdlib.h> +#include "bundle_context.h" +#include "dm_dependency_manager.h" + +struct dm_dependency_activator_base { + dm_dependency_manager_pt manager; + bundle_context_pt context; + service_registration_pt reg; + dm_info_service_pt info; + void* userData; +}; + +typedef struct dm_dependency_activator_base * dependency_activator_base_pt; + +celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) { + celix_status_t status = CELIX_ENOMEM; + + dependency_activator_base_pt dependency_activator = calloc(1, sizeof(struct dm_dependency_activator_base)); + dm_info_service_pt serv = calloc(1, sizeof(*serv)); + + if (dependency_activator != NULL && serv != NULL) { + dependency_activator->context = context; + dm_create(context, &dependency_activator->userData); + dependency_activator->info = serv; + + status = dependencyManager_create(dependency_activator->context, &dependency_activator->manager); + } else { + status = CELIX_ENOMEM; + + } + + if (status == CELIX_SUCCESS) { + *userData = dependency_activator; + } else { + if (dependency_activator != NULL) { + dependencyManager_destroy(dependency_activator->manager); + } + free(dependency_activator); + free(serv); + } + + return status; +} + +celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) { + celix_status_t status; + dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData; + + + status = dm_init(dependency_activator->userData, context, dependency_activator->manager); + + if (status == CELIX_SUCCESS) { + //Create the service + dependency_activator->info->handle = dependency_activator->manager; + dependency_activator->info->getInfo = (void *) dependencyManager_getInfo; + dependency_activator->info->destroyInfo = (void *) dependencyManager_destroyInfo; + + status = bundleContext_registerService(context, DM_INFO_SERVICE_NAME, dependency_activator->info, NULL, + &(dependency_activator->reg)); + } + + return status; +} + +celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context __attribute__((unused))) { + celix_status_t status = CELIX_SUCCESS; + dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData; + + // Remove the service + status = serviceRegistration_unregister(dependency_activator->reg); + dependencyManager_removeAllComponents(dependency_activator->manager); + + return status; +} + +celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context __attribute__((unused))) { + celix_status_t status = CELIX_SUCCESS; + dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData; + + if(dependency_activator==NULL){ + return CELIX_ILLEGAL_ARGUMENT; + } + + status = dm_destroy(dependency_activator->userData, dependency_activator->context, + dependency_activator->manager); + + if (status == CELIX_SUCCESS) { + dependencyManager_destroy(dependency_activator->manager); + } + + dependency_activator->userData = NULL; + dependency_activator->manager = NULL; + + if (dependency_activator != NULL) { + free(dependency_activator->info); + } + free(dependency_activator); + + return status; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/dependency_manager_cxx/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/CMakeLists.txt b/dependency_manager_cxx/CMakeLists.txt index fd3cfe6..34feec9 100644 --- a/dependency_manager_cxx/CMakeLists.txt +++ b/dependency_manager_cxx/CMakeLists.txt @@ -18,41 +18,6 @@ celix_subproject(DEPENDENCY_MANAGER_CXX "Option to build the C++ dependency manager static library" ON DEPS framework DEPENDENCY_MANAGER) if (DEPENDENCY_MANAGER_CXX) - #set -Wall, -Werror locally, currenctly cpputest contains warnings - set(CMAKE_CXX_FLAGS "-Wall -Werror -fno-rtti -fno-exceptions ${CMAKE_CXX_FLAGS}") - - # Add -fPIC for x86_64 Unix platforms; this lib will be linked to a shared lib - if(UNIX AND NOT WIN32) - find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin ) - if(CMAKE_UNAME) - exec_program(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR) - set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL "processor type (i386 and x86_64)") - if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") - add_definitions(-fPIC) - endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") - endif(CMAKE_UNAME) - endif(UNIX AND NOT WIN32) - - include_directories(include) - include_directories("${PROJECT_SOURCE_DIR}/utils/public/include") - include_directories("${PROJECT_SOURCE_DIR}/dependency_manager/public/include") - include_directories("${PROJECT_SOURCE_DIR}/dependency_manager/private/include") - - set(DM_DIR "${PROJECT_SOURCE_DIR}/dependency_manager") - - add_library(dependency_manager_cxx_static STATIC - ${DM_DIR}/private/src/dm_component_impl.c - ${DM_DIR}/private/src/dm_service_dependency.c - ${DM_DIR}/private/src/dm_event.c - ${DM_DIR}/private/src/dm_dependency_manager_impl.c - - src/DependencyManager.cc - src/ServiceDependency.cc - src/dm_activator_base_cxx.cc - ) - #set_target_properties(dependency_manager_cxx_static PROPERTIES SOVERSION 1) - target_link_libraries(dependency_manager_cxx_static celix_framework) - install( DIRECTORY include/celix @@ -61,6 +26,5 @@ if (DEPENDENCY_MANAGER_CXX) COMPONENT dependency_manager_cxx ) - - install(TARGETS dependency_manager_cxx_static DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dependency_manager_cxx) + endif (DEPENDENCY_MANAGER_CXX) http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/dependency_manager_cxx/include/celix/dm/DependencyManager.h ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/include/celix/dm/DependencyManager.h b/dependency_manager_cxx/include/celix/dm/DependencyManager.h index c5905db..67f9c3f 100644 --- a/dependency_manager_cxx/include/celix/dm/DependencyManager.h +++ b/dependency_manager_cxx/include/celix/dm/DependencyManager.h @@ -28,15 +28,11 @@ #include "bundle_context.h" #include "dm_dependency_manager.h" -#include <list> +#include <vector> namespace celix { namespace dm { class DependencyManager { - private: - bundle_context_pt context = {nullptr}; - std::list<std::unique_ptr<BaseComponent>> components {}; - dm_dependency_manager_pt cDepMan {nullptr}; public: DependencyManager(bundle_context_pt context); virtual ~DependencyManager(); @@ -51,15 +47,7 @@ namespace celix { namespace dm { * @return Returns a reference to the DM Component */ template<class T> - Component<T>& createComponent(std::string name = std::string{}) { - Component<T>* cmp = name.empty() ? - Component<T>::create(this->context) : - Component<T>::create(this->context, name); - if (cmp->isValid()) { - this->components.push_back(std::unique_ptr<BaseComponent> {cmp}); - } - return *cmp; - } + Component<T>& createComponent(std::string name = std::string{}); /** * Creates and adds a new DM Component for a component of type T and setting @@ -68,9 +56,7 @@ namespace celix { namespace dm { * @return Returns a reference to the DM Component */ template<class T> - Component<T>& createComponent(std::unique_ptr<T>&& rhs, std::string name = std::string{}) { - return this->createComponent<T>(name).setInstance(std::move(rhs)); - } + Component<T>& createComponent(std::unique_ptr<T>&& rhs, std::string name = std::string{}); /** * Creates and adds a new DM Component for a component of type T and setting @@ -79,9 +65,7 @@ namespace celix { namespace dm { * @return Returns a reference to the DM Component */ template<class T> - Component<T>& createComponent(std::shared_ptr<T> rhs, std::string name = std::string{}) { - return this->createComponent<T>(name).setInstance(rhs); - } + Component<T>& createComponent(std::shared_ptr<T> rhs, std::string name = std::string{}); /** * Creates and adds a new DM Component for a component of type T and setting @@ -90,9 +74,7 @@ namespace celix { namespace dm { * @return Returns a reference to the DM Component */ template<class T> - Component<T>& createComponent(T rhs, std::string name = std::string{}) { - return this->createComponent<T>(name).setInstance(std::forward<T>(rhs)); - } + Component<T>& createComponent(T rhs, std::string name = std::string{}); /** * Starts the Dependency Manager @@ -103,8 +85,14 @@ namespace celix { namespace dm { * Stops the Dependency Manager */ void stop(); + private: + bundle_context_pt context {nullptr}; + std::vector<std::unique_ptr<BaseComponent>> components {}; + dm_dependency_manager_pt cDepMan {nullptr}; }; }} +#include "celix/dm/DependencyManager_Impl.h" + #endif //CELIX_DM_DEPENDENCYMANAGER_H http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/dependency_manager_cxx/include/celix/dm/DependencyManager_Impl.h ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/include/celix/dm/DependencyManager_Impl.h b/dependency_manager_cxx/include/celix/dm/DependencyManager_Impl.h new file mode 100644 index 0000000..d434371 --- /dev/null +++ b/dependency_manager_cxx/include/celix/dm/DependencyManager_Impl.h @@ -0,0 +1,75 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +using namespace celix::dm; + +DependencyManager::DependencyManager(bundle_context_pt context) : context(context), components() { + this->cDepMan = nullptr; + dependencyManager_create(context, &this->cDepMan); +} + +DependencyManager::~DependencyManager() { + dependencyManager_destroy(this->cDepMan); + this->cDepMan = nullptr; +} + +bundle_context_pt DependencyManager::bundleContext() const { + return context; +} + +dm_dependency_manager_pt DependencyManager::cDependencyManager() const { + return cDepMan; +} + +void DependencyManager::start() { + for(std::unique_ptr<BaseComponent>& cmp : components) { + dependencyManager_add(cDepMan, cmp->cComponent()); + } +} + +void DependencyManager::stop() { + dependencyManager_removeAllComponents(cDepMan); + components.clear(); +} + +template<class T> +Component<T>& DependencyManager::createComponent(std::string name) { + Component<T>* cmp = name.empty() ? + Component<T>::create(this->context) : + Component<T>::create(this->context, name); + if (cmp->isValid()) { + this->components.push_back(std::unique_ptr<BaseComponent> {cmp}); + } + return *cmp; +} + +template<class T> +Component<T>& DependencyManager::createComponent(std::unique_ptr<T>&& rhs, std::string name) { + return this->createComponent<T>(name).setInstance(std::move(rhs)); +} + +template<class T> +Component<T>& DependencyManager::createComponent(std::shared_ptr<T> rhs, std::string name) { + return this->createComponent<T>(name).setInstance(rhs); +} + +template<class T> +Component<T>& DependencyManager::createComponent(T rhs, std::string name) { + return this->createComponent<T>(name).setInstance(std::forward<T>(rhs)); +} http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/dependency_manager_cxx/include/celix/dm/DmActivator.h ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/include/celix/dm/DmActivator.h b/dependency_manager_cxx/include/celix/dm/DmActivator.h index fb5b0f2..547a2da 100644 --- a/dependency_manager_cxx/include/celix/dm/DmActivator.h +++ b/dependency_manager_cxx/include/celix/dm/DmActivator.h @@ -20,20 +20,20 @@ #ifndef CELIX_DM_ACTIVATOR_H #define CELIX_DM_ACTIVATOR_H -#include "celix/dm/DependencyManager.h" #include <utility> +#include "celix/dm/DependencyManager.h" + namespace celix { namespace dm { class DmActivator { - protected: - DependencyManager& mng; - DmActivator(DependencyManager& m) : mng(m) {} public: - virtual ~DmActivator() = default; + DmActivator(DependencyManager& m); + virtual ~DmActivator(); - DependencyManager& manager() const { return this->mng; } + DependencyManager& manager() const; + bundle_context_pt context() const; /** * The init of the DM Activator. Should be overridden by the bundle specific DM activator. @@ -58,7 +58,26 @@ namespace celix { namespace dm { * @returns A pointer to a DmActivator. The Dependency Manager is responsible for deleting the pointer when the bundle is stopped. */ static DmActivator* create(DependencyManager& mng); + + protected: + bundle_context_pt ctx; + DependencyManager& mng; }; + }} +#ifndef CELIX_CREATE_BUNDLE_ACTIVATOR_SYMBOLS +#define CELIX_CREATE_BUNDLE_ACTIVATOR_SYMBOLS 1 +#endif + +#if CELIX_CREATE_BUNDLE_ACTIVATOR_SYMBOLS == 1 +extern "C" celix_status_t bundleActivator_create(bundle_context_pt context, void **userData); +extern "C" celix_status_t bundleActivator_start(void *userData, bundle_context_pt context); +extern "C" celix_status_t bundleActivator_stop(void *userData, bundle_context_pt context); +extern "C" celix_status_t bundleActivator_destroy(void *userData, bundle_context_pt context); +#endif + + +#include "celix/dm/DmActivator_Impl.h" + #endif //CELIX_DM_ACTIVATOR_H http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/dependency_manager_cxx/include/celix/dm/DmActivator_Impl.h ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/include/celix/dm/DmActivator_Impl.h b/dependency_manager_cxx/include/celix/dm/DmActivator_Impl.h new file mode 100644 index 0000000..3223012 --- /dev/null +++ b/dependency_manager_cxx/include/celix/dm/DmActivator_Impl.h @@ -0,0 +1,125 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +using namespace celix::dm; + +DmActivator::DmActivator(DependencyManager& m) : ctx{m.bundleContext()}, mng{m} {} + +DmActivator::~DmActivator() = default; + +DependencyManager& DmActivator::manager() const { + return this->mng; +} + +bundle_context_pt DmActivator::context() const { + return this->ctx; +} + +namespace celix { namespace dm { namespace /*anon*/ { + class DmActivatorImpl { + private: + DependencyManager mng; + bundle_context_pt ctx; + DmActivator *act; + service_registration_pt reg{nullptr}; + dm_info_service_t info{nullptr, nullptr, nullptr}; + + public: + DmActivatorImpl(bundle_context_pt c) : mng{c}, ctx{c} { act = DmActivator::create(mng); } + + ~DmActivatorImpl() { delete act; } + + celix_status_t start() { + celix_status_t status = CELIX_SUCCESS; + + this->act->init(); + this->mng.start(); + + //Create and register the dm info service + this->info.handle = this->mng.cDependencyManager(); + this->info.getInfo = (celix_status_t (*)(void *, + dm_dependency_manager_info_pt *)) dependencyManager_getInfo; + this->info.destroyInfo = (void (*)(void *, dm_dependency_manager_info_pt)) dependencyManager_destroyInfo; + status = bundleContext_registerService(this->ctx, (char *) DM_INFO_SERVICE_NAME, &this->info, NULL, + &(this->reg)); + + return status; + } + + celix_status_t stop() { + celix_status_t status = CELIX_SUCCESS; + + // Remove the service + if (this->reg != nullptr) { + status = serviceRegistration_unregister(this->reg); + this->reg = nullptr; + } + // Remove all components + dependencyManager_removeAllComponents(this->mng.cDependencyManager()); + + return status; + } + }; +}}} + + +celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) { + int status = CELIX_SUCCESS; + DmActivatorImpl* impl = nullptr; +#ifdef __EXCEPTIONS + impl = new DmActivatorImpl(context); +#else + impl = new(std::nothrow) DmActivatorImpl(context); +#endif + + if (impl == nullptr) { + status = CELIX_ENOMEM; + } else { + *userData = impl; + } + return status; +} + +#if CELIX_CREATE_BUNDLE_ACTIVATOR_SYMBOLS == 1 +celix_status_t bundleActivator_start(void *userData, bundle_context_pt context __attribute__((unused))) { + int status = CELIX_SUCCESS; + DmActivatorImpl* impl = static_cast<DmActivatorImpl*>(userData); + if (impl != nullptr) { + status = impl->start(); + } + return status; +} + +celix_status_t bundleActivator_stop(void *userData, bundle_context_pt context __attribute__((unused))) { + int status = CELIX_SUCCESS; + DmActivatorImpl* impl = static_cast<DmActivatorImpl*>(userData); + if (impl != nullptr) { + status = impl->stop(); + } + return status; +} + +celix_status_t bundleActivator_destroy(void *userData, bundle_context_pt context __attribute__((unused))) { + DmActivatorImpl* impl = static_cast<DmActivatorImpl*>(userData); + if (impl != nullptr) { + delete impl; + } + return CELIX_SUCCESS; +} +#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/dependency_manager_cxx/include/celix/dm/ServiceDependency.h ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/include/celix/dm/ServiceDependency.h b/dependency_manager_cxx/include/celix/dm/ServiceDependency.h index 55be966..bcf7658 100644 --- a/dependency_manager_cxx/include/celix/dm/ServiceDependency.h +++ b/dependency_manager_cxx/include/celix/dm/ServiceDependency.h @@ -31,10 +31,6 @@ #include <iostream> #include <functional> -/** - * TODO add a dependency for a whiteboard pattern or marker service. e.g. a service where the type is irrelevant. - */ - namespace celix { namespace dm { class DependencyManager; //forward declaration @@ -84,19 +80,6 @@ namespace celix { namespace dm { template<class T, typename I> class CServiceDependency : public TypedServiceDependency<T> { using type = I; - private: - std::string name {}; - std::string filter {}; - std::string versionRange {}; - - std::function<void(const I* service, Properties&& properties)> setFp{nullptr}; - std::function<void(const I* service, Properties&& properties)> addFp{nullptr}; - std::function<void(const I* service, Properties&& properties)> removeFp{nullptr}; - - void setupCallbacks(); - int invokeCallback(std::function<void(const I*, Properties&&)> fp, service_reference_pt ref, const void* service); - - void setupService(); public: CServiceDependency(const std::string name, bool valid = true); virtual ~CServiceDependency() = default; @@ -184,25 +167,24 @@ namespace celix { namespace dm { * For C service dependencies 'service.lang=C' will be added. */ CServiceDependency<T,I>& setAddLanguageFilter(bool addLang); - }; - - template<class T, class I> - class ServiceDependency : public TypedServiceDependency<T> { - using type = I; private: - bool addCxxLanguageFilter {true}; std::string name {}; std::string filter {}; std::string versionRange {}; - std::string modifiedFilter {}; - std::function<void(I* service, Properties&& properties)> setFp{nullptr}; - std::function<void(I* service, Properties&& properties)> addFp{nullptr}; - std::function<void(I* service, Properties&& properties)> removeFp{nullptr}; + std::function<void(const I* service, Properties&& properties)> setFp{nullptr}; + std::function<void(const I* service, Properties&& properties)> addFp{nullptr}; + std::function<void(const I* service, Properties&& properties)> removeFp{nullptr}; - void setupService(); void setupCallbacks(); - int invokeCallback(std::function<void(I*, Properties&&)> fp, service_reference_pt ref, const void* service); + int invokeCallback(std::function<void(const I*, Properties&&)> fp, service_reference_pt ref, const void* service); + + void setupService(); + }; + + template<class T, class I> + class ServiceDependency : public TypedServiceDependency<T> { + using type = I; public: ServiceDependency(const std::string name = std::string{}, bool valid = true); virtual ~ServiceDependency() = default; @@ -296,6 +278,20 @@ namespace celix { namespace dm { * Should be called before */ ServiceDependency<T,I>& setAddLanguageFilter(bool addLang); + private: + bool addCxxLanguageFilter {true}; + std::string name {}; + std::string filter {}; + std::string versionRange {}; + std::string modifiedFilter {}; + + std::function<void(I* service, Properties&& properties)> setFp{nullptr}; + std::function<void(I* service, Properties&& properties)> addFp{nullptr}; + std::function<void(I* service, Properties&& properties)> removeFp{nullptr}; + + void setupService(); + void setupCallbacks(); + int invokeCallback(std::function<void(I*, Properties&&)> fp, service_reference_pt ref, const void* service); }; }} http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h b/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h index 85f5504..6ff695f 100644 --- a/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h +++ b/dependency_manager_cxx/include/celix/dm/ServiceDependency_Impl.h @@ -23,6 +23,27 @@ using namespace celix::dm; +BaseServiceDependency::BaseServiceDependency(bool v) : valid{v} { + if (this->valid) { + serviceDependency_create(&this->cServiceDep); + //NOTE using suspend as default strategy + serviceDependency_setStrategy(this->cServiceDep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND); + } +} + +void BaseServiceDependency::setDepStrategy(DependencyUpdateStrategy strategy) { + if (!valid) { + return; + } + if (strategy == DependencyUpdateStrategy::locking) { + serviceDependency_setStrategy(this->cServiceDependency(), DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING); + } else if (strategy == DependencyUpdateStrategy::suspend) { + serviceDependency_setStrategy(this->cServiceDependency(), DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND); + } else { + std::cerr << "Unexpected dependency update strategy. Cannot convert for dm_depdendency\n"; + } +} + template<class T, typename I> CServiceDependency<T,I>::CServiceDependency(const std::string name, bool valid) : TypedServiceDependency<T>(valid) { this->name = name; http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/dependency_manager_cxx/src/DependencyManager.cc ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/src/DependencyManager.cc b/dependency_manager_cxx/src/DependencyManager.cc deleted file mode 100644 index b07383d..0000000 --- a/dependency_manager_cxx/src/DependencyManager.cc +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "celix/dm/DependencyManager.h" - -using namespace celix::dm; - -DependencyManager::DependencyManager(bundle_context_pt context) : context(context), components() { - this->cDepMan = nullptr; - dependencyManager_create(context, &this->cDepMan); -} - -DependencyManager::~DependencyManager() { - dependencyManager_destroy(this->cDepMan); - this->cDepMan = nullptr; -} - -bundle_context_pt DependencyManager::bundleContext() const { - return context; -} - -dm_dependency_manager_pt DependencyManager::cDependencyManager() const { - return cDepMan; -} - -void DependencyManager::start() { - for(std::unique_ptr<BaseComponent>& cmp : components) { - dependencyManager_add(cDepMan, cmp->cComponent()); - } -} - -void DependencyManager::stop() { - dependencyManager_removeAllComponents(cDepMan); - components.clear(); -} - - - http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/dependency_manager_cxx/src/ServiceDependency.cc ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/src/ServiceDependency.cc b/dependency_manager_cxx/src/ServiceDependency.cc deleted file mode 100644 index 452ecc8..0000000 --- a/dependency_manager_cxx/src/ServiceDependency.cc +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "celix/dm/ServiceDependency.h" -#include <iostream> - -using namespace celix::dm; - -BaseServiceDependency::BaseServiceDependency(bool v) : valid{v} { - if (this->valid) { - serviceDependency_create(&this->cServiceDep); - //NOTE using suspend as default strategy - serviceDependency_setStrategy(this->cServiceDep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND); - } -} - -void BaseServiceDependency::setDepStrategy(DependencyUpdateStrategy strategy) { - if (!valid) { - return; - } - if (strategy == DependencyUpdateStrategy::locking) { - serviceDependency_setStrategy(this->cServiceDependency(), DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING); - } else if (strategy == DependencyUpdateStrategy::suspend) { - serviceDependency_setStrategy(this->cServiceDependency(), DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND); - } else { - std::cerr << "Unexpected dependency update strategy. Cannot convert for dm_depdendency\n"; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/dependency_manager_cxx/src/dm_activator_base_cxx.cc ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/src/dm_activator_base_cxx.cc b/dependency_manager_cxx/src/dm_activator_base_cxx.cc deleted file mode 100644 index f2ef89a..0000000 --- a/dependency_manager_cxx/src/dm_activator_base_cxx.cc +++ /dev/null @@ -1,130 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -#include "celix/dm/DmActivator.h" -#include "celix/dm/DependencyManager.h" - -extern "C" { -#include <stdlib.h> -#include "bundle_context.h" -#include "celix_errno.h" -#include "dm_dependency_manager.h" -#include "bundle_activator.h" -#include "dm_info.h" -#include "dm_activator.h" - - -struct dm_dependency_activator_base { - dm_dependency_activator_base(std::shared_ptr<celix::dm::DependencyManager> man, std::shared_ptr<celix::dm::DmActivator> act) : manager(man), activator(act) {} - bundle_context_pt context {nullptr}; - service_registration_pt reg {nullptr}; - dm_info_service_t info {nullptr,nullptr,nullptr}; - - std::shared_ptr<celix::dm::DependencyManager> manager {nullptr}; - std::shared_ptr<celix::dm::DmActivator> activator {nullptr}; -}; - -typedef struct dm_dependency_activator_base *dependency_activator_base_pt; - -celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) { - celix_status_t status = CELIX_SUCCESS; - -#ifdef __EXCEPTIONS - auto man = std::shared_ptr<celix::dm::DependencyManager>{new celix::dm::DependencyManager(context)}; - auto dmAct = std::shared_ptr<celix::dm::DmActivator> {DmActivator::create(*man)}; - dependency_activator_base_pt act = new dm_dependency_activator_base(man, dmAct); -#else - auto man = std::shared_ptr<celix::dm::DependencyManager>{new(std::nothrow) celix::dm::DependencyManager(context)}; - auto dmAct = std::shared_ptr<celix::dm::DmActivator> {DmActivator::create(*man)}; - dependency_activator_base_pt act = new(std::nothrow) dm_dependency_activator_base(man, dmAct); -#endif - - - if (act != nullptr) { - act->context = context; - act->reg = nullptr; - act->info.handle = nullptr; - act->info.destroyInfo = nullptr; - act->info.getInfo = nullptr; - } else { - status = CELIX_ENOMEM; - } - - if (status == CELIX_SUCCESS) { - *userData = act; - } else { - delete act; - } - - return status; -} - -celix_status_t bundleActivator_start(void *userData, bundle_context_pt context) { - celix_status_t status = CELIX_SUCCESS; - dependency_activator_base_pt act = (dependency_activator_base_pt) userData; - - if (act == nullptr || act->manager == nullptr) { - return CELIX_ILLEGAL_STATE; - } - - act->activator->init(); - act->manager->start(); - - if (status == CELIX_SUCCESS) { - //Create the service - act->info.handle = act->manager->cDependencyManager(); - act->info.getInfo = (celix_status_t (*)(void *, dm_dependency_manager_info_pt *)) dependencyManager_getInfo; - act->info.destroyInfo = (void (*)(void *, dm_dependency_manager_info_pt)) dependencyManager_destroyInfo; - - status = bundleContext_registerService(context, (char *) DM_INFO_SERVICE_NAME, &act->info, NULL, &(act->reg)); - } - - return status; -} - -celix_status_t bundleActivator_stop(void *userData, bundle_context_pt context __attribute__((unused))) { - celix_status_t status = CELIX_SUCCESS; - dependency_activator_base_pt act = (dependency_activator_base_pt) userData; - - if (act == nullptr || act->manager == nullptr) { - return CELIX_ILLEGAL_STATE; - } - - // Remove the service - status = serviceRegistration_unregister(act->reg); - dependencyManager_removeAllComponents(act->manager->cDependencyManager()); - - return status; -} - -celix_status_t bundleActivator_destroy(void *userData, bundle_context_pt context __attribute__((unused))) { - celix_status_t status = CELIX_SUCCESS; - dependency_activator_base_pt act = (dependency_activator_base_pt) userData; - - if (act == NULL) { - return CELIX_ILLEGAL_STATE; - } - - act->activator->deinit(); - act->manager->stop(); - - delete act; - return status; -} - -} http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/examples/dm_example_cxx/phase1/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase1/CMakeLists.txt b/examples/dm_example_cxx/phase1/CMakeLists.txt index 9f125ef..2f476c8 100644 --- a/examples/dm_example_cxx/phase1/CMakeLists.txt +++ b/examples/dm_example_cxx/phase1/CMakeLists.txt @@ -29,12 +29,12 @@ add_bundle(phase1_cxx ) IF(APPLE) - target_link_libraries(phase1_cxx celix_framework -Wl,-all_load dependency_manager_cxx_static) + target_link_libraries(phase1_cxx celix_framework -Wl,-all_load dependency_manager_static) else() if(ENABLE_ADDRESS_SANITIZER) #With asan there can be undefined symbols - target_link_libraries(phase1_cxx -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(phase1_cxx -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) else() - target_link_libraries(phase1_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(phase1_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) endif() endif() http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/examples/dm_example_cxx/phase2a/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase2a/CMakeLists.txt b/examples/dm_example_cxx/phase2a/CMakeLists.txt index c423380..cccbba9 100644 --- a/examples/dm_example_cxx/phase2a/CMakeLists.txt +++ b/examples/dm_example_cxx/phase2a/CMakeLists.txt @@ -30,12 +30,12 @@ add_bundle(phase2a_cxx IF(APPLE) - target_link_libraries(phase2a_cxx celix_framework -Wl,-all_load dependency_manager_cxx_static) + target_link_libraries(phase2a_cxx celix_framework -Wl,-all_load dependency_manager_static) else() if(ENABLE_ADDRESS_SANITIZER) #With asan there can be undefined symbols - target_link_libraries(phase2a_cxx -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(phase2a_cxx -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) else() - target_link_libraries(phase2a_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(phase2a_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) endif() endif() http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/examples/dm_example_cxx/phase2b/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase2b/CMakeLists.txt b/examples/dm_example_cxx/phase2b/CMakeLists.txt index ae73563..7b2beb1 100644 --- a/examples/dm_example_cxx/phase2b/CMakeLists.txt +++ b/examples/dm_example_cxx/phase2b/CMakeLists.txt @@ -30,12 +30,12 @@ add_bundle(phase2b_cxx ) IF(APPLE) - target_link_libraries(phase2b_cxx celix_framework -Wl,-all_load dependency_manager_cxx_static) + target_link_libraries(phase2b_cxx celix_framework -Wl,-all_load dependency_manager_static) else() if(ENABLE_ADDRESS_SANITIZER) #With asan there can be undefined symbols - target_link_libraries(phase2b_cxx -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(phase2b_cxx -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) else() - target_link_libraries(phase2b_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(phase2b_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) endif() endif() http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/examples/dm_example_cxx/phase3/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase3/CMakeLists.txt b/examples/dm_example_cxx/phase3/CMakeLists.txt index 8877ac2..e648f2e 100644 --- a/examples/dm_example_cxx/phase3/CMakeLists.txt +++ b/examples/dm_example_cxx/phase3/CMakeLists.txt @@ -30,12 +30,12 @@ add_bundle(phase3_cxx IF(APPLE) - target_link_libraries(phase3_cxx celix_framework -Wl,-all_load dependency_manager_cxx_static) + target_link_libraries(phase3_cxx celix_framework -Wl,-all_load dependency_manager_static) else() if(ENABLE_ADDRESS_SANITIZER) #With asan there can be undefined symbols - target_link_libraries(phase3_cxx -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(phase3_cxx -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) else() - target_link_libraries(phase3_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(phase3_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) endif() endif() http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/examples/dm_example_cxx/phase3_locking/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/phase3_locking/CMakeLists.txt b/examples/dm_example_cxx/phase3_locking/CMakeLists.txt index 52b0f3a..ea756ba 100644 --- a/examples/dm_example_cxx/phase3_locking/CMakeLists.txt +++ b/examples/dm_example_cxx/phase3_locking/CMakeLists.txt @@ -29,12 +29,12 @@ add_bundle(phase3_locking_cxx ) IF(APPLE) - target_link_libraries(phase3_locking_cxx celix_framework -Wl,-all_load dependency_manager_cxx_static) + target_link_libraries(phase3_locking_cxx celix_framework -Wl,-all_load dependency_manager_static) else() if(ENABLE_ADDRESS_SANITIZER) #With asan there can be undefined symbols - target_link_libraries(phase3_locking_cxx -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(phase3_locking_cxx -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) else() - target_link_libraries(phase3_locking_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(phase3_locking_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) endif() endif() http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/examples/services_example_cxx/bar/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/services_example_cxx/bar/CMakeLists.txt b/examples/services_example_cxx/bar/CMakeLists.txt index d43b1b5..26f2154 100644 --- a/examples/services_example_cxx/bar/CMakeLists.txt +++ b/examples/services_example_cxx/bar/CMakeLists.txt @@ -28,12 +28,12 @@ add_bundle(bar_cxx ) IF(APPLE) - target_link_libraries(bar_cxx celix_framework -Wl,-all_load dependency_manager_cxx_static) + target_link_libraries(bar_cxx celix_framework -Wl,-all_load dependency_manager_static) else() if(ENABLE_ADDRESS_SANITIZER) #With asan there can be undefined symbols - target_link_libraries(bar_cxx -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(bar_cxx -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) else() - target_link_libraries(bar_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(bar_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) endif() endif() \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/examples/services_example_cxx/baz/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/services_example_cxx/baz/CMakeLists.txt b/examples/services_example_cxx/baz/CMakeLists.txt index 23ae7e4..30ce858 100644 --- a/examples/services_example_cxx/baz/CMakeLists.txt +++ b/examples/services_example_cxx/baz/CMakeLists.txt @@ -28,12 +28,12 @@ add_bundle(baz_cxx ) IF(APPLE) - target_link_libraries(baz_cxx celix_framework -Wl,-all_load dependency_manager_cxx_static) + target_link_libraries(baz_cxx celix_framework -Wl,-all_load dependency_manager_static) else() if(ENABLE_ADDRESS_SANITIZER) #With asan there can be undefined symbols - target_link_libraries(baz_cxx -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(baz_cxx -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) else() - target_link_libraries(baz_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(baz_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) endif() endif() http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/examples/services_example_cxx/foo/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/services_example_cxx/foo/CMakeLists.txt b/examples/services_example_cxx/foo/CMakeLists.txt index 6c36936..6a6a9d8 100644 --- a/examples/services_example_cxx/foo/CMakeLists.txt +++ b/examples/services_example_cxx/foo/CMakeLists.txt @@ -32,8 +32,8 @@ IF(APPLE) else() if(ENABLE_ADDRESS_SANITIZER) #With asan there can be undefined symbols - target_link_libraries(foo_cxx -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(foo_cxx -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) else() - target_link_libraries(foo_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_cxx_static -Wl,--no-whole-archive celix_framework) + target_link_libraries(foo_cxx -Wl,--no-undefined -Wl,--whole-archive dependency_manager_static -Wl,--no-whole-archive celix_framework) endif() endif() \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/framework/private/src/bundle_archive.c ---------------------------------------------------------------------- diff --git a/framework/private/src/bundle_archive.c b/framework/private/src/bundle_archive.c index 3a58b27..675f0d9 100644 --- a/framework/private/src/bundle_archive.c +++ b/framework/private/src/bundle_archive.c @@ -23,6 +23,7 @@ * \author <a href="mailto:[email protected]">Apache Celix Project Team</a> * \copyright Apache License, Version 2.0 */ +#include <string.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -32,10 +33,7 @@ #include <unistd.h> #include "bundle_archive.h" -#include "bundle_revision.h" #include "linked_list_iterator.h" -#include "celix_log.h" - struct bundleArchive { long id; http://git-wip-us.apache.org/repos/asf/celix/blob/b8b16fd6/framework/private/src/celix_errorcodes.c ---------------------------------------------------------------------- diff --git a/framework/private/src/celix_errorcodes.c b/framework/private/src/celix_errorcodes.c index ec25cff..1fd6fd8 100644 --- a/framework/private/src/celix_errorcodes.c +++ b/framework/private/src/celix_errorcodes.c @@ -23,37 +23,40 @@ * \author <a href="mailto:[email protected]">Apache Celix Project Team</a> * \copyright Apache License, Version 2.0 */ +#include <stdio.h> #include <string.h> #include "celix_errno.h" -static char *celix_error_string(celix_status_t statcode) { +static char* celix_error_string(celix_status_t statcode) { switch (statcode) { - case CELIX_BUNDLE_EXCEPTION: - return "Bundle exception"; - case CELIX_INVALID_BUNDLE_CONTEXT: - return "Invalid bundle context"; - case CELIX_ILLEGAL_ARGUMENT: - return "Illegal argument"; - case CELIX_INVALID_SYNTAX: - return "Invalid syntax"; - case CELIX_FRAMEWORK_SHUTDOWN: - return "Framework shutdown"; - case CELIX_ILLEGAL_STATE: - return "Illegal state"; - case CELIX_FRAMEWORK_EXCEPTION: - return "Framework exception"; - case CELIX_FILE_IO_EXCEPTION: - return "File I/O exception"; - case CELIX_SERVICE_EXCEPTION: - return "Service exception"; + case CELIX_BUNDLE_EXCEPTION: + return "Bundle exception"; + case CELIX_INVALID_BUNDLE_CONTEXT: + return "Invalid bundle context"; + case CELIX_ILLEGAL_ARGUMENT: + return "Illegal argument"; + case CELIX_INVALID_SYNTAX: + return "Invalid syntax"; + case CELIX_FRAMEWORK_SHUTDOWN: + return "Framework shutdown"; + case CELIX_ILLEGAL_STATE: + return "Illegal state"; + case CELIX_FRAMEWORK_EXCEPTION: + return "Framework exception"; + case CELIX_FILE_IO_EXCEPTION: + return "File I/O exception"; + case CELIX_SERVICE_EXCEPTION: + return "Service exception"; + default: + return "Unknown code"; } - return "Unknown code"; } -char *celix_strerror(celix_status_t errorcode, char *buffer, size_t bufferSize) { +char* celix_strerror(celix_status_t errorcode, char *buffer, size_t bufferSize) { if (errorcode < CELIX_START_ERROR) { - return strerror(errorcode); + strerror_r(errorcode, buffer, bufferSize); + return buffer; } else { char * str = celix_error_string(errorcode); strncpy(buffer, str, bufferSize);
