This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch feature/gh-142-rsa-issues
in repository https://gitbox.apache.org/repos/asf/celix.git
The following commit(s) were added to refs/heads/feature/gh-142-rsa-issues by
this push:
new 83a602a gh-142: Adds missing files
83a602a is described below
commit 83a602afd16aaa7877fb741c4e5db03087366900
Author: Pepijn Noltes <[email protected]>
AuthorDate: Tue Jan 21 16:59:20 2020 +0100
gh-142: Adds missing files
---
.../examples/remote_example_api/CMakeLists.txt | 26 ++++++++
.../remote_example_api/include/remote_example.h | 50 ++++++++++++++
.../org.apache.celix.RemoteExample.avdl | 19 ++++++
.../org.apache.celix.RemoteExample.avpr | 55 ++++++++++++++++
.../examples/remote_example_service/CMakeLists.txt | 29 +++++++++
.../src/remote_example_activator.c | 60 +++++++++++++++++
.../src/remote_example_impl.c | 76 ++++++++++++++++++++++
.../src/remote_example_impl.h | 36 ++++++++++
8 files changed, 351 insertions(+)
diff --git a/bundles/remote_services/examples/remote_example_api/CMakeLists.txt
b/bundles/remote_services/examples/remote_example_api/CMakeLists.txt
new file mode 100644
index 0000000..1a3a3bb
--- /dev/null
+++ b/bundles/remote_services/examples/remote_example_api/CMakeLists.txt
@@ -0,0 +1,26 @@
+# 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.
+
+#[[
+Note use avro-tools.jar (idl command) to generate avpr from avdl
+#]]
+
+add_library(remote_example_api INTERFACE)
+target_include_directories(remote_example_api INTERFACE include)
+set_target_properties(remote_example_api PROPERTIES
+ "INTERFACE_DESCRIPTOR"
+ "${CMAKE_CURRENT_LIST_DIR}/org.apache.celix.RemoteExample.avpr")
diff --git
a/bundles/remote_services/examples/remote_example_api/include/remote_example.h
b/bundles/remote_services/examples/remote_example_api/include/remote_example.h
new file mode 100644
index 0000000..da60648
--- /dev/null
+++
b/bundles/remote_services/examples/remote_example_api/include/remote_example.h
@@ -0,0 +1,50 @@
+/**
+ *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_REMOTE_EXAMPLE_H
+#define CELIX_REMOTE_EXAMPLE_H
+
+#include <stdint.h>
+
+struct complex {
+ double a;
+ double b;
+ struct {
+ int32_t len;
+ int32_t cap;
+ char** buf;
+ };
+};
+
+#define REMOTE_EXAMPLE_NAME "org.apache.celix.RemoteExample"
+
+typedef struct remote_example {
+ void *handle;
+
+ int (*pow)(void *handle, double a, double b, double *out);
+ int (*fib)(void *handle, int32_t n, int32_t *out);
+
+ int (*setName1)(void *handle, char *n, char **out);
+ int (*setName2)(void *handle, const char *n, char **out);
+
+ //TODO int (*updateComplex)(void *handle, struct complex *c, struct
complex **out);
+
+} remote_example_t;
+
+#endif //CELIX_REMOTE_EXAMPLE_H
diff --git
a/bundles/remote_services/examples/remote_example_api/org.apache.celix.RemoteExample.avdl
b/bundles/remote_services/examples/remote_example_api/org.apache.celix.RemoteExample.avdl
new file mode 100644
index 0000000..417c8b2
--- /dev/null
+++
b/bundles/remote_services/examples/remote_example_api/org.apache.celix.RemoteExample.avdl
@@ -0,0 +1,19 @@
+@namespace("org.apache.celix")
+protocol RemoteExample {
+
+ //simple input
+ double pow(double a, double b);
+ int fib(int n);
+
+ //string input
+ string setName1(string n); //callee takes ownership of string n
+ string setName2(string @const(true) n); //caller keeps ownership of string n
+
+ record Complex {
+ double a;
+ double b;
+ array<string> names;
+ }
+
+ //Complex updateComplex(Complex c);
+}
\ No newline at end of file
diff --git
a/bundles/remote_services/examples/remote_example_api/org.apache.celix.RemoteExample.avpr
b/bundles/remote_services/examples/remote_example_api/org.apache.celix.RemoteExample.avpr
new file mode 100644
index 0000000..54c32ac
--- /dev/null
+++
b/bundles/remote_services/examples/remote_example_api/org.apache.celix.RemoteExample.avpr
@@ -0,0 +1,55 @@
+{
+ "protocol" : "RemoteExample",
+ "namespace" : "org.apache.celix",
+ "types" : [ {
+ "type" : "record",
+ "name" : "Complex",
+ "fields" : [ {
+ "name" : "a",
+ "type" : "double"
+ }, {
+ "name" : "b",
+ "type" : "double"
+ }, {
+ "name" : "names",
+ "type" : {
+ "type" : "array",
+ "items" : "string"
+ }
+ } ]
+ } ],
+ "messages" : {
+ "pow" : {
+ "request" : [ {
+ "name" : "a",
+ "type" : "double"
+ }, {
+ "name" : "b",
+ "type" : "double"
+ } ],
+ "response" : "double"
+ },
+ "fib" : {
+ "request" : [ {
+ "name" : "n",
+ "type" : "int"
+ } ],
+ "response" : "int"
+ },
+ "setName1" : {
+ "request" : [ {
+ "name" : "n",
+ "type" : "string"
+ } ],
+ "response" : "string"
+ },
+ "setName2" : {
+ "request" : [ {
+ "name" : "n",
+ "type" : "string",
+ "const" : true
+ } ],
+ "response" : "string"
+ }
+ }
+}
\ No newline at end of file
diff --git
a/bundles/remote_services/examples/remote_example_service/CMakeLists.txt
b/bundles/remote_services/examples/remote_example_service/CMakeLists.txt
new file mode 100644
index 0000000..03a2261
--- /dev/null
+++ b/bundles/remote_services/examples/remote_example_service/CMakeLists.txt
@@ -0,0 +1,29 @@
+# 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.
+
+add_celix_bundle(remote_example_service
+ SOURCES
+ src/remote_example_activator.c
+ src/remote_example_impl.c
+ SYMBOLIC_NAME "apache_celix_remote_example_service"
+ VERSION 0.0.1
+)
+target_include_directories(remote_example_service PRIVATE src)
+target_link_libraries(remote_example_service PRIVATE Celix::rsa_spi
remote_example_api)
+
+get_target_property(DESCR remote_example_api INTERFACE_DESCRIPTOR)
+celix_bundle_files(remote_example_service ${DESCR} DESTINATION .)
diff --git
a/bundles/remote_services/examples/remote_example_service/src/remote_example_activator.c
b/bundles/remote_services/examples/remote_example_service/src/remote_example_activator.c
new file mode 100644
index 0000000..98092e2
--- /dev/null
+++
b/bundles/remote_services/examples/remote_example_service/src/remote_example_activator.c
@@ -0,0 +1,60 @@
+/**
+ *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 <stdlib.h>
+
+#include <celix_api.h>
+
+#include "remote_example.h"
+#include "remote_constants.h"
+#include "remote_example_impl.h"
+
+struct activator {
+ remote_example_impl_t *impl;
+ remote_example_t service;
+ long svcId;
+};
+
+celix_status_t remoteExampleBndStart(struct activator *act,
celix_bundle_context_t *ctx) {
+ act->svcId = -1L;
+ act->impl = remoteExample_create();
+ if (act->impl != NULL) {
+ act->service.handle = act->impl;
+ act->service.pow = (void*)remoteExample_fib;
+ act->service.fib = (void*)remoteExample_fib;
+ act->service.setName1 = (void*)remoteExample_fib;
+ act->service.setName2 = (void*)remoteExample_fib;
+ //TODO update complex
+
+ celix_properties_t *properties = celix_properties_create();
+ celix_properties_set(properties, OSGI_RSA_SERVICE_EXPORTED_INTERFACES,
REMOTE_EXAMPLE_NAME);
+ act->svcId = celix_bundleContext_registerService(ctx, &act->service,
REMOTE_EXAMPLE_NAME, properties);
+ }
+ return CELIX_SUCCESS;
+}
+
+celix_status_t remoteExampleBndStop(struct activator *act,
celix_bundle_context_t *ctx) {
+ celix_bundleContext_unregisterService(ctx, act->svcId);
+ if (act->impl != NULL) {
+ remoteExample_destroy(act->impl);
+ }
+ return CELIX_SUCCESS;
+}
+
+CELIX_GEN_BUNDLE_ACTIVATOR(struct activator, remoteExampleBndStart,
remoteExampleBndStop);
diff --git
a/bundles/remote_services/examples/remote_example_service/src/remote_example_impl.c
b/bundles/remote_services/examples/remote_example_service/src/remote_example_impl.c
new file mode 100644
index 0000000..b1193b2
--- /dev/null
+++
b/bundles/remote_services/examples/remote_example_service/src/remote_example_impl.c
@@ -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.
+ */
+
+#include <math.h>
+#include <string.h>
+
+#include "remote_example_impl.h"
+
+struct remote_example_impl {
+ char *name;
+};
+
+remote_example_impl_t* remoteExample_create(void) {
+ return calloc(1, sizeof(remote_example_impl_t));
+}
+void remoteExample_destroy(remote_example_impl_t* impl) {
+ if (impl != NULL) {
+ free(impl->name);
+ }
+ free(impl);
+}
+
+int remoteExample_pow(remote_example_impl_t* impl, double a, double b, double
*out) {
+ *out = pow(a, b);
+ return 0;
+}
+
+static int fib_int(int n)
+{
+ if (n <= 1) {
+ return n;
+ } else {
+ return fib_int(n-1) + fib_int(n-2);
+ }
+}
+
+int remoteExample_fib(remote_example_impl_t* impl, int32_t a, int32_t *out) {
+ *out = fib_int(a);
+ return 0;
+}
+
+int remoteExample_setName1(remote_example_impl_t* impl, char *n, char **out) {
+ //note taking ownership of n;
+ if (impl->name != NULL) {
+ free(impl->name);
+ }
+ impl->name = n;
+ *out = strndup(impl->name, 1024 * 1024);
+ return 0;
+}
+
+int remoteExample_setName2(remote_example_impl_t* impl, const char *n, char
**out) {
+ //note _not_ taking ownership of n;
+ if (impl->name != NULL) {
+ free(impl->name);
+ }
+ impl->name = strndup(n, 1024 * 1024);
+ *out = strndup(impl->name, 1024 * 1024);
+ return 0;
+}
\ No newline at end of file
diff --git
a/bundles/remote_services/examples/remote_example_service/src/remote_example_impl.h
b/bundles/remote_services/examples/remote_example_service/src/remote_example_impl.h
new file mode 100644
index 0000000..3bd2f70
--- /dev/null
+++
b/bundles/remote_services/examples/remote_example_service/src/remote_example_impl.h
@@ -0,0 +1,36 @@
+/**
+ *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_REMOTE_EXAMPLE_IMPL_H
+#define CELIX_REMOTE_EXAMPLE_IMPL_H
+
+#include <stdlib.h>
+
+typedef struct remote_example_impl remote_example_impl_t;
+
+remote_example_impl_t* remoteExample_create(void);
+void remoteExample_destroy(remote_example_impl_t* impl);
+
+int remoteExample_pow(remote_example_impl_t* impl, double a, double b, double
*out);
+int remoteExample_fib(remote_example_impl_t* impl, int32_t a, int32_t *out);
+int remoteExample_setName1(remote_example_impl_t* impl, char *n, char **out);
+int remoteExample_setName2(remote_example_impl_t* impl, const char *n, char
**out);
+
+//TODO complex
+#endif //CELIX_REMOTE_EXAMPLE_IMPL_H