http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix/dm/Component_Impl.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix/dm/Component_Impl.h b/libs/framework/include/celix/dm/Component_Impl.h index 7848c6a..54914be 100644 --- a/libs/framework/include/celix/dm/Component_Impl.h +++ b/libs/framework/include/celix/dm/Component_Impl.h @@ -30,7 +30,7 @@ using namespace celix::dm; template<class T> -Component<T>::Component(const bundle_context_pt context, std::string name) : BaseComponent(context, name) {} +Component<T>::Component(celix_bundle_context_t *context, std::string name) : BaseComponent(context, name) {} template<class T> Component<T>::~Component() { @@ -42,7 +42,7 @@ template<class I> Component<T>& Component<T>::addInterfaceWithName(const std::string serviceName, const std::string version, const Properties properties) { if (!serviceName.empty()) { //setup c properties - properties_pt cProperties = properties_create(); + celix_properties_t *cProperties = properties_create(); properties_set(cProperties, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_CXX_LANGUAGE); for (const auto& pair : properties) { properties_set(cProperties, (char *) pair.first.c_str(), (char *) pair.second.c_str()); @@ -52,7 +52,7 @@ Component<T>& Component<T>::addInterfaceWithName(const std::string serviceName, I* intfPtr = static_cast<I*>(cmpPtr); //NOTE T should implement I const char *cVersion = version.empty() ? nullptr : version.c_str(); - component_addInterface(this->cComponent(), (char *) serviceName.c_str(), (char *) cVersion, + celix_dmComponent_addInterface(this->cComponent(), (char *) serviceName.c_str(), (char *) cVersion, intfPtr, cProperties); } else { std::cerr << "Cannot add interface with a empty name\n"; @@ -78,14 +78,14 @@ template<class T> template<class I> Component<T>& Component<T>::addCInterface(const I* svc, const std::string serviceName, const std::string version, const Properties properties) { static_assert(std::is_pod<I>::value, "Service I must be a 'Plain Old Data' object"); - properties_pt cProperties = properties_create(); + celix_properties_t *cProperties = properties_create(); properties_set(cProperties, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE); for (const auto& pair : properties) { properties_set(cProperties, (char*)pair.first.c_str(), (char*)pair.second.c_str()); } const char *cVersion = version.empty() ? nullptr : version.c_str(); - component_addInterface(this->cComponent(), (char*)serviceName.c_str(), (char*)cVersion, svc, cProperties); + celix_dmComponent_addInterface(this->cComponent(), (char*)serviceName.c_str(), (char*)cVersion, svc, cProperties); return *this; }; @@ -94,7 +94,7 @@ template<class T> template<class I> Component<T>& Component<T>::removeCInterface(const I* svc){ static_assert(std::is_pod<I>::value, "Service I must be a 'Plain Old Data' object"); - component_removeInterface(this->cComponent(), svc); + celix_dmComponent_removeInterface(this->cComponent(), svc); return *this; }; @@ -111,7 +111,7 @@ ServiceDependency<T,I>& Component<T>::createServiceDependency(const std::string } #endif this->dependencies.push_back(dep); - component_addServiceDependency(cComponent(), dep->cServiceDependency()); + celix_dmComponent_addServiceDependency(cComponent(), dep->cServiceDependency()); dep->setComponentInstance(&getInstance()); return *dep; } @@ -137,7 +137,7 @@ CServiceDependency<T,I>& Component<T>::createCServiceDependency(const std::strin } #endif this->dependencies.push_back(dep); - component_addServiceDependency(cComponent(), dep->cServiceDependency()); + celix_dmComponent_addServiceDependency(cComponent(), dep->cServiceDependency()); dep->setComponentInstance(&getInstance()); return *dep; } @@ -151,13 +151,13 @@ Component<T>& Component<T>::remove(CServiceDependency<T,I>& dep) { } template<class T> -Component<T>* Component<T>::create(bundle_context_pt context) { +Component<T>* Component<T>::create(celix_bundle_context_t *context) { std::string name = typeName<T>(); return Component<T>::create(context, name); } template<class T> -Component<T>* Component<T>::create(bundle_context_pt context, std::string name) { +Component<T>* Component<T>::create(celix_bundle_context_t *context, std::string name) { #ifdef __EXCEPTIONS Component<T>* cmp = new Component<T>{context, name}; #else @@ -268,7 +268,7 @@ Component<T>& Component<T>::setCallbacks( return 0; }; - component_setCallbacks(this->cComponent(), cInit, cStart, cStop, cDeinit); + celix_dmComponent_setCallbacks(this->cComponent(), cInit, cStart, cStop, cDeinit); return *this; } @@ -322,7 +322,7 @@ Component<T>& Component<T>::setCallbacks( return 0; }; - component_setCallbacks(this->cComponent(), cInit, cStart, cStop, cDeinit); + celix_dmComponent_setCallbacks(this->cComponent(), cInit, cStart, cStop, cDeinit); return *this; } @@ -330,7 +330,7 @@ Component<T>& Component<T>::setCallbacks( template<class T> Component<T>& Component<T>::removeCallbacks() { - component_setCallbacks(this->cComponent(), nullptr, nullptr, nullptr, nullptr); + celix_dmComponent_setCallbacks(this->cComponent(), nullptr, nullptr, nullptr, nullptr); return *this; }
http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix/dm/DependencyManager.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix/dm/DependencyManager.h b/libs/framework/include/celix/dm/DependencyManager.h index f90a03c..0f77da7 100644 --- a/libs/framework/include/celix/dm/DependencyManager.h +++ b/libs/framework/include/celix/dm/DependencyManager.h @@ -24,7 +24,7 @@ #include "bundle_context.h" #include "celix_bundle_context.h" -#include "dm_dependency_manager.h" +#include "celix_dependency_manager.h" #include <vector> #include <mutex> @@ -36,7 +36,7 @@ namespace celix { namespace dm { class DependencyManager { public: - DependencyManager(bundle_context_pt ctx) : context(ctx) { + DependencyManager(celix_bundle_context_t *ctx) : context(ctx) { this->cDepMan = celix_bundleContext_getDependencyManager(ctx); } @@ -58,8 +58,8 @@ namespace celix { namespace dm { DependencyManager(const DependencyManager&) = delete; DependencyManager& operator=(const DependencyManager&) = delete; - bundle_context_pt bundleContext() const { return context; } - dm_dependency_manager_pt cDependencyManager() const { return cDepMan; } + celix_bundle_context_t* bundleContext() const { return context; } + celix_dependency_manager_t *cDependencyManager() const { return cDepMan; } /** @@ -111,7 +111,7 @@ namespace celix { namespace dm { } for (auto it = toBeStartedComponents.begin(); it != toBeStartedComponents.end(); ++it) { - dependencyManager_add(cDepMan, (*it)->cComponent()); + celix_dependencyManager_add(cDepMan, (*it)->cComponent()); { std::lock_guard<std::recursive_mutex> lock(componentsMutex); startedComponents.push_back(std::move(*it)); @@ -131,15 +131,15 @@ namespace celix { namespace dm { * Stops the Dependency Manager */ void stop() { - dependencyManager_removeAllComponents(cDepMan); + celix_dependencyManager_removeAllComponents(cDepMan); queuedComponents.clear(); startedComponents.clear(); } private: - bundle_context_pt context {nullptr}; + celix_bundle_context_t *context {nullptr}; std::vector<std::unique_ptr<BaseComponent>> queuedComponents {}; std::vector<std::unique_ptr<BaseComponent>> startedComponents {}; - dm_dependency_manager_pt cDepMan {nullptr}; + celix_dependency_manager_t* cDepMan {nullptr}; std::recursive_mutex componentsMutex{}; }; http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix/dm/DmActivator.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix/dm/DmActivator.h b/libs/framework/include/celix/dm/DmActivator.h index d7aac3c..55a7573 100644 --- a/libs/framework/include/celix/dm/DmActivator.h +++ b/libs/framework/include/celix/dm/DmActivator.h @@ -38,7 +38,7 @@ namespace celix { namespace dm { DependencyManager& manager() const { return this->mng; } - bundle_context_pt context() const { return this->ctx; } + celix_bundle_context_t* context() const { return this->ctx; } /** * The init of the DM Activator. Should be overridden by the bundle specific DM activator. @@ -66,7 +66,7 @@ namespace celix { namespace dm { protected: DependencyManager& mng; - bundle_context_pt ctx; + celix_bundle_context_t *ctx; private: int start() { celix_status_t status = CELIX_SUCCESS; @@ -82,15 +82,15 @@ namespace celix { namespace dm { this->deinit(); // Remove all components - dependencyManager_removeAllComponents(this->mng.cDependencyManager()); + celix_dependencyManager_removeAllComponents(this->mng.cDependencyManager()); return status; } - friend int ::bundleActivator_create(::bundle_context_pt, void**); - friend int ::bundleActivator_start(void*, ::bundle_context_pt); - friend int ::bundleActivator_stop(void*, ::bundle_context_pt); - friend int ::bundleActivator_destroy(void*, ::bundle_context_pt); + friend int ::bundleActivator_create(::celix_bundle_context_t*, void**); + friend int ::bundleActivator_start(void*, ::celix_bundle_context_t*); + friend int ::bundleActivator_stop(void*, ::celix_bundle_context_t*); + friend int ::bundleActivator_destroy(void*, ::celix_bundle_context_t*); }; }} http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix/dm/ServiceDependency.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix/dm/ServiceDependency.h b/libs/framework/include/celix/dm/ServiceDependency.h index f439b82..59d43f0 100644 --- a/libs/framework/include/celix/dm/ServiceDependency.h +++ b/libs/framework/include/celix/dm/ServiceDependency.h @@ -43,16 +43,16 @@ namespace celix { namespace dm { class BaseServiceDependency { protected: const bool valid; - dm_service_dependency_pt cServiceDep {nullptr}; + celix_dm_service_dependency_t *cServiceDep {nullptr}; void setDepStrategy(DependencyUpdateStrategy strategy) { if (!valid) { return; } if (strategy == DependencyUpdateStrategy::locking) { - serviceDependency_setStrategy(this->cServiceDependency(), DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING); + celix_dmServiceDependency_setStrategy(this->cServiceDependency(), DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING); } else if (strategy == DependencyUpdateStrategy::suspend) { - serviceDependency_setStrategy(this->cServiceDependency(), DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND); + celix_dmServiceDependency_setStrategy(this->cServiceDependency(), DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND); } else { std::cerr << "Unexpected dependency update strategy. Cannot convert for dm_depdendency\n"; } @@ -60,9 +60,9 @@ namespace celix { namespace dm { public: BaseServiceDependency(bool v) : valid{v} { if (this->valid) { - serviceDependency_create(&this->cServiceDep); + this->cServiceDep = celix_dmServiceDependency_create(); //NOTE using suspend as default strategy - serviceDependency_setStrategy(this->cServiceDep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND); + celix_dmServiceDependency_setStrategy(this->cServiceDep, DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND); } } @@ -79,7 +79,7 @@ namespace celix { namespace dm { /** * Returns the C DM service dependency */ - dm_service_dependency_pt cServiceDependency() const { return cServiceDep; } + celix_dm_service_dependency_t *cServiceDependency() const { return cServiceDep; } }; template<class T> @@ -202,7 +202,7 @@ namespace celix { namespace dm { 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); + int invokeCallback(std::function<void(const I*, Properties&&)> fp, const celix_properties_t *props, const void* service); void setupService(); }; @@ -316,7 +316,7 @@ namespace celix { namespace dm { void setupService(); void setupCallbacks(); - int invokeCallback(std::function<void(I*, Properties&&)> fp, service_reference_pt ref, const void* service); + int invokeCallback(std::function<void(I*, Properties&&)> fp, const celix_properties_t *props, const void* service); }; }} http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix/dm/ServiceDependency_Impl.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix/dm/ServiceDependency_Impl.h b/libs/framework/include/celix/dm/ServiceDependency_Impl.h index 0f0dc26..5254728 100644 --- a/libs/framework/include/celix/dm/ServiceDependency_Impl.h +++ b/libs/framework/include/celix/dm/ServiceDependency_Impl.h @@ -20,6 +20,7 @@ #include <vector> #include <iostream> #include "constants.h" +#include "celix_properties.h" using namespace celix::dm; @@ -50,7 +51,7 @@ void CServiceDependency<T,I>::setupService() { } const char* cversion = this->versionRange.empty() ? nullptr : versionRange.c_str(); const char* cfilter = filter.empty() ? nullptr : filter.c_str(); - serviceDependency_setService(this->cServiceDependency(), this->name.c_str(), cversion, cfilter); + celix_dmServiceDependency_setService(this->cServiceDependency(), this->name.c_str(), cversion, cfilter); }; template<class T, typename I> @@ -68,7 +69,7 @@ CServiceDependency<T,I>& CServiceDependency<T,I>::setRequired(bool req) { if (!this->valid) { return *this; } - serviceDependency_setRequired(this->cServiceDependency(), req); + celix_dmServiceDependency_setRequired(this->cServiceDependency(), req); return *this; } @@ -158,49 +159,47 @@ void CServiceDependency<T,I>::setupCallbacks() { return; } - int(*cset)(void*, service_reference_pt, const void*) {nullptr}; - int(*cadd)(void*, service_reference_pt, const void*) {nullptr}; - int(*crem)(void*, service_reference_pt, const void*) {nullptr}; + int(*cset)(void*, void *, const celix_properties_t*) {nullptr}; + int(*cadd)(void*, void *, const celix_properties_t*) {nullptr}; + int(*crem)(void*, void *, const celix_properties_t*) {nullptr}; if (setFp != nullptr) { - cset = [](void* handle, service_reference_pt ref, const void* service) -> int { + cset = [](void* handle, void *service, const celix_properties_t *props) -> int { auto dep = (CServiceDependency<T,I>*) handle; - return dep->invokeCallback(dep->setFp, ref, service); + return dep->invokeCallback(dep->setFp, props, service); }; } if (addFp != nullptr) { - cadd = [](void* handle, service_reference_pt ref, const void* service) -> int { + cadd = [](void* handle, void *service, const celix_properties_t *props) -> int { auto dep = (CServiceDependency<T,I>*) handle; - return dep->invokeCallback(dep->addFp, ref, service); + return dep->invokeCallback(dep->addFp, props, service); }; } if (removeFp != nullptr) { - crem= [](void* handle, service_reference_pt ref, const void* service) -> int { + crem= [](void* handle, void *service, const celix_properties_t *props) -> int { auto dep = (CServiceDependency<T,I>*) handle; - return dep->invokeCallback(dep->removeFp, ref, service); + return dep->invokeCallback(dep->removeFp, props, service); }; } - serviceDependency_setCallbackHandle(this->cServiceDependency(), this); - serviceDependency_setCallbacksWithServiceReference(this->cServiceDependency(), cset, cadd, nullptr, crem, nullptr); + celix_dmServiceDependency_setCallbackHandle(this->cServiceDependency(), this); + celix_dm_service_dependency_callback_options_t opts{}; + opts.addWithProps = cadd; + opts.removeWithProps = crem; + opts.setWithProps = cset; + celix_dmServiceDependency_setCallbacksWithOptions(this->cServiceDependency(), &opts); } template<class T, typename I> -int CServiceDependency<T,I>::invokeCallback(std::function<void(const I*, Properties&&)> fp, service_reference_pt ref, const void* service) { - service_registration_pt reg {nullptr}; - properties_pt props {nullptr}; - +int CServiceDependency<T,I>::invokeCallback(std::function<void(const I*, Properties&&)> fp, const celix_properties_t *props, const void* service) { Properties properties {}; const char* key {nullptr}; const char* value {nullptr}; - if (ref != nullptr) { - serviceReference_getServiceRegistration(ref, ®); - serviceRegistration_getProperties(reg, &props); - + if (props != nullptr) { hash_map_iterator_t iter = hashMapIterator_construct((hash_map_pt)props); while(hashMapIterator_hasNext(&iter)) { key = (const char*) hashMapIterator_nextKey(&iter); - value = properties_get(props, key); + value = celix_properties_get(props, key, NULL); //std::cout << "got property " << key << "=" << value << "\n"; properties[key] = value; } @@ -271,7 +270,7 @@ void ServiceDependency<T,I>::setupService() { this->modifiedFilter = this->filter; } - serviceDependency_setService(this->cServiceDependency(), n.c_str(), v, this->modifiedFilter.c_str()); + celix_dmServiceDependency_setService(this->cServiceDependency(), n.c_str(), v, this->modifiedFilter.c_str()); } template<class T, class I> @@ -377,7 +376,7 @@ ServiceDependency<T,I>& ServiceDependency<T,I>::setCallbacks( template<class T, class I> ServiceDependency<T,I>& ServiceDependency<T,I>::setRequired(bool req) { - serviceDependency_setRequired(this->cServiceDependency(), req); + celix_dmServiceDependency_setRequired(this->cServiceDependency(), req); return *this; } @@ -388,28 +387,22 @@ ServiceDependency<T,I>& ServiceDependency<T,I>::setStrategy(DependencyUpdateStra }; template<class T, class I> -int ServiceDependency<T,I>::invokeCallback(std::function<void(I*, Properties&&)> fp, service_reference_pt ref, const void* service) { - service_registration_pt reg {nullptr}; - properties_pt props {nullptr}; +int ServiceDependency<T,I>::invokeCallback(std::function<void(I*, Properties&&)> fp, const celix_properties_t *props, const void* service) { I *svc = (I*)service; Properties properties {}; const char* key {nullptr}; const char* value {nullptr}; - if (ref != nullptr) { - serviceReference_getServiceRegistration(ref, ®); - serviceRegistration_getProperties(reg, &props); if (props != nullptr) { hash_map_iterator_t iter = hashMapIterator_construct((hash_map_pt)props); while(hashMapIterator_hasNext(&iter)) { key = (const char*) hashMapIterator_nextKey(&iter); - value = properties_get(props, key); + value = celix_properties_get(props, key, NULL); //std::cout << "got property " << key << "=" << value << "\n"; properties[key] = value; } } - } fp(svc, std::move(properties)); //explicit move of lvalue properties. return 0; @@ -421,29 +414,33 @@ void ServiceDependency<T,I>::setupCallbacks() { return; } - int(*cset)(void*, service_reference_pt, const void*) {nullptr}; - int(*cadd)(void*, service_reference_pt, const void*) {nullptr}; - int(*crem)(void*, service_reference_pt, const void*) {nullptr}; + int(*cset)(void*, void *, const celix_properties_t*) {nullptr}; + int(*cadd)(void*, void *, const celix_properties_t*) {nullptr}; + int(*crem)(void*, void *, const celix_properties_t*) {nullptr}; if (setFp != nullptr) { - cset = [](void* handle, service_reference_pt ref, const void* service) -> int { + cset = [](void* handle, void *service, const celix_properties_t* props) -> int { auto dep = (ServiceDependency<T,I>*) handle; - return dep->invokeCallback(dep->setFp, ref, service); + return dep->invokeCallback(dep->setFp, props, service); }; } if (addFp != nullptr) { - cadd = [](void* handle, service_reference_pt ref, const void* service) -> int { + cadd = [](void* handle, void *service, const celix_properties_t* props) -> int { auto dep = (ServiceDependency<T,I>*) handle; - return dep->invokeCallback(dep->addFp, ref, service); + return dep->invokeCallback(dep->addFp, props, service); }; } if (removeFp != nullptr) { - crem = [](void* handle, service_reference_pt ref, const void* service) -> int { + crem = [](void* handle, void *service, const celix_properties_t*props) -> int { auto dep = (ServiceDependency<T,I>*) handle; - return dep->invokeCallback(dep->removeFp, ref, service); + return dep->invokeCallback(dep->removeFp, props, service); }; } - serviceDependency_setCallbackHandle(this->cServiceDependency(), this); - serviceDependency_setCallbacksWithServiceReference(this->cServiceDependency(), cset, cadd, nullptr, crem, nullptr); + celix_dmServiceDependency_setCallbackHandle(this->cServiceDependency(), this); + celix_dm_service_dependency_callback_options_t opts{}; + opts.setWithProps = cset; + opts.addWithProps = cadd; + opts.removeWithProps = crem; + celix_dmServiceDependency_setCallbacksWithOptions(this->cServiceDependency(), &opts); }; http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_api.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix_api.h b/libs/framework/include/celix_api.h index b941a78..bb1fd01 100644 --- a/libs/framework/include/celix_api.h +++ b/libs/framework/include/celix_api.h @@ -38,7 +38,8 @@ #include "celix_framework_factory.h" #include "celix_launcher.h" -#include "dm_dependency_manager.h" +#include "celix_dependency_manager.h" +#include "celix_dm_component.h" #include "dm_service_dependency.h" #include "celix_bundle_activator.h" http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_bundle_context.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix_bundle_context.h b/libs/framework/include/celix_bundle_context.h index 6ecc445..fc7d978 100644 --- a/libs/framework/include/celix_bundle_context.h +++ b/libs/framework/include/celix_bundle_context.h @@ -770,7 +770,7 @@ long celix_bundleContext_trackServiceTrackers( * * @return the dependency manager or NULL if unsuccessful. */ -dm_dependency_manager_t* celix_bundleContext_getDependencyManager(celix_bundle_context_t *ctx); +celix_dependency_manager_t* celix_bundleContext_getDependencyManager(celix_bundle_context_t *ctx); /** http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_dependency_manager.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix_dependency_manager.h b/libs/framework/include/celix_dependency_manager.h new file mode 100644 index 0000000..e850d0a --- /dev/null +++ b/libs/framework/include/celix_dependency_manager.h @@ -0,0 +1,86 @@ +/** + *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. + */ + +#ifndef CELIX_DEPENDENCY_MANAGER_H_ +#define CELIX_DEPENDENCY_MANAGER_H_ + +#include "celix_types.h" + +#include "celix_errno.h" +#include "celix_array_list.h" +#include "celix_dm_info.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * Adds a DM component to the dependency manager + */ +celix_status_t celix_dependencyManager_add(celix_dependency_manager_t *manager, celix_dm_component_t *component); + +/** + * Removes a DM component from the dependency manager and destroys it + */ +celix_status_t celix_dependencyManager_remove(celix_dependency_manager_t *manager, celix_dm_component_t *component); + +/** + * Removes all DM components from the dependency manager + */ +celix_status_t celix_dependencyManager_removeAllComponents(celix_dependency_manager_t *manager); + +/** + * Create and returns a dependency manager info struct for the specified bundle. + * The dependency manager info contains information about the state of the dependency manager components + * + * Caller has ownership of the return value (use celix_dependencyManager_destroyInfo to free the memory). + * + * @param manager The dependency manager + * @param bndId The bundle id to get the info from. + * @returns The dependency manager info for the provided bundle id or NULL if the bundle id is invalid. + */ +celix_dependency_manager_info_t* celix_dependencyManager_createInfo(celix_dependency_manager_t *manager, long bndId); + +/** + * Create and returns a dependency manager info structd for all started bundles. + * The dependency manager info contains information about the state of the dependency manager components + * + * Caller has ownership of the return values (use celix_dependencyManager_destroyInfos to free the memory). + * + * @param manager The dependency manager + * @returns A celix array of dependency manager infos for the provided bundle id or NULL if the bundle id is invalid. + */ +celix_array_list_t * /*celix_dependency_manager_info_t entries*/ celix_dependencyManager_createInfos(celix_dependency_manager_t *manager); + +/** + * Destroys a DM info struct. + */ +void celix_dependencyManager_destroyInfo(celix_dependency_manager_t *manager, celix_dependency_manager_info_t *info); + +/** + * Destroys a celix array list of DM info structs. + */ +void celix_dependencyManager_destroyInfos(celix_dependency_manager_t *manager, celix_array_list_t * infos /*entries celix_dependency_manager_info_t*/); + +#ifdef __cplusplus +} +#endif + +#endif /* CELIX_DEPENDENCY_MANAGER_H_ */ http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_dm_component.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix_dm_component.h b/libs/framework/include/celix_dm_component.h new file mode 100644 index 0000000..bcfaf52 --- /dev/null +++ b/libs/framework/include/celix_dm_component.h @@ -0,0 +1,154 @@ +/** + *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. + */ + +#ifndef CELIX_COMPONENT_H_ +#define CELIX_COMPONENT_H_ + +#include <stdbool.h> + +#include "celix_types.h" +#include "celix_errno.h" +#include "properties.h" +#include "array_list.h" +#include "celix_dm_info.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum celix_dm_component_state_enum { + DM_CMP_STATE_INACTIVE = 1, + DM_CMP_STATE_WAITING_FOR_REQUIRED = 2, + DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED = 3, + DM_CMP_STATE_TRACKING_OPTIONAL = 4, +} celix_dm_component_state_t; + +#define CELIX_DM_COMPONENT_MAX_ID_LENGTH 64 +#define CELIX_DM_COMPONENT_MAX_NAME_LENGTH 128 + +typedef int (*celix_dm_cmp_lifecycle_fpt)(void *userData); + +/** + * Creates a DM Component + * Caller has ownership. + */ +celix_dm_component_t* celix_dmComponent_create(celix_bundle_context_t *context, const char* name); + +/** + * Destroys a DM Component + */ +void celix_dmComponent_destroy(celix_dm_component_t *cmp); + +/** + * Specify if a default 'service.lang=C' should be added to the properties of interfaces if no 'service.lang' has been + * provided. Default is false. Note that this should be set before using component_addInterface. + */ +celix_status_t celix_dmComponent_setCLanguageProperty(celix_dm_component_t *component, bool setCLangProp); + + +/** + * Adds a C interface to provide as service to the Celix framework. + * + * @param serviceName the service name. + * @param version The version of the interface (e.g. "1.0.0"), Can be a NULL pointer. + * @param properties To (meta) properties to provide with the service. Can be a NULL pointer. + */ +celix_status_t celix_dmComponent_addInterface(celix_dm_component_t *component, const char* serviceName, const char* serviceVersion, const void* service, celix_properties_t *properties); + +/** + * Removed a C interface from a component the Celix framework. + * + * @param serviceName the service name. + * @return CELIX_SUCCESS when removed, CELIX_ILLEGAL_ARGUMENT when the component does not provide the interface + */ +celix_status_t celix_dmComponent_removeInterface(celix_dm_component_t *component, const void* service); +/** + * Sets the implementation of the component. e.g. the component handle/self/this pointer. + */ +celix_status_t celix_dmComponent_setImplementation(celix_dm_component_t *component, void* implementation); + +/** + * Returns an arraylist of service names. The caller owns the arraylist and strings (char *) + */ +celix_status_t celix_dmComponent_getInterfaces(celix_dm_component_t *component, celix_array_list_t **servicesNames); + +/** + * Adds a C service dependency to the component + */ +celix_status_t celix_dmComponent_addServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dep); + +/** + * Removes a C service dependency to the component + */ +celix_status_t celix_dmComponent_removeServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency); + +/** + * Returns the current state of the component. + */ +celix_dm_component_state_t celix_dmComponent_currentState(celix_dm_component_t *cmp); + +/** + * Returns the implementation of the component. e.g. the component handle/self/this pointer. + */ +void * celix_dmComponent_getImplementation(celix_dm_component_t *cmp); + +/** + * Returns the DM component name. This is used when printing information about the component. + */ +const char* celix_dmComponent_getName(celix_dm_component_t *cmp); + +/** + * Returns bundle context for the bundle where this DM component is part of. + */ +celix_status_t celix_dmComponent_getBundleContext(celix_dm_component_t *component, celix_bundle_context_t **out); + +/** + * Set the component life cycle callbacks. + * The first argument will be the component implementation (@see component_getImplementation) + */ +celix_status_t celix_dmComponent_setCallbacks(celix_dm_component_t *component, celix_dm_cmp_lifecycle_fpt init, celix_dm_cmp_lifecycle_fpt start, celix_dm_cmp_lifecycle_fpt stop, celix_dm_cmp_lifecycle_fpt deinit); + +/** + * Set the component life cycle callbacks using a MACRO for improving the type safety. + */ +#define CELIX_DMCOMPONENT_SETCALLBACKS(dmCmp, type, init, start, stop, deinit) \ + do { \ + int (*tmp_init)(type) = (init); \ + int (*tmp_start)(type) = (start); \ + int (*tmp_stop)(type) = (stop); \ + int (*tmp_deinit)(type) = (deinit); \ + celix_dmComponent_setCallbacks((dmCmp), (celix_dm_cmp_lifecycle_fpt)tmp_init, (celix_dm_cmp_lifecycle_fpt)tmp_start, (celix_dm_cmp_lifecycle_fpt)tmp_stop, (celix_dm_cmp_lifecycle_fpt)tmp_deinit); \ + } while(0) + +/** + * Create a DM Component info struct. Containing information about the component. + * Caller has ownership. + */ +celix_status_t celix_dmComponent_getComponentInfo(celix_dm_component_t *component, dm_component_info_pt *info); + +/** + * Destroys a DM Component info struct. + */ +void celix_dmComponent_destroyComponentInfo(dm_component_info_pt info); + +#ifdef __cplusplus +} +#endif + +#endif /* COMPONENT_H_ */ http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_dm_info.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix_dm_info.h b/libs/framework/include/celix_dm_info.h new file mode 100644 index 0000000..3010b9c --- /dev/null +++ b/libs/framework/include/celix_dm_info.h @@ -0,0 +1,76 @@ +/** + *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. + */ +#ifndef CELIX_DM_INFO_H_ +#define CELIX_DM_INFO_H_ + + + +#include <stdbool.h> +#include "celix_array_list.h" +#include "celix_properties.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +struct celix_dm_interface_info_struct { + char* name; + celix_properties_t *properties; +}; +typedef struct celix_dm_interface_info_struct *dm_interface_info_pt; //deprecated +typedef struct celix_dm_interface_info_struct dm_interface_info_t; //deprecated +typedef struct celix_dm_interface_info_struct celix_dm_interface_info_t; + +struct celix_dm_service_dependency_info_struct { + char *filter; + bool available; + bool required; + size_t count; +}; +typedef struct celix_dm_service_dependency_info_struct *dm_service_dependency_info_pt; //deprecated +typedef struct celix_dm_service_dependency_info_struct dm_service_dependency_info_t; //deprecated +typedef struct celix_dm_service_dependency_info_struct celix_dm_service_dependency_info_t; + +struct celix_dm_component_info_struct { + char id[64]; + char name[128]; + bool active; + char * state; + celix_array_list_t *interfaces; // type dm_interface_info_pt + celix_array_list_t *dependency_list; // type dm_service_dependency_info_pt +}; +typedef struct celix_dm_component_info_struct *dm_component_info_pt; //deprecated +typedef struct celix_dm_component_info_struct dm_component_info_t; //deprecated +typedef struct celix_dm_component_info_struct celix_dm_component_info_t; + +struct celix_dm_dependency_manager_info_struct { + long bndId; + celix_array_list_t *components; // type dm_component_info +}; +typedef struct celix_dm_dependency_manager_info_struct *dm_dependency_manager_info_pt; //deprecated +typedef struct celix_dm_dependency_manager_info_struct dm_dependency_manager_info_t; //deprecated +typedef struct celix_dm_dependency_manager_info_struct celix_dependency_manager_info_t; + + +#ifdef __cplusplus +} +#endif + +#endif //CELIX_DM_INFO_H_ http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_dm_service_dependency.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix_dm_service_dependency.h b/libs/framework/include/celix_dm_service_dependency.h new file mode 100644 index 0000000..6908096 --- /dev/null +++ b/libs/framework/include/celix_dm_service_dependency.h @@ -0,0 +1,169 @@ +/** + *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. + */ + +#ifndef CELIX_DM_SERVICE_DEPENDENCY_H_ +#define CELIX_DM_SERVICE_DEPENDENCY_H_ + +#include "celix_types.h" +#include "celix_errno.h" +#include "celix_threads.h" + +#include "celix_dm_info.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef enum celix_dm_service_dependency_strategy_enum { + DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING, + DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND +} celix_dm_service_dependency_strategy_t; + +typedef int (*celix_dm_service_update_fp)(void *handle, void* service); +typedef int (*celix_dm_service_swap_fp)(void *handle, void* oldService, void* newService); + +typedef int (*celix_dm_service_update_with_props_fp)(void *handle, void* service, const celix_properties_t *props); +typedef int (*celix_dm_service_swap_with_props_fp)(void *handle, void* oldService, void* newService, const celix_properties_t *newProps); + +typedef struct celix_dm_service_dependency_callback_options { + celix_dm_service_update_fp set; + celix_dm_service_update_fp add; + celix_dm_service_update_fp remove; + celix_dm_service_swap_fp swap; + + celix_dm_service_update_with_props_fp setWithProps; + celix_dm_service_update_with_props_fp addWithProps; + celix_dm_service_update_with_props_fp removeWithProps; + celix_dm_service_swap_with_props_fp swapWithProps; +} celix_dm_service_dependency_callback_options_t; + +#define CELIX_EMPTY_DM_SERVICE_DEPENDENCY_CALLBACK_OPTIONS { .set = NULL, \ + .add = NULL, \ + .remove = NULL, \ + .swap = NULL, \ + .setWithProps = NULL, \ + .addWithProps = NULL, \ + .removeWithProps = NULL, \ + .swapWithProps = NULL } + +/** + * Create a service dependency. + * Caller has ownership. + */ +celix_dm_service_dependency_t* celix_dmServiceDependency_create(void); + +/** + * Destroys a service dependency. + * Caller has ownership. + */ +void celix_dmServiceDependency_destroy(celix_dm_service_dependency_t *dep); + +/** + * Specify if the service dependency is required. default is false + */ +celix_status_t celix_dmServiceDependency_setRequired(celix_dm_service_dependency_t *dependency, bool required); + +/** + * Specify if the servide dependency should add a C language filter for this dependency if no "service.lang" part if found the in the provided filter. + * Default is false + */ +celix_status_t celix_dmServiceDependency_setAddCLanguageFilter(celix_dm_service_dependency_t *dependency, bool addCLangFilter); + + +/** + * Specify if the service dependency update strategy. + * + * The DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING strategy notifies the component in case the dependencies set + * changes (e.g. a dependency is added/removed): the component is responsible for protecting via locks + * the dependencies list and check (always under lock) if the service he's depending on is still available. + * + * The DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND (default when no strategy is explicitly set) reliefs the programmer + * from dealing with service dependencies' consistency issues: in case this strategy is adopted, the component + * is stopped and restarted (i.e. temporarily suspended) upon service dependencies' changes. + * + * Default strategy is DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND + */ +celix_status_t celix_dmServiceDependency_setStrategy(celix_dm_service_dependency_t *dependency, celix_dm_service_dependency_strategy_t strategy); + +/** + * Return the service dependency update strategy. + */ +celix_dm_service_dependency_strategy_t celix_dmServiceDependency_getStrategy(celix_dm_service_dependency_t *dependency); + +/** + * Set the service name, version range and filter. + * + * @param serviceName The service name. Must have a value. + * @param serviceVersionRange The service version range, can be a NULL pointer. + * @param filter The (additional) filter to use (e.g. "(location=front)"). Can be a NULL pointer. + */ +celix_status_t celix_dmServiceDependency_setService(celix_dm_service_dependency_t *dependency, const char* serviceName, const char* serviceVersionRange, const char* filter); + +/** + * Returns the service depenendy filter. + */ +const char* celix_dmServiceDependency_getFilter(celix_dm_service_dependency_t *dependency); + +/** + * Set the set callbacks when services specified by the service dependency + * The first argument of the callbacks will be the component implement (@see component_getImplementation) + * The second the argument a pointer to an instance of a service struct of the specified service dependency. + */ +celix_status_t celix_dmServiceDependency_setCallback(celix_dm_service_dependency_t *dependency, celix_dm_service_update_fp set); + +/** + * Set the set function callbacks when services specified by the service dependency + * The first argument of the callbacks will be the component implement (@see component_getImplementation) + * The second argument of th callbacks will be a pointer to an instance of a service struct of the specified service dependency. + * The third argument of th callbacks will be a pointer to a service properties of the a service instance of the specified service dependency. + */ +celix_status_t celix_dmServiceDependency_setCallbackWithProperties(celix_dm_service_dependency_t *dependency, celix_dm_service_update_with_props_fp set); + +/** + * Set the set, add, change, remove and swap function callbacks when services specified by the service dependency + * are (respectively) set, added, changed, removed or swapped. + * + * The version with the WithProps suffix will be called with as third argument the service properties. + */ +celix_status_t celix_dmServiceDependency_setCallbacksWithOptions(celix_dm_service_dependency_t *dependency, const celix_dm_service_dependency_callback_options_t *opts); + +/** + * Set the callback handle to be used in the callbacks. Note that this normally should not be set, because the + * result of component_getImplementation() is used + * This can be used in rare cases when the callbacks are actually interceptors. e.g. in the case of C++ support. + */ +celix_status_t celix_dmServiceDependency_setCallbackHandle(celix_dm_service_dependency_t *dependency, void* handle); + +/** + * Creates a service dependency info. The service dependency info struct contains information about the service dependency. + * The caller is the owner + */ +dm_service_dependency_info_t* celix_dmServiceDependency_createInfo(celix_dm_service_dependency_t* dep); + +/** + * Destroy a provided service dependency info struct. + */ +void celix_dmServiceDependency_destroyInfo(celix_dm_service_dependency_t *dep, dm_service_dependency_info_t *info); + +#ifdef __cplusplus +} +#endif + +#endif /* CELIX_DM_SERVICE_DEPENDENCY_H_ */ http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_framework.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix_framework.h b/libs/framework/include/celix_framework.h index 39116f6..a4c784b 100644 --- a/libs/framework/include/celix_framework.h +++ b/libs/framework/include/celix_framework.h @@ -19,8 +19,6 @@ #ifndef CELIX_FRAMEWORK_H_ #define CELIX_FRAMEWORK_H_ -typedef struct framework celix_framework_t; - #include "celix_types.h" #include "celix_properties.h" http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_framework_factory.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix_framework_factory.h b/libs/framework/include/celix_framework_factory.h index 70d2678..74e7c06 100644 --- a/libs/framework/include/celix_framework_factory.h +++ b/libs/framework/include/celix_framework_factory.h @@ -31,7 +31,7 @@ extern "C" { * @param config The framework configuration. Can be NULL. * @return a started framework or NULL */ -framework_t* frameworkFactory_newFramework(properties_t *config); +celix_framework_t* frameworkFactory_newFramework(celix_properties_t *config); #ifdef __cplusplus http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_launcher.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix_launcher.h b/libs/framework/include/celix_launcher.h index 579eef7..19ab9f9 100644 --- a/libs/framework/include/celix_launcher.h +++ b/libs/framework/include/celix_launcher.h @@ -49,7 +49,7 @@ extern "C" { * @param embeddedConfig The optional embbeded config, will be overriden with the config.properties if found. * @return CELIX_SUCCESS if successful. */ -int celixLauncher_launchAndWaitForShutdown(int argc, char *argv[], properties_t *embeddedConfig); +int celixLauncher_launchAndWaitForShutdown(int argc, char *argv[], celix_properties_t *embeddedConfig); /** @@ -63,7 +63,7 @@ int celixLauncher_launchAndWaitForShutdown(int argc, char *argv[], properties_t * @param framework Output parameter for the framework. * @return CELIX_SUCCESS if successful. */ -int celixLauncher_launch(const char *configFile, framework_t **framework); +int celixLauncher_launch(const char *configFile, celix_framework_t **framework); /** * Launches the a celix framework and returns the framework. @@ -76,7 +76,7 @@ int celixLauncher_launch(const char *configFile, framework_t **framework); * @param framework Output parameter for the framework. * @return CELIX_SUCCESS if successful. */ -int celixLauncher_launchWithStream(FILE *config, framework_t **framework); +int celixLauncher_launchWithStream(FILE *config, celix_framework_t **framework); /** * Launches the a celix framework and returns the framework. @@ -89,25 +89,25 @@ int celixLauncher_launchWithStream(FILE *config, framework_t **framework); * @param framework Output parameter for the framework. * @return CELIX_SUCCESS if successful. */ -int celixLauncher_launchWithProperties(properties_t *config, framework_t **framework); +int celixLauncher_launchWithProperties(celix_properties_t *config, celix_framework_t **framework); /** * Wait (blocks) for the shutdown of the provided celix framework. * @param framework The framework to wait for. */ -void celixLauncher_waitForShutdown(framework_t *framework); +void celixLauncher_waitForShutdown(celix_framework_t *framework); /** * Stop the provided celix framework. * @param framework The framework to stop. */ -void celixLauncher_stop(framework_t *framework); +void celixLauncher_stop(celix_framework_t *framework); /** * Destroys the provided framework and if needed stops it first. * @param framework The framework to stop. */ -void celixLauncher_destroy(framework_t *framework); +void celixLauncher_destroy(celix_framework_t *framework); #ifdef __cplusplus } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/celix_types.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/celix_types.h b/libs/framework/include/celix_types.h index 9f73a42..f59c8aa 100644 --- a/libs/framework/include/celix_types.h +++ b/libs/framework/include/celix_types.h @@ -25,30 +25,44 @@ * These types are declared in a separate header for forward declaration */ -typedef struct bundle * bundle_pt; -typedef struct bundle bundle_t; -typedef struct bundle celix_bundle_t; -typedef struct bundleArchive *bundle_archive_pt; -typedef struct bundleArchive bundle_archive_t; - -typedef struct bundleRevision *bundle_revision_pt; -typedef struct bundleRevision bundle_revision_t; +#ifdef ADD_CELIX_DEPRECATED_WARNING +#define CELIX_DEPRECATED_ATTR __attribute__ ((deprecated)) +#define CELIX_DEPRECATED_ATTR_MSG(msg) __attribute__ ((deprecated(msg))) +#else +#define CELIX_DEPRECATED_ATTR +#define CELIX_DEPRECATED_ATTR_MSG(msg) +#endif -typedef struct bundleContext *bundle_context_pt; -typedef struct bundleContext bundle_context_t; -typedef struct bundleContext celix_bundle_context_t; -typedef struct dm_dependency_manager *dm_dependency_manager_pt; -typedef struct dm_dependency_manager dm_dependency_manager_t; +typedef struct celix_framework celix_framework_t; +typedef struct celix_bundle celix_bundle_t; +typedef struct celix_bundle_context celix_bundle_context_t; +typedef struct celix_dependency_manager celix_dependency_manager_t; +typedef struct celix_dm_component_struct celix_dm_component_t; +typedef struct celix_dm_service_dependency celix_dm_service_dependency_t; -typedef struct dm_component_struct *dm_component_pt; -typedef struct dm_component_struct dm_component_t; +//deprecated +typedef struct celix_dependency_manager dm_dependency_manager_t CELIX_DEPRECATED_ATTR; +typedef struct celix_dependency_manager *dm_dependency_manager_pt CELIX_DEPRECATED_ATTR; +typedef struct celix_dm_component_struct *dm_component_pt CELIX_DEPRECATED_ATTR; +typedef struct celix_dm_component_struct dm_component_t CELIX_DEPRECATED_ATTR; +typedef struct celix_dm_service_dependency *dm_service_dependency_pt CELIX_DEPRECATED_ATTR; +typedef struct celix_dm_service_dependency dm_service_dependency_t CELIX_DEPRECATED_ATTR; -typedef struct dm_service_dependency *dm_service_dependency_pt; -typedef struct dm_service_dependency dm_service_dependency_t; +typedef struct celix_bundle_context *bundle_context_pt CELIX_DEPRECATED_ATTR; +typedef struct celix_bundle_context bundle_context_t CELIX_DEPRECATED_ATTR; +typedef struct celix_framework *framework_pt CELIX_DEPRECATED_ATTR; +typedef struct celix_framework framework_t CELIX_DEPRECATED_ATTR; +typedef struct celix_bundle * bundle_pt CELIX_DEPRECATED_ATTR; +typedef struct celix_bundle bundle_t CELIX_DEPRECATED_ATTR; -typedef struct service_factory *service_factory_pt; //deprecated +// will be deprecated in the future +typedef struct bundleArchive *bundle_archive_pt; +typedef struct bundleArchive bundle_archive_t; +typedef struct bundleRevision *bundle_revision_pt; +typedef struct bundleRevision bundle_revision_t; +typedef struct service_factory *service_factory_pt; typedef struct serviceReference * service_reference_pt; #endif //CELIX_CELIX_TYPES_H http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/dm_activator.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/dm_activator.h b/libs/framework/include/dm_activator.h index 1e06331..3b9d89a 100644 --- a/libs/framework/include/dm_activator.h +++ b/libs/framework/include/dm_activator.h @@ -29,10 +29,10 @@ #ifndef DM_ACTIVATOR_BASE_H_ #define DM_ACTIVATOR_BASE_H_ - +#include "celix_types.h" #include "bundle_context.h" #include "celix_errno.h" -#include "dm_dependency_manager.h" +#include "celix_dependency_manager.h" #include "dm_component.h" #include "dm_service_dependency.h" #include "celix_bundle_activator.h" @@ -41,6 +41,10 @@ extern "C" { #endif +#ifdef ADD_CELIX_DEPRECATED_WARNING +#warning This header is deprecated, use the celix_bundle_activator instead. the Dependency manager can be retreived from the bundle context. +#endif + /** * Should be implemented by a bundle specific DM activator. * Should allocate and initialize a bundle specific activator struct. @@ -52,13 +56,13 @@ celix_status_t dm_create(bundle_context_pt context, void ** userData); * Will be called after the dm_create function. * Can be used to specify with use of the provided dependency manager the bundle specific components. */ -celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager); +celix_status_t dm_init(void * userData, bundle_context_pt context, celix_dependency_manager_t *manager); /** * Should be implemented by a bundle specific DM activator. * Should deinitialize and deallocate the undle specific activator struct. */ -celix_status_t dm_destroy(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager); +celix_status_t dm_destroy(void * userData, bundle_context_pt context, celix_dependency_manager_t *manager); #ifdef __cplusplus } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/dm_component.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/dm_component.h b/libs/framework/include/dm_component.h index 0e5bd6b..88b9f37 100644 --- a/libs/framework/include/dm_component.h +++ b/libs/framework/include/dm_component.h @@ -33,44 +33,40 @@ #include "celix_errno.h" #include "properties.h" #include "array_list.h" -#include "dm_info.h" +#include "celix_dm_info.h" +#include "celix_dm_component.h" #ifdef __cplusplus extern "C" { #endif -typedef enum dm_component_state_enum { - DM_CMP_STATE_INACTIVE = 1, - DM_CMP_STATE_WAITING_FOR_REQUIRED = 2, - DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED = 3, - DM_CMP_STATE_TRACKING_OPTIONAL = 4, -} dm_component_state_t; +typedef enum celix_dm_component_state_enum dm_component_state_t CELIX_DEPRECATED_ATTR; //deprecated #define DM_COMPONENT_MAX_ID_LENGTH 64 #define DM_COMPONENT_MAX_NAME_LENGTH 128 -typedef int (*init_fpt)(void *userData); -typedef int (*start_fpt)(void *userData); -typedef int (*stop_fpt)(void *userData); -typedef int (*deinit_fpt)(void *userData); +typedef int (*init_fpt)(void *userData) CELIX_DEPRECATED_ATTR; +typedef int (*start_fpt)(void *userData) CELIX_DEPRECATED_ATTR; +typedef int (*stop_fpt)(void *userData) CELIX_DEPRECATED_ATTR; +typedef int (*deinit_fpt)(void *userData) CELIX_DEPRECATED_ATTR; /** * Creates a DM Component * Caller has ownership. */ -celix_status_t component_create(bundle_context_t *context, const char* name, dm_component_t **component); +celix_status_t component_create(celix_bundle_context_t *context, const char* name, celix_dm_component_t **component) CELIX_DEPRECATED_ATTR; /** * Destroys a DM Component */ -void component_destroy(dm_component_t *component); +void component_destroy(celix_dm_component_t *component) CELIX_DEPRECATED_ATTR; /** * Specify if a default 'service.lang=C' should be added to the properties of interfaces if no 'service.lang' has been * provided. Default is false. Note that this should be set before using component_addInterface. */ -celix_status_t component_setCLanguageProperty(dm_component_t *component, bool setCLangProp); +celix_status_t component_setCLanguageProperty(celix_dm_component_t *component, bool setCLangProp) CELIX_DEPRECATED_ATTR; /** @@ -80,7 +76,7 @@ celix_status_t component_setCLanguageProperty(dm_component_t *component, bool se * @param version The version of the interface (e.g. "1.0.0"), Can be a NULL pointer. * @param properties To (meta) properties to provide with the service. Can be a NULL pointer. */ -celix_status_t component_addInterface(dm_component_t *component, const char* serviceName, const char* serviceVersion, const void* service, properties_t *properties); +celix_status_t component_addInterface(celix_dm_component_t *component, const char* serviceName, const char* serviceVersion, const void* service, celix_properties_t *properties) CELIX_DEPRECATED_ATTR; /** * Removed a C interface from a component the Celix framework. @@ -88,52 +84,52 @@ celix_status_t component_addInterface(dm_component_t *component, const char* ser * @param serviceName the service name. * @return CELIX_SUCCESS when removed, CELIX_ILLEGAL_ARGUMENT when the component does not provide the interface */ -celix_status_t component_removeInterface(dm_component_pt component, const void* service); +celix_status_t component_removeInterface(celix_dm_component_t *component, const void* service) CELIX_DEPRECATED_ATTR; /** * Sets the implementation of the component. e.g. the component handle/self/this pointer. */ -celix_status_t component_setImplementation(dm_component_t *component, void* implementation); +celix_status_t component_setImplementation(celix_dm_component_t *component, void* implementation) CELIX_DEPRECATED_ATTR; /** * Returns an arraylist of service names. The caller owns the arraylist and strings (char *) */ -celix_status_t component_getInterfaces(dm_component_t *component, array_list_t **servicesNames); +celix_status_t component_getInterfaces(celix_dm_component_t *component, celix_array_list_t **servicesNames) CELIX_DEPRECATED_ATTR; /** * Adds a C service dependency to the component */ -celix_status_t component_addServiceDependency(dm_component_t *component, dm_service_dependency_t *dep); +celix_status_t component_addServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dep) CELIX_DEPRECATED_ATTR; /** * Removes a C service dependency to the component */ -celix_status_t component_removeServiceDependency(dm_component_t *component, dm_service_dependency_t *dependency); +celix_status_t component_removeServiceDependency(celix_dm_component_t *component, celix_dm_service_dependency_t *dependency) CELIX_DEPRECATED_ATTR; /** * Returns the current state of the component. */ -dm_component_state_t component_currentState(dm_component_t *cmp); +celix_dm_component_state_t component_currentState(celix_dm_component_t *cmp) CELIX_DEPRECATED_ATTR; /** * Returns the implementation of the component. e.g. the component handle/self/this pointer. */ -void * component_getImplementation(dm_component_t *cmp); +void * component_getImplementation(celix_dm_component_t *cmp) CELIX_DEPRECATED_ATTR; /** * Returns the DM component name. This is used when printing information about the component. */ -const char * component_getName(dm_component_t *cmp); +const char * component_getName(celix_dm_component_t *cmp) CELIX_DEPRECATED_ATTR; /** * Returns bundle context for the bundle where this DM component is part of. */ -celix_status_t component_getBundleContext(dm_component_t *component, bundle_context_t **out); +celix_status_t component_getBundleContext(celix_dm_component_t *component, celix_bundle_context_t **out) CELIX_DEPRECATED_ATTR; /** * Set the component life cycle callbacks. * The first argument will be the component implementation (@see component_getImplementation) */ -celix_status_t component_setCallbacks(dm_component_t *component, init_fpt init, start_fpt start, stop_fpt stop, deinit_fpt deinit); +celix_status_t component_setCallbacks(celix_dm_component_t *component, celix_dm_cmp_lifecycle_fpt init, celix_dm_cmp_lifecycle_fpt start, celix_dm_cmp_lifecycle_fpt stop, celix_dm_cmp_lifecycle_fpt deinit) CELIX_DEPRECATED_ATTR; /** * Set the component life cycle callbacks using a MACRO for improving the type safety. @@ -144,19 +140,19 @@ celix_status_t component_setCallbacks(dm_component_t *component, init_fpt init, int (*tmp_start)(type) = (start); \ int (*tmp_stop)(type) = (stop); \ int (*tmp_deinit)(type) = (deinit); \ - component_setCallbacks((dmCmp), (init_fpt)tmp_init, (start_fpt)tmp_start, (stop_fpt)tmp_stop, (deinit_fpt)tmp_deinit); \ + component_setCallbacks((dmCmp), (celix_dm_cmp_lifecycle_fpt)tmp_init, (celix_dm_cmp_lifecycle_fpt)tmp_start, (celix_dm_cmp_lifecycle_fpt)tmp_stop, (celix_dm_cmp_lifecycle_fpt)tmp_deinit); \ } while(0) /** * Create a DM Component info struct. Containing information about the component. * Caller has ownership. */ -celix_status_t component_getComponentInfo(dm_component_t *component, dm_component_info_pt *info); +celix_status_t component_getComponentInfo(celix_dm_component_t *component, dm_component_info_pt *info) CELIX_DEPRECATED_ATTR; /** * Destroys a DM Component info struct. */ -void component_destroyComponentInfo(dm_component_info_pt info); +void component_destroyComponentInfo(dm_component_info_pt info) CELIX_DEPRECATED_ATTR; #ifdef __cplusplus } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/dm_dependency_manager.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/dm_dependency_manager.h b/libs/framework/include/dm_dependency_manager.h index 1fce27f..034a6bf 100644 --- a/libs/framework/include/dm_dependency_manager.h +++ b/libs/framework/include/dm_dependency_manager.h @@ -31,50 +31,48 @@ #include "celix_errno.h" #include "array_list.h" -#include "dm_info.h" +#include "celix_dm_info.h" #ifdef __cplusplus extern "C" { #endif - /** * Creates a dependency manager. * Caller has ownership. */ - //TODO make this private, dep man should always be retrieved from the bundle context -celix_status_t dependencyManager_create(bundle_context_t *context, dm_dependency_manager_t **manager); +celix_status_t dependencyManager_create(celix_bundle_context_t *context, celix_dependency_manager_t **manager) CELIX_DEPRECATED_ATTR; /** * Destroys the provided dependency manager */ -void dependencyManager_destroy(dm_dependency_manager_t *manager); +void dependencyManager_destroy(celix_dependency_manager_t *manager) CELIX_DEPRECATED_ATTR; /** * Adds a DM component to the dependency manager */ -celix_status_t dependencyManager_add(dm_dependency_manager_t *manager, dm_component_t *component); +celix_status_t dependencyManager_add(celix_dependency_manager_t *manager, celix_dm_component_t *component)CELIX_DEPRECATED_ATTR; /** * Removes a DM component from the dependency manager and destroys it */ -celix_status_t dependencyManager_remove(dm_dependency_manager_t *manager, dm_component_t *component); +celix_status_t dependencyManager_remove(celix_dependency_manager_t *manager, celix_dm_component_t *component) CELIX_DEPRECATED_ATTR; /** * Removes all DM components from the dependency manager */ -celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_t *manager); +celix_status_t dependencyManager_removeAllComponents(celix_dependency_manager_t *manager) CELIX_DEPRECATED_ATTR; /** * Create and returns a DM Info struct. Which contains information about the state of the DM components * Caller has ownership. */ -celix_status_t dependencyManager_getInfo(dm_dependency_manager_t *manager, dm_dependency_manager_info_t **info); +celix_status_t dependencyManager_getInfo(celix_dependency_manager_t *manager, dm_dependency_manager_info_pt *info) CELIX_DEPRECATED_ATTR; /** * Destroys a DM info struct. */ -void dependencyManager_destroyInfo(dm_dependency_manager_t *manager, dm_dependency_manager_info_t *info); +void dependencyManager_destroyInfo(celix_dependency_manager_t *manager, dm_dependency_manager_info_pt info) CELIX_DEPRECATED_ATTR; #ifdef __cplusplus } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/dm_info.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/dm_info.h b/libs/framework/include/dm_info.h deleted file mode 100644 index 8074ab6..0000000 --- a/libs/framework/include/dm_info.h +++ /dev/null @@ -1,76 +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_server.h - * - * \date 15 Oct 2015 - * \author <a href="mailto:[email protected]">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ -#ifndef CELIX_DM_INFO_SERVICE_H -#define CELIX_DM_INFO_SERVICE_H - - - -#include <stdbool.h> -#include "array_list.h" -#include "properties.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define DM_INFO_SERVICE_NAME "dm_info" - - -typedef struct dm_interface_info_struct { - char* name; - properties_pt properties; -} dm_interface_info_t; -typedef struct dm_interface_info_struct *dm_interface_info_pt; - -typedef struct dm_service_dependency_info_struct { - char *filter; - bool available; - bool required; - size_t count; -} dm_service_dependency_info_t; -typedef struct dm_service_dependency_info_struct *dm_service_dependency_info_pt; - -typedef struct dm_component_info_struct { - char id[64]; - char name[128]; - bool active; - char * state; - array_list_pt interfaces; // type dm_interface_info_pt - array_list_pt dependency_list; // type dm_service_dependency_info_pt -} dm_component_info_t; -typedef struct dm_component_info_struct *dm_component_info_pt; - -typedef struct dm_dependency_manager_info_struct { - array_list_pt components; // type dm_component_info -} dm_dependency_manager_info_t; -typedef struct dm_dependency_manager_info_struct *dm_dependency_manager_info_pt; - - -#ifdef __cplusplus -} -#endif - -#endif //CELIX_DM_INFO_SERVICE_H http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/dm_service_dependency.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/dm_service_dependency.h b/libs/framework/include/dm_service_dependency.h index 9ed78e3..0ff549e 100644 --- a/libs/framework/include/dm_service_dependency.h +++ b/libs/framework/include/dm_service_dependency.h @@ -32,17 +32,15 @@ #include "celix_threads.h" #include "service_reference.h" -#include "dm_info.h" +#include "celix_dm_info.h" +#include "celix_dm_service_dependency.h" #ifdef __cplusplus extern "C" { #endif -typedef enum dm_service_dependency_strategy_enum { - DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING, - DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND -} dm_service_dependency_strategy_t; +typedef enum celix_dm_service_dependency_strategy_enum dm_service_dependency_strategy_t CELIX_DEPRECATED_ATTR; typedef int (*service_set_fpt)(void *handle, const void* service); typedef int (*service_add_fpt)(void *handle, const void* service); @@ -60,24 +58,24 @@ typedef celix_status_t (*service_swap_with_ref_fpt)(void *handle, service_refere * Create a service dependency. * Caller has ownership. */ -celix_status_t serviceDependency_create(dm_service_dependency_t **dep); +celix_status_t serviceDependency_create(celix_dm_service_dependency_t **dep) CELIX_DEPRECATED_ATTR; /** * Destroys a service dependency. * Caller has ownership. */ -celix_status_t serviceDependency_destroy(dm_service_dependency_t **dep); +celix_status_t serviceDependency_destroy(celix_dm_service_dependency_t **dep) CELIX_DEPRECATED_ATTR; /** * Specify if the service dependency is required. default is false */ -celix_status_t serviceDependency_setRequired(dm_service_dependency_t *dependency, bool required); +celix_status_t serviceDependency_setRequired(celix_dm_service_dependency_t *dependency, bool required) CELIX_DEPRECATED_ATTR; /** * Specify if the servide dependency should add a C language filter for this dependency if no "service.lang" part if found the in the provided filter. * Default is false */ -celix_status_t serviceDependency_setAddCLanguageFilter(dm_service_dependency_t *dependency, bool addCLangFilter); +celix_status_t serviceDependency_setAddCLanguageFilter(celix_dm_service_dependency_t *dependency, bool addCLangFilter) CELIX_DEPRECATED_ATTR; /** @@ -93,12 +91,12 @@ celix_status_t serviceDependency_setAddCLanguageFilter(dm_service_dependency_t * * * Default strategy is DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND */ -celix_status_t serviceDependency_setStrategy(dm_service_dependency_t *dependency,dm_service_dependency_strategy_t strategy); +celix_status_t serviceDependency_setStrategy(celix_dm_service_dependency_t *dependency, celix_dm_service_dependency_strategy_t strategy) CELIX_DEPRECATED_ATTR; /** * Return the service dependency update strategy. */ -celix_status_t serviceDependency_getStrategy(dm_service_dependency_t *dependency,dm_service_dependency_strategy_t* strategy); +celix_status_t serviceDependency_getStrategy(celix_dm_service_dependency_t *dependency, celix_dm_service_dependency_strategy_t* strategy) CELIX_DEPRECATED_ATTR; /** * Set the service name, version range and filter. @@ -107,12 +105,12 @@ celix_status_t serviceDependency_getStrategy(dm_service_dependency_t *dependency * @param serviceVersionRange The service version range, can be a NULL pointer. * @param filter The (additional) filter to use (e.g. "(location=front)"). Can be a NULL pointer. */ -celix_status_t serviceDependency_setService(dm_service_dependency_t *dependency, const char* serviceName, const char* serviceVersionRange, const char* filter); +celix_status_t serviceDependency_setService(celix_dm_service_dependency_t *dependency, const char* serviceName, const char* serviceVersionRange, const char* filter) CELIX_DEPRECATED_ATTR; /** * Returns the service depenendy filter. */ -celix_status_t serviceDependency_getFilter(dm_service_dependency_t *dependency, const char** filter); +celix_status_t serviceDependency_getFilter(celix_dm_service_dependency_t *dependency, const char** filter) CELIX_DEPRECATED_ATTR; /** * Set the set, add, change, remove and swap function callbacks when services specified by the service dependency @@ -120,7 +118,7 @@ celix_status_t serviceDependency_getFilter(dm_service_dependency_t *dependency, * The first argument of the callbacks will be the component implement (@see component_getImplementation) * The second the argument a pointer to an instance of a service struct of the specified service dependency. */ -celix_status_t serviceDependency_setCallbacks(dm_service_dependency_t *dependency, service_set_fpt set, service_add_fpt add, service_change_fpt change, service_remove_fpt remove, service_swap_fpt swap); +celix_status_t serviceDependency_setCallbacks(celix_dm_service_dependency_t *dependency, service_set_fpt set, service_add_fpt add, service_change_fpt change, service_remove_fpt remove, service_swap_fpt swap) CELIX_DEPRECATED_ATTR; /** * Set the set, add, change, remove and swap function callbacks when services specified by the service dependency @@ -129,13 +127,13 @@ celix_status_t serviceDependency_setCallbacks(dm_service_dependency_t *dependenc * The second argument of th callbacks will be a pointer to an instance of a service struct of the specified service dependency. * The third argument of th callbacks will be a pointer to a service reference of the a service instance of the specified service dependency. */ -celix_status_t serviceDependency_setCallbacksWithServiceReference(dm_service_dependency_t *dependency, service_set_with_ref_fpt set, service_add_with_ref_fpt add, service_change_with_ref_fpt change, service_remove_with_ref_fpt remove, service_swap_with_ref_fpt swap); +celix_status_t serviceDependency_setCallbacksWithServiceReference(celix_dm_service_dependency_t *dependency, service_set_with_ref_fpt set, service_add_with_ref_fpt add, service_change_with_ref_fpt change, service_remove_with_ref_fpt remove, service_swap_with_ref_fpt swap) CELIX_DEPRECATED_ATTR; /** * Specifies which field member (pointer to) to update when a service dependencies is set. * If provided the provided service_lock will be used for locking when updating the service instance. */ -celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_t *dependency, celix_thread_mutex_t *service_lock, const void** field); +celix_status_t serviceDependency_setAutoConfigure(celix_dm_service_dependency_t *dependency, celix_thread_mutex_t *service_lock, const void** field) CELIX_DEPRECATED_ATTR; #define serviceDependency_setCallbacksSafe(dep, cmpType, servType, set, add, change, remove, swap) \ do { \ @@ -152,18 +150,18 @@ celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_t *depen * result of component_getImplementation() is used * This can be used in rare cases when the callbacks are actually interceptors. e.g. in the case of C++ support. */ -celix_status_t serviceDependency_setCallbackHandle(dm_service_dependency_t *dependency, void* handle); +celix_status_t serviceDependency_setCallbackHandle(celix_dm_service_dependency_t *dependency, void* handle) CELIX_DEPRECATED_ATTR; /** * Creates a service dependency info. The service dependency info struct contains information about the service dependency. * The caller is the owner */ -celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_t* dep, dm_service_dependency_info_t **info); +celix_status_t serviceDependency_getServiceDependencyInfo(celix_dm_service_dependency_t* dep, dm_service_dependency_info_t **info) CELIX_DEPRECATED_ATTR; /** * Destroy a provided service dependency info struct. */ -void dependency_destroyDependencyInfo(dm_service_dependency_info_t *info); +void dependency_destroyDependencyInfo(dm_service_dependency_info_t *info) CELIX_DEPRECATED_ATTR; #ifdef __cplusplus } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/framework.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/framework.h b/libs/framework/include/framework.h index f02b784..6864da5 100644 --- a/libs/framework/include/framework.h +++ b/libs/framework/include/framework.h @@ -27,9 +27,6 @@ #ifndef FRAMEWORK_H_ #define FRAMEWORK_H_ -typedef struct framework *framework_pt; -typedef struct framework framework_t; - #include "celix_errno.h" #include "framework_exports.h" #include "bundle.h" @@ -41,19 +38,19 @@ extern "C" { #endif // #TODO: Move to FrameworkFactory according the OSGi Spec -FRAMEWORK_EXPORT celix_status_t framework_create(framework_t **framework, properties_t *config); +FRAMEWORK_EXPORT celix_status_t framework_create(celix_framework_t **framework, celix_properties_t *config); -FRAMEWORK_EXPORT celix_status_t framework_start(framework_t *framework); +FRAMEWORK_EXPORT celix_status_t framework_start(celix_framework_t *framework); -FRAMEWORK_EXPORT celix_status_t framework_stop(framework_t *framework); +FRAMEWORK_EXPORT celix_status_t framework_stop(celix_framework_t *framework); -FRAMEWORK_EXPORT celix_status_t framework_destroy(framework_t *framework); +FRAMEWORK_EXPORT celix_status_t framework_destroy(celix_framework_t *framework); -FRAMEWORK_EXPORT celix_status_t framework_waitForStop(framework_t *framework); +FRAMEWORK_EXPORT celix_status_t framework_waitForStop(celix_framework_t *framework); -FRAMEWORK_EXPORT celix_status_t framework_getFrameworkBundle(framework_t *framework, bundle_t **bundle); +FRAMEWORK_EXPORT celix_status_t framework_getFrameworkBundle(celix_framework_t *framework, celix_bundle_t **bundle); -bundle_context_t* framework_getContext(framework_t *framework); +celix_bundle_context_t* framework_getContext(celix_framework_t *framework); #ifdef __cplusplus } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/listener_hook_service.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/listener_hook_service.h b/libs/framework/include/listener_hook_service.h index d80c09e..ce1befe 100644 --- a/libs/framework/include/listener_hook_service.h +++ b/libs/framework/include/listener_hook_service.h @@ -39,7 +39,7 @@ extern "C" { #endif struct listener_hook_info { - bundle_context_pt context; + celix_bundle_context_t *context; const char *filter; bool removed; }; @@ -47,9 +47,9 @@ struct listener_hook_info { struct listener_hook_service { void *handle; - celix_status_t (*added)(void *hook, array_list_pt listeners); + celix_status_t (*added)(void *hook, celix_array_list_t *listeners); - celix_status_t (*removed)(void *hook, array_list_pt listeners); + celix_status_t (*removed)(void *hook, celix_array_list_t *listeners); }; #ifdef __cplusplus http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/manifest.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/manifest.h b/libs/framework/include/manifest.h index eeccfbc..a6b5d59 100644 --- a/libs/framework/include/manifest.h +++ b/libs/framework/include/manifest.h @@ -36,7 +36,7 @@ extern "C" { #endif struct manifest { - properties_pt mainAttributes; + celix_properties_t *mainAttributes; hash_map_pt attributes; }; @@ -50,7 +50,7 @@ FRAMEWORK_EXPORT celix_status_t manifest_destroy(manifest_pt manifest); FRAMEWORK_EXPORT void manifest_clear(manifest_pt manifest); -FRAMEWORK_EXPORT properties_pt manifest_getMainAttributes(manifest_pt manifest); +FRAMEWORK_EXPORT celix_properties_t *manifest_getMainAttributes(manifest_pt manifest); FRAMEWORK_EXPORT celix_status_t manifest_getEntries(manifest_pt manifest, hash_map_pt *map); http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/module.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/module.h b/libs/framework/include/module.h index 463fd86..446547a 100644 --- a/libs/framework/include/module.h +++ b/libs/framework/include/module.h @@ -41,9 +41,9 @@ typedef struct module *module_pt; extern "C" { #endif -module_pt module_create(manifest_pt headerMap, const char *moduleId, bundle_pt bundle); +module_pt module_create(manifest_pt headerMap, const char *moduleId, celix_bundle_t *bundle); -module_pt module_createFrameworkModule(bundle_pt bundle); +module_pt module_createFrameworkModule(celix_bundle_t *bundle); void module_destroy(module_pt module); @@ -67,25 +67,25 @@ FRAMEWORK_EXPORT bool module_isResolved(module_pt module); FRAMEWORK_EXPORT void module_setResolved(module_pt module); -FRAMEWORK_EXPORT bundle_pt module_getBundle(module_pt module); +FRAMEWORK_EXPORT celix_bundle_t *module_getBundle(module_pt module); FRAMEWORK_EXPORT linked_list_pt module_getRequirements(module_pt module); FRAMEWORK_EXPORT linked_list_pt module_getCapabilities(module_pt module); -FRAMEWORK_EXPORT array_list_pt module_getDependentImporters(module_pt module); +FRAMEWORK_EXPORT celix_array_list_t *module_getDependentImporters(module_pt module); FRAMEWORK_EXPORT void module_addDependentImporter(module_pt module, module_pt importer); FRAMEWORK_EXPORT void module_removeDependentImporter(module_pt module, module_pt importer); -FRAMEWORK_EXPORT array_list_pt module_getDependentRequirers(module_pt module); +FRAMEWORK_EXPORT celix_array_list_t *module_getDependentRequirers(module_pt module); FRAMEWORK_EXPORT void module_addDependentRequirer(module_pt module, module_pt requirer); FRAMEWORK_EXPORT void module_removeDependentRequirer(module_pt module, module_pt requirer); -FRAMEWORK_EXPORT array_list_pt module_getDependents(module_pt module); +FRAMEWORK_EXPORT celix_array_list_t *module_getDependents(module_pt module); FRAMEWORK_EXPORT celix_status_t module_getGroup(module_pt module, const char **group); http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/service_reference.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/service_reference.h b/libs/framework/include/service_reference.h index e094b4c..8c32106 100644 --- a/libs/framework/include/service_reference.h +++ b/libs/framework/include/service_reference.h @@ -31,10 +31,10 @@ extern "C" { #endif -FRAMEWORK_EXPORT celix_status_t serviceReference_getBundle(service_reference_pt reference, bundle_pt *bundle); +FRAMEWORK_EXPORT celix_status_t serviceReference_getBundle(service_reference_pt reference, celix_bundle_t **bundle); FRAMEWORK_EXPORT bool -serviceReference_isAssignableTo(service_reference_pt reference, bundle_pt requester, const char *serviceName); +serviceReference_isAssignableTo(service_reference_pt reference, celix_bundle_t *requester, const char *serviceName); FRAMEWORK_EXPORT celix_status_t serviceReference_getProperty(service_reference_pt reference, const char *key, const char **value); @@ -58,7 +58,7 @@ FRAMEWORK_EXPORT int serviceReference_equals2(const void *reference1, const void FRAMEWORK_EXPORT celix_status_t serviceReference_compareTo(service_reference_pt reference, service_reference_pt compareTo, int *compare); -FRAMEWORK_EXPORT celix_status_t serviceReference_getUsingBundles(service_reference_pt ref, array_list_pt *out); +FRAMEWORK_EXPORT celix_status_t serviceReference_getUsingBundles(service_reference_pt ref, celix_array_list_t **out); #ifdef __cplusplus } http://git-wip-us.apache.org/repos/asf/celix/blob/2492416e/libs/framework/include/service_registration.h ---------------------------------------------------------------------- diff --git a/libs/framework/include/service_registration.h b/libs/framework/include/service_registration.h index 8e661ec..ea44155 100644 --- a/libs/framework/include/service_registration.h +++ b/libs/framework/include/service_registration.h @@ -38,10 +38,10 @@ extern "C" { FRAMEWORK_EXPORT celix_status_t serviceRegistration_unregister(service_registration_t *registration); FRAMEWORK_EXPORT celix_status_t -serviceRegistration_getProperties(service_registration_t *registration, properties_pt *properties); +serviceRegistration_getProperties(service_registration_t *registration, celix_properties_t **properties); FRAMEWORK_EXPORT celix_status_t -serviceRegistration_setProperties(service_registration_t *registration, properties_pt properties); +serviceRegistration_setProperties(service_registration_t *registration, celix_properties_t *properties); FRAMEWORK_EXPORT celix_status_t serviceRegistration_getServiceName(service_registration_t *registration, const char **serviceName);
