http://git-wip-us.apache.org/repos/asf/celix/blob/2e04253d/libs/framework/src/framework_private.h ---------------------------------------------------------------------- diff --cc libs/framework/src/framework_private.h index 0000000,dcfe75f..fc7b0cf mode 000000,100644..100644 --- a/libs/framework/src/framework_private.h +++ b/libs/framework/src/framework_private.h @@@ -1,0 -1,164 +1,156 @@@ + /** + *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. + */ -/* - * framework_private.h - * - * \date May 22, 2013 - * \author <a href="mailto:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ + + + #ifndef FRAMEWORK_PRIVATE_H_ + #define FRAMEWORK_PRIVATE_H_ + + #include "celix_framework.h" + #include "framework.h" + + #include "manifest.h" + #include "wire.h" + #include "hash_map.h" + #include "array_list.h" + #include "celix_errno.h" + #include "service_factory.h" + #include "bundle_archive.h" + #include "service_listener.h" + #include "bundle_listener.h" + #include "framework_listener.h" + #include "service_registration.h" + #include "bundle_context.h" + #include "bundle_cache.h" + #include "celix_log.h" + + #include "celix_threads.h" + + struct framework { -#ifdef WITH_APR - apr_pool_t *pool; -#endif ++ char uuid[37]; ++ + struct bundle * bundle; + hash_map_pt installedBundleMap; + hash_map_pt installRequestMap; + + celix_thread_mutex_t serviceListenersLock; + array_list_pt serviceListeners; + + array_list_pt frameworkListeners; + celix_thread_mutex_t frameworkListenersLock; + + array_list_pt bundleListeners; + celix_thread_mutex_t bundleListenerLock; + + long nextBundleId; + celix_service_registry_t *registry; + bundle_cache_pt cache; + + celix_thread_cond_t shutdownGate; + celix_thread_cond_t condition; + + celix_thread_mutex_t installedBundleMapLock; + celix_thread_mutex_t installRequestLock; + celix_thread_mutex_t mutex; + celix_thread_mutex_t bundleLock; + + celix_thread_t globalLockThread; + array_list_pt globalLockWaitersList; + int globalLockCount; + + bool interrupted; + bool shutdown; + + properties_pt configurationMap; + + array_list_pt requests; + celix_thread_cond_t dispatcher; + celix_thread_mutex_t dispatcherLock; + celix_thread_t dispatcherThread; + celix_thread_t shutdownThread; + + framework_logger_pt logger; + }; + + FRAMEWORK_EXPORT celix_status_t fw_getProperty(framework_pt framework, const char* name, const char* defaultValue, const char** value); + + FRAMEWORK_EXPORT celix_status_t fw_installBundle(framework_pt framework, bundle_pt * bundle, const char * location, const char *inputFile); + FRAMEWORK_EXPORT celix_status_t fw_uninstallBundle(framework_pt framework, bundle_pt bundle); + + FRAMEWORK_EXPORT celix_status_t framework_getBundleEntry(framework_pt framework, bundle_pt bundle, const char* name, char** entry); + + FRAMEWORK_EXPORT celix_status_t fw_startBundle(framework_pt framework, bundle_pt bundle, int options); + FRAMEWORK_EXPORT celix_status_t framework_updateBundle(framework_pt framework, bundle_pt bundle, const char* inputFile); + FRAMEWORK_EXPORT celix_status_t fw_stopBundle(framework_pt framework, bundle_pt bundle, bool record); + + FRAMEWORK_EXPORT celix_status_t fw_registerService(framework_pt framework, service_registration_pt * registration, bundle_pt bundle, const char* serviceName, const void* svcObj, properties_pt properties); + FRAMEWORK_EXPORT celix_status_t fw_registerServiceFactory(framework_pt framework, service_registration_pt * registration, bundle_pt bundle, const char* serviceName, service_factory_pt factory, properties_pt properties); + FRAMEWORK_EXPORT void fw_unregisterService(service_registration_pt registration); + + FRAMEWORK_EXPORT celix_status_t fw_getServiceReferences(framework_pt framework, array_list_pt *references, bundle_pt bundle, const char* serviceName, const char* filter); + FRAMEWORK_EXPORT celix_status_t framework_ungetServiceReference(framework_pt framework, bundle_pt bundle, service_reference_pt reference); + FRAMEWORK_EXPORT celix_status_t fw_getService(framework_pt framework, bundle_pt bundle, service_reference_pt reference, const void** service); + FRAMEWORK_EXPORT celix_status_t framework_ungetService(framework_pt framework, bundle_pt bundle, service_reference_pt reference, bool *result); + FRAMEWORK_EXPORT celix_status_t fw_getBundleRegisteredServices(framework_pt framework, bundle_pt bundle, array_list_pt *services); + FRAMEWORK_EXPORT celix_status_t fw_getBundleServicesInUse(framework_pt framework, bundle_pt bundle, array_list_pt *services); + + FRAMEWORK_EXPORT void fw_addServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener, const char* filter); + FRAMEWORK_EXPORT void fw_removeServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener); + + FRAMEWORK_EXPORT celix_status_t fw_addBundleListener(framework_pt framework, bundle_pt bundle, bundle_listener_pt listener); + FRAMEWORK_EXPORT celix_status_t fw_removeBundleListener(framework_pt framework, bundle_pt bundle, bundle_listener_pt listener); + + FRAMEWORK_EXPORT celix_status_t fw_addFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener); + FRAMEWORK_EXPORT celix_status_t fw_removeFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener); + + FRAMEWORK_EXPORT void fw_serviceChanged(framework_pt framework, service_event_type_e eventType, service_registration_pt registration, properties_pt oldprops); + + FRAMEWORK_EXPORT celix_status_t fw_isServiceAssignable(framework_pt fw, bundle_pt requester, service_reference_pt reference, bool* assignable); + + //bundle_archive_t fw_createArchive(long id, char * location); + //void revise(bundle_archive_t archive, char * location); + FRAMEWORK_EXPORT celix_status_t getManifest(bundle_archive_pt archive, manifest_pt *manifest); + + FRAMEWORK_EXPORT bundle_pt findBundle(bundle_context_pt context); + FRAMEWORK_EXPORT service_registration_pt findRegistration(service_reference_pt reference); + + FRAMEWORK_EXPORT service_reference_pt listToArray(array_list_pt list); + FRAMEWORK_EXPORT celix_status_t framework_markResolvedModules(framework_pt framework, linked_list_pt wires); + + FRAMEWORK_EXPORT array_list_pt framework_getBundles(framework_pt framework); + FRAMEWORK_EXPORT bundle_pt framework_getBundle(framework_pt framework, const char* location); + FRAMEWORK_EXPORT bundle_pt framework_getBundleById(framework_pt framework, long id); + + + + + + + + + /********************************************************************************************************************** + ********************************************************************************************************************** + * Updated API + ********************************************************************************************************************** + **********************************************************************************************************************/ + + void celix_framework_useBundles(framework_t *fw, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd)); -void celix_framework_useBundle(framework_t *fw, long bundleId, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd)); ++bool celix_framework_useBundle(framework_t *fw, long bundleId, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd)); + service_registration_t* celix_framework_registerServiceFactory(framework_t *fw , const celix_bundle_t *bnd, const char* serviceName, celix_service_factory_t *factory, celix_properties_t *properties); + + #endif /* FRAMEWORK_PRIVATE_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/2e04253d/libs/utils/CMakeLists.txt ---------------------------------------------------------------------- diff --cc libs/utils/CMakeLists.txt index 0000000,595eabd..7b667c2 mode 000000,100644..100644 --- a/libs/utils/CMakeLists.txt +++ b/libs/utils/CMakeLists.txt @@@ -1,0 -1,119 +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. + + set(MEMSTREAM_SOURCES ) + set(MEMSTREAM_INCLUDES ) + if (APPLE OR ANDROID) + set(MEMSTREAM_SOURCES src/memstream/open_memstream.c src/memstream/fmemopen.c) + set(MEMSTREAM_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/memstream) + install(DIRECTORY include/memstream/ DESTINATION include/celix/memstream COMPONENT framework) + endif() + + add_library(utils SHARED + src/array_list.c + src/hash_map.c + src/linked_list.c + src/linked_list_iterator.c + src/celix_threads.c + src/version.c + src/version_range.c + src/thpool.c + src/properties.c + src/utils.c + src/filter.c + ${MEMSTREAM_SOURCES} + ) + set_target_properties(utils PROPERTIES OUTPUT_NAME "celix_utils") + + if (ANDROID) + target_compile_definitions(utils PRIVATE -DUSE_FILE32API) + endif () + + target_include_directories(utils PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> + $<BUILD_INTERFACE:${MEMSTREAM_INCLUDE_DIR}> + $<INSTALL_INTERFACE:include/celix> + ) + target_include_directories(utils PRIVATE src) + set_target_properties(utils PROPERTIES "SOVERSION" 2) + + IF(UNIX AND NOT ANDROID) + target_link_libraries(utils PRIVATE m pthread) + ELSEIF(ANDROID) + target_link_libraries(utils PRIVATE m) + ENDIF() + + install(TARGETS utils EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework) + install(DIRECTORY include/ DESTINATION include/celix COMPONENT framework + PATTERN memstream* EXCLUDE) + + #Alias setup to match external usage + add_library(Celix::utils ALIAS utils) + + + celix_subproject(UTILS-TESTS "Option to build the utilities library tests" "OFF") + if (ENABLE_TESTING AND UTILS-TESTS) + find_package(CppUTest REQUIRED) + - include_directories(${CUNIT_INCLUDE_DIRS}) - include_directories(${CPPUTEST_INCLUDE_DIR}) ++ include_directories(SYSTEM ${CUNIT_INCLUDE_DIRS}) ++ include_directories(SYSTEM ${CPPUTEST_INCLUDE_DIR}) + include_directories(include) + include_directories(src) + + add_executable(hash_map_test private/test/hash_map_test.cpp) + target_link_libraries(hash_map_test Celix::utils ${CPPUTEST_LIBRARY} pthread) + + add_executable(array_list_test private/test/array_list_test.cpp) + target_link_libraries(array_list_test Celix::utils ${CPPUTEST_LIBRARY} pthread) + + add_executable(celix_threads_test private/test/celix_threads_test.cpp) + target_link_libraries(celix_threads_test Celix::utils ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} pthread) + add_executable(linked_list_test private/test/linked_list_test.cpp) + target_link_libraries(linked_list_test Celix::utils ${CPPUTEST_LIBRARY} pthread) + + add_executable(thread_pool_test private/test/thread_pool_test.cpp) + target_link_libraries(thread_pool_test Celix::utils ${CPPUTEST_LIBRARY} pthread) + + add_executable(properties_test private/test/properties_test.cpp) + target_link_libraries(properties_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread) + + add_executable(utils_test private/test/utils_test.cpp) + target_link_libraries(utils_test ${CPPUTEST_LIBRARY} Celix::utils pthread) + + add_executable(filter_test private/test/filter_test.cpp) + target_link_libraries(filter_test ${CPPUTEST_LIBRARY} Celix::utils pthread) + + configure_file(private/resources-test/properties.txt ${CMAKE_CURRENT_BINARY_DIR}/resources-test/properties.txt COPYONLY) + + add_test(NAME run_array_list_test COMMAND array_list_test) + add_test(NAME run_hash_map_test COMMAND hash_map_test) + add_test(NAME run_celix_threads_test COMMAND celix_threads_test) + add_test(NAME run_thread_pool_test COMMAND thread_pool_test) + add_test(NAME run_linked_list_test COMMAND linked_list_test) + add_test(NAME run_properties_test COMMAND properties_test) + add_test(NAME run_utils_test COMMAND utils_test) + add_test(NAME filter_test COMMAND filter_test) + + SETUP_TARGET_FOR_COVERAGE(array_list_test array_list_test ${CMAKE_BINARY_DIR}/coverage/array_list_test/array_list_test) + SETUP_TARGET_FOR_COVERAGE(hash_map hash_map_test ${CMAKE_BINARY_DIR}/coverage/hash_map_test/hash_map_test) + SETUP_TARGET_FOR_COVERAGE(celix_threads_test celix_threads_test ${CMAKE_BINARY_DIR}/coverage/celix_threads_test/celix_threads_test) + SETUP_TARGET_FOR_COVERAGE(thread_pool_test thread_pool_test ${CMAKE_BINARY_DIR}/coverage/thread_pool_test/thread_pool_test) + SETUP_TARGET_FOR_COVERAGE(linked_list_test linked_list_test ${CMAKE_BINARY_DIR}/coverage/linked_list_test/linked_list_test) + SETUP_TARGET_FOR_COVERAGE(properties_test properties_test ${CMAKE_BINARY_DIR}/coverage/properties_test/properties_test) + SETUP_TARGET_FOR_COVERAGE(utils_test utils_test ${CMAKE_BINARY_DIR}/coverage/utils_test/utils_test) + + endif(ENABLE_TESTING AND UTILS-TESTS) http://git-wip-us.apache.org/repos/asf/celix/blob/2e04253d/libs/utils/CMakeLists.txt.orig ---------------------------------------------------------------------- diff --cc libs/utils/CMakeLists.txt.orig index 0000000,0000000..d88a2e0 new file mode 100644 --- /dev/null +++ b/libs/utils/CMakeLists.txt.orig @@@ -1,0 -1,0 +1,129 @@@ ++# 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. ++ ++set(MEMSTREAM_SOURCES ) ++set(MEMSTREAM_INCLUDES ) ++if (APPLE OR ANDROID) ++ set(MEMSTREAM_SOURCES src/memstream/open_memstream.c src/memstream/fmemopen.c) ++ set(MEMSTREAM_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/memstream) ++ install(DIRECTORY include/memstream/ DESTINATION include/celix/memstream COMPONENT framework) ++endif() ++ ++add_library(utils SHARED ++ src/array_list.c ++ src/hash_map.c ++ src/linked_list.c ++ src/linked_list_iterator.c ++ src/celix_threads.c ++ src/version.c ++ src/version_range.c ++ src/thpool.c ++ src/properties.c ++ src/utils.c ++ src/filter.c ++ ${MEMSTREAM_SOURCES} ++) ++set_target_properties(utils PROPERTIES OUTPUT_NAME "celix_utils") ++ ++if (ANDROID) ++ target_compile_definitions(utils PRIVATE -DUSE_FILE32API) ++endif () ++ ++target_include_directories(utils PUBLIC ++ $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> ++ $<BUILD_INTERFACE:${MEMSTREAM_INCLUDE_DIR}> ++ $<INSTALL_INTERFACE:include/celix> ++) ++target_include_directories(utils PRIVATE src) ++set_target_properties(utils PROPERTIES "SOVERSION" 2) ++ ++IF(UNIX AND NOT ANDROID) ++ target_link_libraries(utils PRIVATE m pthread) ++ELSEIF(ANDROID) ++ target_link_libraries(utils PRIVATE m) ++ENDIF() ++ ++install(TARGETS utils EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework) ++install(DIRECTORY include/ DESTINATION include/celix COMPONENT framework ++ PATTERN memstream* EXCLUDE) ++ ++#Alias setup to match external usage ++add_library(Celix::utils ALIAS utils) ++ ++ ++celix_subproject(UTILS-TESTS "Option to build the utilities library tests" "OFF") ++if (ENABLE_TESTING AND UTILS-TESTS) ++ find_package(CppUTest REQUIRED) ++ ++<<<<<<< HEAD:utils/CMakeLists.txt ++ SET(CMAKE_SKIP_BUILD_RPATH FALSE) ++ SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) ++ SET(CMAKE_INSTALL_RPATH "${PROJECT_BINARY_DIR}/utils") ++ ++ ++ include_directories(SYSTEM ${CUNIT_INCLUDE_DIRS}) ++ include_directories(SYSTEM ${CPPUTEST_INCLUDE_DIR}) ++======= ++ include_directories(${CUNIT_INCLUDE_DIRS}) ++ include_directories(${CPPUTEST_INCLUDE_DIR}) ++>>>>>>> develop:libs/utils/CMakeLists.txt ++ include_directories(include) ++ include_directories(src) ++ ++ add_executable(hash_map_test private/test/hash_map_test.cpp) ++ target_link_libraries(hash_map_test Celix::utils ${CPPUTEST_LIBRARY} pthread) ++ ++ add_executable(array_list_test private/test/array_list_test.cpp) ++ target_link_libraries(array_list_test Celix::utils ${CPPUTEST_LIBRARY} pthread) ++ ++ add_executable(celix_threads_test private/test/celix_threads_test.cpp) ++ target_link_libraries(celix_threads_test Celix::utils ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} pthread) ++ add_executable(linked_list_test private/test/linked_list_test.cpp) ++ target_link_libraries(linked_list_test Celix::utils ${CPPUTEST_LIBRARY} pthread) ++ ++ add_executable(thread_pool_test private/test/thread_pool_test.cpp) ++ target_link_libraries(thread_pool_test Celix::utils ${CPPUTEST_LIBRARY} pthread) ++ ++ add_executable(properties_test private/test/properties_test.cpp) ++ target_link_libraries(properties_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread) ++ ++ add_executable(utils_test private/test/utils_test.cpp) ++ target_link_libraries(utils_test ${CPPUTEST_LIBRARY} Celix::utils pthread) ++ ++ add_executable(filter_test private/test/filter_test.cpp) ++ target_link_libraries(filter_test ${CPPUTEST_LIBRARY} Celix::utils pthread) ++ ++ configure_file(private/resources-test/properties.txt ${CMAKE_CURRENT_BINARY_DIR}/resources-test/properties.txt COPYONLY) ++ ++ add_test(NAME run_array_list_test COMMAND array_list_test) ++ add_test(NAME run_hash_map_test COMMAND hash_map_test) ++ add_test(NAME run_celix_threads_test COMMAND celix_threads_test) ++ add_test(NAME run_thread_pool_test COMMAND thread_pool_test) ++ add_test(NAME run_linked_list_test COMMAND linked_list_test) ++ add_test(NAME run_properties_test COMMAND properties_test) ++ add_test(NAME run_utils_test COMMAND utils_test) ++ add_test(NAME filter_test COMMAND filter_test) ++ ++ SETUP_TARGET_FOR_COVERAGE(array_list_test array_list_test ${CMAKE_BINARY_DIR}/coverage/array_list_test/array_list_test) ++ SETUP_TARGET_FOR_COVERAGE(hash_map hash_map_test ${CMAKE_BINARY_DIR}/coverage/hash_map_test/hash_map_test) ++ SETUP_TARGET_FOR_COVERAGE(celix_threads_test celix_threads_test ${CMAKE_BINARY_DIR}/coverage/celix_threads_test/celix_threads_test) ++ SETUP_TARGET_FOR_COVERAGE(thread_pool_test thread_pool_test ${CMAKE_BINARY_DIR}/coverage/thread_pool_test/thread_pool_test) ++ SETUP_TARGET_FOR_COVERAGE(linked_list_test linked_list_test ${CMAKE_BINARY_DIR}/coverage/linked_list_test/linked_list_test) ++ SETUP_TARGET_FOR_COVERAGE(properties_test properties_test ${CMAKE_BINARY_DIR}/coverage/properties_test/properties_test) ++ SETUP_TARGET_FOR_COVERAGE(utils_test utils_test ${CMAKE_BINARY_DIR}/coverage/utils_test/utils_test) ++ ++endif(ENABLE_TESTING AND UTILS-TESTS)