You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by ab...@apache.org on 2011/11/17 13:45:57 UTC

svn commit: r1203171 - in /incubator/celix/trunk: ./ examples/hello_world/ remote_services/calc_shell/private/src/ remote_services/discovery/private/src/ remote_services/example_endpoint/private/src/ remote_services/example_proxy/private/src/ remote_se...

Author: abroekhuis
Date: Thu Nov 17 12:45:56 2011
New Revision: 1203171

URL: http://svn.apache.org/viewvc?rev=1203171&view=rev
Log:
Remote Services updates

Modified:
    incubator/celix/trunk/Remote Services.launch
    incubator/celix/trunk/examples/hello_world/activator.c
    incubator/celix/trunk/remote_services/calc_shell/private/src/add_command.c
    incubator/celix/trunk/remote_services/calc_shell/private/src/sqrt_command.c
    incubator/celix/trunk/remote_services/calc_shell/private/src/sub_command.c
    incubator/celix/trunk/remote_services/discovery/private/src/discovery.c
    incubator/celix/trunk/remote_services/example_endpoint/private/src/example_endpoint_impl.c
    incubator/celix/trunk/remote_services/example_proxy/private/src/example_proxy_impl.c
    incubator/celix/trunk/remote_services/example_service/private/src/example_impl.c
    incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c

Modified: incubator/celix/trunk/Remote Services.launch
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/Remote%20Services.launch?rev=1203171&r1=1203170&r2=1203171&view=diff
==============================================================================
--- incubator/celix/trunk/Remote Services.launch (original)
+++ incubator/celix/trunk/Remote Services.launch Thu Nov 17 12:45:56 2011
@@ -29,7 +29,7 @@
 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
 <booleanAttribute key="org.eclipse.cdt.launch.ENABLE_REGISTER_BOOKKEEPING" value="false"/>
 <booleanAttribute key="org.eclipse.cdt.launch.ENABLE_VARIABLE_BOOKKEEPING" value="false"/>
-<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;userData-userData-bundleActivator_stop-(cast)&quot; val=&quot;log_writer_t&quot;/&gt;&lt;content id=&quot;userData-fw_startBundle-(cast)&quot; val=&quot;DEPENDENCY_ACTIVATOR_BASE&quot;/&gt;&lt;content id=&quot;userData-data-bundleActivator_start-(cast)&quot; val=&quot;log_writer_t&quot;/&gt;&lt;content id=&quot;userData-*userData-userData-bundleActivator_create-(cast)&quot; val=&quot;log_writer_t&quot;/&gt;&lt;content id=&quot;*userData-userData-bundleActivator_create-(cast)&quot; val=&quot;DEPENDENCY_ACTIVATOR_BASE&quot;/&gt;&lt;content id=&quot;userData-userData-fw_startBundle-(cast)&quot; val=&quot;log_writer_t&quot;/&gt;&lt;content id=&quot;key-hashMapIterator_remove-(cast)&quot; val=&quot;char *&quot;/&gt;&lt;content id=&quot;componentData-bundleActivator_create-(cast)&quot; val=&quo
 t;log_writer_t&quot;/&gt;&lt;content id=&quot;*table-table-exportedServices-admin-activator-bundleActivator_stop-(cast_to_array)&quot; val=&quot;0:1&quot;/&gt;&lt;content id=&quot;userData-bundleActivator_stop-(cast)&quot; val=&quot;DEPENDENCY_ACTIVATOR_BASE&quot;/&gt;&lt;/contentList&gt;"/>
+<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;userData-bundleActivator_stop-(cast)&quot; val=&quot;DEPENDENCY_ACTIVATOR_BASE&quot;/&gt;&lt;content id=&quot;*table-table-exportedServices-admin-activator-bundleActivator_stop-(cast_to_array)&quot; val=&quot;0:1&quot;/&gt;&lt;content id=&quot;componentData-bundleActivator_create-(cast)&quot; val=&quot;log_writer_t&quot;/&gt;&lt;content id=&quot;key-hashMapIterator_remove-(cast)&quot; val=&quot;char *&quot;/&gt;&lt;content id=&quot;userData-userData-fw_startBundle-(cast)&quot; val=&quot;log_writer_t&quot;/&gt;&lt;content id=&quot;*userData-userData-bundleActivator_create-(cast)&quot; val=&quot;DEPENDENCY_ACTIVATOR_BASE&quot;/&gt;&lt;content id=&quot;userData-*userData-userData-bundleActivator_create-(cast)&quot; val=&quot;log_writer_t&quot;/&gt;&lt;content id=&quot;userData-data-bundleAct
 ivator_start-(cast)&quot; val=&quot;log_writer_t&quot;/&gt;&lt;content id=&quot;userData-fw_startBundle-(cast)&quot; val=&quot;DEPENDENCY_ACTIVATOR_BASE&quot;/&gt;&lt;content id=&quot;userData-userData-bundleActivator_stop-(cast)&quot; val=&quot;log_writer_t&quot;/&gt;&lt;/contentList&gt;"/>
 <stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;globalVariableList/&gt;&#10;"/>
 <stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList/&gt;&#10;"/>
 <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/launcher/launcher"/>

Modified: incubator/celix/trunk/examples/hello_world/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/hello_world/activator.c?rev=1203171&r1=1203170&r2=1203171&view=diff
==============================================================================
--- incubator/celix/trunk/examples/hello_world/activator.c (original)
+++ incubator/celix/trunk/examples/hello_world/activator.c Thu Nov 17 12:45:56 2011
@@ -48,7 +48,6 @@ celix_status_t bundleActivator_create(BU
 celix_status_t bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
 	struct userData * data = (struct userData *) userData;
 	printf("Hello %s\n", data->word);
-
 	return CELIX_SUCCESS;
 }
 

Modified: incubator/celix/trunk/remote_services/calc_shell/private/src/add_command.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/calc_shell/private/src/add_command.c?rev=1203171&r1=1203170&r2=1203171&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/calc_shell/private/src/add_command.c (original)
+++ incubator/celix/trunk/remote_services/calc_shell/private/src/add_command.c Thu Nov 17 12:45:56 2011
@@ -62,7 +62,7 @@ void addCommand_execute(COMMAND command,
 					status = example->add(example->example, a, b, &result);
 					if (status == CELIX_SUCCESS) {
 						char line[256];
-						sprintf(line, "ADD: %f + %f = %f\n", a, b, result);
+						sprintf(line, "CALCULATOR_SHELL: Add: %f + %f = %f\n", a, b, result);
 						out(line);
 					} else {
 						out("ADD: Unexpected exception in Calc service\n");

Modified: incubator/celix/trunk/remote_services/calc_shell/private/src/sqrt_command.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/calc_shell/private/src/sqrt_command.c?rev=1203171&r1=1203170&r2=1203171&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/calc_shell/private/src/sqrt_command.c (original)
+++ incubator/celix/trunk/remote_services/calc_shell/private/src/sqrt_command.c Thu Nov 17 12:45:56 2011
@@ -60,7 +60,7 @@ void sqrtCommand_execute(COMMAND command
 				status = example->sqrt(example->example, a, &result);
 				if (status == CELIX_SUCCESS) {
 					char line[256];
-					sprintf(line, "SQRT: sqrt %f = %f\n", a, result);
+					sprintf(line, "CALCULATOR_SHELL: Sqrt: %f = %f\n", a, result);
 					out(line);
 				} else {
 					out("SQRT: Unexpected exception in Calc service\n");

Modified: incubator/celix/trunk/remote_services/calc_shell/private/src/sub_command.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/calc_shell/private/src/sub_command.c?rev=1203171&r1=1203170&r2=1203171&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/calc_shell/private/src/sub_command.c (original)
+++ incubator/celix/trunk/remote_services/calc_shell/private/src/sub_command.c Thu Nov 17 12:45:56 2011
@@ -64,7 +64,7 @@ void subCommand_execute(COMMAND command,
 					status = example->sub(example->example, a, b, &result);
 					if (status == CELIX_SUCCESS) {
 						char line[256];
-						sprintf(line, "SUB: %f - %f = %f\n", a, b, result);
+						sprintf(line, "CALCULATOR_SHELL: Sub: %f - %f = %f\n", a, b, result);
 						out(line);
 					} else {
 						out("SUB: Unexpected exception in Calc service\n");

Modified: incubator/celix/trunk/remote_services/discovery/private/src/discovery.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/discovery/private/src/discovery.c?rev=1203171&r1=1203170&r2=1203171&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/discovery/private/src/discovery.c (original)
+++ incubator/celix/trunk/remote_services/discovery/private/src/discovery.c Thu Nov 17 12:45:56 2011
@@ -69,6 +69,9 @@ celix_status_t discovery_create(apr_pool
 		(*discovery)->slpServices = hashMap_create(string_hash, NULL, string_equals, NULL);
 		(*discovery)->running = true;
 		(*discovery)->rsaPort = getenv("RSA_PORT");
+		if ((*discovery)->rsaPort == NULL) {
+			printf("No RemoteServiceAdmin port set, set it using RSA_PORT!\n");
+		}
 		(*discovery)->handled = NULL;
 		arrayList_create(pool, &(*discovery)->handled);
 		(*discovery)->registered = NULL;
@@ -268,6 +271,13 @@ celix_status_t discovery_endpointRemoved
 		status = discovery_constructServiceUrl(discovery, endpoint, &serviceUrl);
 		if (status == CELIX_SUCCESS) {
 			status = discovery_deregisterEndpoint(discovery, serviceUrl);
+			int i;
+			for (i = 0; i < arrayList_size(discovery->registered); i++) {
+				char *url = arrayList_get(discovery->registered, i);
+				if (strcmp(url, serviceUrl) == 0) {
+					arrayList_remove(discovery->registered, i);
+				}
+			}
 		}
 	}
 

Modified: incubator/celix/trunk/remote_services/example_endpoint/private/src/example_endpoint_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/example_endpoint/private/src/example_endpoint_impl.c?rev=1203171&r1=1203170&r2=1203171&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/example_endpoint/private/src/example_endpoint_impl.c (original)
+++ incubator/celix/trunk/remote_services/example_endpoint/private/src/example_endpoint_impl.c Thu Nov 17 12:45:56 2011
@@ -37,6 +37,7 @@ celix_status_t exampleEndpoint_setServic
 celix_status_t exampleEndpoint_handleRequest(remote_endpoint_t ep, char *request, char *data, char **reply) {
 	celix_status_t status = CELIX_SUCCESS;
 
+	printf("EXAMPLE ENDPOINT: Handle request \"%s\" with data \"%s\"\n", request, data);
 	if (strcmp(request, "add") == 0) {
 		exampleEndpoint_add(ep, data, reply);
 	} else if (strcmp(request, "sub") == 0) {

Modified: incubator/celix/trunk/remote_services/example_proxy/private/src/example_proxy_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/example_proxy/private/src/example_proxy_impl.c?rev=1203171&r1=1203170&r2=1203171&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/example_proxy/private/src/example_proxy_impl.c (original)
+++ incubator/celix/trunk/remote_services/example_proxy/private/src/example_proxy_impl.c Thu Nov 17 12:45:56 2011
@@ -46,7 +46,7 @@ celix_status_t exampleProxy_add(example_
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (example->endpoint != NULL) {
-		printf("PROXY: URL: %s\n", example->endpoint->id);
+		printf("CALCULATOR_PROXY: URL: %s\n", example->endpoint->id);
 		char *url = apr_pstrcat(example->pool, example->endpoint->id, "/add", NULL);
 
 		json_t *root;
@@ -68,7 +68,7 @@ celix_status_t exampleProxy_add(example_
 			json_unpack(reply, "{s:f}", "result", result);
 		}
 	} else {
-		printf("PROXY: No endpoint information available");
+		printf("CALCULATOR_PROXY: No endpoint information available");
 	}
 
 	return status;
@@ -77,7 +77,7 @@ celix_status_t exampleProxy_add(example_
 celix_status_t exampleProxy_sub(example_t example, double a, double b, double *result) {
 	celix_status_t status = CELIX_SUCCESS;
 	if (example->endpoint != NULL) {
-		printf("PROXY: URL: %s\n", example->endpoint->id);
+		printf("CALCULATOR_PROXY: URL: %s\n", example->endpoint->id);
 		char *url = apr_pstrcat(example->pool, example->endpoint->id, "/sub", NULL);
 
 		json_t *root;
@@ -99,7 +99,7 @@ celix_status_t exampleProxy_sub(example_
 			json_unpack(reply, "{s:f}", "result", result);
 		}
 	} else {
-		printf("PROXY: No endpoint information available");
+		printf("CALCULATOR_PROXY: No endpoint information available");
 	}
 
 	return status;
@@ -108,7 +108,7 @@ celix_status_t exampleProxy_sub(example_
 celix_status_t exampleProxy_sqrt(example_t example, double a, double *result) {
 	celix_status_t status = CELIX_SUCCESS;
 	if (example->endpoint != NULL) {
-		printf("PROXY: URL: %s\n", example->endpoint->id);
+		printf("CALCULATOR_PROXY: URL: %s\n", example->endpoint->id);
 		char *url = apr_pstrcat(example->pool, example->endpoint->id, "/sqrt", NULL);
 
 		json_t *root;
@@ -130,7 +130,7 @@ celix_status_t exampleProxy_sqrt(example
 			json_unpack(reply, "{s:f}", "result", result);
 		}
 	} else {
-		printf("PROXY: No endpoint information available");
+		printf("CALCULATOR_PROXY: No endpoint information available");
 	}
 
 	return status;
@@ -155,7 +155,7 @@ celix_status_t exampleProxy_postRequest(
 		res = curl_easy_perform(curl);
 		curl_easy_cleanup(curl);
 
-		printf("Data read: %s\n", get->writeptr);
+		printf("CALCULATOR_PROXY: Data read: \"%s\"\n", get->writeptr);
 
 	}
 	return status;

Modified: incubator/celix/trunk/remote_services/example_service/private/src/example_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/example_service/private/src/example_impl.c?rev=1203171&r1=1203170&r2=1203171&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/example_service/private/src/example_impl.c (original)
+++ incubator/celix/trunk/remote_services/example_service/private/src/example_impl.c Thu Nov 17 12:45:56 2011
@@ -26,6 +26,7 @@ celix_status_t example_add(example_t exa
 	celix_status_t status = CELIX_SUCCESS;
 
 	*result = a + b;
+	printf("CALCULATOR: Add: %f + %f = %f\n", a, b, *result);
 
 	return status;
 }
@@ -34,6 +35,7 @@ celix_status_t example_sub(example_t exa
 	celix_status_t status = CELIX_SUCCESS;
 
 	*result = a - b;
+	printf("CALCULATOR: Sub: %f + %f = %f\n", a, b, *result);
 
 	return status;
 }
@@ -43,7 +45,9 @@ celix_status_t example_sqrt(example_t ex
 
 	if (a > 0) {
 		*result = sqrt(a);
+		printf("CALCULATOR: Sqrt: %f = %f\n", a, *result);
 	} else {
+		printf("CALCULATOR: Sqrt: %f = ERR\n", a);
 		status = CELIX_ILLEGAL_ARGUMENT;
 	}
 

Modified: incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c?rev=1203171&r1=1203170&r2=1203171&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c (original)
+++ incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c Thu Nov 17 12:45:56 2011
@@ -45,6 +45,9 @@ celix_status_t remoteServiceAdmin_create
 
 		// Start webserver
 		const char *port = getenv("RSA_PORT");
+		if (port == NULL) {
+			printf("No RemoteServiceAdmin port set, set it using RSA_PORT!\n");
+		}
 		const char *options[] = {"listening_ports", port, NULL};
 		(*admin)->ctx = mg_start(remoteServiceAdmin_callback, (*admin), options);
 	}
@@ -82,7 +85,7 @@ celix_status_t remoteServiceAdmin_stop(r
  */
 void *remoteServiceAdmin_callback(enum mg_event event, struct mg_connection *conn, const struct mg_request_info *request_info) {
 	if (request_info->uri != NULL) {
-		printf("RSA Handle request: %s\n", request_info->uri);
+		printf("REMOTE_SERVICE_ADMIN: Handle request: %s\n", request_info->uri);
 		remote_service_admin_t rsa = request_info->user_data;
 
 		if (strncmp(request_info->uri, "/services/", 10) == 0) {
@@ -96,11 +99,9 @@ void *remoteServiceAdmin_callback(enum m
 			char service[pos+1];
 			strncpy(service, rest, pos);
 			service[pos] = '\0';
-			printf("RSA Find Handler for Service: %s\n", service);
 
 			char request[length - pos];
 			strncpy(request, rest + pos + 1, length - pos);
-			printf("RSA Send Request: %s\n", request);
 
 			const char *lengthStr = mg_get_header(conn, (const char *) "Content-Length");
 			int datalength = apr_atoi64(lengthStr);
@@ -116,7 +117,6 @@ void *remoteServiceAdmin_callback(enum m
 				for (expIt = 0; expIt < arrayList_size(exports); expIt++) {
 					export_registration_t export = arrayList_get(exports, expIt);
 					if (strcmp(service, export->endpointDescription->service) == 0) {
-						printf("RSA Sending Request: %s\n", request);
 						char *reply = NULL;
 						export->endpoint->handleRequest(export->endpoint->endpoint, request, data, &reply);
 						if (reply != NULL) {