celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [1/2] celix git commit: CELIX-446: Reverts dependency_manager back to a (now minimal) static lib instead of empty interface lib
Date Fri, 25 May 2018 12:23:59 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 9e6bb84b3 -> 7b427160b


CELIX-446: Reverts dependency_manager back to a (now minimal) static lib instead of empty
interface lib


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/2883d9af
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/2883d9af
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/2883d9af

Branch: refs/heads/develop
Commit: 2883d9af26be3e02b259626d19ca1204253c5074
Parents: 03df0ed
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Fri May 25 14:19:49 2018 +0200
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Fri May 25 14:19:49 2018 +0200

----------------------------------------------------------------------
 dependency_manager/CMakeLists.txt     | 20 ++++++++--
 dependency_manager/api/dm_activator.h | 63 ++++++++++++++++++++++++++++++
 dependency_manager/src/dm_activator.c | 41 +++++++++++++++++++
 framework/src/bundle_context.c        |  1 +
 framework/src/framework.c             | 44 +++------------------
 shell/CMakeLists.txt                  |  4 +-
 shell/src/dm_shell_list_command.c     | 19 +++++----
 7 files changed, 140 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/2883d9af/dependency_manager/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/dependency_manager/CMakeLists.txt b/dependency_manager/CMakeLists.txt
index eb6f428..c236adb 100644
--- a/dependency_manager/CMakeLists.txt
+++ b/dependency_manager/CMakeLists.txt
@@ -16,8 +16,21 @@
 # under the License.
 
 #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(dependency_manager_static STATIC src/dm_activator.c)
+target_include_directories(dependency_manager_static PUBLIC
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/api>
+        $<INSTALL_INTERFACE:include/celix/dependency_manager>
+)
+target_link_libraries(dependency_manager_static PUBLIC Celix::framework)
+
+add_library(dependency_manager_so SHARED src/dm_activator.c)
+target_include_directories(dependency_manager_so PUBLIC
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/api>
+        $<INSTALL_INTERFACE:include/celix/dependency_manager>
+)
+target_link_libraries(dependency_manager_so PUBLIC Celix::framework)
+
+#now part of the the shell bundle
 add_library(dm_shell INTERFACE)
 
 #Setup target aliases to match external usage
@@ -25,6 +38,7 @@ 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)
 
-#install dummy libs
+#install libs & dummy libs
 install(TARGETS dependency_manager_static dependency_manager_so dm_shell EXPORT celix DESTINATION
${CMAKE_INSTALL_LIBDIR} COMPONENT framework)
+install(DIRECTORY api/ DESTINATION include/celix/dependency_manager COMPONENT framework)
 

http://git-wip-us.apache.org/repos/asf/celix/blob/2883d9af/dependency_manager/api/dm_activator.h
----------------------------------------------------------------------
diff --git a/dependency_manager/api/dm_activator.h b/dependency_manager/api/dm_activator.h
new file mode 100644
index 0000000..ffbf6b2
--- /dev/null
+++ b/dependency_manager/api/dm_activator.h
@@ -0,0 +1,63 @@
+/**
+ * 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 "celix_bundle_context.h"
+#include "dm_dependency_manager.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(celix_bundle_context_t *ctx, 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, celix_bundle_context_t *ctx, dm_dependency_manager_t
*mng);
+
+/**
+ * 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, celix_bundle_context_t *ctx, dm_dependency_manager_t
*mng);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DM_ACTIVATOR_BASE_H_ */
+

http://git-wip-us.apache.org/repos/asf/celix/blob/2883d9af/dependency_manager/src/dm_activator.c
----------------------------------------------------------------------
diff --git a/dependency_manager/src/dm_activator.c b/dependency_manager/src/dm_activator.c
new file mode 100644
index 0000000..8a99803
--- /dev/null
+++ b/dependency_manager/src/dm_activator.c
@@ -0,0 +1,41 @@
+/**
+ * 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>
+
+
+celix_status_t bundleActivator_create(celix_bundle_context_t *ctx, void **userData) {
+    return dm_create(ctx, userData);
+}
+
+celix_status_t bundleActivator_start(void *userData, celix_bundle_context_t *ctx) {
+    dm_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx);
+    return dm_init(userData, ctx, mng);
+}
+
+celix_status_t bundleActivator_stop(void * userData __attribute__((unused)), celix_bundle_context_t
*ctx __attribute__((unused))) {
+    return CELIX_SUCCESS; //nothing to do (no dm_deinit)
+}
+
+celix_status_t bundleActivator_destroy(void * userData, celix_bundle_context_t *ctx __attribute__((unused)))
{
+    dm_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(ctx);
+    return dm_destroy(userData, ctx, mng);
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/2883d9af/framework/src/bundle_context.c
----------------------------------------------------------------------
diff --git a/framework/src/bundle_context.c b/framework/src/bundle_context.c
index 2407e2d..3e075d0 100644
--- a/framework/src/bundle_context.c
+++ b/framework/src/bundle_context.c
@@ -84,6 +84,7 @@ celix_status_t bundleContext_destroy(bundle_context_pt context) {
 	    arrayList_destroy(context->svcRegistrations);
 
 	    if (context->mng != NULL) {
+	        dependencyManager_removeAllComponents(context->mng);
             dependencyManager_destroy(context->mng);
             context->mng = NULL;
 	    }

http://git-wip-us.apache.org/repos/asf/celix/blob/2883d9af/framework/src/framework.c
----------------------------------------------------------------------
diff --git a/framework/src/framework.c b/framework/src/framework.c
index 2460434..6554e40 100644
--- a/framework/src/framework.c
+++ b/framework/src/framework.c
@@ -42,16 +42,13 @@
 #include "service_registration_private.h"
 #include "bundle_private.h"
 #include "celix_bundle_context.h"
+#include "bundle_context_private.h"
 
 typedef celix_status_t (*create_function_fp)(bundle_context_t *context, void **userData);
 typedef celix_status_t (*start_function_fp)(void *userData, bundle_context_t *context);
 typedef celix_status_t (*stop_function_fp)(void *userData, bundle_context_t *context);
 typedef celix_status_t (*destroy_function_fp)(void *userData, bundle_context_t *context);
 
-typedef celix_status_t (*dm_create_fp)(bundle_context_t *context, void ** userData);
-typedef celix_status_t (*dm_init_fp)(void * userData, bundle_context_pt context, dm_dependency_manager_pt
manager);
-typedef celix_status_t (*dm_destroy_fp)(void * userData, bundle_context_pt context, dm_dependency_manager_pt
manager);
-
 struct activator {
     void * userData;
 
@@ -59,10 +56,6 @@ struct activator {
     start_function_fp start;
     stop_function_fp stop;
     destroy_function_fp destroy;
-
-    dm_create_fp dmCreate;
-    dm_init_fp dmInit;
-    dm_destroy_fp dmDestroy;
 };
 
 celix_status_t framework_setBundleStateAndNotify(framework_pt framework, bundle_pt bundle,
int state);
@@ -794,27 +787,11 @@ celix_status_t fw_startBundle(framework_pt framework, bundle_pt bundle,
int opti
                         stop_function_fp stop = (stop_function_fp) fw_getSymbol((handle_t)
bundle_getHandle(bundle), OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP);
                         destroy_function_fp destroy = (destroy_function_fp) fw_getSymbol((handle_t)
bundle_getHandle(bundle), OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY);
 
-                        dm_create_fp dmCreate = fw_getSymbol((handle_t)bundle_getHandle(bundle),
OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_CREATE);
-                        dm_init_fp dmInit = fw_getSymbol((handle_t)bundle_getHandle(bundle),
OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_INIT);
-                        dm_destroy_fp dmDestroy = fw_getSymbol((handle_t)bundle_getHandle(bundle),
OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_DESTROY);
-
                         activator->create = create;
                         activator->start = start;
                         activator->stop = stop;
                         activator->destroy = destroy;
 
-                        activator->dmCreate = dmCreate;
-                        activator->dmInit = dmInit;
-                        activator->dmDestroy = dmDestroy;
-
-                        if (activator->dmCreate != NULL) {
-                            //only allow one activator, if dm is used -> set other to
NULL
-                            activator->create = NULL;
-                            activator->start = NULL;
-                            activator->stop = NULL;
-                            activator->destroy = NULL;
-                        }
-
                         status = CELIX_DO_IF(status, bundle_setActivator(bundle, activator));
 
                         status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework,
bundle, OSGI_FRAMEWORK_BUNDLE_STARTING));
@@ -828,19 +805,11 @@ celix_status_t fw_startBundle(framework_pt framework, bundle_pt bundle,
int opti
                                 if (status == CELIX_SUCCESS) {
                                     activator->userData = userData;
                                 }
-                            } else if (dmCreate != NULL) {
-                                status = CELIX_DO_IF(status, dmCreate(context, &userData));
-                                if (status == CELIX_SUCCESS) {
-                                    activator->userData = userData;
-                                }
                             }
                         }
                         if (status == CELIX_SUCCESS) {
                             if (start != NULL) {
                                 status = CELIX_DO_IF(status, start(userData, context));
-                            } else if (dmInit != NULL) {
-                                dm_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(context);
-                                status = CELIX_DO_IF(status, dmInit(userData, context, mng));
                             }
                         }
 
@@ -1004,18 +973,15 @@ celix_status_t fw_stopBundle(framework_pt framework, bundle_pt bundle,
bool reco
 	        if (status == CELIX_SUCCESS) {
                 if (activator->stop != NULL) {
                     status = CELIX_DO_IF(status, activator->stop(activator->userData,
context));
-                } else if (activator->dmInit != NULL) {
-                    //NOTE there is no dmDeinit -> "just" call removeAllComponents
-                    dm_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(context);
-                    dependencyManager_removeAllComponents(mng);
+                    if (status == CELIX_SUCCESS) {
+                        dm_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(context);
+                        dependencyManager_removeAllComponents(mng);
+                    }
                 }
 	        }
             if (status == CELIX_SUCCESS) {
                 if (activator->destroy != NULL) {
                     status = CELIX_DO_IF(status, activator->destroy(activator->userData,
context));
-                } else if (activator->dmDestroy != NULL) {
-                    dm_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(context);
-                    status = CELIX_DO_IF(status, activator->dmDestroy(activator->userData,
context, mng));
                 }
 	        }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/2883d9af/shell/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt
index 622e0ee..7bba23b 100644
--- a/shell/CMakeLists.txt
+++ b/shell/CMakeLists.txt
@@ -23,7 +23,7 @@ if (SHELL)
 			$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
 			$<INSTALL_INTERFACE:include/celix/shell>
 	)
-        install(TARGETS shell_api EXPORT celix COMPONENT shell)
+	install(TARGETS shell_api EXPORT celix COMPONENT shell)
 	install(DIRECTORY include/ DESTINATION include/celix/shell COMPONENT shell)
 
     add_celix_bundle(shell
@@ -45,7 +45,7 @@ if (SHELL)
 		  src/dm_shell_list_command
 	)
 	target_include_directories(shell PRIVATE src)
-        target_include_directories(shell SYSTEM PRIVATE	${CURL_INCLUDE_DIRS})
+	target_include_directories(shell SYSTEM PRIVATE	${CURL_INCLUDE_DIRS})
 	target_link_libraries(shell PRIVATE Celix::shell_api ${CURL_LIBRARIES} Celix::log_service_api
Celix::log_helper)
 
 	install_celix_bundle(shell EXPORT celix COMPONENT shell)

http://git-wip-us.apache.org/repos/asf/celix/blob/2883d9af/shell/src/dm_shell_list_command.c
----------------------------------------------------------------------
diff --git a/shell/src/dm_shell_list_command.c b/shell/src/dm_shell_list_command.c
index d2a0dbb..6b92c17 100644
--- a/shell/src/dm_shell_list_command.c
+++ b/shell/src/dm_shell_list_command.c
@@ -166,16 +166,19 @@ celix_status_t dmListCommand_execute(void* handle, char * line, FILE
*out, FILE
                 dm_dependency_manager_info_t *info = NULL;
                 dependencyManager_getInfo(mng, &info);
                 if (info != NULL) {
-                    fprintf(out, "[Bundle: %ld]\n", bndId);
-                    for (unsigned int cmpCnt = 0; cmpCnt < arrayList_size(info->components);
cmpCnt++) {
-                        dm_component_info_pt compInfo = arrayList_get(info->components,
cmpCnt);
-                        if (fullInfo) {
-                            printFullInfo(out, useColors, compInfo);
-                        } else {
-                            printBasicInfo(out, useColors, compInfo);
+                    size_t size = celix_arrayList_size(info->components);
+                    if (size > 0) {
+                        fprintf(out, "[Bundle: %ld]\n", bndId);
+                        for (unsigned int cmpCnt = 0; cmpCnt < size; cmpCnt++) {
+                            dm_component_info_pt compInfo = celix_arrayList_get(info->components,
cmpCnt);
+                            if (fullInfo) {
+                                printFullInfo(out, useColors, compInfo);
+                            } else {
+                                printBasicInfo(out, useColors, compInfo);
+                            }
                         }
+                        fprintf(out, "\n");
                     }
-                    fprintf(out, "\n");
                     dependencyManager_destroyInfo(mng, info);
                 }
 


Mime
View raw message