xuzhenbao commented on code in PR #437:
URL: https://github.com/apache/celix/pull/437#discussion_r956062014


##########
bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_export_registration.c:
##########
@@ -0,0 +1,358 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <rsa_shm_export_registration.h>
+#include <rsa_rpc_service.h>
+#include <rsa_request_handler_service.h>
+#include <rsa_shm_constants.h>
+#include <endpoint_description.h>
+#include <remote_constants.h>
+#include <celix_log_helper.h>
+#include <celix_ref.h>
+#include <celix_api.h>
+#include <string.h>
+#include <assert.h>
+#include <stdbool.h>
+
+struct export_reference {
+    endpoint_description_t *endpoint;
+    service_reference_pt reference;
+};
+
+typedef struct export_request_handler_service_entry {
+    struct celix_ref ref;
+    celix_thread_rwlock_t lock; //projects below
+    rsa_request_handler_service_t *reqHandlerSvc;
+}export_request_handler_service_entry_t;
+
+struct export_registration {
+    struct celix_ref ref;
+    celix_bundle_context_t * context;
+    celix_log_helper_t* logHelper;
+    endpoint_description_t * endpointDesc;
+    service_reference_pt reference;
+    long rpcSvcTrkId;
+    rsa_rpc_service_t *rpcSvc;
+    long reqHandlerSvcTrkId;
+    long reqHandlerSvcId;
+    export_request_handler_service_entry_t *reqHandlerSvcEntry;
+};
+
+static void exportRegistration_addRpcSvc(void *handle, void *svc);
+static void exportRegistration_removeRpcSvc(void *handle, void *svc);
+static void exportRegistration_addRequestHandlerSvc(void *handle, void *svc);
+static void exportRegistration_removeRequestHandlerSvc(void *handle, void 
*svc);
+static void exportRegistration_destroy(export_registration_t *export);
+static export_request_handler_service_entry_t 
*exportRegistration_createReqHandlerSvcEntry(void);
+static void 
exportRegistration_retainReqHandlerSvcEntry(export_request_handler_service_entry_t
 *reqHandlerSvcEntry);
+static void 
exportRegistration_releaseReqHandlerSvcEntry(export_request_handler_service_entry_t
 *reqHandlerSvcEntry);
+
+celix_status_t exportRegistration_create(celix_bundle_context_t *context,
+        celix_log_helper_t *logHelper, service_reference_pt reference,
+        endpoint_description_t *endpointDesc, export_registration_t 
**exportOut) {
+    celix_status_t status = CELIX_SUCCESS;
+    if (context == NULL || logHelper == NULL || reference == NULL
+            || endpointDescription_isInvalid(endpointDesc) || exportOut == 
NULL) {
+        return CELIX_ILLEGAL_ARGUMENT;
+    }
+    export_registration_t *export = calloc(1, sizeof(*export));
+    assert(export != NULL);
+    celix_ref_init(&export->ref);
+    export->context = context;
+    export->logHelper = logHelper;
+
+    export->endpointDesc = endpointDescription_clone(endpointDesc);
+    assert(export->endpointDesc != NULL);
+
+    export->rpcSvc = NULL;
+    export->reqHandlerSvcTrkId = -1;
+    export->reqHandlerSvcId = -1;
+    export->reqHandlerSvcEntry = NULL;
+    export->reference = reference;
+    status = bundleContext_retainServiceReference(context, reference);
+    if (status != CELIX_SUCCESS) {
+        celix_logHelper_error(logHelper,"RSA export reg: Retain refrence for 
%s failed. %d.", endpointDesc->service,status);
+        goto err_retaining_service_ref;
+    }
+
+    export->reqHandlerSvcEntry = exportRegistration_createReqHandlerSvcEntry();
+    if (export->reqHandlerSvcEntry == NULL) {
+        celix_logHelper_error(export->logHelper,"RSA export reg: Error 
creating endpoint svc entry.");
+        status = CELIX_SERVICE_EXCEPTION;
+        goto ep_svc_entry_err;
+    }
+
+    /* If the properties of exported service include 'RSA_RPC_TYPE_KEY',

Review Comment:
   I have added a `service.exported.configs`, and it prefix is  
`celix.remote.admin.rpc_type.`. A whole `RSA_RPC_TYPE` value as follows: 
`celix.remote.admin.rpc_type.json`,`celix.remote.admin.rpc_type.avpr`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to