in bundles/remote_services/rsa_rpc_json/src/rsa_json_rpc_proxy_impl.c [69:140]
static void rsaJsonRpcProxy_ungetService(void *handle, const celix_bundle_t *requestingBundle,
const celix_properties_t *svcProperties);
static celix_status_t rsaJsonRpcProxy_create(rsa_json_rpc_proxy_factory_t *proxyFactory,
const celix_bundle_t *requestingBundle, rsa_json_rpc_proxy_t **proxyOut);
static void rsaJsonRpcProxy_destroy(rsa_json_rpc_proxy_t *proxy);
static void rsaJsonRpcProxy_unregisterFacSvcDone(void *data);
celix_status_t rsaJsonRpcProxy_factoryCreate(celix_bundle_context_t* ctx,
celix_log_helper_t* logHelper,
FILE* logFile,
remote_interceptors_handler_t* interceptorsHandler,
const endpoint_description_t* endpointDesc,
rsa_request_sender_tracker_t* reqSenderTracker,
long requestSenderSvcId,
unsigned int serialProtoId,
rsa_json_rpc_proxy_factory_t** proxyFactoryOut) {
assert(ctx != NULL);
assert(logHelper != NULL);
assert(interceptorsHandler != NULL);
assert(endpointDesc != NULL);
assert(reqSenderTracker != NULL);
assert(requestSenderSvcId > 0);
assert(proxyFactoryOut != NULL);
celix_autofree rsa_json_rpc_proxy_factory_t* proxyFactory =
(rsa_json_rpc_proxy_factory_t*)calloc(1, sizeof(*proxyFactory));
if (proxyFactory == NULL) {
return CELIX_ENOMEM;
}
proxyFactory->ctx = ctx;
proxyFactory->logHelper = logHelper;
proxyFactory->callsLogFile = logFile;
proxyFactory->interceptorsHandler = interceptorsHandler;
proxyFactory->reqSenderTracker = reqSenderTracker;
proxyFactory->reqSenderSvcId = requestSenderSvcId;
proxyFactory->serialProtoId = serialProtoId;
CELIX_BUILD_ASSERT(sizeof(long) == sizeof(void*)); // The hash_map uses the pointer as key, so this should be true
celix_autoptr(celix_long_hash_map_t) proxies = proxyFactory->proxies = celix_longHashMap_create();
if (proxyFactory->proxies == NULL) {
celix_logHelper_error(logHelper, "Proxy: Error creating proxy map.");
return CELIX_ENOMEM;
}
celix_autoptr(endpoint_description_t) endpointDescCopy = proxyFactory->endpointDesc =
endpointDescription_clone(endpointDesc);
if (proxyFactory->endpointDesc == NULL) {
celix_logHelper_error(logHelper, "Proxy: Failed to clone endpoint description.");
return CELIX_ENOMEM;
}
proxyFactory->factory.handle = proxyFactory;
proxyFactory->factory.getService = rsaJsonRpcProxy_getService;
proxyFactory->factory.ungetService = rsaJsonRpcProxy_ungetService;
celix_properties_t* svcProperties = NULL;
celix_status_t status =
celix_rsaUtils_createServicePropertiesFromEndpointProperties(endpointDesc->properties, &svcProperties);
if (status != CELIX_SUCCESS) {
return status;
}
assert(svcProperties != NULL);
proxyFactory->factorySvcId = celix_bundleContext_registerServiceFactoryAsync(
ctx, &proxyFactory->factory, endpointDesc->serviceName, svcProperties);
if (proxyFactory->factorySvcId < 0) {
celix_logHelper_error(logHelper, "Proxy: Error Registering proxy service.");
return CELIX_SERVICE_EXCEPTION;
}
celix_steal_ptr(endpointDescCopy);
celix_steal_ptr(proxies);
*proxyFactoryOut = celix_steal_ptr(proxyFactory);
return CELIX_SUCCESS;
}