You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2018/04/25 19:12:11 UTC
[7/7] celix git commit: CELIX-425: Adds the c dependency manager to
the framework. Also adds some empty interface libraries so that the changes
are backwards compatible.
CELIX-425: Adds the c dependency manager to the framework. Also adds some empty interface libraries so that the changes are backwards compatible.
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/5992be15
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/5992be15
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/5992be15
Branch: refs/heads/develop
Commit: 5992be15e6e4d9a6de9ef2ce673f28fdc7586ee7
Parents: f1f38c0
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Tue Apr 24 21:36:10 2018 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Wed Apr 25 21:11:53 2018 +0200
----------------------------------------------------------------------
cmake/cmake_celix/ContainerPackaging.cmake | 42 +-
cmake/cmake_celix/DockerPackaging.cmake | 30 +-
dependency_manager/CMakeLists.txt | 82 +-
dependency_manager/api/dm_activator.h | 65 -
dependency_manager/api/dm_component.h | 158 --
dependency_manager/api/dm_dependency_manager.h | 84 -
dependency_manager/api/dm_info.h | 81 -
dependency_manager/api/dm_service_dependency.h | 171 ---
dependency_manager/src/dm_activator.c | 119 --
dependency_manager/src/dm_component_impl.c | 1451 ------------------
dependency_manager/src/dm_component_impl.h | 48 -
dependency_manager/src/dm_dependency.h | 41 -
.../src/dm_dependency_manager_impl.c | 139 --
.../src/dm_dependency_manager_impl.h | 45 -
dependency_manager/src/dm_event.c | 105 --
dependency_manager/src/dm_event.h | 72 -
dependency_manager/src/dm_service_dependency.c | 811 ----------
.../src/dm_service_dependency_impl.h | 104 --
dependency_manager/src/dm_shell_activator.c | 94 --
dependency_manager/src/dm_shell_list_command.c | 191 ---
dependency_manager/src/dm_shell_list_command.h | 42 -
dependency_manager_cxx/CMakeLists.txt | 8 +-
.../include/celix/dm/DmActivator.h | 14 -
.../dm_example/phase2a/src/phase2a_activator.c | 8 +-
framework/CMakeLists.txt | 2 +
framework/include/bundle.h | 3 +-
framework/include/bundle_activator.h | 8 +-
framework/include/bundle_archive.h | 4 +-
framework/include/bundle_context.h | 21 +-
framework/include/bundle_listener.h | 12 +-
framework/include/bundle_revision.h | 4 +-
framework/include/celix_api.h | 3 +
framework/include/celix_types.h | 49 +
framework/include/constants.h | 6 +
framework/include/dm_activator.h | 67 +
framework/include/dm_component.h | 158 ++
framework/include/dm_dependency_manager.h | 82 +
framework/include/dm_info.h | 76 +
framework/include/dm_service_dependency.h | 172 +++
framework/src/bundle_context.c | 19 +
framework/src/bundle_context_private.h | 3 +-
framework/src/dm_component_impl.c | 1451 ++++++++++++++++++
framework/src/dm_component_impl.h | 48 +
framework/src/dm_dependency.h | 41 +
framework/src/dm_dependency_manager_impl.c | 139 ++
framework/src/dm_dependency_manager_impl.h | 45 +
framework/src/dm_event.c | 105 ++
framework/src/dm_event.h | 72 +
framework/src/dm_service_dependency.c | 811 ++++++++++
framework/src/dm_service_dependency_impl.h | 104 ++
framework/src/framework.c | 115 +-
shell/CMakeLists.txt | 1 +
shell/include/dm_shell_list_command.h | 42 +
shell/src/activator.c | 9 +-
shell/src/dm_shell_list_command.c | 189 +++
shell/src/std_commands.h | 2 +
56 files changed, 3859 insertions(+), 4009 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/cmake/cmake_celix/ContainerPackaging.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/ContainerPackaging.cmake b/cmake/cmake_celix/ContainerPackaging.cmake
index 28d63bc..9379d39 100644
--- a/cmake/cmake_celix/ContainerPackaging.cmake
+++ b/cmake/cmake_celix/ContainerPackaging.cmake
@@ -256,18 +256,24 @@ function(celix_container_bundles_dir)
)
set(HANDLED TRUE)
elseif (TARGET ${BUNDLE})
- get_target_property(IMP ${BUNDLE} BUNDLE_IMPORTED)
- if (IMP) #An imported bundle target -> handle target without DEPENDS
- string(MAKE_C_IDENTIFIER ${BUNDLE} BUNDLE_ID) #Create id with no special chars (e.g. for target like Celix::shell)
- set(OUT "${CMAKE_BINARY_DIR}/celix/gen/${CONTAINER_TARGET}/copy-bundle-for-target-${BUNDLE_ID}.timestamp")
- set(DEST "${CONTAINER_LOC}/${BD_DIR_NAME}/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>")
- add_custom_command(OUTPUT ${OUT}
- COMMAND ${CMAKE_COMMAND} -E touch ${OUT}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${CONTAINER_LOC}/${BD_DIR_NAME}
- COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>" ${DEST}
- COMMENT "Copying (imported) bundle '${BUNDLE}' to '${CONTAINER_LOC}/${BD_DIR_NAME}'"
- )
+ get_target_property(TARGET_TYPE ${BUNDLE} TYPE)
+ if (TARGET_TYPE STREQUAL "INTERFACE_LIBRARY")
+ #ignore
set(HANDLED TRUE)
+ else ()
+ get_target_property(IMP ${BUNDLE} BUNDLE_IMPORTED)
+ if (IMP) #An imported bundle target -> handle target without DEPENDS
+ string(MAKE_C_IDENTIFIER ${BUNDLE} BUNDLE_ID) #Create id with no special chars (e.g. for target like Celix::shell)
+ set(OUT "${CMAKE_BINARY_DIR}/celix/gen/${CONTAINER_TARGET}/copy-bundle-for-target-${BUNDLE_ID}.timestamp")
+ set(DEST "${CONTAINER_LOC}/${BD_DIR_NAME}/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>")
+ add_custom_command(OUTPUT ${OUT}
+ COMMAND ${CMAKE_COMMAND} -E touch ${OUT}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CONTAINER_LOC}/${BD_DIR_NAME}
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>" ${DEST}
+ COMMENT "Copying (imported) bundle '${BUNDLE}' to '${CONTAINER_LOC}/${BD_DIR_NAME}'"
+ )
+ set(HANDLED TRUE)
+ endif ()
endif ()
endif ()
@@ -321,11 +327,17 @@ function(celix_container_bundles)
set(ABS_LOC "${BUNDLE}")
set(HANDLED TRUE)
elseif (TARGET ${BUNDLE})
- get_target_property(IMP ${BUNDLE} BUNDLE_IMPORTED)
- if (IMP) #An imported bundle target -> handle target without DEPENDS
- set(COPY_LOC "bundles/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>")
- set(ABS_LOC "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>")
+ get_target_property(TARGET_TYPE ${BUNDLE} TYPE)
+ if (TARGET_TYPE STREQUAL "INTERFACE_LIBRARY")
+ #ignore. this can be used to keep targets name, but ignore it use in containers (e.g. Celix::dm_shell)
set(HANDLED TRUE)
+ else()
+ get_target_property(IMP ${BUNDLE} BUNDLE_IMPORTED)
+ if (IMP) #An imported bundle target -> handle target without DEPENDS
+ set(COPY_LOC "bundles/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>")
+ set(ABS_LOC "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>")
+ set(HANDLED TRUE)
+ endif ()
endif ()
endif ()
http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/cmake/cmake_celix/DockerPackaging.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/DockerPackaging.cmake b/cmake/cmake_celix/DockerPackaging.cmake
index 2faca5c..ea5b8e0 100644
--- a/cmake/cmake_celix/DockerPackaging.cmake
+++ b/cmake/cmake_celix/DockerPackaging.cmake
@@ -262,19 +262,25 @@ function(celix_docker_bundles)
list(APPEND BUNDLES "${BUNDLES_DIR}/${BUNDLE_FILENAME}")
set(HANDLED TRUE)
elseif (TARGET ${BUNDLE})
- get_target_property(IMP ${BUNDLE} BUNDLE_IMPORTED)
- if (IMP) #An imported bundle target -> handle target without DEPENDS
- string(MAKE_C_IDENTIFIER ${BUNDLE} BUNDLE_ID) #Create id with no special chars (e.g. for target like Celix::shell)
- set(OUT "${CMAKE_BINARY_DIR}/celix/gen/${DOCKER_TARGET}/copy-bundle-for-target-${BUNDLE_ID}.timestamp")
- set(DEST "${LOC}/${BUNDLES_DIR}/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>")
- add_custom_command(OUTPUT ${OUT}
- COMMAND ${CMAKE_COMMAND} -E touch ${OUT}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${LOC}/${BUNDLES_DIR}
- COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>" ${DEST}
- COMMENT "Copying (imported) bundle '${BUNDLE}' to '${LOC}/${BUNDLES_DIR}'"
- )
- list(APPEND BUNDLES "${BUNDLES_DIR}/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>")
+ get_target_property(TARGET_TYPE ${BUNDLE} TYPE)
+ if (TARGET_TYPE STREQUAL "INTERFACE_LIBRARY")
+ #ignore
set(HANDLED TRUE)
+ else ()
+ get_target_property(IMP ${BUNDLE} BUNDLE_IMPORTED)
+ if (IMP) #An imported bundle target -> handle target without DEPENDS
+ string(MAKE_C_IDENTIFIER ${BUNDLE} BUNDLE_ID) #Create id with no special chars (e.g. for target like Celix::shell)
+ set(OUT "${CMAKE_BINARY_DIR}/celix/gen/${DOCKER_TARGET}/copy-bundle-for-target-${BUNDLE_ID}.timestamp")
+ set(DEST "${LOC}/${BUNDLES_DIR}/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>")
+ add_custom_command(OUTPUT ${OUT}
+ COMMAND ${CMAKE_COMMAND} -E touch ${OUT}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${LOC}/${BUNDLES_DIR}
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>" ${DEST}
+ COMMENT "Copying (imported) bundle '${BUNDLE}' to '${LOC}/${BUNDLES_DIR}'"
+ )
+ list(APPEND BUNDLES "${BUNDLES_DIR}/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>")
+ set(HANDLED TRUE)
+ endif ()
endif ()
endif ()
http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/dependency_manager/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/dependency_manager/CMakeLists.txt b/dependency_manager/CMakeLists.txt
index a9fa7bd..165a2a4 100644
--- a/dependency_manager/CMakeLists.txt
+++ b/dependency_manager/CMakeLists.txt
@@ -15,79 +15,13 @@
# specific language governing permissions and limitations
# under the License.
-celix_subproject(DEPENDENCY_MANAGER "Option to build the dependency manager static library" ON DEPS framework)
-if (DEPENDENCY_MANAGER)
+#dummy libaries to ensure backward compatability with projects using the dependency manager libs/shell
+add_library(dependency_manager_static INTERFACE)
+add_library(dependency_manager_so INTERFACE)
+add_library(dm_shell INTERFACE)
- # Add -fPIC for x86_64 Unix platforms; this lib will be linked to a shared lib
- if(UNIX AND NOT WIN32)
- find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin )
- if(CMAKE_UNAME)
- exec_program(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR)
- set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL "processor type (i386 and x86_64)")
- if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
- set(DM_COMP_OPT "-fPIC")
- endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
- endif(CMAKE_UNAME)
- endif(UNIX AND NOT WIN32)
+#Setup target aliases to match external usage
+add_library(Celix::dm_shell ALIAS dm_shell)
+add_library(Celix::dependency_manager_static ALIAS dependency_manager_static)
+add_library(Celix::dependency_manager_so ALIAS dependency_manager_so)
- add_library(dependency_manager_static STATIC
- src/dm_component_impl
- src/dm_service_dependency
- src/dm_event
- src/dm_dependency_manager_impl
- src/dm_activator
- )
- set_target_properties(dependency_manager_static PROPERTIES OUTPUT_NAME "celix_dependency_manager_static")
- target_link_libraries(dependency_manager_static Celix::framework)
- target_compile_options(dependency_manager_static PRIVATE ${DM_COMP_OPT})
-
- add_library(dependency_manager_so SHARED
- src/dm_component_impl
- src/dm_service_dependency
- src/dm_event
- src/dm_dependency_manager_impl
- src/dm_activator
- )
- set_target_properties(dependency_manager_so PROPERTIES OUTPUT_NAME "celix_dependency_manager_so")
- set_target_properties(dependency_manager_so PROPERTIES SOVERSION 1)
-
- if (APPLE)
- target_link_libraries(dependency_manager_so Celix::framework "-undefined dynamic_lookup")
- else()
- target_link_libraries(dependency_manager_so Celix::framework)
- endif()
-
- target_include_directories(dependency_manager_static PUBLIC
- $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/api>
- $<INSTALL_INTERFACE:include/celix/dependency_manager>
- )
- target_include_directories(dependency_manager_static PRIVATE src)
- target_include_directories(dependency_manager_so PUBLIC
- $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/api>
- $<INSTALL_INTERFACE:include/celix/dependency_manager>
- )
- target_include_directories(dependency_manager_so PRIVATE src)
-
- add_celix_bundle(dm_shell
- SYMBOLIC_NAME "apache_celix_dm_shell"
- VERSION "1.0.0"
- NAME "Apache Celix DM Shell Commands"
- SOURCES
- src/dm_shell_activator
- src/dm_shell_list_command
- )
- target_include_directories(dm_shell PRIVATE api src)
- target_link_libraries(dm_shell PRIVATE Celix::shell_api)
-
- install_celix_bundle(dm_shell EXPORT celix)
- install(TARGETS dependency_manager_so dependency_manager_static EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dependency_manager)
- install(DIRECTORY api/ DESTINATION include/celix/dependency_manager COMPONENT dependency_manager)
-
- unset(DM_COMP_OPT)
-
-
- #Setup target aliases to match external usage
- add_library(Celix::dm_shell ALIAS dm_shell)
- add_library(Celix::dependency_manager_static ALIAS dependency_manager_static)
- add_library(Celix::dependency_manager_so ALIAS dependency_manager_so)
-endif (DEPENDENCY_MANAGER)
http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/dependency_manager/api/dm_activator.h
----------------------------------------------------------------------
diff --git a/dependency_manager/api/dm_activator.h b/dependency_manager/api/dm_activator.h
deleted file mode 100644
index bba62e6..0000000
--- a/dependency_manager/api/dm_activator.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
- * dm_activator_base.h
- *
- * \date 26 Jul 2014
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-#ifndef DM_ACTIVATOR_BASE_H_
-#define DM_ACTIVATOR_BASE_H_
-
-
-#include "bundle_context.h"
-#include "celix_errno.h"
-#include "dm_dependency_manager.h"
-#include "bundle_activator.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Should be implemented by a bundle specific DM activator.
- * Should allocate and initialize a bundle specific activator struct.
- */
-celix_status_t dm_create(bundle_context_pt context, void ** userData);
-
-/**
- * Should be implemented by a bundle specific DM activator.
- * 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);
-
-/**
- * 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);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DM_ACTIVATOR_BASE_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/dependency_manager/api/dm_component.h
----------------------------------------------------------------------
diff --git a/dependency_manager/api/dm_component.h b/dependency_manager/api/dm_component.h
deleted file mode 100644
index 2cdad6d..0000000
--- a/dependency_manager/api/dm_component.h
+++ /dev/null
@@ -1,158 +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_component.h
- *
- * \date 8 Oct 2014
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef COMPONENT_H_
-#define COMPONENT_H_
-
-
-#include <bundle_context.h>
-#include <celix_errno.h>
-
-#include "dm_service_dependency.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct dm_component_struct *dm_component_pt;
-
-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;
-
-#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);
-
-/**
- * Creates a DM Component
- * Caller has ownership.
- */
-celix_status_t component_create(bundle_context_pt context, const char* name, dm_component_pt *component);
-
-/**
- * Destroys a DM Component
- */
-void component_destroy(dm_component_pt component);
-
-
-/**
- * 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_pt 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 component_addInterface(dm_component_pt component, const char* serviceName, const char* serviceVersion, const void* service, properties_pt properties);
-
-/**
- * Sets the implementation of the component. e.g. the component handle/self/this pointer.
- */
-celix_status_t component_setImplementation(dm_component_pt component, void* implementation);
-
-/**
- * Returns an arraylist of service names. The caller owns the arraylist and strings (char *)
- */
-celix_status_t component_getInterfaces(dm_component_pt component, array_list_pt *servicesNames);
-
-/**
- * Adds a C service dependency to the component
- */
-celix_status_t component_addServiceDependency(dm_component_pt component, dm_service_dependency_pt dep);
-
-/**
- * Removes a C service dependency to the component
- */
-celix_status_t component_removeServiceDependency(dm_component_pt component, dm_service_dependency_pt dependency);
-
-/**
- * Returns the current state of the component.
- */
-dm_component_state_t component_currentState(dm_component_pt cmp);
-
-/**
- * Returns the implementation of the component. e.g. the component handle/self/this pointer.
- */
-void * component_getImplementation(dm_component_pt cmp);
-
-/**
- * Returns the DM component name. This is used when printing information about the component.
- */
-const char * component_getName(dm_component_pt cmp);
-
-/**
- * Returns bundle context for the bundle where this DM component is part of.
- */
-celix_status_t component_getBundleContext(dm_component_pt component, bundle_context_pt *out);
-
-/**
- * Set the component life cycle callbacks.
- * The first argument will be the component implementation (@see component_getImplementation)
- */
-celix_status_t component_setCallbacks(dm_component_pt component, init_fpt init, start_fpt start, stop_fpt stop, deinit_fpt deinit);
-
-/**
- * Set the component life cycle callbacks using a MACRO for improving the type safety.
- */
-#define component_setCallbacksSafe(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); \
- component_setCallbacks((dmCmp), (init_fpt)tmp_init, (start_fpt)tmp_start, (stop_fpt)tmp_stop, (deinit_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_pt component, dm_component_info_pt *info);
-
-/**
- * Destroys a DM Component info struct.
- */
-void component_destroyComponentInfo(dm_component_info_pt info);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* COMPONENT_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/dependency_manager/api/dm_dependency_manager.h
----------------------------------------------------------------------
diff --git a/dependency_manager/api/dm_dependency_manager.h b/dependency_manager/api/dm_dependency_manager.h
deleted file mode 100644
index 8e01302..0000000
--- a/dependency_manager/api/dm_dependency_manager.h
+++ /dev/null
@@ -1,84 +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_dependency_manager.h
- *
- * \date 22 Feb 2014
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef DM_DEPENDENCY_MANAGER_H_
-#define DM_DEPENDENCY_MANAGER_H_
-
-
-#include "bundle_context.h"
-#include "celix_errno.h"
-#include "array_list.h"
-#include "dm_info.h"
-#include "dm_component.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct dm_dependency_manager *dm_dependency_manager_pt;
-
-/**
- * Creates a dependency manager.
- * Caller has ownership.
- */
-celix_status_t dependencyManager_create(bundle_context_pt context, dm_dependency_manager_pt *manager);
-
-/**
- * Destroys the provided dependency manager
- */
-void dependencyManager_destroy(dm_dependency_manager_pt manager);
-
-/**
- * Adds a DM component to the dependency manager
- */
-celix_status_t dependencyManager_add(dm_dependency_manager_pt manager, dm_component_pt component);
-
-/**
- * Removes a DM component from the dependency manager and destroys it
- */
-celix_status_t dependencyManager_remove(dm_dependency_manager_pt manager, dm_component_pt component);
-
-/**
- * Removes all DM components from the dependency manager
- */
-celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_pt manager);
-
-/**
- * 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_pt manager, dm_dependency_manager_info_pt *info);
-
-/**
- * Destroys a DM info struct.
- */
-void dependencyManager_destroyInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt info);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DM_DEPENDENCY_MANAGER_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/dependency_manager/api/dm_info.h
----------------------------------------------------------------------
diff --git a/dependency_manager/api/dm_info.h b/dependency_manager/api/dm_info.h
deleted file mode 100644
index f5e6b47..0000000
--- a/dependency_manager/api/dm_info.h
+++ /dev/null
@@ -1,81 +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:dev@celix.apache.org">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"
-
-#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_pt;
-
-typedef struct dm_service_dependency_info_struct {
- char *filter;
- bool available;
- bool required;
- size_t count;
-} * 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_pt;
-
-typedef struct dm_dependency_manager_info_struct {
- array_list_pt components; // type dm_component_info
-} * dm_dependency_manager_info_pt;
-
-struct dm_info_service_struct {
- void *handle;
-
- /*Note: dm_caller has the ownership of the result.*/
- celix_status_t (*getInfo)(void *handle, dm_dependency_manager_info_pt *info);
- void (*destroyInfo)(void *handle, dm_dependency_manager_info_pt info);
-};
-
-typedef struct dm_info_service_struct dm_info_service_t;
-typedef dm_info_service_t* dm_info_service_pt;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //CELIX_DM_INFO_SERVICE_H
http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/dependency_manager/api/dm_service_dependency.h
----------------------------------------------------------------------
diff --git a/dependency_manager/api/dm_service_dependency.h b/dependency_manager/api/dm_service_dependency.h
deleted file mode 100644
index fb34230..0000000
--- a/dependency_manager/api/dm_service_dependency.h
+++ /dev/null
@@ -1,171 +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_service_dependency.h
- *
- * \date 8 Oct 2014
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef DM_SERVICE_DEPENDENCY_H_
-#define DM_SERVICE_DEPENDENCY_H_
-
-#include "service_reference.h"
-#include "celix_errno.h"
-#include "dm_info.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-typedef struct dm_service_dependency *dm_service_dependency_pt;
-
-typedef enum dm_service_dependency_strategy_enum {
- DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING,
- DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
-} dm_service_dependency_strategy_t;
-
-typedef int (*service_set_fpt)(void *handle, const void* service);
-typedef int (*service_add_fpt)(void *handle, const void* service);
-typedef int (*service_change_fpt)(void *handle, const void* service);
-typedef int (*service_remove_fpt)(void *handle, const void* service);
-typedef int (*service_swap_fpt)(void *handle, const void* oldService, const void* newService);
-
-typedef celix_status_t (*service_set_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
-typedef celix_status_t (*service_add_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
-typedef celix_status_t (*service_change_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
-typedef celix_status_t (*service_remove_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
-typedef celix_status_t (*service_swap_with_ref_fpt)(void *handle, service_reference_pt oldReference, const void* oldService, service_reference_pt newReference, const void* newService);
-
-/**
- * Create a service dependency.
- * Caller has ownership.
- */
-celix_status_t serviceDependency_create(dm_service_dependency_pt *dependency_ptr);
-
-/**
- * Destroys a service dependency.
- * Caller has ownership.
- */
-celix_status_t serviceDependency_destroy(dm_service_dependency_pt *dependency_ptr);
-
-/**
- * Specify if the service dependency is required. default is false
- */
-celix_status_t serviceDependency_setRequired(dm_service_dependency_pt 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 serviceDependency_setAddCLanguageFilter(dm_service_dependency_pt 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 serviceDependency_setStrategy(dm_service_dependency_pt dependency,dm_service_dependency_strategy_t strategy);
-
-/**
- * Return the service dependency update strategy.
- */
-celix_status_t serviceDependency_getStrategy(dm_service_dependency_pt dependency,dm_service_dependency_strategy_t* strategy);
-
-/**
- * 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 serviceDependency_setService(dm_service_dependency_pt dependency, const char* serviceName, const char* serviceVersionRange, const char* filter);
-
-/**
- * Returns the service depenendy filter.
- */
-celix_status_t serviceDependency_getFilter(dm_service_dependency_pt dependency, const char** filter);
-
-/**
- * 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 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_pt dependency, service_set_fpt set, service_add_fpt add, service_change_fpt change, service_remove_fpt remove, service_swap_fpt swap);
-
-/**
- * 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 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 reference of the a service instance of the specified service dependency.
- */
-celix_status_t serviceDependency_setCallbacksWithServiceReference(dm_service_dependency_pt 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);
-
-/**
- * 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_pt dependency, celix_thread_mutex_t *service_lock, const void** field);
-
-#define serviceDependency_setCallbacksSafe(dep, cmpType, servType, set, add, change, remove, swap) \
- do { \
- int (*tmpSet)(cmpType, servType) = set; \
- int (*tmpAdd)(cmpType, servType) = add; \
- int (*tmpChange)(cmpType, servType) = change; \
- int (*tmpRemove)(cmpType, servType) = remove; \
- int (*tmpSwap)(cmpType, servType, servType) = swap; \
- serviceDependency_setCallbacks((dep), (service_set_fpt)tmpSet, (service_add_fpt)tmpAdd, (service_change_fpt)tmpChange, (service_remove_fpt)tmpRemove, (service_swap_fpt)tmpSwap); \
- } while(0)
-
-/**
- * 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 serviceDependency_setCallbackHandle(dm_service_dependency_pt dependency, void* handle);
-
-/**
- * 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_pt, dm_service_dependency_info_pt *info);
-
-/**
- * Destroy a provided service dependency info struct.
- */
-void dependency_destroyDependencyInfo(dm_service_dependency_info_pt info);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DM_SERVICE_DEPENDENCY_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/5992be15/dependency_manager/src/dm_activator.c
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_activator.c b/dependency_manager/src/dm_activator.c
deleted file mode 100644
index 8de3bf1..0000000
--- a/dependency_manager/src/dm_activator.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "dm_activator.h"
-
-#include <stdlib.h>
-
-struct dm_dependency_activator_base {
- dm_dependency_manager_pt manager;
- bundle_context_pt context;
- service_registration_pt reg;
- dm_info_service_pt info;
- void* userData;
-};
-
-typedef struct dm_dependency_activator_base * dependency_activator_base_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- celix_status_t status = CELIX_ENOMEM;
-
- dependency_activator_base_pt dependency_activator = calloc(1, sizeof(struct dm_dependency_activator_base));
- dm_info_service_pt serv = calloc(1, sizeof(*serv));
-
- if (dependency_activator != NULL && serv != NULL) {
- dependency_activator->context = context;
- dm_create(context, &dependency_activator->userData);
- dependency_activator->info = serv;
-
- status = dependencyManager_create(dependency_activator->context, &dependency_activator->manager);
- } else {
- status = CELIX_ENOMEM;
-
- }
-
- if (status == CELIX_SUCCESS) {
- *userData = dependency_activator;
- } else {
- if (dependency_activator != NULL) {
- dependencyManager_destroy(dependency_activator->manager);
- }
- free(dependency_activator);
- free(serv);
- }
-
- return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
- celix_status_t status;
- dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
-
-
- status = dm_init(dependency_activator->userData, context, dependency_activator->manager);
-
- if (status == CELIX_SUCCESS) {
- //Create the service
- dependency_activator->info->handle = dependency_activator->manager;
- dependency_activator->info->getInfo = (void *) dependencyManager_getInfo;
- dependency_activator->info->destroyInfo = (void *) dependencyManager_destroyInfo;
-
- status = bundleContext_registerService(context, DM_INFO_SERVICE_NAME, dependency_activator->info, NULL,
- &(dependency_activator->reg));
- }
-
- return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context __attribute__((unused))) {
- celix_status_t status = CELIX_SUCCESS;
- dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
-
- // Remove the service
- status = serviceRegistration_unregister(dependency_activator->reg);
- dependencyManager_removeAllComponents(dependency_activator->manager);
-
- return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context __attribute__((unused))) {
- celix_status_t status = CELIX_SUCCESS;
- dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
-
- if(dependency_activator==NULL){
- return CELIX_ILLEGAL_ARGUMENT;
- }
-
- status = dm_destroy(dependency_activator->userData, dependency_activator->context,
- dependency_activator->manager);
-
- if (status == CELIX_SUCCESS) {
- dependencyManager_destroy(dependency_activator->manager);
- }
-
- dependency_activator->userData = NULL;
- dependency_activator->manager = NULL;
-
- if (dependency_activator != NULL) {
- free(dependency_activator->info);
- }
- free(dependency_activator);
-
- return status;
-}
\ No newline at end of file