incubator-celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject svn commit: r1519495 - in /incubator/celix/trunk: framework/ framework/private/src/ framework/public/include/ remote_services/discovery_bonjour/ remote_services/discovery_bonjour/private/src/ remote_services/discovery_slp/private/include/ remote_servic...
Date Mon, 02 Sep 2013 18:52:55 GMT
Author: pnoltes
Date: Mon Sep  2 18:52:54 2013
New Revision: 1519495

URL: http://svn.apache.org/r1519495
Log:
CELIX-65: Updated bonjour support. Updated framework and slp discovery for a  standard approach for framework uuid.  Adjusted remote_service_admin to include a url property so that discovery also will work for a not REST solution. 

Removed:
    incubator/celix/trunk/remote_services/remote_service_admin_http/
    incubator/celix/trunk/remote_services/utils/CMakeLists.txt
    incubator/celix/trunk/remote_services/utils/private/
    incubator/celix/trunk/remote_services/utils/public/include/remote_services_utils.h
Modified:
    incubator/celix/trunk/framework/CMakeLists.txt
    incubator/celix/trunk/framework/private/src/framework.c
    incubator/celix/trunk/framework/public/include/celix_errno.h
    incubator/celix/trunk/framework/public/include/constants.h
    incubator/celix/trunk/remote_services/discovery_bonjour/CMakeLists.txt
    incubator/celix/trunk/remote_services/discovery_bonjour/private/src/discovery.c
    incubator/celix/trunk/remote_services/discovery_bonjour/private/src/discovery_activator.c
    incubator/celix/trunk/remote_services/discovery_slp/private/include/discovery.h
    incubator/celix/trunk/remote_services/discovery_slp/private/src/discovery.c
    incubator/celix/trunk/remote_services/discovery_slp/private/src/discovery_activator.c
    incubator/celix/trunk/remote_services/example_proxy/private/src/example_proxy_impl.c
    incubator/celix/trunk/remote_services/example_service/public/include/example_service.h
    incubator/celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h
    incubator/celix/trunk/remote_services/remote_service_admin/private/src/import_registration_impl.c
    incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_activator.c
    incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c
    incubator/celix/trunk/remote_services/topology_manager/CMakeLists.txt
    incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c
    incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c

Modified: incubator/celix/trunk/framework/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/CMakeLists.txt?rev=1519495&r1=1519494&r2=1519495&view=diff
==============================================================================
--- incubator/celix/trunk/framework/CMakeLists.txt (original)
+++ incubator/celix/trunk/framework/CMakeLists.txt Mon Sep  2 18:52:54 2013
@@ -58,7 +58,7 @@ if (FRAMEWORK) 
 		${IO}
 	 
 	)
-    target_link_libraries(celix_framework celix_utils ${ZLIB_LIBRARY} ${APR_LIBRARY})
+    target_link_libraries(celix_framework celix_utils ${ZLIB_LIBRARY} ${APR_LIBRARY} ${APRUTIL_LIBRARY})
     
     install(TARGETS celix_framework DESTINATION lib COMPONENT framework)
     FILE(GLOB files "public/include/*.h")

Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1519495&r1=1519494&r2=1519495&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Mon Sep  2 18:52:54 2013
@@ -36,6 +36,7 @@
 #include <apr_thread_cond.h>
 #include <apr_thread_mutex.h>
 #include <apr_thread_proc.h>
+#include <apr_uuid.h>
 #ifdef _WIN32
 #include <winbase.h>
 #include <windows.h>
@@ -327,6 +328,14 @@ celix_status_t fw_init(framework_pt fram
 	hash_map_pt wires;
 	array_list_pt archives;
 	bundle_archive_pt archive = NULL;
+	char uuid[APR_UUID_FORMATTED_LENGTH+1];
+
+	/*create and store framework uuid*/
+	apr_uuid_t aprUuid;
+	apr_uuid_get(&aprUuid);
+	apr_uuid_format(uuid, &aprUuid);
+	setenv(FRAMEWORK_UUID, uuid, true);
+
 
 	if (status != CELIX_SUCCESS) {
 		framework_releaseBundleLock(framework, framework->bundle);

Modified: incubator/celix/trunk/framework/public/include/celix_errno.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/celix_errno.h?rev=1519495&r1=1519494&r2=1519495&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/celix_errno.h (original)
+++ incubator/celix/trunk/framework/public/include/celix_errno.h Mon Sep  2 18:52:54 2013
@@ -32,12 +32,13 @@
 #define CELIX_ERRNO_H_
 
 #include <errno.h>
+#include <apr_errno.h>
 
 #include "framework_exports.h"
 
 /*!
  * Helper macro which check the current status and executes the provided expression if the
- * status is still CELIX_SUCESS (0)
+ * status is still CELIX_SUCCESS (0)
  */
 #define CELIX_DO_IF(status, expr) ((status) == CELIX_SUCCESS) ? (expr) : (status)
 
@@ -50,7 +51,7 @@
 /*!
  * Status type returned by all functions in Celix
  */
-typedef int celix_status_t;
+typedef apr_status_t celix_status_t;
 
 /*!
  * Return a readable string for the given error code.
@@ -66,7 +67,17 @@ FRAMEWORK_EXPORT char *celix_strerror(ce
 /*!
  * Starting point for Celix errors.
  */
-#define CELIX_START_ERROR 20000
+#define CELIX_START_ERROR APR_OS_START_USERERR
+
+/*!
+ * The range for Celix errors.
+ */
+#define CELIX_ERRSPACE_SIZE 1000
+
+/*!
+ * The start error number user application can use.
+ */
+#define CELIX_START_USERERR (CELIX_START_ERROR + CELIX_ERRSPACE_SIZE)
 
 /*!
  * Exception indicating a problem with a bundle

Modified: incubator/celix/trunk/framework/public/include/constants.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/constants.h?rev=1519495&r1=1519494&r2=1519495&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/constants.h (original)
+++ incubator/celix/trunk/framework/public/include/constants.h Mon Sep  2 18:52:54 2013
@@ -45,6 +45,7 @@ static const char * const EXPORT_PACKAGE
 static const char * const IMPORT_PACKAGE = "Import-Service";
 
 static const char * const FRAMEWORK_STORAGE = "org.osgi.framework.storage";
+static const char * const FRAMEWORK_UUID = "org.osgi.framework.uuid";
 
 
 #endif /* CONSTANTS_H_ */

Modified: incubator/celix/trunk/remote_services/discovery_bonjour/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/discovery_bonjour/CMakeLists.txt?rev=1519495&r1=1519494&r2=1519495&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/discovery_bonjour/CMakeLists.txt (original)
+++ incubator/celix/trunk/remote_services/discovery_bonjour/CMakeLists.txt Mon Sep  2 18:52:54 2013
@@ -17,7 +17,6 @@
 
 #TODO find_package(DNS-SD REQUIRED)
 
-#TODO include_directories(${SLP_INCLUDE_DIRS})
 include_directories("/usr/include") #TODO check if this has impact on the generated project indexer paths
 include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
 include_directories("${PROJECT_SOURCE_DIR}/remote_services/utils/public/include")
@@ -30,8 +29,8 @@ SET_HEADER(BUNDLE_SYMBOLICNAME "apache_c
 SET_HEADERS("Bundle-Name: Apache Celix RSA BONJOUR Discovery")
 
 bundle(discovery_bonjour SOURCES 
-	private/src/discovery 
-	private/src/discovery_activator
+	private/src/discovery.c
+	private/src/discovery_activator.c
 )
 
 target_link_libraries(discovery_bonjour celix_framework ${APRUTIL_LIBRARY}) # TODO ${SLP_LIBRARIES})

Modified: incubator/celix/trunk/remote_services/discovery_bonjour/private/src/discovery.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/discovery_bonjour/private/src/discovery.c?rev=1519495&r1=1519494&r2=1519495&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/discovery_bonjour/private/src/discovery.c (original)
+++ incubator/celix/trunk/remote_services/discovery_bonjour/private/src/discovery.c Mon Sep  2 18:52:54 2013
@@ -19,7 +19,7 @@
 /*
  * discovery.c
  *
- *  \date       Oct 4, 2011
+ *  \date       Sep 1, 2013
  *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
  *  \copyright	Apache License, Version 2.0
  */
@@ -31,6 +31,7 @@
 
 #include <dns_sd.h>
 
+#include "constants.h"
 #include "bundle_context.h"
 #include "array_list.h"
 #include "utils.h"
@@ -38,56 +39,62 @@
 #include "filter.h"
 #include "service_reference.h"
 #include "service_registration.h"
+#include "remote_constants.h"
 
 #include "discovery.h"
 
 static void *APR_THREAD_FUNC discovery_poll(apr_thread_t *thd, void *data);
-static void discovery_browseCallback(
-		    DNSServiceRef sdRef,
-		    DNSServiceFlags flags,
-		    uint32_t interfaceIndex,
-		    DNSServiceErrorType errorCode,
-		    const char                          *serviceName,
-		    const char                          *regtype,
-		    const char                          *replyDomain,
-		    void                                *context
-		);
-static void discovery_resolveCallback
-(
-    DNSServiceRef sdRef,
-    DNSServiceFlags flags,
-    uint32_t interfaceIndex,
-    DNSServiceErrorType errorCode,
-    const char                          *fullname,
-    const char                          *hosttarget,
-    uint16_t port,                                   /* In network byte order */
-    uint16_t txtLen,
-    const unsigned char                 *txtRecord,
-    void                                *context
-);
-static celix_status_t discovery_deregisterEndpoint(discovery_pt discovery, const char *serviceUrl);
-static celix_status_t discovery_addService(discovery_pt discovery, endpoint_description_pt endpoint);
-static celix_status_t discovery_removeService(discovery_pt discovery, endpoint_description_pt endpoint);
+static void discovery_browseCallback(DNSServiceRef sdRef, DNSServiceFlags flags,
+		uint32_t interfaceIndex, DNSServiceErrorType errorCode,
+		const char *serviceName, const char *regtype, const char *replyDomain,
+		void *context);
+static void discovery_resolveAddCallback(DNSServiceRef sdRef,
+		DNSServiceFlags flags, uint32_t interfaceIndex,
+		DNSServiceErrorType errorCode, const char *fullname,
+		const char *hosttarget, uint16_t port, /* In network byte order */
+		uint16_t txtLen, const unsigned char *txtRecord, void *context);
+static void discovery_resolveRemoveCallback(DNSServiceRef sdRef,
+		DNSServiceFlags flags, uint32_t interfaceIndex,
+		DNSServiceErrorType errorCode, const char *fullname,
+		const char *hosttarget, uint16_t port, /* In network byte order */
+		uint16_t txtLen, const unsigned char *txtRecord, void *context);
+static celix_status_t discovery_informEndpointListeners(discovery_pt discovery, endpoint_description_pt endpoint, bool addingService);
 
-static const char * const DEFAULT_RSA_PORT = "555";
+static const char * const DEFAULT_DISCOVERY_PORT = "8889";
 static const char * const OSGI_SERVICE_TYPE = "_osgi._udp";
 
+typedef struct discovered_endpoint_entry {
+	apr_pool_t *pool;
+	endpoint_description_pt endpointDescription;
+} * discovered_endpoint_entry_pt;
+
+typedef struct disclosed_endpoint_entry {
+	apr_pool_t *pool;
+	endpoint_description_pt endpointDescription;
+	TXTRecordRef *txtRecord;
+	DNSServiceRef dnsServiceRef;
+} * disclosed_endpoint_entry_pt;
+
+
 struct discovery {
 	bundle_context_pt context;
 	apr_pool_t *pool;
 
-	hash_map_pt listenerReferences;
 
-	bool running;
+	apr_thread_mutex_t *listenerReferencesMutex;
+	apr_thread_mutex_t *discoveredServicesMutex;
+	apr_thread_mutex_t *disclosedServicesMutex;
+
+	hash_map_pt listenerReferences; //key=serviceReference, value=?? TODO
+	hash_map_pt discoveredServices; //key=endpointId (string), value=discovered_endpoint_entry_pt;
+	hash_map_pt disclosedServices; //key=endpointId (string), value=disclosed_endpoint_entry_pt;
+
+	volatile bool running;
 	apr_thread_t *poll;
 	DNSServiceRef browseRef;
 
-	hash_map_pt slpServices;
-
-	char *rsaPort;
-
-	array_list_pt handled;
-	array_list_pt registered;
+	char *discoveryPort;
+	char *frameworkUuid;
 };
 
 celix_status_t discovery_create(apr_pool_t *pool, bundle_context_pt context, discovery_pt *discovery) {
@@ -100,18 +107,29 @@ 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)->discoveredServices = hashMap_create(string_hash, NULL, string_equals, NULL);
+		(*discovery)->disclosedServices = hashMap_create(string_hash, NULL, string_equals, NULL);
 		(*discovery)->running = true;
 		(*discovery)->browseRef = NULL;
-		(*discovery)->rsaPort = getenv("RSA_PORT");
-		if ((*discovery)->rsaPort == NULL) {
-			printf("No RemoteServiceAdmin port set, set it using RSA_PORT! Using default port (%s)\n", DEFAULT_RSA_PORT);
-			(*discovery)->rsaPort = DEFAULT_RSA_PORT;
+		(*discovery)->discoveryPort = NULL;
+		(*discovery)->listenerReferencesMutex = NULL;
+		(*discovery)->discoveredServicesMutex = NULL;
+		(*discovery)->disclosedServicesMutex = NULL;
+		(*discovery)->frameworkUuid = NULL;
+
+		bundleContext_getProperty(context, FRAMEWORK_UUID, &(*discovery)->frameworkUuid);
+
+		CELIX_DO_IF(status, status = apr_thread_mutex_create(&(*discovery)->listenerReferencesMutex, APR_THREAD_MUTEX_DEFAULT, pool));
+		CELIX_DO_IF(status, status = apr_thread_mutex_create(&(*discovery)->discoveredServicesMutex, APR_THREAD_MUTEX_DEFAULT, pool));
+		CELIX_DO_IF(status, status = apr_thread_mutex_create(&(*discovery)->disclosedServicesMutex, APR_THREAD_MUTEX_DEFAULT, pool));
+
+		char *port = NULL;
+		bundleContext_getProperty(context, "DISCOVERY_PORT", &port);
+		if (port == NULL) {
+			(*discovery)->discoveryPort = DEFAULT_DISCOVERY_PORT;
+		} else {
+			(*discovery)->discoveryPort = apr_pstrdup(pool, port);
 		}
-		(*discovery)->handled = NULL;
-		arrayList_create(pool, &(*discovery)->handled);
-		(*discovery)->registered = NULL;
-		arrayList_create(pool, &(*discovery)->registered);
 
 		DNSServiceErrorType error = DNSServiceBrowse(
 				 &(*discovery)->browseRef,
@@ -122,15 +140,18 @@ celix_status_t discovery_create(apr_pool
 				   discovery_browseCallback,
 				   (*discovery)/* may be NULL */
 				   );
+		if (error != kDNSServiceErr_NoError) {
+			status = CELIX_ILLEGAL_STATE;
+		}
 
-		apr_thread_create(&(*discovery)->poll, NULL, discovery_poll, *discovery, (*discovery)->pool);
+		status = CELIX_DO_IF(status, apr_thread_create(&(*discovery)->poll, NULL, discovery_poll, *discovery, (*discovery)->pool));
 	}
 
 	return status;
 }
 
 celix_status_t discovery_stop(discovery_pt discovery) {
-	celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status;
 
 	apr_status_t tstat;
 	discovery->running = false;
@@ -140,11 +161,37 @@ celix_status_t discovery_stop(discovery_
 		status = CELIX_BUNDLE_EXCEPTION;
 	}
 
-	int i;
-	for (i = 0; i < arrayList_size(discovery->registered); i++) {
-		char *url = arrayList_get(discovery->registered, i);
-		discovery_deregisterEndpoint(discovery, url);
+	apr_thread_mutex_lock(discovery->disclosedServicesMutex);
+	hash_map_iterator_pt iter = hashMapIterator_create(discovery->disclosedServices);
+	while (hashMapIterator_nextEntry(iter)) {
+		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+		disclosed_endpoint_entry_pt endpointEntry = hashMapEntry_getValue(entry);
+		DNSServiceRefDeallocate(endpointEntry->dnsServiceRef);
 	}
+	hashMapIterator_destroy(iter);
+
+	iter = hashMapIterator_create(discovery->discoveredServices);
+	while (hashMapIterator_hasNext(iter)) {
+		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+		discovered_endpoint_entry_pt endpointEntry = hashMapEntry_getValue(entry);
+		discovery_informEndpointListeners(discovery, endpointEntry->endpointDescription, false);
+	}
+	hashMapIterator_destroy(iter);
+
+	hashMap_destroy(discovery->disclosedServices, false, false);
+
+	discovery->disclosedServices = NULL;
+	apr_thread_mutex_unlock(discovery->disclosedServicesMutex);
+
+	apr_thread_mutex_lock(discovery->discoveredServicesMutex);
+	hashMap_destroy(discovery->discoveredServices, false, false);
+	discovery->discoveredServices = NULL;
+	apr_thread_mutex_unlock(discovery->discoveredServicesMutex);
+
+	apr_thread_mutex_lock(discovery->listenerReferencesMutex);
+	hashMap_destroy(discovery->listenerReferences, false, false);
+	discovery->listenerReferences = NULL;
+	apr_thread_mutex_unlock(discovery->listenerReferencesMutex);
 
 	return status;
 }
@@ -153,53 +200,96 @@ celix_status_t discovery_endpointAdded(v
 	celix_status_t status = CELIX_SUCCESS;
 	discovery_pt discovery = handle;
 
-	printf("discovery_endpointAdded CALLED\n");
+	printf("DISCOVERY: Endpoint for %s, with filter \"%s\" added\n", endpoint->service, machtedFilter);
+	disclosed_endpoint_entry_pt entry = NULL;
+	apr_pool_t *childPool = NULL;
+	status = apr_pool_create(&childPool, discovery->pool);
+
+	if (status == CELIX_SUCCESS) {
+		entry = apr_palloc(childPool, sizeof(*entry));
+		if (entry == NULL) {
+			status = CELIX_ENOMEM;
+			apr_pool_destroy(childPool);
+		} else {
+			entry->pool = childPool;
+			entry->endpointDescription = endpoint;
+		}
+	}
 
-	DNSServiceRef sdRef = NULL;
-	DNSServiceErrorType error;
-	TXTRecordRef txtRecord;
-
-    TXTRecordCreate (&txtRecord, 256, NULL);//TODO search for correct default record size
-    char serviceId[16];
-    sprintf(serviceId, "%li", endpoint->serviceId);
-
-    TXTRecordSetValue(&txtRecord, "service", strlen(endpoint->service), endpoint->service);
-    TXTRecordSetValue(&txtRecord, "service.id", strlen(serviceId), serviceId);
-
-    hash_map_iterator_pt iter = hashMapIterator_create(endpoint->properties);
-    while (hashMapIterator_hasNext(iter))  {
-    	hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-    	char *key = hashMapEntry_getKey(entry);
-    	char *value = hashMapEntry_getValue(entry);
-    	TXTRecordSetValue(&txtRecord, key, strlen(value), value);
-    }
-
-    int port = atoi(discovery->rsaPort);
-    int portInNetworkByteOrder = ((port << 8) & 0xFF00) | ((port >> 8) & 0xFF); //TODO assuming little endian ?? correct? check with ifdef?
-
-    error = DNSServiceRegister (
-       &sdRef,
-       0,
-       0,
-       endpoint->service, /* may be NULL */
-       OSGI_SERVICE_TYPE,
-       NULL, /* may be NULL */
-       NULL, /* may be NULL */
-       portInNetworkByteOrder, /* In network byte order */
-       TXTRecordGetLength(&txtRecord),
-       TXTRecordGetBytesPtr(&txtRecord), /* may be NULL */
-       NULL, /* may be NULL */
-       NULL /* may be NULL */
-       );
+	if (status == CELIX_SUCCESS) {
+		DNSServiceRef sdRef = NULL;
+		DNSServiceErrorType error;
+		TXTRecordRef txtRecord;
+
+		TXTRecordCreate(&txtRecord, 256, NULL ); //TODO search for correct default record size
+		char serviceId[16];
+		sprintf(serviceId, "%li", endpoint->serviceId);
+
+		TXTRecordSetValue(&txtRecord, "service", strlen(endpoint->service),
+				endpoint->service);
+		TXTRecordSetValue(&txtRecord, "service.id", strlen(serviceId),
+				serviceId);
+		TXTRecordSetValue(&txtRecord, "endpoint.id", strlen(endpoint->id),
+				endpoint->id);
+		TXTRecordSetValue(&txtRecord, "framework.uuid", strlen(discovery->frameworkUuid), discovery->frameworkUuid);
+
+		hash_map_iterator_pt iter = hashMapIterator_create(
+				endpoint->properties);
+		while (hashMapIterator_hasNext(iter)) {
+			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+			char *key = hashMapEntry_getKey(entry);
+			char *value = hashMapEntry_getValue(entry);
+			TXTRecordSetValue(&txtRecord, key, strlen(value), value);
+		}
+		hashMapIterator_destroy(iter);
+
+		int port = atoi(discovery->discoveryPort);
+		int portInNetworkByteOrder = ((port << 8) & 0xFF00)
+				| ((port >> 8) & 0xFF); //FIXME assuming little endian
+
+		error = DNSServiceRegister(&sdRef, 0, 0, endpoint->service,
+					OSGI_SERVICE_TYPE, NULL,
+					NULL, portInNetworkByteOrder, /* In network byte order */
+					TXTRecordGetLength(&txtRecord), TXTRecordGetBytesPtr(&txtRecord),
+					NULL, NULL );
+
+		if (error != kDNSServiceErr_NoError) {
+			status = CELIX_ILLEGAL_STATE;
+//			printf("Registered record in dns-sd got error code %i\n", error);
+		} else {
+			//entry->txtRecord=txtRecord; TODO
+			entry->dnsServiceRef = sdRef;
+			apr_thread_mutex_lock(discovery->disclosedServicesMutex);
+			if (discovery->disclosedServices != NULL) {
+				hashMap_put(discovery->disclosedServices, endpoint->id, entry);
+			}
+			apr_thread_mutex_unlock(discovery->disclosedServicesMutex);
+		}
+	}
 
 
-    printf("Registered record in dns-sd got error code %i\n", error);
 
 	return status;
 }
 
 celix_status_t discovery_endpointRemoved(void *handle, endpoint_description_pt endpoint, char *machtedFilter) {
 	celix_status_t status = CELIX_SUCCESS;
+	discovery_pt discovery = handle;
+
+	disclosed_endpoint_entry_pt entry = NULL;
+	apr_thread_mutex_lock(discovery->disclosedServicesMutex);
+	if (discovery->disclosedServices != NULL) {
+		entry = hashMap_remove(discovery->disclosedServices, endpoint->id);
+	}
+	if (entry != NULL) {
+		DNSServiceRefDeallocate(entry->dnsServiceRef);
+		apr_pool_destroy(entry->pool);
+	} else {
+		status = CELIX_ILLEGAL_STATE;
+	}
+	apr_thread_mutex_unlock(discovery->disclosedServicesMutex);
+
+
 	return status;
 }
 
@@ -226,7 +316,11 @@ celix_status_t discovery_endpointListene
 		printf("DISCOVERY: EndpointListener Ignored - Discovery listener\n");
 	} else {
 		printf("DISCOVERY: EndpointListener Added - Add Scope\n");
-		discovery_updateEndpointListener(discovery, reference, (endpoint_listener_pt) service);
+		apr_thread_mutex_lock(discovery->listenerReferencesMutex);
+		if (discovery->listenerReferences != NULL) {
+			hashMap_put(discovery->listenerReferences, reference, NULL /*TODO is the scope value needed?*/);
+		}
+		apr_thread_mutex_unlock(discovery->listenerReferencesMutex);
 	}
 
 	return status;
@@ -236,7 +330,7 @@ celix_status_t discovery_endpointListene
 	celix_status_t status = CELIX_SUCCESS;
 	discovery_pt discovery = handle;
 
-	printf("DISCOVERY: EndpointListener Modified - Update Scope TODO\n");
+//	printf("DISCOVERY: EndpointListener Modified - Update Scope TODO\n");
 
 	return status;
 }
@@ -248,14 +342,12 @@ celix_status_t discovery_endpointListene
 	discovery_pt discovery = handle;
 
 	printf("DISCOVERY: EndpointListener Removed\n");
-	hashMap_remove(discovery->listenerReferences, reference);
-
-	return status;
-}
+	apr_thread_mutex_lock(discovery->listenerReferencesMutex);
+	if (discovery->listenerReferences != NULL) {
+		hashMap_remove(discovery->listenerReferences, reference);
+	}
+	apr_thread_mutex_unlock(discovery->listenerReferencesMutex);
 
-celix_status_t discovery_updateEndpointListener(discovery_pt discovery,
-		service_reference_pt reference, endpoint_listener_pt service) {
-	celix_status_t status = CELIX_SUCCESS;
 	return status;
 }
 
@@ -276,53 +368,143 @@ static void discovery_browseCallback(DNS
 		void *context) {
 	discovery_pt discovery = context;
 	if (flags & kDNSServiceFlagsAdd) {
-		printf("Added service with %s %s %s\n", serviceName, regtype,
-				replyDomain);
+//		printf("Added service with %s %s %s\n", serviceName, regtype,
+//				replyDomain);
 		DNSServiceRef resolveRef = NULL;
 		DNSServiceErrorType resolveError = DNSServiceResolve(&resolveRef, 0, 0,
-				serviceName, regtype, replyDomain, discovery_resolveCallback,
+				serviceName, regtype, replyDomain, discovery_resolveAddCallback,
 				context);
-		printf("Resolve return with error %i\n", resolveError);
-		DNSServiceProcessResult(resolveRef);
+//		printf("Resolve return with error %i\n", resolveError);
+		if (resolveError == kDNSServiceErr_NoError) {
+			DNSServiceProcessResult(resolveRef);
+		} else {
+			//TODO print error / handle error?
+		}
 	} else {
-		printf("Removed service with %s %s %s\n", serviceName, regtype,
-				replyDomain);
+//		printf("Removed service with %s %s %s\n", serviceName, regtype,
+//				replyDomain);
+		DNSServiceRef resolveRef = NULL;
+		DNSServiceErrorType resolveError = DNSServiceResolve(&resolveRef, 0, 0,
+				serviceName, regtype, replyDomain, discovery_resolveRemoveCallback,
+				context);
+		if (resolveError == kDNSServiceErr_NoError) {
+			DNSServiceProcessResult(resolveRef);
+		} else {
+			//TODO print error / handle error?
+		}
 	}
 }
 
-static void discovery_resolveCallback(DNSServiceRef sdRef,
+static void discovery_resolveRemoveCallback(DNSServiceRef sdRef,
 		DNSServiceFlags flags, uint32_t interfaceIndex,
 		DNSServiceErrorType errorCode, const char *fullname,
 		const char *hosttarget, uint16_t port, /* In network byte order */
 		uint16_t txtLen, const unsigned char *txtRecord, void *context) {
-	printf("In resolve callback!\n");
-	int length = TXTRecordGetCount(txtLen, txtRecord);
-	printf("Found txt record with item count %i\n|", length);
-	for (int i=0; i<length; i+=1) {
-		char key[128];
-		void *value = NULL;
-		int valueSize = 0;
-		TXTRecordGetItemAtIndex(txtLen, txtRecord, i, 128, key, &valueSize, &value);
-		printf("Found key=value %s=%s\n", key, value);
+	discovery_pt discovery = context;
+
+	apr_thread_mutex_lock(discovery->discoveredServicesMutex);
+	discovered_endpoint_entry_pt entry = NULL;
+	if (discovery->discoveredServices != NULL) {
+		entry = hashMap_remove(discovery->discoveredServices, (void *)fullname);
+	}
+	apr_thread_mutex_unlock(discovery->discoveredServicesMutex);
+	if (entry != NULL) {
+		discovery_informEndpointListeners(discovery, entry->endpointDescription, true);
+		properties_destroy(entry->endpointDescription->properties);
+		apr_pool_destroy(entry->pool);
+	} else {
+		//unknown or own endpoint -> ignore
 	}
+
 }
 
-static celix_status_t discovery_deregisterEndpoint(discovery_pt discovery, const char *serviceUrl) {
-	celix_status_t status = CELIX_SUCCESS;
-	printf("DISCOVERY: Remove endpoint: %s\n", serviceUrl);
-	printf("TODO\n");
+static void discovery_resolveAddCallback(DNSServiceRef sdRef,
+		DNSServiceFlags flags, uint32_t interfaceIndex,
+		DNSServiceErrorType errorCode, const char *fullname,
+		const char *hosttarget, uint16_t port, /* In network byte order */
+		uint16_t txtLen, const unsigned char *txtRecord, void *context) {
+	discovery_pt discovery = context;
 
-	return status;
-}
+	properties_pt props = properties_create();
+	int length = TXTRecordGetCount(txtLen, txtRecord);
+//	printf("Found txt record with item count %i\n|", length);
+	for (int i = 0; i < length; i += 1) {
+		char key[256];
+		char valueBuf[257]; //max uint8 + 1
+		const void *value = NULL;
+		uint8_t valueSize = 0;
+		TXTRecordGetItemAtIndex(txtLen, txtRecord, i, 256, key, &valueSize,
+				&value);
+		memcpy(valueBuf, value, valueSize);
+		valueBuf[valueSize] = '\0';
+//		printf("Found key=value %s=%s\n", key, valueBuf);
+		properties_set(props, key, valueBuf);
+	}
 
-static celix_status_t discovery_addService(discovery_pt discovery, endpoint_description_pt endpoint) {
-	celix_status_t status = CELIX_SUCCESS;
-	//TODO should be called when dns-sd find a services, forward to listeners
-	return status;
+	//check if framework uuid is not this framework uuid
+	char *endpointUuid = properties_get(props, (char *)ENDPOINT_FRAMEWORK_UUID);
+
+	if (endpointUuid == NULL) {
+		printf("DISCOVERY: Cannot process endpoint, no %s property\n", ENDPOINT_FRAMEWORK_UUID);
+	} else if (strcmp(endpointUuid, discovery->frameworkUuid) != 0) {
+		apr_pool_t *childPool = NULL;
+		apr_pool_create(&childPool, discovery->pool);
+		discovered_endpoint_entry_pt entry = apr_palloc(childPool, sizeof(*entry));
+		endpoint_description_pt endpoint = apr_palloc(childPool, sizeof(*endpoint));
+		//FIXME endpoint id for http should be the url
+		endpoint->id = apr_pstrdup(childPool, fullname);
+		endpoint->serviceId = 0 /*TODO*/;
+		endpoint->service = properties_get(props, "service");
+		endpoint->properties = props;
+		apr_thread_mutex_lock(discovery->discoveredServicesMutex);
+		if (discovery->discoveredServices != NULL) {
+			hashMap_put(discovery->discoveredServices, endpoint->id, entry);
+		}
+		apr_thread_mutex_unlock(discovery->discoveredServicesMutex);
+		discovery_informEndpointListeners(discovery, endpoint, true);
+	} else {
+		//ignore self disclosed endpoints!
+		printf("DISCOVERY: Ignoring own endpoint, with service %s!\n", properties_get(props, "service"));
+		properties_destroy(props);
+	}
 }
 
-static celix_status_t discovery_removeService(discovery_pt discovery, endpoint_description_pt endpoint) {
+static celix_status_t discovery_informEndpointListeners(discovery_pt discovery, endpoint_description_pt endpoint, bool endpointAdded) {
 	celix_status_t status = CELIX_SUCCESS;
-	//TODO should be called when dns-sd notices a removal of a services, forward to listeners
+
+	// Inform listeners of new endpoint
+	apr_thread_mutex_lock(discovery->listenerReferencesMutex);
+	if (discovery->listenerReferences != NULL) {
+		hash_map_iterator_pt iter = hashMapIterator_create(discovery->listenerReferences);
+		while (hashMapIterator_hasNext(iter)) {
+			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+			service_reference_pt reference = hashMapEntry_getKey(entry);
+			endpoint_listener_pt listener = NULL;
+
+			service_registration_pt registration = NULL;
+			serviceReference_getServiceRegistration(reference, &registration);
+			properties_pt serviceProperties = NULL;
+			serviceRegistration_getProperties(registration, &serviceProperties);
+			char *scope = properties_get(serviceProperties,
+					(char *) ENDPOINT_LISTENER_SCOPE);
+			filter_pt filter = filter_create(scope, discovery->pool);
+			bool matchResult = false;
+			filter_match(filter, endpoint->properties, &matchResult);
+			if (matchResult) {
+				printf("DISCOVERY: Add service (%s)\n", endpoint->service);
+				bundleContext_getService(discovery->context, reference,
+						(void**) &listener);
+				if (endpointAdded) {
+					listener->endpointAdded(listener->handle, endpoint, NULL );
+				} else {
+					listener->endpointRemoved(listener->handle, endpoint, NULL );
+				}
+
+			}
+		}
+		hashMapIterator_destroy(iter);
+	}
+	apr_thread_mutex_unlock(discovery->listenerReferencesMutex);
+
 	return status;
 }

Modified: incubator/celix/trunk/remote_services/discovery_bonjour/private/src/discovery_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/discovery_bonjour/private/src/discovery_activator.c?rev=1519495&r1=1519494&r2=1519495&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/discovery_bonjour/private/src/discovery_activator.c (original)
+++ incubator/celix/trunk/remote_services/discovery_bonjour/private/src/discovery_activator.c Mon Sep  2 18:52:54 2013
@@ -49,10 +49,11 @@ struct activator {
 	service_registration_pt endpointListenerService;
 };
 
-celix_status_t discoveryActivator_createEPLTracker(struct activator *activator, service_tracker_pt *tracker);
-celix_status_t discoveryActivator_getUUID(struct activator *activator, char **uuidStr);
+celix_status_t discoveryActivator_createEPLTracker(struct activator *activator,
+		service_tracker_pt *tracker);
 
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+celix_status_t bundleActivator_create(bundle_context_pt context,
+		void **userData) {
 	celix_status_t status = CELIX_SUCCESS;
 	apr_pool_t *parentPool = NULL;
 	apr_pool_t *pool = NULL;
@@ -71,7 +72,8 @@ celix_status_t bundleActivator_create(bu
 
 		discovery_create(pool, context, &activator->discovery);
 
-		discoveryActivator_createEPLTracker(activator, &activator->endpointListenerTracker);
+		discoveryActivator_createEPLTracker(activator,
+				&activator->endpointListenerTracker);
 
 		*userData = activator;
 	}
@@ -79,16 +81,20 @@ celix_status_t bundleActivator_create(bu
 	return status;
 }
 
-celix_status_t discoveryActivator_createEPLTracker(struct activator *activator,  service_tracker_pt *tracker) {
+celix_status_t discoveryActivator_createEPLTracker(struct activator *activator,
+		service_tracker_pt *tracker) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	service_tracker_customizer_pt customizer = NULL;
 
-	status = serviceTrackerCustomizer_create(activator->pool, activator->discovery, discovery_endpointListenerAdding,
-			discovery_endpointListenerAdded, discovery_endpointListenerModified, discovery_endpointListenerRemoved, &customizer);
+	status = serviceTrackerCustomizer_create(activator->pool,
+			activator->discovery, discovery_endpointListenerAdding,
+			discovery_endpointListenerAdded, discovery_endpointListenerModified,
+			discovery_endpointListenerRemoved, &customizer);
 
 	if (status == CELIX_SUCCESS) {
-		status = serviceTracker_create(activator->pool, activator->context, "endpoint_listener", customizer, tracker);
+		status = serviceTracker_create(activator->pool, activator->context,
+				(char *) endpoint_listener_service, customizer, tracker);
 
 		serviceTracker_open(activator->endpointListenerTracker);
 	}
@@ -102,7 +108,8 @@ celix_status_t bundleActivator_start(voi
 	apr_pool_t *pool = NULL;
 	apr_pool_create(&pool, activator->pool);
 
-	endpoint_listener_pt endpointListener = apr_palloc(pool, sizeof(*endpointListener));
+	endpoint_listener_pt endpointListener = apr_palloc(pool,
+			sizeof(*endpointListener));
 	endpointListener->handle = activator->discovery;
 	endpointListener->endpointAdded = discovery_endpointAdded;
 	endpointListener->endpointRemoved = discovery_endpointRemoved;
@@ -110,10 +117,13 @@ celix_status_t bundleActivator_start(voi
 	properties_pt props = properties_create();
 	properties_set(props, "DISCOVERY", "true");
 	char *uuid = NULL;
-	discoveryActivator_getUUID(activator, &uuid);
+	bundleContext_getProperty(context, FRAMEWORK_UUID, &uuid);
 	char *scope = apr_pstrcat(activator->pool, "(&(", OBJECTCLASS, "=*)(", ENDPOINT_FRAMEWORK_UUID, "=", uuid, "))", NULL);
+	printf("DISCOVERY SCOPE IS: %s\n", scope);
 	properties_set(props, (char *) ENDPOINT_LISTENER_SCOPE, scope);
-	status = bundleContext_registerService(context, (char *) endpoint_listener_service, endpointListener, props, &activator->endpointListenerService);
+	status = bundleContext_registerService(context,
+			(char *) endpoint_listener_service, endpointListener, props,
+			&activator->endpointListenerService);
 
 	return status;
 }
@@ -122,31 +132,15 @@ celix_status_t bundleActivator_stop(void
 	celix_status_t status = CELIX_SUCCESS;
 	struct activator *activator = userData;
 
-	discovery_stop(activator->discovery);
 	serviceTracker_close(activator->endpointListenerTracker);
 	serviceRegistration_unregister(activator->endpointListenerService);
+	discovery_stop(activator->discovery);
 
 	return status;
 }
 
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	return status;
-}
-
-celix_status_t discoveryActivator_getUUID(struct activator *activator, char **uuidStr) {
+celix_status_t bundleActivator_destroy(void * userData,
+		bundle_context_pt context) {
 	celix_status_t status = CELIX_SUCCESS;
-
-	status = bundleContext_getProperty(activator->context, ENDPOINT_FRAMEWORK_UUID, uuidStr);
-	if (status == CELIX_SUCCESS) {
-		if (*uuidStr == NULL) {
-			apr_uuid_t uuid;
-			apr_uuid_get(&uuid);
-			*uuidStr = apr_palloc(activator->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/discovery_slp/private/include/discovery.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/discovery_slp/private/include/discovery.h?rev=1519495&r1=1519494&r2=1519495&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/discovery_slp/private/include/discovery.h (original)
+++ incubator/celix/trunk/remote_services/discovery_slp/private/include/discovery.h Mon Sep  2 18:52:54 2013
@@ -42,7 +42,7 @@ celix_status_t discovery_endpointListene
 celix_status_t discovery_endpointListenerModified(void * handle, service_reference_pt reference, void * service);
 celix_status_t discovery_endpointListenerRemoved(void * handle, service_reference_pt reference, void * service);
 
-celix_status_t discovery_updateEndpointListener(discovery_pt discovery, service_reference_pt reference, endpoint_listener_pt service);
+//celix_status_t discovery_updateEndpointListener(discovery_pt discovery, service_reference_pt reference, endpoint_listener_pt service);
 
 
 #endif /* DISCOVERY_H_ */

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=1519495&r1=1519494&r2=1519495&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 Mon Sep  2 18:52:54 2013
@@ -50,7 +50,7 @@ struct discovery {
 
 	hash_map_pt slpServices;
 
-	char *rsaPort;
+	char *discoveryPort;
 
 	array_list_pt handled;
 	array_list_pt registered;
@@ -88,8 +88,8 @@ celix_status_t discovery_create(apr_pool
 		(*discovery)->listenerReferences = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2, NULL);
 		(*discovery)->slpServices = hashMap_create(string_hash, NULL, string_equals, NULL);
 		(*discovery)->running = true;
-		(*discovery)->rsaPort = getenv("RSA_PORT");
-		if ((*discovery)->rsaPort == NULL) {
+		(*discovery)->discoveryPort = getenv("RSA_PORT");
+		if ((*discovery)->discoveryPort == NULL) {
 			printf("No RemoteServiceAdmin port set, set it using RSA_PORT!\n");
 		}
 		(*discovery)->handled = NULL;
@@ -224,7 +224,7 @@ celix_status_t discovery_constructServic
 				if (stat != APR_SUCCESS) {
 					status = CELIX_BUNDLE_EXCEPTION;
 				} else {
-					*serviceUrl = apr_pstrcat(discovery->pool, "service:osgi.remote:http://", ip, ":", discovery->rsaPort, "/services/", endpoint->service, NULL);
+					*serviceUrl = apr_pstrcat(discovery->pool, "service:osgi.remote:http://", ip, ":", discovery->discoveryPort, "/services/", endpoint->service, NULL);
 				}
 			}
 		}

Modified: incubator/celix/trunk/remote_services/discovery_slp/private/src/discovery_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/discovery_slp/private/src/discovery_activator.c?rev=1519495&r1=1519494&r2=1519495&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/discovery_slp/private/src/discovery_activator.c (original)
+++ incubator/celix/trunk/remote_services/discovery_slp/private/src/discovery_activator.c Mon Sep  2 18:52:54 2013
@@ -50,7 +50,6 @@ struct activator {
 };
 
 celix_status_t discoveryActivator_createEPLTracker(struct activator *activator, service_tracker_pt *tracker);
-celix_status_t discoveryActivator_getUUID(struct activator *activator, char **uuidStr);
 
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
 	celix_status_t status = CELIX_SUCCESS;
@@ -110,7 +109,7 @@ celix_status_t bundleActivator_start(voi
 	properties_pt props = properties_create();
 	properties_set(props, "DISCOVERY", "true");
 	char *uuid = NULL;
-	discoveryActivator_getUUID(activator, &uuid);
+	bundleContext_getProperty(activator->context, FRAMEWORK_UUID, &uuid);
 	char *scope = apr_pstrcat(activator->pool, "(&(", OBJECTCLASS, "=*)(", ENDPOINT_FRAMEWORK_UUID, "=", uuid, "))", NULL);
 	properties_set(props, (char *) ENDPOINT_LISTENER_SCOPE, scope);
 	status = bundleContext_registerService(context, (char *) endpoint_listener_service, endpointListener, props, &activator->endpointListenerService);
@@ -133,20 +132,3 @@ celix_status_t bundleActivator_destroy(v
 	celix_status_t status = CELIX_SUCCESS;
 	return status;
 }
-
-celix_status_t discoveryActivator_getUUID(struct activator *activator, char **uuidStr) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	status = bundleContext_getProperty(activator->context, ENDPOINT_FRAMEWORK_UUID, uuidStr);
-	if (status == CELIX_SUCCESS) {
-		if (*uuidStr == NULL) {
-			apr_uuid_t uuid;
-			apr_uuid_get(&uuid);
-			*uuidStr = apr_palloc(activator->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/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=1519495&r1=1519494&r2=1519495&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 Mon Sep  2 18:52:54 2013
@@ -67,8 +67,9 @@ celix_status_t exampleProxy_add(example_
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (example->endpoint != NULL) {
-		printf("CALCULATOR_PROXY: URL: %s\n", example->endpoint->id);
-		char *url = apr_pstrcat(example->pool, example->endpoint->id, "/add", NULL);
+		char *serviceUrl = properties_get(example->endpoint->properties, "url");
+		printf("CALCULATOR_PROXY: URL: %s\n", serviceUrl);
+		char *url = apr_pstrcat(example->pool, serviceUrl, "/add", NULL);
 
 		json_t *root;
 		root = json_pack("{s:f, s:f}", "a", a, "b", b);

Modified: incubator/celix/trunk/remote_services/example_service/public/include/example_service.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/example_service/public/include/example_service.h?rev=1519495&r1=1519494&r2=1519495&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/example_service/public/include/example_service.h (original)
+++ incubator/celix/trunk/remote_services/example_service/public/include/example_service.h Mon Sep  2 18:52:54 2013
@@ -40,4 +40,13 @@ struct example_service {
 	celix_status_t (*sqrt)(example_pt example, double a, double *result);
 };
 
+
+/*
+ * interface example_service {
+ * 	double add(double a, double b);
+ * 	double sub(double a, double b);
+ * 	double sqrt(double a);
+ * }
+ */
+
 #endif /* EXAMPLE_SERVICE_H_ */

Modified: incubator/celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h?rev=1519495&r1=1519494&r2=1519495&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h (original)
+++ incubator/celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h Mon Sep  2 18:52:54 2013
@@ -50,6 +50,8 @@ struct remote_service_admin {
 	hash_map_pt exportedServices;
 	hash_map_pt importedServices;
 
+	char *port;
+
 	struct mg_context *ctx;
 };
 

Modified: incubator/celix/trunk/remote_services/remote_service_admin/private/src/import_registration_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/remote_service_admin/private/src/import_registration_impl.c?rev=1519495&r1=1519494&r2=1519495&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/remote_service_admin/private/src/import_registration_impl.c (original)
+++ incubator/celix/trunk/remote_services/remote_service_admin/private/src/import_registration_impl.c Mon Sep  2 18:52:54 2013
@@ -121,6 +121,7 @@ celix_status_t importRegistration_proxyA
 	celix_status_t status = CELIX_SUCCESS;
 	import_registration_pt registration = handle;
 
+	printf("PROXY added called!");
 	remote_proxy_service_pt proxy = service;
 	if (registration->proxy == NULL) {
 		registration->reference = reference;

Modified: incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_activator.c?rev=1519495&r1=1519494&r2=1519495&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_activator.c (original)
+++ incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_activator.c Mon Sep  2 18:52:54 2013
@@ -111,7 +111,6 @@ celix_status_t bundleActivator_stop(void
 	serviceRegistration_unregister(activator->registration);
 	activator->registration = NULL;
 
-
 	return status;
 }
 

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=1519495&r1=1519494&r2=1519495&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 Mon Sep  2 18:52:54 2013
@@ -26,7 +26,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <apr_uuid.h>
 #include <apr_strings.h>
 
 #include "remote_service_admin_impl.h"
@@ -46,10 +45,13 @@ static const char *ajax_reply_start =
   "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);
 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);
-celix_status_t remoteServiceAdmin_getUUID(remote_service_admin_pt rsa, char **uuidStr);
+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) {
 	celix_status_t status = CELIX_SUCCESS;
@@ -67,7 +69,9 @@ celix_status_t remoteServiceAdmin_create
 		char *port = NULL;
 		bundleContext_getProperty(context, "RSA_PORT", &port);
 		if (port == NULL) {
-			printf("No RemoteServiceAdmin port set, set it using RSA_PORT!\n");
+			(*admin)->port = DEFAULT_PORT;
+		} else {
+			(*admin)->port = apr_pstrdup(pool, port);
 		}
 		const char *options[] = {"listening_ports", port, NULL};
 		(*admin)->ctx = mg_start(remoteServiceAdmin_callback, (*admin), options);
@@ -252,10 +256,15 @@ celix_status_t remoteServiceAdmin_instal
 	properties_set(endpointProperties, (char *) OBJECTCLASS, interface);
 	properties_set(endpointProperties, (char *) ENDPOINT_SERVICE_ID, serviceId);
 	char *uuid = NULL;
-	remoteServiceAdmin_getUUID(admin, &uuid);
+	bundleContext_getProperty(admin->context, FRAMEWORK_UUID, &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;
 	remoteServiceAdmin_createEndpointDescription(admin, serviceProperties, endpointProperties, interface, &endpointDescription);
@@ -264,6 +273,39 @@ celix_status_t remoteServiceAdmin_instal
 	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 status = CELIX_SUCCESS;
@@ -277,7 +319,7 @@ celix_status_t remoteServiceAdmin_create
 		status = CELIX_ENOMEM;
 	} else {
 		char *uuid = NULL;
-		status = bundleContext_getProperty(admin->context, ENDPOINT_FRAMEWORK_UUID, &uuid);
+		status = bundleContext_getProperty(admin->context, (char *)FRAMEWORK_UUID, &uuid);
 		if (status == CELIX_SUCCESS) {
 			(*description)->properties = endpointProperties;
 			(*description)->frameworkUUID = uuid;
@@ -342,20 +384,3 @@ celix_status_t importReference_getImport
 	celix_status_t status = CELIX_SUCCESS;
 	return status;
 }
-
-celix_status_t remoteServiceAdmin_getUUID(remote_service_admin_pt 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/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/topology_manager/CMakeLists.txt?rev=1519495&r1=1519494&r2=1519495&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/topology_manager/CMakeLists.txt (original)
+++ incubator/celix/trunk/remote_services/topology_manager/CMakeLists.txt Mon Sep  2 18:52:54 2013
@@ -31,4 +31,4 @@ bundle(topology_manager SOURCES
     private/include/topology_manager.h
 )
 
-target_link_libraries(topology_manager celix_framework remote_services_utils ${APRUTIL_LIBRARY})
+target_link_libraries(topology_manager celix_framework ${APRUTIL_LIBRARY})

Modified: incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c?rev=1519495&r1=1519494&r2=1519495&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c (original)
+++ incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c Mon Sep  2 18:52:54 2013
@@ -39,8 +39,6 @@
 #include "remote_constants.h"
 #include "listener_hook_service.h"
 
-#include "remote_services_utils.h"
-
 struct activator {
 	apr_pool_t *pool;
 	bundle_context_pt context;
@@ -139,8 +137,9 @@ celix_status_t bundleActivator_start(voi
 
 	properties_pt props = properties_create();
 	char *uuid = NULL;
-	remoteServicesUtils_getUUID(pool, context, &uuid);
+	bundleContext_getProperty(activator->context, (char *)FRAMEWORK_UUID, &uuid);
 	char *scope = apr_pstrcat(pool, "(&(", OBJECTCLASS, "=*)(!(", ENDPOINT_FRAMEWORK_UUID, "=", uuid, ")))", NULL);
+	printf("TOPOLOGY_MANAGER: Endpoint listener Scope is %s\n", scope);
 	properties_set(props, (char *) ENDPOINT_LISTENER_SCOPE, scope);
 
 	bundleContext_registerService(context, (char *) endpoint_listener_service, endpointListener, props, &activator->endpointListenerService);

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=1519495&r1=1519494&r2=1519495&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 Mon Sep  2 18:52:54 2013
@@ -61,8 +61,6 @@ struct import_interest {
 celix_status_t topologyManager_notifyListeners(topology_manager_pt manager, remote_service_admin_service_pt rsa,  array_list_pt registrations);
 celix_status_t topologyManager_notifyListenersOfRemoval(topology_manager_pt manager, remote_service_admin_service_pt rsa,  export_registration_pt export);
 
-celix_status_t topologyManager_getUUID(topology_manager_pt manager, char **uuidStr);
-
 celix_status_t topologyManager_create(bundle_context_pt context, apr_pool_t *pool, topology_manager_pt *manager) {
 	celix_status_t status = CELIX_SUCCESS;
 
@@ -344,7 +342,7 @@ celix_status_t topologyManager_extendFil
 	apr_pool_create(&pool, manager->pool);
 
 	char *uuid = NULL;
-	topologyManager_getUUID(manager, &uuid);
+	bundleContext_getProperty(manager->context, (char *)FRAMEWORK_UUID, &uuid);
 	*updatedFilter = apr_pstrcat(pool, "(&", filter, "(!(", ENDPOINT_FRAMEWORK_UUID, "=", uuid, ")))", NULL);
 
 	return status;
@@ -421,22 +419,3 @@ celix_status_t topologyManager_listenerR
 
 	return status;
 }
-
-celix_status_t topologyManager_getUUID(topology_manager_pt manager, char **uuidStr) {
-	celix_status_t status = CELIX_SUCCESS;
-	apr_pool_t *pool = NULL;
-	apr_pool_create(&pool, manager->pool);
-
-	status = bundleContext_getProperty(manager->context, ENDPOINT_FRAMEWORK_UUID, uuidStr);
-	if (status == CELIX_SUCCESS) {
-		if (*uuidStr == NULL) {
-			apr_uuid_t uuid;
-			apr_uuid_get(&uuid);
-			*uuidStr = apr_palloc(pool, APR_UUID_FORMATTED_LENGTH + 1);
-			apr_uuid_format(*uuidStr, &uuid);
-			setenv(ENDPOINT_FRAMEWORK_UUID, *uuidStr, 1);
-		}
-	}
-
-	return status;
-}



Mime
View raw message