celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rlenfer...@apache.org
Subject [celix] 01/03: Fixed RSA calculator example
Date Wed, 26 Jun 2019 20:38:54 GMT
This is an automated email from the ASF dual-hosted git repository.

rlenferink pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/celix.git

commit ae0d1dd31c8590cccc3bf85667f8dc35695aebaf
Author: Roy Lenferink <lenferinkroy@gmail.com>
AuthorDate: Wed Jun 26 12:46:32 2019 +0200

    Fixed RSA calculator example
---
 bundles/remote_services/examples/CMakeLists.txt           |  4 ++++
 .../examples/calculator_api/CMakeLists.txt                |  2 +-
 .../examples/calculator_api/include/calculator_service.h  |  1 -
 ...or => org.apache.celix.calc.api.Calculator.descriptor} |  0
 .../calculator_service/src/calculator_activator.c         | 15 +++------------
 .../examples/calculator_shell/CMakeLists.txt              |  6 ++----
 .../examples/calculator_shell/src/add_command.c           |  6 +-----
 .../src/org.apache.celix.calc.api.Calculator.descriptor}  |  2 +-
 .../src/org.apache.celix.calc.api.Calculator2.descriptor  | 11 -----------
 .../examples/calculator_shell/src/sqrt_command.c          |  6 +-----
 .../examples/calculator_shell/src/sub_command.c           |  6 +-----
 .../remote_service_admin_dfi/test/src/rsa_tests.cpp       |  2 +-
 .../remote_service_admin_dfi/test/src/tst_activator.c     |  2 +-
 .../topology_manager/tms_tst/tms_tests.cpp                |  2 +-
 14 files changed, 17 insertions(+), 48 deletions(-)

diff --git a/bundles/remote_services/examples/CMakeLists.txt b/bundles/remote_services/examples/CMakeLists.txt
index 1989d5b..c4a029a 100644
--- a/bundles/remote_services/examples/CMakeLists.txt
+++ b/bundles/remote_services/examples/CMakeLists.txt
@@ -56,6 +56,8 @@ if (RSA_EXAMPLES)
                 Celix::shell_tui
                 Celix::log_service
                 Celix::log_writer_stdout
+            PROPERTIES
+                RSA_PORT=8888
         )
 
         add_celix_container(remote-services-dfi-client
@@ -69,6 +71,8 @@ if (RSA_EXAMPLES)
                 Celix::log_writer_stdout
                 calculator_shell
                 Celix::rsa_discovery_etcd
+            PROPERTIES
+                RSA_PORT=8889
         )
     endif ()
 endif (RSA_EXAMPLES)
diff --git a/bundles/remote_services/examples/calculator_api/CMakeLists.txt b/bundles/remote_services/examples/calculator_api/CMakeLists.txt
index 76acfa7..2fb445b 100644
--- a/bundles/remote_services/examples/calculator_api/CMakeLists.txt
+++ b/bundles/remote_services/examples/calculator_api/CMakeLists.txt
@@ -19,4 +19,4 @@ add_library(calculator_api INTERFACE)
 target_include_directories(calculator_api INTERFACE include)
 set_target_properties(calculator_api PROPERTIES
     "INTERFACE_CALCULATOR_DESCRIPTOR"
-    "${CMAKE_CURRENT_LIST_DIR}/include/org.apache.celix.calc.api.Calculator2.descriptor")
\ No newline at end of file
+    "${CMAKE_CURRENT_LIST_DIR}/include/org.apache.celix.calc.api.Calculator.descriptor")
diff --git a/bundles/remote_services/examples/calculator_api/include/calculator_service.h
b/bundles/remote_services/examples/calculator_api/include/calculator_service.h
index 8e2f0dc..a194131 100644
--- a/bundles/remote_services/examples/calculator_api/include/calculator_service.h
+++ b/bundles/remote_services/examples/calculator_api/include/calculator_service.h
@@ -28,7 +28,6 @@
 #define CALCULATOR_SERVICE_H_
 
 #define CALCULATOR_SERVICE "org.apache.celix.calc.api.Calculator"
-#define CALCULATOR2_SERVICE "org.apache.celix.calc.api.Calculator2"
 
 
 typedef struct calculator *calculator_pt;
diff --git a/bundles/remote_services/examples/calculator_api/include/org.apache.celix.calc.api.Calculator2.descriptor
b/bundles/remote_services/examples/calculator_api/include/org.apache.celix.calc.api.Calculator.descriptor
similarity index 100%
copy from bundles/remote_services/examples/calculator_api/include/org.apache.celix.calc.api.Calculator2.descriptor
copy to bundles/remote_services/examples/calculator_api/include/org.apache.celix.calc.api.Calculator.descriptor
diff --git a/bundles/remote_services/examples/calculator_service/src/calculator_activator.c
b/bundles/remote_services/examples/calculator_service/src/calculator_activator.c
index 688a7b0..64b44fd 100644
--- a/bundles/remote_services/examples/calculator_service/src/calculator_activator.c
+++ b/bundles/remote_services/examples/calculator_service/src/calculator_activator.c
@@ -37,7 +37,6 @@ struct activator {
 	calculator_service_pt service;
 
 	service_registration_pt calculatorReg;
-	service_registration_pt calculatorReg2;
 };
 
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
@@ -49,7 +48,6 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 		status = CELIX_ENOMEM;
 	} else {
 		activator->calculatorReg = NULL;
-		activator->calculatorReg2 = NULL;
 
 		*userData = activator;
 	}
@@ -60,7 +58,6 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
 	celix_status_t status = CELIX_SUCCESS;
 	struct activator *activator = userData;
-	properties_pt properties = NULL;
 
 	status = calculator_create(&activator->calculator);
 	if (status == CELIX_SUCCESS) {
@@ -73,14 +70,9 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt
context)
 			activator->service->sub = calculator_sub;
 			activator->service->sqrt = calculator_sqrt;
 
-			properties = properties_create();
-			properties_set(properties, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, (char *) CALCULATOR_SERVICE);
-
-			bundleContext_registerService(context, (char *) CALCULATOR_SERVICE, activator->service,
properties, &activator->calculatorReg);
-
-			properties_pt properties2 = properties_create();
-			properties_set(properties2, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, (char *) CALCULATOR2_SERVICE);
-			bundleContext_registerService(context, CALCULATOR2_SERVICE, activator->service, properties2,
&activator->calculatorReg2);
+			celix_properties_t *properties = celix_properties_create();
+			celix_properties_set(properties, OSGI_RSA_SERVICE_EXPORTED_INTERFACES, CALCULATOR_SERVICE);
+			bundleContext_registerService(context, CALCULATOR_SERVICE, activator->service, properties,
&activator->calculatorReg);
 		}
 	}
 
@@ -92,7 +84,6 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context)
 	struct activator *activator = userData;
 
 	serviceRegistration_unregister(activator->calculatorReg);
-	serviceRegistration_unregister(activator->calculatorReg2);
 
 	free(activator->service);
 
diff --git a/bundles/remote_services/examples/calculator_shell/CMakeLists.txt b/bundles/remote_services/examples/calculator_shell/CMakeLists.txt
index 1eef035..5f3e9e2 100644
--- a/bundles/remote_services/examples/calculator_shell/CMakeLists.txt
+++ b/bundles/remote_services/examples/calculator_shell/CMakeLists.txt
@@ -28,9 +28,7 @@ target_include_directories(calculator_shell PRIVATE src)
 target_link_libraries(calculator_shell PRIVATE Celix::shell_api calculator_api)
 
 celix_bundle_files(calculator_shell
-    ../calculator_api/include/org.apache.celix.calc.api.Calculator2.descriptor
-    #src/org.apache.celix.calc.api.Calculator2.descriptor ##Use this descriptor in case you
want to try out versioning!
+    ../calculator_api/include/org.apache.celix.calc.api.Calculator.descriptor
+    #src/org.apache.celix.calc.api.Calculator.descriptor ##Use this descriptor in case you
want to try out versioning!
     DESTINATION .
 )
-
-
diff --git a/bundles/remote_services/examples/calculator_shell/src/add_command.c b/bundles/remote_services/examples/calculator_shell/src/add_command.c
index b2520ae..04df878 100644
--- a/bundles/remote_services/examples/calculator_shell/src/add_command.c
+++ b/bundles/remote_services/examples/calculator_shell/src/add_command.c
@@ -43,11 +43,7 @@ void addCommand_execute(bundle_context_pt context, char *line, FILE *out,
FILE *
 
     status = bundleContext_getServiceReference(context, (char *) CALCULATOR_SERVICE, &calculatorService);
     if (calculatorService == NULL) {
-        fprintf(err, "ADD: Cannot get reference for %s. Trying to get one for %s\n", CALCULATOR_SERVICE,
CALCULATOR2_SERVICE);
-        status = bundleContext_getServiceReference(context, (char *) CALCULATOR2_SERVICE,
&calculatorService);
-        if (calculatorService == NULL) {
-            fprintf(err, "ADD: Cannot get reference even for %s.\n", CALCULATOR2_SERVICE);
-        }
+        fprintf(err, "ADD: Cannot get reference for %s.\n", CALCULATOR_SERVICE);
     }
     if (status == CELIX_SUCCESS) {
     	char *token = line;
diff --git a/bundles/remote_services/examples/calculator_api/include/org.apache.celix.calc.api.Calculator2.descriptor
b/bundles/remote_services/examples/calculator_shell/src/org.apache.celix.calc.api.Calculator.descriptor
similarity index 94%
rename from bundles/remote_services/examples/calculator_api/include/org.apache.celix.calc.api.Calculator2.descriptor
rename to bundles/remote_services/examples/calculator_shell/src/org.apache.celix.calc.api.Calculator.descriptor
index b784838..35b4df7 100644
--- a/bundles/remote_services/examples/calculator_api/include/org.apache.celix.calc.api.Calculator2.descriptor
+++ b/bundles/remote_services/examples/calculator_shell/src/org.apache.celix.calc.api.Calculator.descriptor
@@ -1,7 +1,7 @@
 :header
 type=interface
 name=calculator
-version=1.3.0
+version=1.2.3
 :annotations
 classname=org.example.Calculator
 :types
diff --git a/bundles/remote_services/examples/calculator_shell/src/org.apache.celix.calc.api.Calculator2.descriptor
b/bundles/remote_services/examples/calculator_shell/src/org.apache.celix.calc.api.Calculator2.descriptor
deleted file mode 100644
index 789af9a..0000000
--- a/bundles/remote_services/examples/calculator_shell/src/org.apache.celix.calc.api.Calculator2.descriptor
+++ /dev/null
@@ -1,11 +0,0 @@
-+:header
-+type=interface
-+name=calculator
-+version=1.2.3
-+:annotations
-+classname=org.example.Calculator
-+:types
-+:methods
-+add(DD)D=add(#am=handle;PDD#am=pre;*D)N
-+sub(DD)D=sub(#am=handle;PDD#am=pre;*D)N
-+sqrt(D)D=sqrt(#am=handle;PD#am=pre;*D)N
diff --git a/bundles/remote_services/examples/calculator_shell/src/sqrt_command.c b/bundles/remote_services/examples/calculator_shell/src/sqrt_command.c
index 2e7238c..928cd59 100644
--- a/bundles/remote_services/examples/calculator_shell/src/sqrt_command.c
+++ b/bundles/remote_services/examples/calculator_shell/src/sqrt_command.c
@@ -41,11 +41,7 @@ void sqrtCommand_execute(bundle_context_pt context, char *line, FILE *out,
FILE
 
     status = bundleContext_getServiceReference(context, (char *) CALCULATOR_SERVICE, &calculatorService);
     if (calculatorService == NULL) {
-        fprintf(err, "SQRT: Cannot get reference for %s. Trying to get one for %s\n", CALCULATOR_SERVICE,
CALCULATOR2_SERVICE);
-        status = bundleContext_getServiceReference(context, (char *) CALCULATOR2_SERVICE,
&calculatorService);
-        if (calculatorService == NULL) {
-            fprintf(err, "SQRT: Cannot get reference even for %s.\n", CALCULATOR2_SERVICE);
-        }
+        fprintf(err, "SQRT: Cannot get reference for %s.\n", CALCULATOR_SERVICE);
     }
     if (status == CELIX_SUCCESS) {
     	char *token = line;
diff --git a/bundles/remote_services/examples/calculator_shell/src/sub_command.c b/bundles/remote_services/examples/calculator_shell/src/sub_command.c
index 672ea4c..ce0d388 100644
--- a/bundles/remote_services/examples/calculator_shell/src/sub_command.c
+++ b/bundles/remote_services/examples/calculator_shell/src/sub_command.c
@@ -41,11 +41,7 @@ void subCommand_execute(bundle_context_pt context, char *line, FILE *out,
FILE *
 
     status = bundleContext_getServiceReference(context, (char *) CALCULATOR_SERVICE, &calculatorService);
     if (calculatorService == NULL) {
-        fprintf(err, "SUB: Cannot get reference for %s. Trying to get one for %s\n", CALCULATOR_SERVICE,
CALCULATOR2_SERVICE);
-        status = bundleContext_getServiceReference(context, (char *) CALCULATOR2_SERVICE,
&calculatorService);
-        if (calculatorService == NULL) {
-            fprintf(err, "SUB: Cannot get reference even for %s.\n", CALCULATOR2_SERVICE);
-        }
+        fprintf(err, "SUB: Cannot get reference for %s\n", CALCULATOR_SERVICE);
     }
     if (status == CELIX_SUCCESS) {
     	char *token = line;
diff --git a/bundles/remote_services/remote_service_admin_dfi/test/src/rsa_tests.cpp b/bundles/remote_services/remote_service_admin_dfi/test/src/rsa_tests.cpp
index 6026ac6..1b1c0d5 100644
--- a/bundles/remote_services/remote_service_admin_dfi/test/src/rsa_tests.cpp
+++ b/bundles/remote_services/remote_service_admin_dfi/test/src/rsa_tests.cpp
@@ -66,7 +66,7 @@ extern "C" {
         rc = bundleContext_getService(context, rsaRef, (void **)&rsa);
         CHECK_EQUAL(CELIX_SUCCESS, rc);
 
-        rc = bundleContext_getServiceReference(context, (char *)CALCULATOR2_SERVICE, &calcRef);
+        rc = bundleContext_getServiceReference(context, (char *)CALCULATOR_SERVICE, &calcRef);
         CHECK_EQUAL(CELIX_SUCCESS, rc);
         CHECK(calcRef != NULL);
 
diff --git a/bundles/remote_services/remote_service_admin_dfi/test/src/tst_activator.c b/bundles/remote_services/remote_service_admin_dfi/test/src/tst_activator.c
index 3db38fb..75e75e0 100644
--- a/bundles/remote_services/remote_service_admin_dfi/test/src/tst_activator.c
+++ b/bundles/remote_services/remote_service_admin_dfi/test/src/tst_activator.c
@@ -57,7 +57,7 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **out)
{
 		act->serv.test = test;
 
 		status = serviceTrackerCustomizer_create(act, NULL, addCalc, NULL, removeCalc, &act->cust);
-		status = CELIX_DO_IF(status, serviceTracker_create(context, CALCULATOR2_SERVICE, act->cust,
&act->tracker));
+		status = CELIX_DO_IF(status, serviceTracker_create(context, CALCULATOR_SERVICE, act->cust,
&act->tracker));
 
 	} else {
 		status = CELIX_ENOMEM;
diff --git a/bundles/remote_services/topology_manager/tms_tst/tms_tests.cpp b/bundles/remote_services/topology_manager/tms_tst/tms_tests.cpp
index 3e99dab..a0486c9 100644
--- a/bundles/remote_services/topology_manager/tms_tst/tms_tests.cpp
+++ b/bundles/remote_services/topology_manager/tms_tst/tms_tests.cpp
@@ -110,7 +110,7 @@ extern "C" {
         rc = bundleContext_getService(context, scopeServiceRef, (void **)&tmScopeService);
         CHECK_EQUAL(CELIX_SUCCESS, rc);
 
-        rc = bundleContext_getServiceReference(context, (char *)CALCULATOR2_SERVICE, &calcRef);
+        rc = bundleContext_getServiceReference(context, (char *)CALCULATOR_SERVICE, &calcRef);
         CHECK_EQUAL(CELIX_SUCCESS, rc);
         CHECK(calcRef != NULL);
 


Mime
View raw message