incubator-celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1528386 - in /incubator/celix/trunk: deployment_admin/private/src/ examples/osgi-in-action/chapter04-paint-example/paint/private/src/ framework/private/src/ framework/public/include/ remote_services/discovery_slp/private/src/ remote_servic...
Date Wed, 02 Oct 2013 09:07:09 GMT
Author: abroekhuis
Date: Wed Oct  2 09:07:09 2013
New Revision: 1528386

URL: http://svn.apache.org/r1528386
Log:
CELIX-56: Renamed utils functions to follow the correct style

Added:
    incubator/celix/trunk/remote_services/remote_service_admin_http/
    incubator/celix/trunk/remote_services/remote_service_admin_http/private/
    incubator/celix/trunk/remote_services/remote_service_admin_http/private/src/
    incubator/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
      - copied, changed from r1528385, incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c
Modified:
    incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c
    incubator/celix/trunk/deployment_admin/private/src/deployment_package.c
    incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c
    incubator/celix/trunk/framework/private/src/framework.c
    incubator/celix/trunk/framework/private/src/manifest.c
    incubator/celix/trunk/framework/private/src/manifest_parser.c
    incubator/celix/trunk/framework/private/src/properties.c
    incubator/celix/trunk/framework/private/src/utils.c
    incubator/celix/trunk/framework/public/include/utils.h
    incubator/celix/trunk/remote_services/discovery_slp/private/src/discovery.c
    incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c
    incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
    incubator/celix/trunk/remote_shell/private/src/remote_shell.c
    incubator/celix/trunk/shell/private/src/shell.c
    incubator/celix/trunk/shell_tui/private/src/shell_tui.c

Modified: incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c?rev=1528386&r1=1528385&r2=1528386&view=diff
==============================================================================
--- incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c (original)
+++ incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c Wed Oct  2 09:07:09
2013
@@ -79,7 +79,7 @@ celix_status_t deploymentAdmin_create(ap
 		(*admin)->running = true;
 		(*admin)->context = context;
 		(*admin)->current = NULL;
-		(*admin)->packages = hashMap_create(string_hash, NULL, string_equals, NULL);
+		(*admin)->packages = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
 		(*admin)->targetIdentification = NULL;
 		(*admin)->pollUrl = NULL;
         bundleContext_getProperty(context, IDENTIFICATION_ID, &(*admin)->targetIdentification);

Modified: incubator/celix/trunk/deployment_admin/private/src/deployment_package.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/deployment_admin/private/src/deployment_package.c?rev=1528386&r1=1528385&r2=1528386&view=diff
==============================================================================
--- incubator/celix/trunk/deployment_admin/private/src/deployment_package.c (original)
+++ incubator/celix/trunk/deployment_admin/private/src/deployment_package.c Wed Oct  2 09:07:09
2013
@@ -53,8 +53,8 @@ celix_status_t deploymentPackage_create(
 		(*package)->manifest = manifest;
 		(*package)->bundleInfos = NULL;
 		(*package)->resourceInfos = NULL;
-		(*package)->nameToBundleInfo = hashMap_create(string_hash, NULL, string_equals, NULL);
-		(*package)->pathToEntry = hashMap_create(string_hash, NULL, string_equals, NULL);
+		(*package)->nameToBundleInfo = hashMap_create(utils_stringHash, NULL, utils_stringEquals,
NULL);
+		(*package)->pathToEntry = hashMap_create(utils_stringHash, NULL, utils_stringEquals,
NULL);
 		status = arrayList_create(pool, &(*package)->bundleInfos);
 		if (status == CELIX_SUCCESS) {
 			status = arrayList_create(pool, &(*package)->resourceInfos);

Modified: incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c?rev=1528386&r1=1528385&r2=1528386&view=diff
==============================================================================
--- incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c
(original)
+++ incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c
Wed Oct  2 09:07:09 2013
@@ -94,7 +94,7 @@ celix_status_t paintFrame_create(bundle_
 		(*frame)->pixMap = NULL;
 		(*frame)->m_selected = NULL;
 		(*frame)->context = context;
-		(*frame)->m_shapes = hashMap_create(string_hash, NULL, string_equals, NULL);
+		(*frame)->m_shapes = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
 		(*frame)->m_defaultShape = defaultShape_create((*frame)->context);
 		linkedList_create((*frame)->pool, &(*frame)->m_shapeComponents);
 

Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1528386&r1=1528385&r2=1528386&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Wed Oct  2 09:07:09 2013
@@ -237,7 +237,7 @@ celix_status_t framework_create(framewor
 											(*framework)->nextBundleId = 1l;
 											(*framework)->cache = NULL;
 
-											(*framework)->installRequestMap = hashMap_create(string_hash, string_hash,
string_equals, string_equals);
+											(*framework)->installRequestMap = hashMap_create(utils_stringHash, utils_stringHash,
utils_stringEquals, utils_stringEquals);
 											(*framework)->serviceListeners = NULL;
 											(*framework)->bundleListeners = NULL;
 											(*framework)->requests = NULL;
@@ -365,7 +365,7 @@ celix_status_t fw_init(framework_pt fram
 		}
 	}
 
-	framework->installedBundleMap = hashMap_create(string_hash, NULL, string_equals, NULL);
+	framework->installedBundleMap = hashMap_create(utils_stringHash, NULL, utils_stringEquals,
NULL);
 
 	status = bundle_getArchive(framework->bundle, &archive);
 	status = bundleArchive_getLocation(archive, &location);

Modified: incubator/celix/trunk/framework/private/src/manifest.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/manifest.c?rev=1528386&r1=1528385&r2=1528386&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/manifest.c (original)
+++ incubator/celix/trunk/framework/private/src/manifest.c Wed Oct  2 09:07:09 2013
@@ -45,7 +45,7 @@ celix_status_t manifest_create(apr_pool_
 		apr_pool_pre_cleanup_register(pool, *manifest, manifest_destroy);
 		(*manifest)->pool = pool;
 		(*manifest)->mainAttributes = properties_create();
-		(*manifest)->attributes = hashMap_create(string_hash, NULL, string_equals, NULL);
+		(*manifest)->attributes = hashMap_create(utils_stringHash, NULL, utils_stringEquals,
NULL);
 	}
 
 	return status;

Modified: incubator/celix/trunk/framework/private/src/manifest_parser.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/manifest_parser.c?rev=1528386&r1=1528385&r2=1528386&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/manifest_parser.c (original)
+++ incubator/celix/trunk/framework/private/src/manifest_parser.c Wed Oct  2 09:07:09 2013
@@ -144,7 +144,7 @@ static linked_list_pt manifestParser_par
                     }
 
                     if (strlen(buffer) > 0) {
-                        linkedList_addElement(list, apr_pstrdup(memory_pool, string_trim(buffer)));
+                        linkedList_addElement(list, apr_pstrdup(memory_pool, utils_stringTrim(buffer)));
                     }
                 }
 
@@ -191,8 +191,8 @@ static linked_list_pt manifestParser_par
                 return NULL;
             }
 
-            dirsMap = hashMap_create(string_hash, NULL, string_equals, NULL);
-            attrsMap = hashMap_create(string_hash, NULL, string_equals, NULL);
+            dirsMap = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
+            attrsMap = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
 
             
             for (pieceIdx = pathCount; pieceIdx < linkedList_size(pieces); pieceIdx++)
{

Modified: incubator/celix/trunk/framework/private/src/properties.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/properties.c?rev=1528386&r1=1528385&r2=1528386&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/properties.c (original)
+++ incubator/celix/trunk/framework/private/src/properties.c Wed Oct  2 09:07:09 2013
@@ -30,51 +30,8 @@
 #include "properties.h"
 #include "utils.h"
 
-//DEFINE_HASHTABLE_INSERT(prop_insert, struct key, struct value);
-//DEFINE_HASHTABLE_REMOVE(prop_remove, struct key, struct value);
-//DEFINE_HASHTABLE_SEARCH(prop_search, struct key, struct value);
-//
-//static unsigned int hashfromkey(void * ks) {
-//	struct key *k = (struct key *) ks;
-//	unsigned long hash = 5381;
-//	int i;
-//	char * ck = strdup(k->key);
-//	for (i=0; i<strlen(ck); ++i) hash = 33*hash + ck[i];
-//	//int c;
-//	//while (c = *ck++) {
-//	//	hash = ((hash << 5) + hash) + c;
-//	//}
-//	free(ck);
-//	return hash;
-//}
-//
-//static int equalskey(void * k1, void * k2) {
-//	struct key * key1 = (struct key *) k1;
-//	struct key * key2 = (struct key *) k2;
-//	return (strcmp(key1->key, key2->key) == 0);
-//}
-//
-//char * addEntry(HASHTABLE properties, char * k, char * v);
-//char * addEntry(HASHTABLE properties, char * k, char * v) {
-//	struct key * search_key = (struct key *) malloc(sizeof(*search_key));
-//	struct key * s_key = (struct key *) malloc(sizeof(*s_key));
-//	struct value * s_value = (struct value *) malloc(sizeof(*s_value));
-//	struct value * oldValue = NULL;
-//	s_key->key = k;
-//	search_key->key = k;
-//	s_value->value = v;
-//	oldValue = prop_search(properties, search_key);
-//	if (oldValue != NULL) {
-//		prop_remove(properties, search_key);
-//	}
-//	free(search_key);
-//	prop_insert(properties, s_key, s_value);
-//
-//	return oldValue == NULL ? NULL : oldValue->value;
-//}
-
-properties_pt properties_create(void) {
-	return hashMap_create(string_hash, string_hash, string_equals, string_equals);
+properties_t properties_create(void) {
+	return hashMap_create(utils_stringHash, utils_stringHash, utils_stringEquals, utils_stringEquals);
 }
 
 void properties_destroy(properties_pt properties) {
@@ -105,9 +62,9 @@ properties_pt properties_load(char * fil
 				unsigned int pos = strcspn(line, "=");
 				if (pos != strlen(line)) {
 					char * ival = NULL;
-					key = string_trim(string_ndup((char *)line, pos));
+					key = utils_stringTrim(string_ndup((char *)line, pos));
 					ival = string_ndup(line+pos+1, strlen(line));
-					value = string_trim(ival);
+					value = utils_stringTrim(ival);
 					if (value != NULL) {
 						char * cmp = string_ndup(value+strlen(value)-1, 1);
 						if (strcmp(cont, cmp) == 0) {
@@ -128,7 +85,7 @@ properties_pt properties_load(char * fil
 				} else {
 					char * old = NULL;
 					split = 0;
-					strcat(value, string_trim(line));
+					strcat(value, utils_stringTrim(line));
 					old = hashMap_put(props, strdup(key), strdup(value));
 				}
 			}

Modified: incubator/celix/trunk/framework/private/src/utils.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/utils.c?rev=1528386&r1=1528385&r2=1528386&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/utils.c (original)
+++ incubator/celix/trunk/framework/private/src/utils.c Wed Oct  2 09:07:09 2013
@@ -29,7 +29,7 @@
 
 #include "utils.h"
 
-unsigned int string_hash(void * string) {
+unsigned int utils_stringHash(void * string) {
 	char * str = (char *) string;
 
 	unsigned int hash = 1315423911;
@@ -44,10 +44,13 @@ unsigned int string_hash(void * string) 
 	return hash;
 }
 
-int string_equals(void * string, void * toCompare) {
+int utils_stringEquals(void * string, void * toCompare) {
 	return strcmp((char *)string, (char *) toCompare) == 0;
 }
 
+/**
+ * \deprecated APR provides a correct alternative: apr_pstrndup
+ */
 char * string_ndup(const char *s, size_t n) {
 	size_t len = strlen(s);
 	char *ret;
@@ -62,7 +65,7 @@ char * string_ndup(const char *s, size_t
 	return ret;
 }
 
-char * string_trim(char * string) {
+char * utils_stringTrim(char * string) {
 	char * copy = string;
 
 	char *end;

Modified: incubator/celix/trunk/framework/public/include/utils.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/utils.h?rev=1528386&r1=1528385&r2=1528386&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/utils.h (original)
+++ incubator/celix/trunk/framework/public/include/utils.h Wed Oct  2 09:07:09 2013
@@ -34,10 +34,10 @@
 #include "celixbool.h"
 #include "framework_exports.h"
 
-FRAMEWORK_EXPORT unsigned int string_hash(void * string);
-FRAMEWORK_EXPORT int string_equals(void * string, void * toCompare);
+FRAMEWORK_EXPORT unsigned int utils_stringHash(void * string);
+FRAMEWORK_EXPORT int utils_stringEquals(void * string, void * toCompare);
 FRAMEWORK_EXPORT char * string_ndup(const char *s, size_t n);
-FRAMEWORK_EXPORT char * string_trim(char * string);
+FRAMEWORK_EXPORT char * utils_stringTrim(char * string);
 
 FRAMEWORK_EXPORT celix_status_t thread_equalsSelf(apr_os_thread_t thread, bool *equals);
 

Modified: incubator/celix/trunk/remote_services/discovery_slp/private/src/discovery.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/discovery_slp/private/src/discovery.c?rev=1528386&r1=1528385&r2=1528386&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/discovery_slp/private/src/discovery.c (original)
+++ incubator/celix/trunk/remote_services/discovery_slp/private/src/discovery.c Wed Oct  2
09:07:09 2013
@@ -86,7 +86,7 @@ celix_status_t discovery_create(apr_pool
 		(*discovery)->context = context;
 		(*discovery)->pool = pool;
 		(*discovery)->listenerReferences = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2,
NULL);
-		(*discovery)->slpServices = hashMap_create(string_hash, NULL, string_equals, NULL);
+		(*discovery)->slpServices = hashMap_create(utils_stringHash, NULL, utils_stringEquals,
NULL);
 		(*discovery)->running = true;
 		(*discovery)->discoveryPort = getenv("RSA_PORT");
 		if ((*discovery)->discoveryPort == NULL) {

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=1528386&r1=1528385&r2=1528386&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
Wed Oct  2 09:07:09 2013
@@ -223,11 +223,11 @@ celix_status_t remoteServiceAdmin_export
 		printf("RSA: Export services (%s)\n", exports);
 		array_list_pt interfaces = NULL;
 		arrayList_create(admin->pool, &interfaces);
-		if (strcmp(string_trim(exports), "*") == 0) {
+		if (strcmp(utils_stringTrim(exports), "*") == 0) {
 			char *token;
 			char *interface = apr_strtok(provided, ",", &token);
 			while (interface != NULL) {
-				arrayList_add(interfaces, string_trim(interface));
+				arrayList_add(interfaces, utils_stringTrim(interface));
 				interface = apr_strtok(NULL, ",", &token);
 			}
 		} else {

Copied: incubator/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
(from r1528385, 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_http/private/src/remote_service_admin_impl.c?p2=incubator/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c&p1=incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c&r1=1528385&r2=1528386&rev=1528386&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_http/private/src/remote_service_admin_impl.c
Wed Oct  2 09:07:09 2013
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include <apr_uuid.h>
 #include <apr_strings.h>
 
 #include "remote_service_admin_impl.h"
@@ -39,22 +40,14 @@
 #include "service_reference.h"
 #include "service_registration.h"
 
-static const char *ajax_reply_start =
-  "HTTP/1.1 200 OK\r\n"
-  "Cache: no-cache\r\n"
-  "Content-Type: application/x-javascript\r\n"
-  "\r\n";
-
-
-static const char *DEFAULT_PORT = "8888";
-
-//void *remoteServiceAdmin_callback(enum mg_event event, struct mg_connection *conn, const
struct mg_request_info *request_info);
-static int remoteServiceAdmin_callback(struct mg_connection *conn);
-celix_status_t remoteServiceAdmin_installEndpoint(remote_service_admin_pt admin, export_registration_pt
registration, service_reference_pt reference, char *interface);
-celix_status_t remoteServiceAdmin_createEndpointDescription(remote_service_admin_pt admin,
properties_pt serviceProperties, properties_pt endpointProperties, char *interface, endpoint_description_pt
*description);
-static celix_status_t constructServiceUrl(remote_service_admin_pt admin, char *service, char
**serviceUrl);
 
-celix_status_t remoteServiceAdmin_create(apr_pool_t *pool, bundle_context_pt context, remote_service_admin_pt
*admin) {
+
+void *remoteServiceAdmin_callback(enum mg_event event, struct mg_connection *conn, const
struct mg_request_info *request_info);
+celix_status_t remoteServiceAdmin_installEndpoint(remote_service_admin_t admin, export_registration_t
registration, service_reference_t reference, char *interface);
+celix_status_t remoteServiceAdmin_createEndpointDescription(remote_service_admin_t admin,
properties_t serviceProperties, properties_t endpointProperties, char *interface, endpoint_description_t
*description);
+celix_status_t remoteServiceAdmin_getUUID(remote_service_admin_t rsa, char **uuidStr);
+
+celix_status_t remoteServiceAdmin_create(apr_pool_t *pool, bundle_context_t context, remote_service_admin_t
*admin) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	*admin = apr_palloc(pool, sizeof(**admin));
@@ -70,43 +63,33 @@ celix_status_t remoteServiceAdmin_create
 		char *port = NULL;
 		bundleContext_getProperty(context, "RSA_PORT", &port);
 		if (port == NULL) {
-			(*admin)->port = (char *)DEFAULT_PORT;
-		} else {
-			(*admin)->port = apr_pstrdup(pool, port);
+			printf("No RemoteServiceAdmin port set, set it using RSA_PORT!\n");
 		}
-		printf("Start webserver: %s\n", (*admin)->port);
-		const char *options[] = { "listening_ports", (*admin)->port, NULL};
-
-		// Prepare callbacks structure. We have only one callback, the rest are NULL.
-		struct mg_callbacks callbacks;
-		memset(&callbacks, 0, sizeof(callbacks));
-		callbacks.begin_request = remoteServiceAdmin_callback;
-
-		(*admin)->ctx = mg_start(&callbacks, (*admin), options);
-		printf("Start webserver %p\n", (*admin)->ctx);
+		const char *options[] = {"listening_ports", port, NULL};
+		(*admin)->ctx = mg_start(remoteServiceAdmin_callback, (*admin), options);
 	}
 
 	return status;
 }
 
-celix_status_t remoteServiceAdmin_stop(remote_service_admin_pt admin) {
+celix_status_t remoteServiceAdmin_stop(remote_service_admin_t admin) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	hash_map_iterator_pt iter = hashMapIterator_create(admin->exportedServices);
+	hash_map_iterator_t iter = hashMapIterator_create(admin->exportedServices);
 	while (hashMapIterator_hasNext(iter)) {
-		array_list_pt exports = hashMapIterator_nextValue(iter);
+		array_list_t exports = hashMapIterator_nextValue(iter);
 		int i;
 		for (i = 0; i < arrayList_size(exports); i++) {
-			export_registration_pt export = arrayList_get(exports, i);
+			export_registration_t export = arrayList_get(exports, i);
 			exportRegistration_stopTracking(export);
 		}
 	}
 	iter = hashMapIterator_create(admin->importedServices);
 	while (hashMapIterator_hasNext(iter)) {
-		array_list_pt exports = hashMapIterator_nextValue(iter);
+		array_list_t exports = hashMapIterator_nextValue(iter);
 		int i;
 		for (i = 0; i < arrayList_size(exports); i++) {
-			import_registration_pt export = arrayList_get(exports, i);
+			import_registration_t export = arrayList_get(exports, i);
 			importRegistration_stopTracking(export);
 		}
 	}
@@ -114,69 +97,16 @@ celix_status_t remoteServiceAdmin_stop(r
 	return status;
 }
 
-/**
- * Request: http://host:port/services/{service}/{request}
- */
-//void *remoteServiceAdmin_callback(enum mg_event event, struct mg_connection *conn, const
struct mg_request_info *request_info) {
-
-static int remoteServiceAdmin_callback(struct mg_connection *conn) {
-	const struct mg_request_info *request_info = mg_get_request_info(conn);
-	if (request_info->uri != NULL) {
-		printf("REMOTE_SERVICE_ADMIN: Handle request: %s\n", request_info->uri);
-		remote_service_admin_pt rsa = request_info->user_data;
-
-		if (strncmp(request_info->uri, "/services/", 10) == 0) {
-			// uri = /services/myservice/call
-			const char *uri = request_info->uri;
-			// rest = myservice/call
-			const char *rest = uri+10;
-			int length = strlen(rest);
-			char *callStart = strchr(rest, '/');
-			int pos = callStart - rest;
-			char service[pos+1];
-			strncpy(service, rest, pos);
-			service[pos] = '\0';
-
-			char request[length - pos];
-			strncpy(request, rest + pos + 1, length - pos);
-
-			const char *lengthStr = mg_get_header(conn, (const char *) "Content-Length");
-			int datalength = apr_atoi64(lengthStr);
-			char data[datalength+1];
-			mg_read(conn, data, datalength);
-			data[datalength] = '\0';
-
-			hash_map_iterator_pt iter = hashMapIterator_create(rsa->exportedServices);
-			while (hashMapIterator_hasNext(iter)) {
-				hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-				array_list_pt exports = hashMapEntry_getValue(entry);
-				int expIt = 0;
-				for (expIt = 0; expIt < arrayList_size(exports); expIt++) {
-					export_registration_pt export = arrayList_get(exports, expIt);
-					if (strcmp(service, export->endpointDescription->service) == 0) {
-						char *reply = NULL;
-						export->endpoint->handleRequest(export->endpoint->endpoint, request, data,
&reply);
-						if (reply != NULL) {
-							mg_printf(conn, "%s", ajax_reply_start);
-							mg_printf(conn, "%s", reply);
-						}
-					}
-				}
-			}
-		}
-	}
 
-	return 1;
-}
 
-celix_status_t remoteServiceAdmin_handleRequest(remote_service_admin_pt rsa, char *service,
char *request, char *data, char **reply) {
-	hash_map_iterator_pt iter = hashMapIterator_create(rsa->exportedServices);
+celix_status_t remoteServiceAdmin_handleRequest(remote_service_admin_t rsa, char *service,
char *request, char *data, char **reply) {
+	hash_map_iterator_t iter = hashMapIterator_create(rsa->exportedServices);
 	while (hashMapIterator_hasNext(iter)) {
-		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-		array_list_pt exports = hashMapEntry_getValue(entry);
+		hash_map_entry_t entry = hashMapIterator_nextEntry(iter);
+		array_list_t exports = hashMapEntry_getValue(entry);
 		int expIt = 0;
 		for (expIt = 0; expIt < arrayList_size(exports); expIt++) {
-			export_registration_pt export = arrayList_get(exports, expIt);
+			export_registration_t export = arrayList_get(exports, expIt);
 			if (strcmp(service, export->endpointDescription->service) == 0) {
 				export->endpoint->handleRequest(export->endpoint->endpoint, request, data,
reply);
 			}
@@ -185,34 +115,13 @@ celix_status_t remoteServiceAdmin_handle
 	return CELIX_SUCCESS;
 }
 
-celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, char *serviceId,
properties_pt properties, array_list_pt *registrations) {
+celix_status_t remoteServiceAdmin_exportService(remote_service_admin_t admin, service_reference_t
reference, properties_t properties, array_list_t *registrations) {
 	celix_status_t status = CELIX_SUCCESS;
 	arrayList_create(admin->pool, registrations);
-	array_list_pt references = NULL;
-	service_reference_pt reference = NULL;
-	service_registration_pt registration = NULL;
-	apr_pool_t *tmpPool = NULL;
-
-	apr_pool_create(&tmpPool, admin->pool);
-	if (tmpPool == NULL) {
-		return CELIX_ENOMEM;
-	} else {
-		char *filter = apr_pstrcat(admin->pool, "(", (char *)SERVICE_ID, "=", serviceId, ")",
NULL); /*FIXME memory leak*/
-		bundleContext_getServiceReferences(admin->context, NULL, filter, &references);
-		apr_pool_destroy(tmpPool);
-		if (arrayList_size(references) >= 1) {
-			reference = arrayList_get(references, 0);
-		}
-	}
-
-	if (reference == NULL) {
-		printf("ERROR: expected a reference for service id %s\n", serviceId);
-		return CELIX_ILLEGAL_STATE;
-	}
-
 
+	service_registration_t registration = NULL;
 	serviceReference_getServiceRegistration(reference, &registration);
-	properties_pt serviceProperties = NULL;
+	properties_t serviceProperties = NULL;
 	serviceRegistration_getProperties(registration, &serviceProperties);
 	char *exports = properties_get(serviceProperties, (char *) SERVICE_EXPORTED_INTERFACES);
 	char *provided = properties_get(serviceProperties, (char *) OBJECTCLASS);
@@ -221,13 +130,13 @@ celix_status_t remoteServiceAdmin_export
 		printf("RSA: No Services to export.\n");
 	} else {
 		printf("RSA: Export services (%s)\n", exports);
-		array_list_pt interfaces = NULL;
+		array_list_t interfaces = NULL;
 		arrayList_create(admin->pool, &interfaces);
-		if (strcmp(string_trim(exports), "*") == 0) {
+		if (strcmp(utils_stringTrim(exports), "*") == 0) {
 			char *token;
 			char *interface = apr_strtok(provided, ",", &token);
 			while (interface != NULL) {
-				arrayList_add(interfaces, string_trim(interface));
+				arrayList_add(interfaces, utils_stringTrim(interface));
 				interface = apr_strtok(NULL, ",", &token);
 			}
 		} else {
@@ -251,7 +160,7 @@ celix_status_t remoteServiceAdmin_export
 			int iter = 0;
 			for (iter = 0; iter < arrayList_size(interfaces); iter++) {
 				char *interface = arrayList_get(interfaces, iter);
-				export_registration_pt registration = NULL;
+				export_registration_t registration = NULL;
 
 				exportRegistration_create(admin->pool, reference, NULL, admin, admin->context,
&registration);
 				arrayList_add(*registrations, registration);
@@ -267,19 +176,19 @@ celix_status_t remoteServiceAdmin_export
 	return status;
 }
 
-celix_status_t remoteServiceAdmin_installEndpoint(remote_service_admin_pt admin, export_registration_pt
registration, service_reference_pt reference, char *interface) {
+celix_status_t remoteServiceAdmin_installEndpoint(remote_service_admin_t admin, export_registration_t
registration, service_reference_t reference, char *interface) {
 	celix_status_t status = CELIX_SUCCESS;
-	properties_pt endpointProperties = properties_create();
-	properties_pt serviceProperties = NULL;
+	properties_t endpointProperties = properties_create();
+	properties_t serviceProperties = NULL;
 
-	service_registration_pt sRegistration = NULL;
+	service_registration_t sRegistration = NULL;
 	serviceReference_getServiceRegistration(reference, &sRegistration);
 
 	serviceRegistration_getProperties(sRegistration, &serviceProperties);
 
-	hash_map_iterator_pt iter = hashMapIterator_create(serviceProperties);
+	hash_map_iterator_t iter = hashMapIterator_create(serviceProperties);
 	while (hashMapIterator_hasNext(iter)) {
-		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+		hash_map_entry_t entry = hashMapIterator_nextEntry(iter);
 		char *key = (char *) hashMapEntry_getKey(entry);
 		char *value = (char *) hashMapEntry_getValue(entry);
 
@@ -289,70 +198,29 @@ celix_status_t remoteServiceAdmin_instal
 	properties_set(endpointProperties, (char *) OBJECTCLASS, interface);
 	properties_set(endpointProperties, (char *) ENDPOINT_SERVICE_ID, serviceId);
 	char *uuid = NULL;
-	bundleContext_getProperty(admin->context, FRAMEWORK_UUID, &uuid);
+	remoteServiceAdmin_getUUID(admin, &uuid);
 	properties_set(endpointProperties, (char *) ENDPOINT_FRAMEWORK_UUID, uuid);
 	char *service = "/services/example";
 	properties_set(endpointProperties, (char *) SERVICE_LOCATION, apr_pstrdup(admin->pool,
service));
-    
-    char *url = NULL;
-    constructServiceUrl(admin,interface, &url);
-    printf("url is %s\n", url);
-    properties_set(endpointProperties, "url", url);
 
-	endpoint_description_pt endpointDescription = NULL;
+	endpoint_description_t endpointDescription = NULL;
 	remoteServiceAdmin_createEndpointDescription(admin, serviceProperties, endpointProperties,
interface, &endpointDescription);
 	exportRegistration_setEndpointDescription(registration, endpointDescription);
 
 	return status;
 }
 
-static celix_status_t constructServiceUrl(remote_service_admin_pt admin, char *service, char
**serviceUrl) {
-	celix_status_t status = CELIX_SUCCESS;
-    
-	if (*serviceUrl != NULL || admin == NULL || service == NULL ) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		char host[APRMAXHOSTLEN + 1];
-		apr_sockaddr_t *sa;
-		char *ip;
-        
-		apr_status_t stat = apr_gethostname(host, APRMAXHOSTLEN + 1, admin->pool); /*TODO mem
leak*/
-		if (stat != APR_SUCCESS) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		} else {
-			stat = apr_sockaddr_info_get(&sa, host, APR_INET, 0, 0, admin->pool); /*TODO mem
leak*/
-			if (stat != APR_SUCCESS) {
-				status = CELIX_BUNDLE_EXCEPTION;
-			} else {
-				stat = apr_sockaddr_ip_get(&ip, sa);
-				if (stat != APR_SUCCESS) {
-					status = CELIX_BUNDLE_EXCEPTION;
-				} else {
-					*serviceUrl = apr_pstrcat(admin->pool, "http://", ip, ":", admin->port, "/services/",
service,	NULL );
-				}
-			}
-		}
-	}
-    
-	return status;
-}
-
-
-
-celix_status_t remoteServiceAdmin_createEndpointDescription(remote_service_admin_pt admin,
properties_pt serviceProperties,
-		properties_pt endpointProperties, char *interface, endpoint_description_pt *description)
{
+celix_status_t remoteServiceAdmin_createEndpointDescription(remote_service_admin_t admin,
properties_t serviceProperties,
+		properties_t endpointProperties, char *interface, endpoint_description_t *description)
{
 	celix_status_t status = CELIX_SUCCESS;
 
-	apr_pool_t *childPool = NULL;
-	apr_pool_create(&childPool, admin->pool);
-
-	*description = apr_palloc(childPool, sizeof(*description));
+	*description = apr_palloc(admin->pool, sizeof(*description));
 //	*description = malloc(sizeof(*description));
 	if (!*description) {
 		status = CELIX_ENOMEM;
 	} else {
 		char *uuid = NULL;
-		status = bundleContext_getProperty(admin->context, (char *)FRAMEWORK_UUID, &uuid);
+		status = bundleContext_getProperty(admin->context, ENDPOINT_FRAMEWORK_UUID, &uuid);
 		if (status == CELIX_SUCCESS) {
 			(*description)->properties = endpointProperties;
 			(*description)->frameworkUUID = uuid;
@@ -365,23 +233,23 @@ celix_status_t remoteServiceAdmin_create
 	return status;
 }
 
-celix_status_t remoteServiceAdmin_getExportedServices(remote_service_admin_pt admin, array_list_pt
*services) {
+celix_status_t remoteServiceAdmin_getExportedServices(remote_service_admin_t admin, array_list_t
*services) {
 	celix_status_t status = CELIX_SUCCESS;
 	return status;
 }
 
-celix_status_t remoteServiceAdmin_getImportedEndpoints(remote_service_admin_pt admin, array_list_pt
*services) {
+celix_status_t remoteServiceAdmin_getImportedEndpoints(remote_service_admin_t admin, array_list_t
*services) {
 	celix_status_t status = CELIX_SUCCESS;
 	return status;
 }
 
-celix_status_t remoteServiceAdmin_importService(remote_service_admin_pt admin, endpoint_description_pt
endpoint, import_registration_pt *registration) {
+celix_status_t remoteServiceAdmin_importService(remote_service_admin_t admin, endpoint_description_t
endpoint, import_registration_t *registration) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	printf("RSA: Import service %s\n", endpoint->service);
 	importRegistration_create(admin->pool, endpoint, admin, admin->context, registration);
 
-	array_list_pt importedRegs = hashMap_get(admin->importedServices, endpoint);
+	array_list_t importedRegs = hashMap_get(admin->importedServices, endpoint);
 	if (importedRegs == NULL) {
 		arrayList_create(admin->pool, &importedRegs);
 		hashMap_put(admin->importedServices, endpoint, importedRegs);
@@ -395,7 +263,7 @@ celix_status_t remoteServiceAdmin_import
 }
 
 
-celix_status_t exportReference_getExportedEndpoint(export_reference_pt reference, endpoint_description_pt
*endpoint) {
+celix_status_t exportReference_getExportedEndpoint(export_reference_t reference, endpoint_description_t
*endpoint) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	*endpoint = reference->endpoint;
@@ -403,17 +271,34 @@ celix_status_t exportReference_getExport
 	return status;
 }
 
-celix_status_t exportReference_getExportedService(export_reference_pt reference) {
+celix_status_t exportReference_getExportedService(export_reference_t reference) {
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
+}
+
+celix_status_t importReference_getImportedEndpoint(import_reference_t reference) {
 	celix_status_t status = CELIX_SUCCESS;
 	return status;
 }
 
-celix_status_t importReference_getImportedEndpoint(import_reference_pt reference) {
+celix_status_t importReference_getImportedService(import_reference_t reference) {
 	celix_status_t status = CELIX_SUCCESS;
 	return status;
 }
 
-celix_status_t importReference_getImportedService(import_reference_pt reference) {
+celix_status_t remoteServiceAdmin_getUUID(remote_service_admin_t rsa, char **uuidStr) {
 	celix_status_t status = CELIX_SUCCESS;
+
+	status = bundleContext_getProperty(rsa->context, ENDPOINT_FRAMEWORK_UUID, uuidStr);
+	if (status == CELIX_SUCCESS) {
+		if (*uuidStr == NULL) {
+			apr_uuid_t uuid;
+			apr_uuid_get(&uuid);
+			*uuidStr = apr_palloc(rsa->pool, APR_UUID_FORMATTED_LENGTH + 1);
+			apr_uuid_format(*uuidStr, &uuid);
+			setenv(ENDPOINT_FRAMEWORK_UUID, *uuidStr, 1);
+		}
+	}
+
 	return status;
 }

Modified: incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c?rev=1528386&r1=1528385&r2=1528386&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
(original)
+++ incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
Wed Oct  2 09:07:09 2013
@@ -74,7 +74,7 @@ celix_status_t topologyManager_create(bu
 		arrayList_create(pool, &(*manager)->rsaList);
 		(*manager)->exportedServices = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2,
NULL);
 		(*manager)->importedServices = hashMap_create(NULL, NULL, NULL, NULL);
-		(*manager)->importInterests = hashMap_create(string_hash, NULL, string_equals, NULL);
+		(*manager)->importInterests = hashMap_create(utils_stringHash, NULL, utils_stringEquals,
NULL);
 	}
 
 	return status;

Modified: incubator/celix/trunk/remote_shell/private/src/remote_shell.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_shell/private/src/remote_shell.c?rev=1528386&r1=1528385&r2=1528386&view=diff
==============================================================================
--- incubator/celix/trunk/remote_shell/private/src/remote_shell.c (original)
+++ incubator/celix/trunk/remote_shell/private/src/remote_shell.c Wed Oct  2 09:07:09 2013
@@ -228,7 +228,7 @@ static celix_status_t remoteShell_connec
 
 	if (status == CELIX_SUCCESS) {
 		char *dline = apr_pstrdup(workPool, command);
-		char *line = string_trim(dline);
+		char *line = utils_stringTrim(dline);
 		int len = strlen(line);
 
 		if (len == 0) {

Modified: incubator/celix/trunk/shell/private/src/shell.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/private/src/shell.c?rev=1528386&r1=1528385&r2=1528386&view=diff
==============================================================================
--- incubator/celix/trunk/shell/private/src/shell.c (original)
+++ incubator/celix/trunk/shell/private/src/shell.c Wed Oct  2 09:07:09 2013
@@ -93,7 +93,7 @@ static celix_status_t shell_createComman
 shell_pt shell_create(apr_pool_t *pool) {
 	shell_pt shell = (shell_pt) malloc(sizeof(*shell));
 	shell->pool = pool;
-	shell->commandNameMap = hashMap_create(string_hash, NULL, string_equals, NULL);
+	shell->commandNameMap = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
 	shell->commandReferenceMap = hashMap_create(NULL, NULL, NULL, NULL);
 	return shell;
 }

Modified: incubator/celix/trunk/shell_tui/private/src/shell_tui.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell_tui/private/src/shell_tui.c?rev=1528386&r1=1528385&r2=1528386&view=diff
==============================================================================
--- incubator/celix/trunk/shell_tui/private/src/shell_tui.c (original)
+++ incubator/celix/trunk/shell_tui/private/src/shell_tui.c Wed Oct  2 09:07:09 2013
@@ -62,7 +62,7 @@ static void *APR_THREAD_FUNC shellTui_ru
 		fgets(in, 256, stdin);
 		needPrompt = true;
 		dline = strdup(in);
-		line = string_trim(dline);
+		line = utils_stringTrim(dline);
 		if (strlen(line) == 0) {
 			continue;
 		}



Mime
View raw message