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->pool, calculatorProxyFactoryService->context, &calculator); calculatorService = apr_palloc(calculatorProxyFactoryService->pool, 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); return status; }
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; 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; *service = calculatorService; return status; }