You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by rl...@apache.org on 2019/07/03 17:54:53 UTC

[celix] 02/02: Refactored properties_pt to celix_properties_t* in pubsub

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 8d603953b24e008d3077fa43f04342657354fa36
Author: Roy Lenferink <le...@gmail.com>
AuthorDate: Wed Jul 3 19:31:26 2019 +0200

    Refactored properties_pt to celix_properties_t* in pubsub
---
 .../subscriber/private/src/ps_sub_activator.c      | 98 +++++++++++-----------
 .../pubsub/pubsub_discovery/src/psd_activator.c    |  6 +-
 bundles/pubsub/pubsub_spi/src/pubsub_endpoint.c    |  4 +-
 .../pubsub_topology_manager/src/pstm_activator.c   | 10 +--
 4 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/bundles/pubsub/examples/pubsub/subscriber/private/src/ps_sub_activator.c b/bundles/pubsub/examples/pubsub/subscriber/private/src/ps_sub_activator.c
index 625bf80..199a0bf 100644
--- a/bundles/pubsub/examples/pubsub/subscriber/private/src/ps_sub_activator.c
+++ b/bundles/pubsub/examples/pubsub/subscriber/private/src/ps_sub_activator.c
@@ -20,8 +20,8 @@
  * ps_sub_activator.c
  *
  *  \date       Sep 21, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
  */
 
 #include <stdlib.h>
@@ -33,82 +33,82 @@
 
 #define SUB_NAME "poi1;poi2"
 static const char * SUB_TOPICS[] = {
-		"poi1",
-		"poi2",
-		NULL
+        "poi1",
+        "poi2",
+        NULL
 };
 
 struct subscriberActivator {
-	array_list_pt registrationList; //List<service_registration_pt>
-	pubsub_subscriber_pt subsvc;
+    array_list_pt registrationList; //List<service_registration_pt>
+    pubsub_subscriber_pt subsvc;
 };
 
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	struct subscriberActivator * act = calloc(1,sizeof(struct subscriberActivator));
-	*userData = act;
-	arrayList_create(&(act->registrationList));
-	return CELIX_SUCCESS;
+    struct subscriberActivator * act = calloc(1,sizeof(struct subscriberActivator));
+    *userData = act;
+    arrayList_create(&(act->registrationList));
+    return CELIX_SUCCESS;
 }
 
 celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	struct subscriberActivator * act = (struct subscriberActivator *) userData;
+    struct subscriberActivator * act = (struct subscriberActivator *) userData;
 
 
-	pubsub_subscriber_pt subsvc = calloc(1,sizeof(*subsvc));
-	pubsub_receiver_pt sub = subscriber_create(SUB_NAME);
-	subsvc->handle = sub;
-	subsvc->receive = pubsub_subscriber_recv;
+    pubsub_subscriber_pt subsvc = calloc(1,sizeof(*subsvc));
+    pubsub_receiver_pt sub = subscriber_create(SUB_NAME);
+    subsvc->handle = sub;
+    subsvc->receive = pubsub_subscriber_recv;
 
-	act->subsvc = subsvc;
+    act->subsvc = subsvc;
 
-	int i;
-	for(i=0; SUB_TOPICS[i] != NULL ;i++){
-		const char* topic = SUB_TOPICS[i];
-		properties_pt props = properties_create();
-		properties_set(props, PUBSUB_SUBSCRIBER_TOPIC,topic);
+    int i;
+    for (i = 0; SUB_TOPICS[i] != NULL; i++) {
+        const char* topic = SUB_TOPICS[i];
+        celix_properties_t *props = celix_properties_create();
+        celix_properties_set(props, PUBSUB_SUBSCRIBER_TOPIC, topic);
 #ifdef USE_SCOPE
-			char *scope;
-			asprintf(&scope, "my_scope_%d", i);
-			properties_set(props,SUBSCRIBER_SCOPE,scope);
-			free(scope);
+        char *scope;
+        asprintf(&scope, "my_scope_%d", i);
+        celix_properties_set(props,SUBSCRIBER_SCOPE,scope);
+        free(scope);
 #endif
-		service_registration_pt reg = NULL;
-		bundleContext_registerService(context, PUBSUB_SUBSCRIBER_SERVICE_NAME, subsvc, props, &reg);
-		arrayList_add(act->registrationList,reg);
-	}
+        service_registration_pt reg = NULL;
+        bundleContext_registerService(context, PUBSUB_SUBSCRIBER_SERVICE_NAME, subsvc, props, &reg);
+        arrayList_add(act->registrationList,reg);
+    }
 
-	subscriber_start((pubsub_receiver_pt)act->subsvc->handle);
+    subscriber_start((pubsub_receiver_pt)act->subsvc->handle);
 
-	return CELIX_SUCCESS;
+    return CELIX_SUCCESS;
 }
 
 celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	struct subscriberActivator * act = (struct subscriberActivator *) userData;
+    struct subscriberActivator * act = (struct subscriberActivator *) userData;
 
-	int i;
-	for(i=0; i<arrayList_size(act->registrationList);i++){
-		service_registration_pt reg = arrayList_get(act->registrationList,i);
-		serviceRegistration_unregister(reg);
+    int i;
+    for (i = 0; i < arrayList_size(act->registrationList); i++) {
+        service_registration_pt reg = arrayList_get(act->registrationList, i);
+        serviceRegistration_unregister(reg);
 
-	}
+    }
 
-	subscriber_stop((pubsub_receiver_pt)act->subsvc->handle);
+    subscriber_stop((pubsub_receiver_pt)act->subsvc->handle);
 
-	return CELIX_SUCCESS;
+    return CELIX_SUCCESS;
 }
 
 celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
 
-	struct subscriberActivator * act = (struct subscriberActivator *) userData;
+    struct subscriberActivator * act = (struct subscriberActivator *) userData;
 
-	act->subsvc->receive = NULL;
-	subscriber_destroy((pubsub_receiver_pt)act->subsvc->handle);
-	act->subsvc->handle = NULL;
-	free(act->subsvc);
-	act->subsvc = NULL;
+    act->subsvc->receive = NULL;
+    subscriber_destroy((pubsub_receiver_pt)act->subsvc->handle);
+    act->subsvc->handle = NULL;
+    free(act->subsvc);
+    act->subsvc = NULL;
 
-	arrayList_destroy(act->registrationList);
-	free(act);
+    arrayList_destroy(act->registrationList);
+    free(act);
 
-	return CELIX_SUCCESS;
+    return CELIX_SUCCESS;
 }
diff --git a/bundles/pubsub/pubsub_discovery/src/psd_activator.c b/bundles/pubsub/pubsub_discovery/src/psd_activator.c
index eeaf679..5201192 100644
--- a/bundles/pubsub/pubsub_discovery/src/psd_activator.c
+++ b/bundles/pubsub/pubsub_discovery/src/psd_activator.c
@@ -74,9 +74,9 @@ static celix_status_t psd_start(psd_activator_t *act, celix_bundle_context_t *ct
 		act->cmdSvc.handle = act->pubsub_discovery;
 		act->cmdSvc.executeCommand = pubsub_discovery_executeCommand;
 		celix_properties_t *props = celix_properties_create();
-		properties_set(props, OSGI_SHELL_COMMAND_NAME, "psd_etcd");
-		properties_set(props, OSGI_SHELL_COMMAND_USAGE, "psd_etcd"); //TODO add search topic/scope option
-		properties_set(props, OSGI_SHELL_COMMAND_DESCRIPTION, "Overview of discovered/announced endpoints from/to ETCD");
+		celix_properties_set(props, OSGI_SHELL_COMMAND_NAME, "psd_etcd");
+		celix_properties_set(props, OSGI_SHELL_COMMAND_USAGE, "psd_etcd"); //TODO add search topic/scope option
+		celix_properties_set(props, OSGI_SHELL_COMMAND_DESCRIPTION, "Overview of discovered/announced endpoints from/to ETCD");
 		act->cmdSvcId = celix_bundleContext_registerService(ctx, &act->cmdSvc, OSGI_SHELL_COMMAND_SERVICE_NAME, props);
 	}
 
diff --git a/bundles/pubsub/pubsub_spi/src/pubsub_endpoint.c b/bundles/pubsub/pubsub_spi/src/pubsub_endpoint.c
index ceb8e90..59f64c8 100644
--- a/bundles/pubsub/pubsub_spi/src/pubsub_endpoint.c
+++ b/bundles/pubsub/pubsub_spi/src/pubsub_endpoint.c
@@ -92,7 +92,7 @@ celix_properties_t* pubsubEndpoint_create(
         const char* adminType,
         const char *serType,
         celix_properties_t *topic_props) {
-	celix_properties_t *ep = properties_create();
+	celix_properties_t *ep = celix_properties_create();
 	pubsubEndpoint_setFields(ep, fwUUID, scope, topic, pubsubType, adminType, serType, topic_props);
 	if (!pubsubEndpoint_isValid(ep, true, true)) {
 	    celix_properties_destroy(ep);
@@ -114,7 +114,7 @@ static void retrieveTopicProperties(void *handle, const celix_bundle_t *bnd) {
 }
 
 celix_properties_t* pubsubEndpoint_createFromSubscriberSvc(bundle_context_t* ctx, long bundleId, const celix_properties_t *svcProps) {
-    celix_properties_t *ep = properties_create();
+    celix_properties_t *ep = celix_properties_create();
 
 	const char* fwUUID = celix_bundleContext_getProperty(ctx, OSGI_FRAMEWORK_FRAMEWORK_UUID, NULL);
 	const char* scope = celix_properties_get(svcProps,  PUBSUB_SUBSCRIBER_SCOPE, PUBSUB_SUBSCRIBER_SCOPE_DEFAULT);
diff --git a/bundles/pubsub/pubsub_topology_manager/src/pstm_activator.c b/bundles/pubsub/pubsub_topology_manager/src/pstm_activator.c
index 5a710cc..93f6836 100644
--- a/bundles/pubsub/pubsub_topology_manager/src/pstm_activator.c
+++ b/bundles/pubsub/pubsub_topology_manager/src/pstm_activator.c
@@ -133,9 +133,9 @@ static int pstm_start(pstm_activator_t *act, celix_bundle_context_t *ctx) {
 		act->shellCmdSvc.handle = act->manager;
 		act->shellCmdSvc.executeCommand = pubsub_topologyManager_shellCommand;
 		celix_properties_t *props = celix_properties_create();
-		properties_set(props, OSGI_SHELL_COMMAND_NAME, "pstm");
-		properties_set(props, OSGI_SHELL_COMMAND_USAGE, "pstm [topology|metrics]"); //TODO add search topic/scope option
-		properties_set(props, OSGI_SHELL_COMMAND_DESCRIPTION, "pubsub_topology_info: Overview of Topology information for PubSub");
+		celix_properties_set(props, OSGI_SHELL_COMMAND_NAME, "pstm");
+		celix_properties_set(props, OSGI_SHELL_COMMAND_USAGE, "pstm [topology|metrics]"); //TODO add search topic/scope option
+		celix_properties_set(props, OSGI_SHELL_COMMAND_DESCRIPTION, "pubsub_topology_info: Overview of Topology information for PubSub");
 		act->shellCmdSvcId = celix_bundleContext_registerService(ctx, &act->shellCmdSvc, OSGI_SHELL_COMMAND_SERVICE_NAME, props);
 	}
 
@@ -144,8 +144,8 @@ static int pstm_start(pstm_activator_t *act, celix_bundle_context_t *ctx) {
 	//2) on add indicate that topic/senders should be reevaluated.
 
 	/* NOTE: Enable those line in order to remotely expose the topic_info service
-	properties_pt props = properties_create();
-	properties_set(props, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, (char *) PUBSUB_TOPIC_INFO_SERVICE);
+	celix_properties_t *props = celix_properties_create();
+	celix_properties_set(props, OSGI_RSA_SERVICE_EXPORTED_INTERFACES, PUBSUB_TOPIC_INFO_SERVICE);
 	status += bundleContext_registerService(context, (char *) PUBSUB_TOPIC_INFO_SERVICE, activator->topicInfo, props, &activator->topicInfoService);
 	*/