Return-Path: X-Original-To: apmail-celix-commits-archive@www.apache.org Delivered-To: apmail-celix-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B635510296 for ; Mon, 22 Dec 2014 16:11:59 +0000 (UTC) Received: (qmail 69728 invoked by uid 500); 22 Dec 2014 16:11:59 -0000 Delivered-To: apmail-celix-commits-archive@celix.apache.org Received: (qmail 69701 invoked by uid 500); 22 Dec 2014 16:11:59 -0000 Mailing-List: contact commits-help@celix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@celix.apache.org Delivered-To: mailing list commits@celix.apache.org Received: (qmail 69691 invoked by uid 99); 22 Dec 2014 16:11:59 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Dec 2014 16:11:59 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 6FEC0AC092E; Mon, 22 Dec 2014 16:11:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1647343 - in /celix/trunk: log_service/public/src/ remote_services/calculator_proxy/ remote_services/calculator_proxy/private/src/ remote_services/remote_service_admin/private/src/ remote_services/remote_service_admin/public/include/ remot... Date: Mon, 22 Dec 2014 16:11:59 -0000 To: commits@celix.apache.org From: abroekhuis@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20141222161159.6FEC0AC092E@hades.apache.org> Author: abroekhuis Date: Mon Dec 22 16:11:58 2014 New Revision: 1647343 URL: http://svn.apache.org/r1647343 Log: Refactored remote proxy Added: celix/trunk/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c Modified: celix/trunk/log_service/public/src/log_helper.c celix/trunk/remote_services/calculator_proxy/CMakeLists.txt celix/trunk/remote_services/calculator_proxy/private/src/calculator_proxy_activator.c celix/trunk/remote_services/calculator_proxy/private/src/calculator_proxy_impl.c celix/trunk/remote_services/remote_service_admin/public/include/remote_proxy.h celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c Modified: celix/trunk/log_service/public/src/log_helper.c URL: http://svn.apache.org/viewvc/celix/trunk/log_service/public/src/log_helper.c?rev=1647343&r1=1647342&r2=1647343&view=diff ============================================================================== --- celix/trunk/log_service/public/src/log_helper.c (original) +++ celix/trunk/log_service/public/src/log_helper.c Mon Dec 22 16:11:58 2014 @@ -157,6 +157,7 @@ celix_status_t logHelper_log(log_helper_ celix_status_t status = CELIX_SUCCESS; va_list listPointer; char msg[512]; + msg[0] = '\0'; bool logged = false; va_start(listPointer, message); Modified: celix/trunk/remote_services/calculator_proxy/CMakeLists.txt URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/calculator_proxy/CMakeLists.txt?rev=1647343&r1=1647342&r2=1647343&view=diff ============================================================================== --- celix/trunk/remote_services/calculator_proxy/CMakeLists.txt (original) +++ celix/trunk/remote_services/calculator_proxy/CMakeLists.txt Mon Dec 22 16:11:58 2014 @@ -30,6 +30,7 @@ SET(BUNDLE_VERSION "0.0.1") bundle(org.apache.celix.calc.api.Calculator_proxy SOURCES private/src/calculator_proxy_activator private/src/calculator_proxy_impl.c + ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c private/include/calculator_proxy_impl.h ) Modified: celix/trunk/remote_services/calculator_proxy/private/src/calculator_proxy_activator.c URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/calculator_proxy/private/src/calculator_proxy_activator.c?rev=1647343&r1=1647342&r2=1647343&view=diff ============================================================================== --- celix/trunk/remote_services/calculator_proxy/private/src/calculator_proxy_activator.c (original) +++ celix/trunk/remote_services/calculator_proxy/private/src/calculator_proxy_activator.c Mon Dec 22 16:11:58 2014 @@ -27,14 +27,18 @@ #include "bundle_activator.h" #include "service_registration.h" +#include "remote_proxy.h" #include "calculator_proxy_impl.h" struct activator { - service_registration_pt proxyFactoryServiceRegistration; - remote_proxy_factory_service_pt proxyFactoryService; + bundle_context_pt context; + remote_proxy_factory_pt factory_ptr; }; +static celix_status_t calculatorProxyFactory_create(void *handle, endpoint_description_pt endpointDescription, remote_service_admin_pt rsa, sendToHandle sendToCallback, properties_pt properties, void **service); +static celix_status_t calculatorProxyFactory_destroy(void *handle, void *service); + celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) { celix_status_t status = CELIX_SUCCESS; @@ -44,8 +48,8 @@ celix_status_t bundleActivator_create(bu if (!activator) { status = CELIX_ENOMEM; } else { - activator->proxyFactoryServiceRegistration = NULL; - activator->proxyFactoryService = NULL; + activator->factory_ptr = NULL; + activator->context = context; *userData = activator; } @@ -56,24 +60,11 @@ celix_status_t bundleActivator_create(bu celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) { celix_status_t status = CELIX_SUCCESS; struct activator *activator = userData; - remote_proxy_factory_service_pt calculatorProxyFactoryService; - - calculatorProxyFactoryService = calloc(1, sizeof(*calculatorProxyFactoryService)); - calculatorProxyFactoryService->context = context; - calculatorProxyFactoryService->proxy_registrations = hashMap_create(NULL, NULL, NULL, NULL); - calculatorProxyFactoryService->proxy_instances = hashMap_create(NULL, NULL, NULL, NULL); - calculatorProxyFactoryService->registerProxyService = calculatorProxy_registerProxyService; - calculatorProxyFactoryService->unregisterProxyService = calculatorProxy_unregisterProxyService; - - properties_pt props = properties_create(); - properties_set(props, (char *) "proxy.interface", (char *) CALCULATOR_SERVICE); - - if (bundleContext_registerService(context, OSGI_RSA_REMOTE_PROXY_FACTORY, calculatorProxyFactoryService, props, &activator->proxyFactoryServiceRegistration) == CELIX_SUCCESS) - { - printf("CALCULATOR_PROXY: Proxy registered OSGI_RSA_REMOTE_PROXY_FACTORY (%s)\n", OSGI_RSA_REMOTE_PROXY_FACTORY); - } - activator->proxyFactoryService = calculatorProxyFactoryService; + remoteProxyFactory_create(context, (char *) CALCULATOR_SERVICE, activator, + calculatorProxyFactory_create, calculatorProxyFactory_destroy, + &activator->factory_ptr); + remoteProxyFactory_register(activator->factory_ptr); return status; } @@ -82,37 +73,53 @@ celix_status_t bundleActivator_stop(void celix_status_t status = CELIX_SUCCESS; struct activator *activator = userData; - // TODO: unregister proxy registrations - serviceRegistration_unregister(activator->proxyFactoryServiceRegistration); - activator->proxyFactoryServiceRegistration = NULL; + remoteProxyFactory_unregister(activator->factory_ptr); + remoteProxyFactory_destroy(&activator->factory_ptr); - hashMap_destroy(activator->proxyFactoryService->proxy_registrations, false, false); + return status; +} - hash_map_iterator_pt iter = hashMapIterator_create(activator->proxyFactoryService->proxy_instances); +celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) { + celix_status_t status = CELIX_SUCCESS; + struct activator *activator = userData; - while(hashMapIterator_hasNext(iter)) { - calculator_service_pt calculatorService = (calculator_service_pt) hashMapIterator_nextValue(iter); + free(activator); - if (calculatorService != NULL) { - free(calculatorService->calculator); - free(calculatorService); - } - } + return status; +} - hashMapIterator_destroy((iter)); +static celix_status_t calculatorProxyFactory_create(void *handle, endpoint_description_pt endpointDescription, remote_service_admin_pt rsa, sendToHandle sendToCallback, properties_pt properties, void **service) { + celix_status_t status = CELIX_SUCCESS; + struct activator *activator = handle; - hashMap_destroy(activator->proxyFactoryService->proxy_instances, false, false); + calculator_service_pt calculatorService = calloc(1, sizeof(*calculatorService)); + calculatorProxy_create(activator->context, &calculatorService->calculator); + calculatorService->add = calculatorProxy_add; + calculatorService->sub = calculatorProxy_sub; + calculatorService->sqrt = calculatorProxy_sqrt; + + calculatorService->calculator->endpoint = endpointDescription; + calculatorService->calculator->sendToHandler = rsa; + calculatorService->calculator->sendToCallback = sendToCallback; - free(activator->proxyFactoryService); + *service = calculatorService; return status; } -celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) { +static celix_status_t calculatorProxyFactory_destroy(void *handle, void *service) { celix_status_t status = CELIX_SUCCESS; - struct activator *activator = userData; + struct activator *activator = handle; + calculator_service_pt calculatorService = service; - free(activator); + if (!calculatorService) { + status = CELIX_ILLEGAL_ARGUMENT; + } + + if (status == CELIX_SUCCESS) { + calculatorProxy_destroy(&calculatorService->calculator); + free(calculatorService); + } return status; } Modified: celix/trunk/remote_services/calculator_proxy/private/src/calculator_proxy_impl.c URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/calculator_proxy/private/src/calculator_proxy_impl.c?rev=1647343&r1=1647342&r2=1647343&view=diff ============================================================================== --- celix/trunk/remote_services/calculator_proxy/private/src/calculator_proxy_impl.c (original) +++ celix/trunk/remote_services/calculator_proxy/private/src/calculator_proxy_impl.c Mon Dec 22 16:11:58 2014 @@ -37,11 +37,6 @@ #define JSON_DECODE_ANY 0 #endif -celix_status_t calculatorProxy_setEndpointDescription(void *proxy, endpoint_description_pt endpoint); -celix_status_t calculatorProxy_setHandler(void *proxy, void *handler); -celix_status_t calculatorProxy_setCallback(void *proxy, sendToHandle callback); - - celix_status_t calculatorProxy_create(bundle_context_pt context, calculator_pt *calculator) { celix_status_t status = CELIX_SUCCESS; *calculator = calloc(1, sizeof(**calculator)); @@ -176,91 +171,3 @@ celix_status_t calculatorProxy_sqrt(calc return status; } - - - -celix_status_t calculatorProxy_registerProxyService(void* proxyFactoryService, endpoint_description_pt endpointDescription, void* rsa, sendToHandle sendToCallback) { - celix_status_t status = CELIX_SUCCESS; - - remote_proxy_factory_service_pt calculatorProxyFactoryService = (remote_proxy_factory_service_pt) proxyFactoryService; - calculator_pt calculator = NULL; - calculator_service_pt calculatorService = NULL; - - calculatorProxy_create(calculatorProxyFactoryService->context, &calculator); - calculatorService = calloc(1, sizeof(*calculatorService)); - calculatorService->calculator = calculator; - calculatorService->add = calculatorProxy_add; - calculatorService->sub = calculatorProxy_sub; - calculatorService->sqrt = calculatorProxy_sqrt; - - properties_pt srvcProps = properties_create(); - properties_set(srvcProps, (char *) "proxy.interface", (char *) CALCULATOR_SERVICE); - properties_set(srvcProps, (char *) "endpoint.framework.uuid", (char *) endpointDescription->frameworkUUID); - - service_registration_pt proxyReg = NULL; - - calculatorProxy_setEndpointDescription(calculator, endpointDescription); - calculatorProxy_setHandler(calculator, rsa); - calculatorProxy_setCallback(calculator, sendToCallback); - - if (bundleContext_registerService(calculatorProxyFactoryService->context, CALCULATOR_SERVICE, calculatorService, srvcProps, &proxyReg) != CELIX_SUCCESS) - { - printf("CALCULATOR_PROXY: error while registering calculator service\n"); - } - - hashMap_put(calculatorProxyFactoryService->proxy_registrations, endpointDescription, proxyReg); - hashMap_put(calculatorProxyFactoryService->proxy_instances, endpointDescription, calculatorService); - - return status; -} - - -celix_status_t calculatorProxy_unregisterProxyService(void* proxyFactoryService, endpoint_description_pt endpointDescription) { - celix_status_t status = CELIX_SUCCESS; - - remote_proxy_factory_service_pt calculatorProxyFactoryService = (remote_proxy_factory_service_pt) proxyFactoryService; - service_registration_pt proxyReg = hashMap_get(calculatorProxyFactoryService->proxy_registrations, endpointDescription); - calculator_service_pt calculatorService = hashMap_get(calculatorProxyFactoryService->proxy_instances, endpointDescription); - - if (proxyReg != NULL) { - serviceRegistration_unregister(proxyReg); - } - - if (calculatorService != NULL) { - free(calculatorService->calculator); - free(calculatorService); - } - - return status; -} - - -celix_status_t calculatorProxy_setEndpointDescription(void *proxy, endpoint_description_pt endpoint) { - celix_status_t status = CELIX_SUCCESS; - - calculator_pt calculator = proxy; - calculator->endpoint = endpoint; - - return status; -} - - -celix_status_t calculatorProxy_setHandler(void *proxy, void *handler) { - celix_status_t status = CELIX_SUCCESS; - - calculator_pt calculator = proxy; - calculator->sendToHandler = handler; - - return status; -} - - -celix_status_t calculatorProxy_setCallback(void *proxy, sendToHandle callback) { - celix_status_t status = CELIX_SUCCESS; - - calculator_pt calculator = proxy; - calculator->sendToCallback = callback; - - return status; -} - Added: celix/trunk/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c?rev=1647343&view=auto ============================================================================== --- celix/trunk/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c (added) +++ celix/trunk/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c Mon Dec 22 16:11:58 2014 @@ -0,0 +1,203 @@ +/* + * remote_proxy_factory_impl.c + * + * Created on: 22 Dec 2014 + * Author: abroekhuis + */ + +#include + +#include "remote_proxy.h" + +typedef struct proxy_instance { + service_registration_pt registration_ptr; + void *service; + properties_pt properties; +} *proxy_instance_pt; + +static celix_status_t remoteProxyFactory_registerProxyService(remote_proxy_factory_pt remote_proxy_factory_ptr, endpoint_description_pt endpointDescription, remote_service_admin_pt rsa, sendToHandle sendToCallback); +static celix_status_t remoteProxyFactory_unregisterProxyService(remote_proxy_factory_pt remote_proxy_factory_ptr, endpoint_description_pt endpointDescription); + +celix_status_t remoteProxyFactory_create(bundle_context_pt context, char *service, void *handle, + createProxyService create, destroyProxyService destroy, + remote_proxy_factory_pt *remote_proxy_factory_ptr) { + celix_status_t status = CELIX_SUCCESS; + + *remote_proxy_factory_ptr = calloc(1, sizeof(**remote_proxy_factory_ptr)); + if (!*remote_proxy_factory_ptr) { + status = CELIX_ENOMEM; + } + + if (status == CELIX_SUCCESS) { + (*remote_proxy_factory_ptr)->context_ptr = context; + (*remote_proxy_factory_ptr)->service = strdup(service); + + (*remote_proxy_factory_ptr)->remote_proxy_factory_service_ptr = NULL; + (*remote_proxy_factory_ptr)->properties = NULL; + (*remote_proxy_factory_ptr)->registration = NULL; + + (*remote_proxy_factory_ptr)->proxy_instances = hashMap_create(NULL, NULL, NULL, NULL); + + (*remote_proxy_factory_ptr)->handle = handle; + + (*remote_proxy_factory_ptr)->create_proxy_service_ptr = create; + (*remote_proxy_factory_ptr)->destroy_proxy_service_ptr = destroy; + } + + return status; +} + +celix_status_t remoteProxyFactory_destroy(remote_proxy_factory_pt *remote_proxy_factory_ptr) { + celix_status_t status = CELIX_SUCCESS; + + if (!*remote_proxy_factory_ptr) { + status = CELIX_ILLEGAL_ARGUMENT; + } + + if (status == CELIX_SUCCESS) { + if ((*remote_proxy_factory_ptr)->proxy_instances) { + hashMap_destroy((*remote_proxy_factory_ptr)->proxy_instances, false, false); + (*remote_proxy_factory_ptr)->proxy_instances = NULL; + } + if ((*remote_proxy_factory_ptr)->service) { + free((*remote_proxy_factory_ptr)->service); + (*remote_proxy_factory_ptr)->service = NULL; + } + free(*remote_proxy_factory_ptr); + *remote_proxy_factory_ptr = NULL; + } + + return status; +} + +celix_status_t remoteProxyFactory_register(remote_proxy_factory_pt remote_proxy_factory_ptr) { + celix_status_t status = CELIX_SUCCESS; + + remote_proxy_factory_ptr->remote_proxy_factory_service_ptr = calloc(1, sizeof(*remote_proxy_factory_ptr->remote_proxy_factory_service_ptr)); + if (!remote_proxy_factory_ptr->remote_proxy_factory_service_ptr) { + status = CELIX_ENOMEM; + } + + if (status == CELIX_SUCCESS) { + remote_proxy_factory_ptr->remote_proxy_factory_service_ptr->factory = remote_proxy_factory_ptr; + remote_proxy_factory_ptr->remote_proxy_factory_service_ptr->registerProxyService = remoteProxyFactory_registerProxyService; + remote_proxy_factory_ptr->remote_proxy_factory_service_ptr->unregisterProxyService = remoteProxyFactory_unregisterProxyService; + + remote_proxy_factory_ptr->properties = properties_create(); + if (!remote_proxy_factory_ptr->properties) { + status = CELIX_BUNDLE_EXCEPTION; + } else { + properties_set(remote_proxy_factory_ptr->properties, "proxy.interface", remote_proxy_factory_ptr->service); + } + } + + if (status == CELIX_SUCCESS) { + status = bundleContext_registerService(remote_proxy_factory_ptr->context_ptr, OSGI_RSA_REMOTE_PROXY_FACTORY, + remote_proxy_factory_ptr->remote_proxy_factory_service_ptr, remote_proxy_factory_ptr->properties, &remote_proxy_factory_ptr->registration); + } + + return status; +} + +celix_status_t remoteProxyFactory_unregister(remote_proxy_factory_pt remote_proxy_factory_ptr) { + celix_status_t status = CELIX_SUCCESS; + + if (!remote_proxy_factory_ptr) { + status = CELIX_ILLEGAL_ARGUMENT; + } + + // #TODO Remove proxy registrations + if (status == CELIX_SUCCESS) { + if (remote_proxy_factory_ptr->registration) { + status = serviceRegistration_unregister(remote_proxy_factory_ptr->registration); + } + if (remote_proxy_factory_ptr->properties) { + properties_destroy(remote_proxy_factory_ptr->properties); + } + if (remote_proxy_factory_ptr->remote_proxy_factory_service_ptr) { + free(remote_proxy_factory_ptr->remote_proxy_factory_service_ptr); + } + } + + return status; +} + +static celix_status_t remoteProxyFactory_registerProxyService(remote_proxy_factory_pt remote_proxy_factory_ptr, endpoint_description_pt endpointDescription, remote_service_admin_pt rsa, sendToHandle sendToCallback) { + celix_status_t status = CELIX_SUCCESS; + proxy_instance_pt proxy_instance_ptr = NULL; + + if (!remote_proxy_factory_ptr || !remote_proxy_factory_ptr->create_proxy_service_ptr) { + status = CELIX_ILLEGAL_ARGUMENT; + } + + if (status == CELIX_SUCCESS) { + proxy_instance_ptr = calloc(1, sizeof(*proxy_instance_ptr)); + if (!proxy_instance_ptr) { + status = CELIX_ENOMEM; + } + } + + if (status == CELIX_SUCCESS) { + proxy_instance_ptr->properties = properties_create(); + if (!proxy_instance_ptr->properties) { + status = CELIX_BUNDLE_EXCEPTION; + } + } + + if (status == CELIX_SUCCESS) { + status = remote_proxy_factory_ptr->create_proxy_service_ptr(remote_proxy_factory_ptr->handle, endpointDescription, rsa, sendToCallback, proxy_instance_ptr->properties, &proxy_instance_ptr->service); + } + + if (status == CELIX_SUCCESS) { + properties_set(proxy_instance_ptr->properties, "proxy.interface", remote_proxy_factory_ptr->service); + properties_set(proxy_instance_ptr->properties, "endpoint.framework.uuid", (char *) endpointDescription->frameworkUUID); + + // #TODO Copy properties from the endpoint + } + + if (status == CELIX_SUCCESS) { + status = bundleContext_registerService(remote_proxy_factory_ptr->context_ptr, remote_proxy_factory_ptr->service, proxy_instance_ptr->service, proxy_instance_ptr->properties, &proxy_instance_ptr->registration_ptr); + } + + if (status == CELIX_SUCCESS) { + hashMap_put(remote_proxy_factory_ptr->proxy_instances, endpointDescription, proxy_instance_ptr); + } + + return status; +} + +static celix_status_t remoteProxyFactory_unregisterProxyService(remote_proxy_factory_pt remote_proxy_factory_ptr, endpoint_description_pt endpointDescription) { + celix_status_t status = CELIX_SUCCESS; + proxy_instance_pt proxy_instance_ptr = NULL; + + if (!remote_proxy_factory_ptr || !endpointDescription || !remote_proxy_factory_ptr->proxy_instances || !remote_proxy_factory_ptr->handle) { + status = CELIX_ILLEGAL_ARGUMENT; + } + + if (status == CELIX_SUCCESS) { + proxy_instance_ptr = hashMap_remove(remote_proxy_factory_ptr->proxy_instances, endpointDescription); + if (proxy_instance_ptr == NULL) { + status = CELIX_BUNDLE_EXCEPTION; + } + } + + if (status == CELIX_SUCCESS) { + if (proxy_instance_ptr->registration_ptr) { + status = serviceRegistration_unregister(proxy_instance_ptr->registration_ptr); + proxy_instance_ptr->properties = NULL; + } + if (proxy_instance_ptr->service) { + status = remote_proxy_factory_ptr->destroy_proxy_service_ptr(remote_proxy_factory_ptr->handle, proxy_instance_ptr->service); + } + if (proxy_instance_ptr->properties) { + properties_destroy(proxy_instance_ptr->properties); + } + if (proxy_instance_ptr) { + free(proxy_instance_ptr); + } + } + + return status; +} + + Modified: celix/trunk/remote_services/remote_service_admin/public/include/remote_proxy.h URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin/public/include/remote_proxy.h?rev=1647343&r1=1647342&r2=1647343&view=diff ============================================================================== --- celix/trunk/remote_services/remote_service_admin/public/include/remote_proxy.h (original) +++ celix/trunk/remote_services/remote_service_admin/public/include/remote_proxy.h Mon Dec 22 16:11:58 2014 @@ -32,20 +32,44 @@ #define OSGI_RSA_REMOTE_PROXY_FACTORY "remote_proxy_factory" -typedef celix_status_t (*sendToHandle)(void *handler, endpoint_description_pt endpointDescription, char *request, char **reply, int* replyStatus); +typedef celix_status_t (*sendToHandle)(remote_service_admin_pt remote_service_admin_ptr, endpoint_description_pt endpointDescription, char *request, char **reply, int* replyStatus); +typedef celix_status_t (*createProxyService)(void *handle, endpoint_description_pt endpointDescription, remote_service_admin_pt rsa, sendToHandle sendToCallback, properties_pt properties, void **service); +typedef celix_status_t (*destroyProxyService)(void *handle, void *service); -typedef struct remote_proxy_service *remote_proxy_service_pt; +typedef struct remote_proxy_factory *remote_proxy_factory_pt; +typedef struct remote_proxy_factory_service *remote_proxy_factory_service_pt; + +struct remote_proxy_factory { + bundle_context_pt context_ptr; + char *service; + + remote_proxy_factory_service_pt remote_proxy_factory_service_ptr; + properties_pt properties; + service_registration_pt registration; -struct remote_proxy_factory_service { - void* context; - void* pool; - hash_map_pt proxy_registrations; hash_map_pt proxy_instances; - celix_status_t (*registerProxyService)(void* proxyFactoryService, endpoint_description_pt endpoint, void* handler, sendToHandle callback); - celix_status_t (*unregisterProxyService)(void* proxyFactoryService, endpoint_description_pt endpoint); + + void *handle; + + createProxyService create_proxy_service_ptr; + destroyProxyService destroy_proxy_service_ptr; }; -typedef struct remote_proxy_factory_service *remote_proxy_factory_service_pt; +struct remote_proxy_factory_service { + remote_proxy_factory_pt factory; + celix_status_t (*registerProxyService)(remote_proxy_factory_pt proxyFactoryService, endpoint_description_pt endpoint, remote_service_admin_pt remote_service_admin_ptr, sendToHandle callback); + celix_status_t (*unregisterProxyService)(remote_proxy_factory_pt proxyFactoryService, endpoint_description_pt endpoint); +}; + +celix_status_t remoteProxyFactory_create(bundle_context_pt context, char *service, void *handle, + createProxyService create, destroyProxyService destroy, + remote_proxy_factory_pt *remote_proxy_factory_ptr); +celix_status_t remoteProxyFactory_destroy(remote_proxy_factory_pt *remote_proxy_factory_ptr); + +celix_status_t remoteProxyFactory_register(remote_proxy_factory_pt remote_proxy_factory_ptr); +celix_status_t remoteProxyFactory_unregister(remote_proxy_factory_pt remote_proxy_factory_ptr); + + #endif /* REMOTE_PROXY_H_ */ Modified: celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c?rev=1647343&r1=1647342&r2=1647343&view=diff ============================================================================== --- celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c (original) +++ celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c Mon Dec 22 16:11:58 2014 @@ -225,7 +225,7 @@ celix_status_t remoteServiceAdmin_stop(r if (importFactory->trackedFactory != NULL) { - importFactory->trackedFactory->unregisterProxyService(importFactory->trackedFactory, importRegistration->endpointDescription); + importFactory->trackedFactory->unregisterProxyService(importFactory->trackedFactory->factory, importRegistration->endpointDescription); } } @@ -576,7 +576,7 @@ celix_status_t remoteServiceAdmin_getImp celix_status_t remoteServiceAdmin_importService(remote_service_admin_pt admin, endpoint_description_pt endpointDescription, import_registration_pt *registration) { celix_status_t status = CELIX_SUCCESS; - logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "RSA: Import service %s", endpointDescription->service); +// logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "RSA: Import service %s", endpointDescription->service); celixThreadMutex_lock(&admin->importedServicesLock); @@ -594,13 +594,14 @@ celix_status_t remoteServiceAdmin_import // factory available if (status != CELIX_SUCCESS || (registration_factory->trackedFactory == NULL)) { - logHelper_log(admin->loghelper, OSGI_LOGSERVICE_WARNING, "RSA: no proxyFactory available."); + // #TODO Why does this fail here? +// logHelper_log(admin->loghelper, OSGI_LOGSERVICE_WARNING, "RSA: no proxyFactory available."); } else { // we create an importRegistration per imported service importRegistration_create(admin->pool, endpointDescription, admin, (sendToHandle) &remoteServiceAdmin_send, admin->context, registration); - registration_factory->trackedFactory->registerProxyService(registration_factory->trackedFactory, endpointDescription, admin, (sendToHandle) &remoteServiceAdmin_send); + registration_factory->trackedFactory->registerProxyService(registration_factory->trackedFactory->factory, endpointDescription, admin, (sendToHandle) &remoteServiceAdmin_send); arrayList_add(registration_factory->registrations, *registration); } @@ -628,7 +629,7 @@ celix_status_t remoteServiceAdmin_remove } else { - registration_factory->trackedFactory->unregisterProxyService(registration_factory->trackedFactory, endpointDescription); + registration_factory->trackedFactory->unregisterProxyService(registration_factory->trackedFactory->factory, endpointDescription); arrayList_removeElement(registration_factory->registrations, registration); importRegistration_destroy(registration);