celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject celix git commit: CELIX-446: Some small additions to the updated api and added some api documentation
Date Thu, 24 May 2018 18:45:10 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 03df0edc9 -> 9e6bb84b3


CELIX-446: Some small additions to the updated api and added some api documentation


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

Branch: refs/heads/develop
Commit: 9e6bb84b32ee5a8b3b282fbcc4ff243f1343c388
Parents: 03df0ed
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Thu May 24 20:44:37 2018 +0200
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Thu May 24 20:44:37 2018 +0200

----------------------------------------------------------------------
 dependency_manager/CMakeLists.txt   |  2 ++
 framework/include/celix_bundle.h    | 28 +++++++++++----
 framework/include/celix_framework.h | 58 ++++++++++++++++++++++++++++++++
 framework/src/bundle.c              |  8 +++++
 framework/src/framework.c           | 28 ++++++++++++++-
 framework/src/framework_private.h   |  1 +
 6 files changed, 118 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/9e6bb84b/dependency_manager/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/dependency_manager/CMakeLists.txt b/dependency_manager/CMakeLists.txt
index eb6f428..a65f9f0 100644
--- a/dependency_manager/CMakeLists.txt
+++ b/dependency_manager/CMakeLists.txt
@@ -17,7 +17,9 @@
 
 #dummy libaries to ensure backward compatability with projects using the dependency manager
libs/shell
 add_library(dependency_manager_static INTERFACE)
+target_link_libraries(dependency_manager_static INTERFACE Celix::framework)
 add_library(dependency_manager_so INTERFACE)
+target_link_libraries(dependency_manager_so INTERFACE Celix::framework)
 add_library(dm_shell INTERFACE)
 
 #Setup target aliases to match external usage

http://git-wip-us.apache.org/repos/asf/celix/blob/9e6bb84b/framework/include/celix_bundle.h
----------------------------------------------------------------------
diff --git a/framework/include/celix_bundle.h b/framework/include/celix_bundle.h
index 74ea9bf..62fdfd0 100644
--- a/framework/include/celix_bundle.h
+++ b/framework/include/celix_bundle.h
@@ -27,16 +27,32 @@
 extern "C" {
 #endif
 
-/**********************************************************************************************************************
- **********************************************************************************************************************
- * Updated API
- **********************************************************************************************************************
- **********************************************************************************************************************/
-
+/**
+ * Returns the bundle id.
+ * @param bnd The bundle
+ * @return The bundle id or < 0 if something went wrong.
+ */
 long celix_bundle_getId(const bundle_t *bnd);
 
+/**
+ * Returns the bundle state.
+ * @param bnd The bundle
+ * @return The bundle state or OSGI_FRAMEWORK_BUNDLE_UNKNOWN if something went wrong.
+ */
 celix_bundle_state_e celix_bundle_getState(const bundle_t *bnd);
 
+/**
+ * Returns a the use-able entry path for the provided relative path to a bundle resource.
+ *
+ * For example if there is a resource entry in the bundle at path 'META-INF/descriptors/foo.descriptor`
this call
+ * will return a absolute or relative path to the extracted location of the bundle resource,
e.g.:
+ * .cache/bundle5/version0.0/META-INF/descriptors/foo.descriptor
+ *
+ * The caller is responsible for freeing the returned path entry.
+ * @param bnd The bundle
+ * @return A use-able path to the bundle resource entry of NULL if the entry is not found.
+ */
+char* celix_bundle_getEntry(const bundle_t* bnd, const char *path);
 
 
 #ifdef __cplusplus

http://git-wip-us.apache.org/repos/asf/celix/blob/9e6bb84b/framework/include/celix_framework.h
----------------------------------------------------------------------
diff --git a/framework/include/celix_framework.h b/framework/include/celix_framework.h
new file mode 100644
index 0000000..ac3193e
--- /dev/null
+++ b/framework/include/celix_framework.h
@@ -0,0 +1,58 @@
+/**
+ *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_FRAMEWORK_H_
+#define CELIX_FRAMEWORK_H_
+
+typedef struct framework celix_framework_t;
+
+#include "celix_types.h"
+#include "celix_properties.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Returns the framework UUID. This is unique for every created framework and will not be
the same if the process is
+ * restarted.
+ */
+const char* celix_framework_getUUID(const celix_framework_t *fw);
+
+/**
+ * Returns the framework bundle context. This is the same as a 'normal' bundle context and
can be used to register, use
+ * and track services. The only difference is that the framework is the bundle.
+ * @param fw The framework
+ * @return A pointer to the bundle context of the framework or NULL if something went wrong.
+ */
+celix_bundle_context_t* celix_framework_getFrameworkContext(const celix_framework_t *fw);
+
+/**
+ * Returns the framework bundle. This is the same as a 'normal' bundle, expect that this
bundle cannot be uninstalled
+ * and the `celix_bundle_getEntry` return a entries relative from the working directory.
+  * @param fw The framework
+ * @return A pointer to the bundle of the framework or NULL if something went wrong.
+ */
+celix_bundle_t* celix_framework_getFrameworkBundle(const celix_framework_t *fw);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CELIX_FRAMEWORK_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/9e6bb84b/framework/src/bundle.c
----------------------------------------------------------------------
diff --git a/framework/src/bundle.c b/framework/src/bundle.c
index fc4cd08..6493c9f 100644
--- a/framework/src/bundle.c
+++ b/framework/src/bundle.c
@@ -714,4 +714,12 @@ long celix_bundle_getId(const bundle_t* bnd) {
 
 celix_bundle_state_e celix_bundle_getState(const bundle_t *bnd) {
 	return bnd->state;
+}
+
+char* celix_bundle_getEntry(const bundle_t* bnd, const char *path) {
+	char *entry = NULL;
+	if (bnd != NULL && bnd->framework != NULL) {
+		framework_getBundleEntry(bnd->framework, (celix_bundle_t*)bnd, path, &entry);
+	}
+	return entry;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/9e6bb84b/framework/src/framework.c
----------------------------------------------------------------------
diff --git a/framework/src/framework.c b/framework/src/framework.c
index 2460434..769ff08 100644
--- a/framework/src/framework.c
+++ b/framework/src/framework.c
@@ -2800,4 +2800,30 @@ service_registration_t* celix_framework_registerServiceFactory(framework_t
*fw ,
     framework_logIfError(fw->logger, status, error, "Cannot register service factory:
%s", serviceName);
 
     return reg;
-}
\ No newline at end of file
+}
+
+const char* celix_framework_getUUID(const celix_framework_t *fw) {
+    if (fw != NULL) {
+        return celix_properties_get(fw->configurationMap, OSGI_FRAMEWORK_FRAMEWORK_UUID);
+    }
+    return NULL;
+}
+
+
+celix_bundle_context_t* celix_framework_getFrameworkContext(const celix_framework_t *fw)
{
+    celix_bundle_context_t* ctx = NULL;
+    if (fw != NULL) {
+        if (fw->bundle != NULL) {
+            ctx = fw->bundle->context;
+        }
+    }
+    return ctx;
+}
+
+celix_bundle_t* celix_framework_getFrameworkBundle(const celix_framework_t *fw) {
+    celix_bundle_t* bnd = NULL;
+    if (fw != NULL) {
+        bnd = fw->bundle;
+    }
+    return bnd;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/9e6bb84b/framework/src/framework_private.h
----------------------------------------------------------------------
diff --git a/framework/src/framework_private.h b/framework/src/framework_private.h
index ab0a940..dcfe75f 100644
--- a/framework/src/framework_private.h
+++ b/framework/src/framework_private.h
@@ -28,6 +28,7 @@
 #ifndef FRAMEWORK_PRIVATE_H_
 #define FRAMEWORK_PRIVATE_H_
 
+#include "celix_framework.h"
 #include "framework.h"
 
 #include "manifest.h"


Mime
View raw message