You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2021/04/15 19:14:26 UTC

[celix] branch feature/cxx_rsa_update created (now 4db46af)

This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a change to branch feature/cxx_rsa_update
in repository https://gitbox.apache.org/repos/asf/celix.git.


      at 4db46af  Renames async remote services to cxx remote services, because the RSA concepts are not directly coupled to async.

This branch includes the following new commits:

     new 883baad  Refactors C++ remote service admin to use IExport(Import)ServiceFactory SPI.
     new 10c9219  Refactors test case to use components instead of svc registrations.
     new 4db46af  Renames async remote services to cxx remote services, because the RSA concepts are not directly coupled to async.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[celix] 03/03: Renames async remote services to cxx remote services, because the RSA concepts are not directly coupled to async.

Posted by pn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch feature/cxx_rsa_update
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 4db46af310f24f38af4fe34f77180c8ce3e0e7ba
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Thu Apr 15 21:12:03 2021 +0200

    Renames async remote services to cxx remote services, because the RSA concepts are not directly coupled to async.
---
 bundles/CMakeLists.txt                             |  2 +-
 .../CMakeLists.txt                                 |  0
 .../admin/CMakeLists.txt                           |  4 +--
 .../admin/gtest/CMakeLists.txt                     |  0
 .../admin/gtest/src/RemoteServiceAdminTestSuite.cc |  0
 .../admin/include/RemoteServiceAdmin.h}            |  4 +--
 .../admin/src/RemoteServiceAdmin.cc}               | 34 +++++++++++-----------
 .../common/CMakeLists.txt                          |  0
 .../common/include/ExportedServiceFactory.h        |  0
 .../common/include/IExportedService.h              |  0
 .../common/include/ImportedServiceFactory.h        |  0
 .../common/src/common.cc                           |  0
 .../discovery_configured/CMakeLists.txt            |  0
 .../doc/configured_discovery.adoc                  |  0
 .../include/ConfiguredDiscoveryManager.h           |  0
 .../include/ConfiguredDiscoveryManagerActivator.h  |  0
 .../include/ConfiguredEndpoint.h                   |  0
 .../include/ConfiguredEndpointProperties.h         |  0
 .../src/ConfiguredDiscoveryManager.cc              |  0
 .../src/ConfiguredDiscoveryManagerActivator.cc     |  0
 .../discovery_configured/src/ConfiguredEndpoint.cc |  0
 .../doc/async_remote_admin.adoc                    |  0
 .../examples/CMakeLists.txt                        |  0
 .../examples/HardcodedExampleProvider.cc           |  0
 .../examples/HardcodedExampleSerializer.cc         |  0
 .../examples/HardcodedExampleSerializer.h          |  0
 .../examples/HardcodedExampleSubscriber.cc         |  0
 .../examples/IHardcodedService.h                   |  0
 .../examples/discovery/endpoint.json               |  0
 .../pubsub_properties/IHardcodedService.properties |  0
 .../rsa_spi/CMakeLists.txt                         |  0
 .../rsa_spi/include/celix/rsa/Constants.h          |  0
 .../rsa_spi/include/celix/rsa/Endpoint.h           |  0
 .../rsa_spi/include/celix/rsa/IEndpointAnnouncer.h |  0
 .../include/celix/rsa/IExportServiceFactory.h      |  0
 .../rsa_spi/include/celix/rsa/IExportedService.h   |  0
 .../include/celix/rsa/IImportServiceFactory.h      |  0
 .../include/celix/rsa/RemoteServicesException.h    |  0
 .../topology_manager/CMakeLists.txt                |  0
 .../topology_manager/include/topology_manager.h    |  0
 .../topology_manager/src/topology_manager.cc       |  0
 41 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/bundles/CMakeLists.txt b/bundles/CMakeLists.txt
index 47083c7..fad202b 100644
--- a/bundles/CMakeLists.txt
+++ b/bundles/CMakeLists.txt
@@ -22,4 +22,4 @@ add_subdirectory(device_access)
 add_subdirectory(deployment_admin)
 add_subdirectory(remote_services)
 add_subdirectory(pubsub)
-add_subdirectory(async_remote_services)
+add_subdirectory(cxx_remote_services)
diff --git a/bundles/async_remote_services/CMakeLists.txt b/bundles/cxx_remote_services/CMakeLists.txt
similarity index 100%
rename from bundles/async_remote_services/CMakeLists.txt
rename to bundles/cxx_remote_services/CMakeLists.txt
diff --git a/bundles/async_remote_services/admin/CMakeLists.txt b/bundles/cxx_remote_services/admin/CMakeLists.txt
similarity index 91%
rename from bundles/async_remote_services/admin/CMakeLists.txt
rename to bundles/cxx_remote_services/admin/CMakeLists.txt
index 4eee9c1..8cc9658 100644
--- a/bundles/async_remote_services/admin/CMakeLists.txt
+++ b/bundles/cxx_remote_services/admin/CMakeLists.txt
@@ -22,13 +22,13 @@ add_celix_bundle(RemoteServiceAdmin
         GROUP "Celix/RSA"
         FILENAME "Celix_RemoteServiceAdmin"
         SOURCES
-            src/admin.cc
+            src/RemoteServiceAdmin.cc
 )
 target_include_directories(RemoteServiceAdmin PRIVATE include)
 target_link_libraries(RemoteServiceAdmin PRIVATE
         Celix::rsa_spi
         Celix::framework
-        Celix::log_helper
+        Celix::log_service_api
 )
 
 if (ENABLE_TESTING)
diff --git a/bundles/async_remote_services/admin/gtest/CMakeLists.txt b/bundles/cxx_remote_services/admin/gtest/CMakeLists.txt
similarity index 100%
rename from bundles/async_remote_services/admin/gtest/CMakeLists.txt
rename to bundles/cxx_remote_services/admin/gtest/CMakeLists.txt
diff --git a/bundles/async_remote_services/admin/gtest/src/RemoteServiceAdminTestSuite.cc b/bundles/cxx_remote_services/admin/gtest/src/RemoteServiceAdminTestSuite.cc
similarity index 100%
rename from bundles/async_remote_services/admin/gtest/src/RemoteServiceAdminTestSuite.cc
rename to bundles/cxx_remote_services/admin/gtest/src/RemoteServiceAdminTestSuite.cc
diff --git a/bundles/async_remote_services/admin/include/admin.h b/bundles/cxx_remote_services/admin/include/RemoteServiceAdmin.h
similarity index 98%
rename from bundles/async_remote_services/admin/include/admin.h
rename to bundles/cxx_remote_services/admin/include/RemoteServiceAdmin.h
index 4d1bd1f..f741af3 100644
--- a/bundles/async_remote_services/admin/include/admin.h
+++ b/bundles/cxx_remote_services/admin/include/RemoteServiceAdmin.h
@@ -33,9 +33,9 @@
 
 #endif
 
-namespace celix::async_rsa {
+namespace celix::rsa {
 
-    class AsyncAdmin {
+    class RemoteServiceAdmin {
     public:
         // Imported endpoint add/remove functions
         void addEndpoint(const std::shared_ptr<celix::rsa::Endpoint>& endpoint);
diff --git a/bundles/async_remote_services/admin/src/admin.cc b/bundles/cxx_remote_services/admin/src/RemoteServiceAdmin.cc
similarity index 85%
rename from bundles/async_remote_services/admin/src/admin.cc
rename to bundles/cxx_remote_services/admin/src/RemoteServiceAdmin.cc
index ee90ccb..be35f71 100644
--- a/bundles/async_remote_services/admin/src/admin.cc
+++ b/bundles/cxx_remote_services/admin/src/RemoteServiceAdmin.cc
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-#include <admin.h>
+#include "RemoteServiceAdmin.h"
 #include "celix/rsa/Constants.h"
 
 #define L_DEBUG(...) \
@@ -37,7 +37,7 @@
         _logService->error(_logService->handle, __VA_ARGS__);           \
     }
 
-void celix::async_rsa::AsyncAdmin::addEndpoint(const std::shared_ptr<celix::rsa::Endpoint>& endpoint) {
+void celix::rsa::RemoteServiceAdmin::addEndpoint(const std::shared_ptr<celix::rsa::Endpoint>& endpoint) {
     assert(endpoint);
 
     auto interface = endpoint->getExportedInterfaces();
@@ -57,7 +57,7 @@ void celix::async_rsa::AsyncAdmin::addEndpoint(const std::shared_ptr<celix::rsa:
     createImportServices();
 }
 
-void celix::async_rsa::AsyncAdmin::removeEndpoint(const std::shared_ptr<celix::rsa::Endpoint>& endpoint) {
+void celix::rsa::RemoteServiceAdmin::removeEndpoint(const std::shared_ptr<celix::rsa::Endpoint>& endpoint) {
     assert(endpoint);
 
     auto id = endpoint->getEndpointId();
@@ -82,7 +82,7 @@ void celix::async_rsa::AsyncAdmin::removeEndpoint(const std::shared_ptr<celix::r
     }
 }
 
-void celix::async_rsa::AsyncAdmin::addImportedServiceFactory(
+void celix::rsa::RemoteServiceAdmin::addImportedServiceFactory(
         const std::shared_ptr<celix::rsa::IImportServiceFactory> &factory,
         const std::shared_ptr<const celix::Properties> &properties) {
     auto targetServiceName = properties->get(celix::rsa::IImportServiceFactory::TARGET_SERVICE_NAME);
@@ -104,7 +104,7 @@ void celix::async_rsa::AsyncAdmin::addImportedServiceFactory(
     createImportServices();
 }
 
-void celix::async_rsa::AsyncAdmin::removeImportedServiceFactory(
+void celix::rsa::RemoteServiceAdmin::removeImportedServiceFactory(
         const std::shared_ptr<celix::rsa::IImportServiceFactory> &/*factory*/,
         const std::shared_ptr<const celix::Properties> &properties) {
     auto targetServiceName = properties->get(celix::rsa::IImportServiceFactory::TARGET_SERVICE_NAME);
@@ -119,7 +119,7 @@ void celix::async_rsa::AsyncAdmin::removeImportedServiceFactory(
     //TODO remove imported services from this factory ??needed
 }
 
-void celix::async_rsa::AsyncAdmin::addExportedServiceFactory(
+void celix::rsa::RemoteServiceAdmin::addExportedServiceFactory(
         const std::shared_ptr<celix::rsa::IExportServiceFactory> &factory,
         const std::shared_ptr<const celix::Properties> &properties) {
     auto targetServiceName = properties->get(celix::rsa::IExportServiceFactory::TARGET_SERVICE_NAME);
@@ -133,7 +133,7 @@ void celix::async_rsa::AsyncAdmin::addExportedServiceFactory(
     createExportServices();
 }
 
-void celix::async_rsa::AsyncAdmin::removeExportedServiceFactory(
+void celix::rsa::RemoteServiceAdmin::removeExportedServiceFactory(
         const std::shared_ptr<celix::rsa::IExportServiceFactory> &/*factory*/,
         const std::shared_ptr<const celix::Properties> &properties) {
     auto targetServiceName = properties->get(celix::rsa::IExportServiceFactory::TARGET_SERVICE_NAME);
@@ -148,7 +148,7 @@ void celix::async_rsa::AsyncAdmin::removeExportedServiceFactory(
     //TODO remove exported services from this factory ??needed
 }
 
-void celix::async_rsa::AsyncAdmin::addService(const std::shared_ptr<void>& /*svc*/, const std::shared_ptr<const celix::Properties>& props) {
+void celix::rsa::RemoteServiceAdmin::addService(const std::shared_ptr<void>& /*svc*/, const std::shared_ptr<const celix::Properties>& props) {
     auto serviceName = props->get(celix::SERVICE_NAME, "");
     if (serviceName.empty()) {
         L_WARN("Adding service to be exported but missing objectclass");
@@ -160,7 +160,7 @@ void celix::async_rsa::AsyncAdmin::addService(const std::shared_ptr<void>& /*svc
     createExportServices();
 }
 
-void celix::async_rsa::AsyncAdmin::removeService(const std::shared_ptr<void>& /*svc*/, const std::shared_ptr<const celix::Properties>& props) {
+void celix::rsa::RemoteServiceAdmin::removeService(const std::shared_ptr<void>& /*svc*/, const std::shared_ptr<const celix::Properties>& props) {
     long svcId = props->getAsLong(celix::SERVICE_ID, -1);
     if (svcId < 0) {
         L_WARN("Removing service to be exported but missing service.id");
@@ -183,7 +183,7 @@ void celix::async_rsa::AsyncAdmin::removeService(const std::shared_ptr<void>& /*
     }
 }
 
-void celix::async_rsa::AsyncAdmin::createImportServices() {
+void celix::rsa::RemoteServiceAdmin::createImportServices() {
     auto it = _toBeImportedServices.begin();
     while (it != _toBeImportedServices.end()) {
         auto interface = (*it)->getExportedInterfaces();
@@ -200,7 +200,7 @@ void celix::async_rsa::AsyncAdmin::createImportServices() {
     }
 }
 
-void celix::async_rsa::AsyncAdmin::createExportServices() {
+void celix::rsa::RemoteServiceAdmin::createExportServices() {
     auto it = _toBeExportedServices.begin();
     while (it != _toBeExportedServices.end()) {
         const auto& svcProperties = **it;
@@ -221,33 +221,33 @@ void celix::async_rsa::AsyncAdmin::createExportServices() {
     }
 }
 
-void celix::async_rsa::AsyncAdmin::setLogger(const std::shared_ptr<celix_log_service>& logService) {
+void celix::rsa::RemoteServiceAdmin::setLogger(const std::shared_ptr<celix_log_service>& logService) {
     _logService = logService;
 }
 
 class AdminActivator {
 public:
     explicit AdminActivator(const std::shared_ptr<celix::BundleContext>& ctx) {
-        auto admin = std::make_shared<celix::async_rsa::AsyncAdmin>();
+        auto admin = std::make_shared<celix::rsa::RemoteServiceAdmin>();
 
         auto& cmp = ctx->getDependencyManager()->createComponent(admin);
         cmp.createServiceDependency<celix::rsa::Endpoint>()
                 .setRequired(false)
                 .setStrategy(celix::dm::DependencyUpdateStrategy::locking)
-                .setCallbacks(&celix::async_rsa::AsyncAdmin::addEndpoint, &celix::async_rsa::AsyncAdmin::removeEndpoint);
+                .setCallbacks(&celix::rsa::RemoteServiceAdmin::addEndpoint, &celix::rsa::RemoteServiceAdmin::removeEndpoint);
         cmp.createServiceDependency<celix::rsa::IImportServiceFactory>()
                 .setRequired(false)
                 .setStrategy(celix::dm::DependencyUpdateStrategy::locking)
-                .setCallbacks(&celix::async_rsa::AsyncAdmin::addImportedServiceFactory, &celix::async_rsa::AsyncAdmin::removeImportedServiceFactory);
+                .setCallbacks(&celix::rsa::RemoteServiceAdmin::addImportedServiceFactory, &celix::rsa::RemoteServiceAdmin::removeImportedServiceFactory);
         cmp.createServiceDependency<celix::rsa::IExportServiceFactory>()
                 .setRequired(false)
                 .setStrategy(celix::dm::DependencyUpdateStrategy::locking)
-                .setCallbacks(&celix::async_rsa::AsyncAdmin::addExportedServiceFactory, &celix::async_rsa::AsyncAdmin::removeExportedServiceFactory);
+                .setCallbacks(&celix::rsa::RemoteServiceAdmin::addExportedServiceFactory, &celix::rsa::RemoteServiceAdmin::removeExportedServiceFactory);
         cmp.createServiceDependency<celix_log_service>(CELIX_LOG_SERVICE_NAME)
                 .setRequired(false)
                 .setFilter(std::string{"("}.append(CELIX_LOG_SERVICE_PROPERTY_NAME).append("=celix::rsa::RemoteServiceAdmin)"))
                 .setStrategy(celix::dm::DependencyUpdateStrategy::suspend)
-                .setCallbacks(&celix::async_rsa::AsyncAdmin::setLogger);
+                .setCallbacks(&celix::rsa::RemoteServiceAdmin::setLogger);
         cmp.build();
 
         //note adding void service dependencies is not supported for the dependency manager, using a service tracker instead.
diff --git a/bundles/async_remote_services/common/CMakeLists.txt b/bundles/cxx_remote_services/common/CMakeLists.txt
similarity index 100%
rename from bundles/async_remote_services/common/CMakeLists.txt
rename to bundles/cxx_remote_services/common/CMakeLists.txt
diff --git a/bundles/async_remote_services/common/include/ExportedServiceFactory.h b/bundles/cxx_remote_services/common/include/ExportedServiceFactory.h
similarity index 100%
rename from bundles/async_remote_services/common/include/ExportedServiceFactory.h
rename to bundles/cxx_remote_services/common/include/ExportedServiceFactory.h
diff --git a/bundles/async_remote_services/common/include/IExportedService.h b/bundles/cxx_remote_services/common/include/IExportedService.h
similarity index 100%
rename from bundles/async_remote_services/common/include/IExportedService.h
rename to bundles/cxx_remote_services/common/include/IExportedService.h
diff --git a/bundles/async_remote_services/common/include/ImportedServiceFactory.h b/bundles/cxx_remote_services/common/include/ImportedServiceFactory.h
similarity index 100%
rename from bundles/async_remote_services/common/include/ImportedServiceFactory.h
rename to bundles/cxx_remote_services/common/include/ImportedServiceFactory.h
diff --git a/bundles/async_remote_services/common/src/common.cc b/bundles/cxx_remote_services/common/src/common.cc
similarity index 100%
rename from bundles/async_remote_services/common/src/common.cc
rename to bundles/cxx_remote_services/common/src/common.cc
diff --git a/bundles/async_remote_services/discovery_configured/CMakeLists.txt b/bundles/cxx_remote_services/discovery_configured/CMakeLists.txt
similarity index 100%
rename from bundles/async_remote_services/discovery_configured/CMakeLists.txt
rename to bundles/cxx_remote_services/discovery_configured/CMakeLists.txt
diff --git a/bundles/async_remote_services/discovery_configured/doc/configured_discovery.adoc b/bundles/cxx_remote_services/discovery_configured/doc/configured_discovery.adoc
similarity index 100%
rename from bundles/async_remote_services/discovery_configured/doc/configured_discovery.adoc
rename to bundles/cxx_remote_services/discovery_configured/doc/configured_discovery.adoc
diff --git a/bundles/async_remote_services/discovery_configured/include/ConfiguredDiscoveryManager.h b/bundles/cxx_remote_services/discovery_configured/include/ConfiguredDiscoveryManager.h
similarity index 100%
rename from bundles/async_remote_services/discovery_configured/include/ConfiguredDiscoveryManager.h
rename to bundles/cxx_remote_services/discovery_configured/include/ConfiguredDiscoveryManager.h
diff --git a/bundles/async_remote_services/discovery_configured/include/ConfiguredDiscoveryManagerActivator.h b/bundles/cxx_remote_services/discovery_configured/include/ConfiguredDiscoveryManagerActivator.h
similarity index 100%
rename from bundles/async_remote_services/discovery_configured/include/ConfiguredDiscoveryManagerActivator.h
rename to bundles/cxx_remote_services/discovery_configured/include/ConfiguredDiscoveryManagerActivator.h
diff --git a/bundles/async_remote_services/discovery_configured/include/ConfiguredEndpoint.h b/bundles/cxx_remote_services/discovery_configured/include/ConfiguredEndpoint.h
similarity index 100%
rename from bundles/async_remote_services/discovery_configured/include/ConfiguredEndpoint.h
rename to bundles/cxx_remote_services/discovery_configured/include/ConfiguredEndpoint.h
diff --git a/bundles/async_remote_services/discovery_configured/include/ConfiguredEndpointProperties.h b/bundles/cxx_remote_services/discovery_configured/include/ConfiguredEndpointProperties.h
similarity index 100%
rename from bundles/async_remote_services/discovery_configured/include/ConfiguredEndpointProperties.h
rename to bundles/cxx_remote_services/discovery_configured/include/ConfiguredEndpointProperties.h
diff --git a/bundles/async_remote_services/discovery_configured/src/ConfiguredDiscoveryManager.cc b/bundles/cxx_remote_services/discovery_configured/src/ConfiguredDiscoveryManager.cc
similarity index 100%
rename from bundles/async_remote_services/discovery_configured/src/ConfiguredDiscoveryManager.cc
rename to bundles/cxx_remote_services/discovery_configured/src/ConfiguredDiscoveryManager.cc
diff --git a/bundles/async_remote_services/discovery_configured/src/ConfiguredDiscoveryManagerActivator.cc b/bundles/cxx_remote_services/discovery_configured/src/ConfiguredDiscoveryManagerActivator.cc
similarity index 100%
rename from bundles/async_remote_services/discovery_configured/src/ConfiguredDiscoveryManagerActivator.cc
rename to bundles/cxx_remote_services/discovery_configured/src/ConfiguredDiscoveryManagerActivator.cc
diff --git a/bundles/async_remote_services/discovery_configured/src/ConfiguredEndpoint.cc b/bundles/cxx_remote_services/discovery_configured/src/ConfiguredEndpoint.cc
similarity index 100%
rename from bundles/async_remote_services/discovery_configured/src/ConfiguredEndpoint.cc
rename to bundles/cxx_remote_services/discovery_configured/src/ConfiguredEndpoint.cc
diff --git a/bundles/async_remote_services/doc/async_remote_admin.adoc b/bundles/cxx_remote_services/doc/async_remote_admin.adoc
similarity index 100%
rename from bundles/async_remote_services/doc/async_remote_admin.adoc
rename to bundles/cxx_remote_services/doc/async_remote_admin.adoc
diff --git a/bundles/async_remote_services/examples/CMakeLists.txt b/bundles/cxx_remote_services/examples/CMakeLists.txt
similarity index 100%
rename from bundles/async_remote_services/examples/CMakeLists.txt
rename to bundles/cxx_remote_services/examples/CMakeLists.txt
diff --git a/bundles/async_remote_services/examples/HardcodedExampleProvider.cc b/bundles/cxx_remote_services/examples/HardcodedExampleProvider.cc
similarity index 100%
rename from bundles/async_remote_services/examples/HardcodedExampleProvider.cc
rename to bundles/cxx_remote_services/examples/HardcodedExampleProvider.cc
diff --git a/bundles/async_remote_services/examples/HardcodedExampleSerializer.cc b/bundles/cxx_remote_services/examples/HardcodedExampleSerializer.cc
similarity index 100%
rename from bundles/async_remote_services/examples/HardcodedExampleSerializer.cc
rename to bundles/cxx_remote_services/examples/HardcodedExampleSerializer.cc
diff --git a/bundles/async_remote_services/examples/HardcodedExampleSerializer.h b/bundles/cxx_remote_services/examples/HardcodedExampleSerializer.h
similarity index 100%
rename from bundles/async_remote_services/examples/HardcodedExampleSerializer.h
rename to bundles/cxx_remote_services/examples/HardcodedExampleSerializer.h
diff --git a/bundles/async_remote_services/examples/HardcodedExampleSubscriber.cc b/bundles/cxx_remote_services/examples/HardcodedExampleSubscriber.cc
similarity index 100%
rename from bundles/async_remote_services/examples/HardcodedExampleSubscriber.cc
rename to bundles/cxx_remote_services/examples/HardcodedExampleSubscriber.cc
diff --git a/bundles/async_remote_services/examples/IHardcodedService.h b/bundles/cxx_remote_services/examples/IHardcodedService.h
similarity index 100%
rename from bundles/async_remote_services/examples/IHardcodedService.h
rename to bundles/cxx_remote_services/examples/IHardcodedService.h
diff --git a/bundles/async_remote_services/examples/discovery/endpoint.json b/bundles/cxx_remote_services/examples/discovery/endpoint.json
similarity index 100%
rename from bundles/async_remote_services/examples/discovery/endpoint.json
rename to bundles/cxx_remote_services/examples/discovery/endpoint.json
diff --git a/bundles/async_remote_services/examples/pubsub_properties/IHardcodedService.properties b/bundles/cxx_remote_services/examples/pubsub_properties/IHardcodedService.properties
similarity index 100%
rename from bundles/async_remote_services/examples/pubsub_properties/IHardcodedService.properties
rename to bundles/cxx_remote_services/examples/pubsub_properties/IHardcodedService.properties
diff --git a/bundles/async_remote_services/rsa_spi/CMakeLists.txt b/bundles/cxx_remote_services/rsa_spi/CMakeLists.txt
similarity index 100%
rename from bundles/async_remote_services/rsa_spi/CMakeLists.txt
rename to bundles/cxx_remote_services/rsa_spi/CMakeLists.txt
diff --git a/bundles/async_remote_services/rsa_spi/include/celix/rsa/Constants.h b/bundles/cxx_remote_services/rsa_spi/include/celix/rsa/Constants.h
similarity index 100%
rename from bundles/async_remote_services/rsa_spi/include/celix/rsa/Constants.h
rename to bundles/cxx_remote_services/rsa_spi/include/celix/rsa/Constants.h
diff --git a/bundles/async_remote_services/rsa_spi/include/celix/rsa/Endpoint.h b/bundles/cxx_remote_services/rsa_spi/include/celix/rsa/Endpoint.h
similarity index 100%
rename from bundles/async_remote_services/rsa_spi/include/celix/rsa/Endpoint.h
rename to bundles/cxx_remote_services/rsa_spi/include/celix/rsa/Endpoint.h
diff --git a/bundles/async_remote_services/rsa_spi/include/celix/rsa/IEndpointAnnouncer.h b/bundles/cxx_remote_services/rsa_spi/include/celix/rsa/IEndpointAnnouncer.h
similarity index 100%
rename from bundles/async_remote_services/rsa_spi/include/celix/rsa/IEndpointAnnouncer.h
rename to bundles/cxx_remote_services/rsa_spi/include/celix/rsa/IEndpointAnnouncer.h
diff --git a/bundles/async_remote_services/rsa_spi/include/celix/rsa/IExportServiceFactory.h b/bundles/cxx_remote_services/rsa_spi/include/celix/rsa/IExportServiceFactory.h
similarity index 100%
rename from bundles/async_remote_services/rsa_spi/include/celix/rsa/IExportServiceFactory.h
rename to bundles/cxx_remote_services/rsa_spi/include/celix/rsa/IExportServiceFactory.h
diff --git a/bundles/async_remote_services/rsa_spi/include/celix/rsa/IExportedService.h b/bundles/cxx_remote_services/rsa_spi/include/celix/rsa/IExportedService.h
similarity index 100%
rename from bundles/async_remote_services/rsa_spi/include/celix/rsa/IExportedService.h
rename to bundles/cxx_remote_services/rsa_spi/include/celix/rsa/IExportedService.h
diff --git a/bundles/async_remote_services/rsa_spi/include/celix/rsa/IImportServiceFactory.h b/bundles/cxx_remote_services/rsa_spi/include/celix/rsa/IImportServiceFactory.h
similarity index 100%
rename from bundles/async_remote_services/rsa_spi/include/celix/rsa/IImportServiceFactory.h
rename to bundles/cxx_remote_services/rsa_spi/include/celix/rsa/IImportServiceFactory.h
diff --git a/bundles/async_remote_services/rsa_spi/include/celix/rsa/RemoteServicesException.h b/bundles/cxx_remote_services/rsa_spi/include/celix/rsa/RemoteServicesException.h
similarity index 100%
rename from bundles/async_remote_services/rsa_spi/include/celix/rsa/RemoteServicesException.h
rename to bundles/cxx_remote_services/rsa_spi/include/celix/rsa/RemoteServicesException.h
diff --git a/bundles/async_remote_services/topology_manager/CMakeLists.txt b/bundles/cxx_remote_services/topology_manager/CMakeLists.txt
similarity index 100%
rename from bundles/async_remote_services/topology_manager/CMakeLists.txt
rename to bundles/cxx_remote_services/topology_manager/CMakeLists.txt
diff --git a/bundles/async_remote_services/topology_manager/include/topology_manager.h b/bundles/cxx_remote_services/topology_manager/include/topology_manager.h
similarity index 100%
rename from bundles/async_remote_services/topology_manager/include/topology_manager.h
rename to bundles/cxx_remote_services/topology_manager/include/topology_manager.h
diff --git a/bundles/async_remote_services/topology_manager/src/topology_manager.cc b/bundles/cxx_remote_services/topology_manager/src/topology_manager.cc
similarity index 100%
rename from bundles/async_remote_services/topology_manager/src/topology_manager.cc
rename to bundles/cxx_remote_services/topology_manager/src/topology_manager.cc

[celix] 01/03: Refactors C++ remote service admin to use IExport(Import)ServiceFactory SPI.

Posted by pn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch feature/cxx_rsa_update
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 883baadcc6492e6f3d76e46904be1a8351def356
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Thu Apr 15 19:31:05 2021 +0200

    Refactors C++ remote service admin to use IExport(Import)ServiceFactory SPI.
---
 bundles/async_remote_services/CMakeLists.txt       |  12 +-
 bundles/async_remote_services/admin/CMakeLists.txt |  32 ++-
 .../{ => admin/gtest}/CMakeLists.txt               |  22 +-
 .../admin/gtest/src/RemoteServiceAdminTestSuite.cc | 279 +++++++++++++++++++++
 .../async_remote_services/admin/include/admin.h    |  61 ++---
 bundles/async_remote_services/admin/src/admin.cc   | 166 ++++++------
 .../async_remote_services/common/CMakeLists.txt    |   1 +
 .../common/include/ImportedServiceFactory.h        |   1 -
 .../async_remote_services/examples/CMakeLists.txt  |   8 +-
 .../async_remote_services/rsa_spi/CMakeLists.txt   |   1 -
 .../rsa_spi/include/celix/rsa/Constants.h          |  10 +-
 .../rsa_spi/include/celix/rsa/Endpoint.h           |  12 +-
 .../include/celix/rsa/IExportServiceFactory.h      |  22 +-
 .../include/celix/rsa/IImportServiceFactory.h      |  22 +-
 libs/framework/include/celix/ServiceRegistration.h |   8 +-
 .../include/celix/dm/DependencyManager_Impl.h      |   2 +-
 16 files changed, 453 insertions(+), 206 deletions(-)

diff --git a/bundles/async_remote_services/CMakeLists.txt b/bundles/async_remote_services/CMakeLists.txt
index c71b538..2257092 100644
--- a/bundles/async_remote_services/CMakeLists.txt
+++ b/bundles/async_remote_services/CMakeLists.txt
@@ -15,12 +15,12 @@
 # specific language governing permissions and limitations
 # under the License.
 
-celix_subproject(ASYNC_REMOTE_SERVICE_ADMIN "Option to enable building the C++17 async Remote Service Admin Service bundles" OFF)
-if (ASYNC_REMOTE_SERVICE_ADMIN)
-    add_subdirectory(common)
+celix_subproject(REMOTE_SERVICE_ADMIN "Option to enable building the C++17 Remote Service Admin Service bundles" OFF)
+if (REMOTE_SERVICE_ADMIN)
+    #add_subdirectory(common)
     add_subdirectory(rsa_spi)
     add_subdirectory(admin)
-    add_subdirectory(topology_manager)
-    add_subdirectory(discovery_configured)
-    add_subdirectory(examples)
+    #add_subdirectory(topology_manager)
+    #add_subdirectory(discovery_configured)
+    #add_subdirectory(examples)
 endif()
\ No newline at end of file
diff --git a/bundles/async_remote_services/admin/CMakeLists.txt b/bundles/async_remote_services/admin/CMakeLists.txt
index b74c41e..4eee9c1 100644
--- a/bundles/async_remote_services/admin/CMakeLists.txt
+++ b/bundles/async_remote_services/admin/CMakeLists.txt
@@ -15,29 +15,27 @@
 # specific language governing permissions and limitations
 # under the License.
 
-add_celix_bundle(async_rsa
+add_celix_bundle(RemoteServiceAdmin
         VERSION 0.9.0
-        SYMBOLIC_NAME "apache_celix_async_remote_service_admin"
-        NAME "Apache Celix Async Remote Service Admin"
-        GROUP "Celix/AsyncRSA"
+        SYMBOLIC_NAME "celix::RemoteServiceAdmin"
+        NAME "Apache Celix Remote Service Admin"
+        GROUP "Celix/RSA"
+        FILENAME "Celix_RemoteServiceAdmin"
         SOURCES
-        src/admin.cc
-        )
-target_include_directories(async_rsa PRIVATE include)
-target_link_libraries(async_rsa PRIVATE
-        Celix::async_rsa_common
-        Celix::pubsub_api
-        Celix::pubsub_spi
+            src/admin.cc
+)
+target_include_directories(RemoteServiceAdmin PRIVATE include)
+target_link_libraries(RemoteServiceAdmin PRIVATE
         Celix::rsa_spi
         Celix::framework
         Celix::log_helper
-        )
+)
 
-#if (ENABLE_TESTING)
-#    add_subdirectory(gtest)
-#endif()
+if (ENABLE_TESTING)
+    add_subdirectory(gtest)
+endif()
 
 
-install_celix_bundle(async_rsa EXPORT celix COMPONENT async_rsa)
+install_celix_bundle(RemoteServiceAdmin EXPORT celix COMPONENT rsa)
 #Setup target aliases to match external usage
-add_library(Celix::async_rsa ALIAS async_rsa)
\ No newline at end of file
+add_library(Celix::RemoteServiceAdmin ALIAS RemoteServiceAdmin)
\ No newline at end of file
diff --git a/bundles/async_remote_services/CMakeLists.txt b/bundles/async_remote_services/admin/gtest/CMakeLists.txt
similarity index 54%
copy from bundles/async_remote_services/CMakeLists.txt
copy to bundles/async_remote_services/admin/gtest/CMakeLists.txt
index c71b538..42e2ce8 100644
--- a/bundles/async_remote_services/CMakeLists.txt
+++ b/bundles/async_remote_services/admin/gtest/CMakeLists.txt
@@ -15,12 +15,16 @@
 # specific language governing permissions and limitations
 # under the License.
 
-celix_subproject(ASYNC_REMOTE_SERVICE_ADMIN "Option to enable building the C++17 async Remote Service Admin Service bundles" OFF)
-if (ASYNC_REMOTE_SERVICE_ADMIN)
-    add_subdirectory(common)
-    add_subdirectory(rsa_spi)
-    add_subdirectory(admin)
-    add_subdirectory(topology_manager)
-    add_subdirectory(discovery_configured)
-    add_subdirectory(examples)
-endif()
\ No newline at end of file
+add_executable(test_cxx_remote_service_admin
+    src/RemoteServiceAdminTestSuite.cc
+)
+
+target_link_libraries(test_cxx_remote_service_admin PRIVATE Celix::framework GTest::gtest GTest::gtest_main Celix::rsa_spi)
+add_dependencies(test_cxx_remote_service_admin RemoteServiceAdmin_bundle)
+
+celix_get_bundle_file(RemoteServiceAdmin REMOTE_SERVICE_ADMIN_BUNDLE_LOCATION)
+target_compile_definitions(test_cxx_remote_service_admin PRIVATE REMOTE_SERVICE_ADMIN_BUNDLE_LOCATION="${REMOTE_SERVICE_ADMIN_BUNDLE_LOCATION}")
+
+
+add_test(NAME test_cxx_remote_service_admin COMMAND test_cxx_remote_service_admin)
+setup_target_for_coverage(test_cxx_remote_service_admin SCAN_DIR ..)
\ No newline at end of file
diff --git a/bundles/async_remote_services/admin/gtest/src/RemoteServiceAdminTestSuite.cc b/bundles/async_remote_services/admin/gtest/src/RemoteServiceAdminTestSuite.cc
new file mode 100644
index 0000000..20ff87e
--- /dev/null
+++ b/bundles/async_remote_services/admin/gtest/src/RemoteServiceAdminTestSuite.cc
@@ -0,0 +1,279 @@
+/*
+ * 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 <gtest/gtest.h>
+
+#include "celix/FrameworkFactory.h"
+#include "celix/rsa/IExportServiceFactory.h"
+#include "celix/rsa/IExportedService.h"
+#include "celix/rsa/IImportServiceFactory.h"
+#include "celix/rsa/Constants.h"
+
+class RemoteServiceAdminTestSuite : public ::testing::Test {
+public:
+    RemoteServiceAdminTestSuite() {
+        fw = celix::createFramework();
+        ctx = fw->getFrameworkBundleContext();
+    }
+
+    std::shared_ptr<celix::Framework> fw{};
+    std::shared_ptr<celix::BundleContext> ctx{};
+};
+
+TEST_F(RemoteServiceAdminTestSuite, startStopStartStopBundle) {
+    auto bndId = ctx->installBundle(REMOTE_SERVICE_ADMIN_BUNDLE_LOCATION);
+    EXPECT_GE(bndId, 0);
+    ctx->stopBundle(bndId);
+    ctx->startBundle(bndId);
+}
+
+
+/**
+ * The StubExported* classes mimic the expected behaviour of export service factories so that this can be used to test
+ * the RemoteServiceAdmin.
+ */
+
+class StubExportedService : public celix::rsa::IExportedService {
+public:
+    ~StubExportedService() noexcept override = default;
+    std::shared_ptr<celix::rsa::Endpoint> getEndpoint() override {
+        return endpoint;
+    }
+private:
+    std::shared_ptr<celix::rsa::Endpoint> endpoint = std::make_shared<celix::rsa::Endpoint>(celix::Properties{}); //can be empty for stub
+};
+
+class StubExportedServiceGuard {
+public:
+    explicit StubExportedServiceGuard(std::shared_ptr<celix::ServiceRegistration> _reg) : reg{std::move(_reg)} {}
+
+    void close() {
+        reg->unregister();
+    }
+private:
+    const std::shared_ptr<celix::ServiceRegistration> reg;
+};
+
+class StubExportServiceRegistration : public celix::rsa::IExportServiceRegistration {
+public:
+    explicit StubExportServiceRegistration(std::weak_ptr<StubExportedServiceGuard> _guard) : guard{std::move(_guard)} {}
+    ~StubExportServiceRegistration() noexcept override {
+        auto g = guard.lock();
+        if (g) {
+            g->close();
+        }
+    }
+
+private:
+    const std::weak_ptr<StubExportedServiceGuard> guard;
+};
+
+class StubExportServiceFactory : public celix::rsa::IExportServiceFactory {
+public:
+    explicit StubExportServiceFactory(std::shared_ptr<celix::BundleContext> _ctx) : ctx{std::move(_ctx)} {}
+
+    std::unique_ptr<celix::rsa::IExportServiceRegistration> exportService(const celix::Properties& /*serviceProperties*/) override {
+        auto svcReg= ctx->registerService<celix::rsa::IExportedService>(std::make_shared<StubExportedService>()).build();
+        auto guard = std::make_shared<StubExportedServiceGuard>(std::move(svcReg));
+
+        std::lock_guard<std::mutex> lock{mutex};
+        guards.emplace_back(guard);
+        return std::make_unique<StubExportServiceRegistration>(guard);
+    }
+
+private:
+    const std::shared_ptr<celix::BundleContext> ctx;
+    std::mutex mutex{};
+    std::vector<std::shared_ptr<StubExportedServiceGuard>> guards{};
+};
+
+class IDummyService {
+public:
+    virtual ~IDummyService() noexcept = default;
+};
+
+class DummyServiceImpl : public IDummyService {
+public:
+    ~DummyServiceImpl() noexcept override = default;
+};
+
+TEST_F(RemoteServiceAdminTestSuite, exportService) {
+    auto bndId = ctx->installBundle(REMOTE_SERVICE_ADMIN_BUNDLE_LOCATION);
+    EXPECT_GE(bndId, 0);
+
+    /**
+     * When I add a export service factory and register a service with exported interfaces the
+     * RemoteServiceAdmin will create a ExportedService with using the service factory
+     */
+     auto count = ctx->useService<celix::rsa::IExportedService>()
+             .build();
+     EXPECT_EQ(0, count);
+
+     auto reg1 = ctx->registerService<celix::rsa::IExportServiceFactory>(std::make_shared<StubExportServiceFactory>(ctx))
+             .addProperty(celix::rsa::IExportServiceFactory::TARGET_SERVICE_NAME, celix::typeName<IDummyService>())
+             .build();
+
+    count = ctx->useService<celix::rsa::IExportedService>()
+            .build();
+    EXPECT_EQ(0, count);
+
+     auto reg2 = ctx->registerService<IDummyService>(std::make_shared<DummyServiceImpl>())
+             .addProperty(celix::rsa::REMOTE_SERVICE_EXPORTED_PROPERTY_NAME, true)
+             .build();
+
+    //rsa called export service factory which created a IExportServiceRegistration, which register the marker interface IExportedService indicating an exported service
+    count = ctx->useService<celix::rsa::IExportedService>()
+            .build();
+    EXPECT_EQ(1, count);
+
+
+    reg1->unregister();
+
+    //removed factory -> removed exported interface
+    count = ctx->useService<celix::rsa::IExportedService>()
+            .build();
+    EXPECT_EQ(0, count);
+}
+
+TEST_F(RemoteServiceAdminTestSuite, exportServiceDifferentOrder) {
+    auto bndId = ctx->installBundle(REMOTE_SERVICE_ADMIN_BUNDLE_LOCATION);
+    EXPECT_GE(bndId, 0);
+
+    /**
+     * When I add a export service factory and register a service with exported interfaces the
+     * RemoteServiceAdmin will create a ExportedService with using the service factory
+     */
+    auto count = ctx->useService<celix::rsa::IExportedService>()
+            .build();
+    EXPECT_EQ(0, count);
+
+    auto reg1 = ctx->registerService<IDummyService>(std::make_shared<DummyServiceImpl>())
+            .addProperty(celix::rsa::REMOTE_SERVICE_EXPORTED_PROPERTY_NAME, true)
+            .build();
+
+    count = ctx->useService<celix::rsa::IExportedService>()
+            .build();
+    EXPECT_EQ(0, count);
+
+    auto reg2 = ctx->registerService<celix::rsa::IExportServiceFactory>(std::make_shared<StubExportServiceFactory>(ctx))
+            .addProperty(celix::rsa::IExportServiceFactory::TARGET_SERVICE_NAME, celix::typeName<IDummyService>())
+            .build();
+
+    //rsa called export service factory which created a IExportServiceRegistration, which register the marker interface IExportedService indicating an exported service
+    count = ctx->useService<celix::rsa::IExportedService>()
+            .build();
+    EXPECT_EQ(1, count);
+}
+
+
+
+
+/**
+ * The StubImported* classes mimic the expected behaviour of import service factories so that this can be used to test
+ * the RemoteServiceAdmin.
+ */
+
+class StubImportedServiceGuard {
+public:
+    explicit StubImportedServiceGuard(std::shared_ptr<celix::ServiceRegistration> _reg) : reg{std::move(_reg)} {}
+
+    void close() {
+        reg->unregister();
+    }
+private:
+    const std::shared_ptr<celix::ServiceRegistration> reg;
+};
+
+class StubImportServiceRegistration : public celix::rsa::IImportServiceRegistration {
+public:
+    explicit StubImportServiceRegistration(std::weak_ptr<StubImportedServiceGuard> _guard) : guard{std::move(_guard)} {}
+    ~StubImportServiceRegistration() noexcept override {
+        auto g = guard.lock();
+        if (g) {
+            g->close();
+        }
+    }
+
+private:
+    const std::weak_ptr<StubImportedServiceGuard> guard;
+};
+
+class StubImportServiceFactory : public celix::rsa::IImportServiceFactory {
+public:
+    explicit StubImportServiceFactory(std::shared_ptr<celix::BundleContext> _ctx) : ctx{std::move(_ctx)} {}
+
+    virtual std::unique_ptr<celix::rsa::IImportServiceRegistration> importService(const celix::rsa::Endpoint& endpoint) {
+           if (endpoint.getExportedInterfaces() == celix::typeName<IDummyService>()) {
+               auto reg = ctx->registerService<IDummyService>(std::make_shared<DummyServiceImpl>())
+                       .addProperty(celix::rsa::REMOTE_SERVICE_IMPORTED_PROPERTY_NAME, true)
+                       .build();
+               std::lock_guard<std::mutex> lock{mutex};
+               auto guard = std::make_shared<StubImportedServiceGuard>(std::move(reg));
+               guards.emplace_back(guard);
+               return std::make_unique<StubImportServiceRegistration>(guard);
+           } else {
+               return {};
+           }
+    }
+
+private:
+    const std::shared_ptr<celix::BundleContext> ctx;
+    std::mutex mutex{};
+    std::vector<std::shared_ptr<StubImportedServiceGuard>> guards{};
+};
+
+TEST_F(RemoteServiceAdminTestSuite, importService) {
+    auto bndId = ctx->installBundle(REMOTE_SERVICE_ADMIN_BUNDLE_LOCATION);
+    EXPECT_GE(bndId, 0);
+
+    /**
+     * When I add a import service factory and register a Endpoint/
+     * RemoteServiceAdmin will create a imported service (proxy for remote service described by the endpoint).
+     */
+    auto count = ctx->useService<IDummyService>()
+            .build();
+    EXPECT_EQ(0, count);
+
+    auto reg1 = ctx->registerService<celix::rsa::IImportServiceFactory>(std::make_shared<StubImportServiceFactory>(ctx))
+            .addProperty(celix::rsa::IImportServiceFactory::TARGET_SERVICE_NAME, celix::typeName<IDummyService>())
+            .build();
+
+    count = ctx->useService<IDummyService>()
+            .build();
+    EXPECT_EQ(0, count);
+
+    auto endpoint = std::make_shared<celix::rsa::Endpoint>(celix::Properties{
+        {celix::rsa::Endpoint::IDENTIFIER, "endpoint-id-1"},
+        {celix::rsa::Endpoint::EXPORTS, celix::typeName<IDummyService>()}});
+    auto reg2 = ctx->registerService<celix::rsa::Endpoint>(std::move(endpoint))
+            .build();
+
+    //rsa called import service factory which created a IImportService, which register a IDummtService
+    count = ctx->useService<IDummyService>()
+            .build();
+    EXPECT_EQ(1, count);
+
+
+    reg1->unregister();
+
+    //removed factory -> removed imported interface
+    count = ctx->useService<IDummyService>()
+            .build();
+    EXPECT_EQ(0, count);
+}
\ No newline at end of file
diff --git a/bundles/async_remote_services/admin/include/admin.h b/bundles/async_remote_services/admin/include/admin.h
index cf5a58a..80be3ad 100644
--- a/bundles/async_remote_services/admin/include/admin.h
+++ b/bundles/async_remote_services/admin/include/admin.h
@@ -19,11 +19,7 @@
 
 #include "celix/rsa/Endpoint.h"
 #include <celix_api.h>
-#include <ImportedServiceFactory.h>
-#include <ExportedServiceFactory.h>
 #include <mutex>
-#include <pubsub/api.h>
-#include <pubsub_message_serialization_service.h>
 #include "celix_log_service.h"
 
 #if defined(__has_include) && __has_include(<version>)
@@ -32,45 +28,26 @@
 
 #if __cpp_lib_memory_resource
 #include <memory_resource>
+#include <celix/rsa/IImportServiceFactory.h>
+#include <celix/rsa/IExportServiceFactory.h>
+
 #endif
 
 namespace celix::async_rsa {
-    class AsyncAdmin;
-
-    struct subscriber_handle {
-        subscriber_handle(long _svcId, AsyncAdmin *_admin, std::string_view _interface) : svcId(_svcId), admin(_admin), interface(_interface) {}
-        subscriber_handle(subscriber_handle const&) = default;
-        subscriber_handle(subscriber_handle&&) = default;
-        subscriber_handle& operator=(subscriber_handle const&) = default;
-        subscriber_handle& operator=(subscriber_handle&&) = default;
-        ~subscriber_handle() = default;
-
-        long svcId;
-        AsyncAdmin *admin;
-        std::string interface;
-    };
 
     class AsyncAdmin {
     public:
-        explicit AsyncAdmin(std::shared_ptr<celix::BundleContext> ctx) noexcept;
-        ~AsyncAdmin() noexcept = default;
-
-        AsyncAdmin(AsyncAdmin const &) = delete;
-        AsyncAdmin(AsyncAdmin&&) = delete;
-        AsyncAdmin& operator=(AsyncAdmin const &) = delete;
-        AsyncAdmin& operator=(AsyncAdmin&&) = delete;
-
         // Imported endpoint add/remove functions
         void addEndpoint(const std::shared_ptr<celix::rsa::Endpoint>& endpoint);
         void removeEndpoint(const std::shared_ptr<celix::rsa::Endpoint>& endpoint);
 
-        // Imported endpoint add/remove functions
-        void addImportedServiceFactory(const std::shared_ptr<celix::async_rsa::IImportedServiceFactory>& factory, const std::shared_ptr<const celix::Properties>& properties);
-        void removeImportedServiceFactory(const std::shared_ptr<celix::async_rsa::IImportedServiceFactory>& factory, const std::shared_ptr<const celix::Properties>& properties);
+        // import service factory. used to create new imported services
+        void addImportedServiceFactory(const std::shared_ptr<celix::rsa::IImportServiceFactory>& factory, const std::shared_ptr<const celix::Properties>& properties);
+        void removeImportedServiceFactory(const std::shared_ptr<celix::rsa::IImportServiceFactory>& factory, const std::shared_ptr<const celix::Properties>& properties);
 
-        // Exported endpoint add/remove functions
-        void addExportedServiceFactory(const std::shared_ptr<celix::async_rsa::IExportedServiceFactory>& factory, const std::shared_ptr<const celix::Properties>& properties);
-        void removeExportedServiceFactory(const std::shared_ptr<celix::async_rsa::IExportedServiceFactory>& factory, const std::shared_ptr<const celix::Properties>& properties);
+        // export service factory. used to create new exported services
+        void addExportedServiceFactory(const std::shared_ptr<celix::rsa::IExportServiceFactory>& factory, const std::shared_ptr<const celix::Properties>& properties);
+        void removeExportedServiceFactory(const std::shared_ptr<celix::rsa::IExportServiceFactory>& factory, const std::shared_ptr<const celix::Properties>& properties);
 
         // Add/remove services, used to track all services registered with celix and check if remote = true.
         void addService(const std::shared_ptr<void>& svc, const std::shared_ptr<const celix::Properties>& properties);
@@ -82,23 +59,23 @@ namespace celix::async_rsa {
         void createExportServices();
         void createImportServices();
 
-        std::shared_ptr<celix::BundleContext> _ctx;
         std::shared_ptr<celix_log_service> _logService{};
         std::mutex _m{}; // protects below
 
 #if __cpp_lib_memory_resource
         std::pmr::unsynchronized_pool_resource _memResource{};
-        std::pmr::unordered_map<std::string, std::shared_ptr<celix::async_rsa::IExportedServiceFactory>> _exportedServiceFactories{&_memResource};
-        std::pmr::unordered_map<std::string, std::shared_ptr<celix::async_rsa::IImportedServiceFactory>> _importedServiceFactories{&_memResource};
-        std::pmr::unordered_map<std::string, std::string> _importedServiceInstances{&_memResource}; //key = endpoint id, value = cmp uuid.
-        std::pmr::unordered_map<long, std::string> _exportedServiceInstances{&_memResource}; //key = service id, value = cmp uuid.
+
+        std::pmr::unordered_map<std::string, std::shared_ptr<celix::rsa::IExportServiceFactory>> _exportServiceFactories{&_memResource}; //key = service name
+        std::pmr::unordered_map<std::string, std::shared_ptr<celix::rsa::IImportServiceFactory>> _importServiceFactories{&_memResource}; //key = service name
+        std::pmr::unordered_map<std::string, std::unique_ptr<celix::rsa::IImportServiceRegistration>> _importedServices{&_memResource}; //key = endpoint id
+        std::pmr::unordered_map<long, std::unique_ptr<celix::rsa::IExportServiceRegistration>> _exportedServices{&_memResource}; //key = service id
 #else
-        std::unordered_map<std::string, std::shared_ptr<celix::async_rsa::IExportedServiceFactory>> _exportedServiceFactories{};
-        std::unordered_map<std::string, std::shared_ptr<celix::async_rsa::IImportedServiceFactory>> _importedServiceFactories{};
-        std::unordered_map<std::string, std::string> _importedServiceInstances{};
-        std::unordered_map<long, std::string> _exportedServiceInstances{};
+        std::unordered_map<std::string, std::shared_ptr<celix::rsa::IExportServiceFactory>> _exportServiceFactories{}; //key = service name
+        std::unordered_map<std::string, std::shared_ptr<celix::rsa::IImportServiceFactory>> _importServiceFactories{}; //key = service name
+        std::unordered_map<std::string, std::unique_ptr<celix::rsa::IImportServiceRegistration>> _importedServices{}; //key = endpoint id
+        std::unordered_map<long, std::unique_ptr<celix::rsa::IExportServiceRegistration>> _exportedServices{}; //key = service id
 #endif
         std::vector<std::shared_ptr<celix::rsa::Endpoint>> _toBeImportedServices{};
-        std::vector<std::pair<std::shared_ptr<void>, std::shared_ptr<const celix::Properties>>> _toBeExportedServices{};
+        std::vector<std::shared_ptr<const celix::Properties>> _toBeExportedServices{};
     };
 }
\ No newline at end of file
diff --git a/bundles/async_remote_services/admin/src/admin.cc b/bundles/async_remote_services/admin/src/admin.cc
index c776599..3b92867 100644
--- a/bundles/async_remote_services/admin/src/admin.cc
+++ b/bundles/async_remote_services/admin/src/admin.cc
@@ -18,9 +18,6 @@
  */
 
 #include <admin.h>
-#include <celix_api.h>
-#include <pubsub_message_serialization_service.h>
-#include <ConfiguredEndpoint.h>
 #include "celix/rsa/Constants.h"
 
 #define L_DEBUG(...) \
@@ -40,10 +37,6 @@
         _logService->error(_logService->handle, __VA_ARGS__);           \
     }
 
-celix::async_rsa::AsyncAdmin::AsyncAdmin(std::shared_ptr<celix::BundleContext> ctx) noexcept : _ctx{std::move(ctx)} {
-
-}
-
 void celix::async_rsa::AsyncAdmin::addEndpoint(const std::shared_ptr<celix::rsa::Endpoint>& endpoint) {
     assert(endpoint);
 
@@ -73,87 +66,89 @@ void celix::async_rsa::AsyncAdmin::removeEndpoint(const std::shared_ptr<celix::r
         return;
     }
 
-    std::lock_guard l(_m);
-
-    _toBeImportedServices.erase(std::remove_if(_toBeImportedServices.begin(), _toBeImportedServices.end(), [&id](auto const &endpoint){
-        return id == endpoint->getEndpointId();
-    }), _toBeImportedServices.end());
+    std::shared_ptr<celix::rsa::IImportServiceRegistration> tmpStore{}; //to ensure destruction outside of lock
+    {
+        std::lock_guard l(_m);
 
+        _toBeImportedServices.erase(std::remove_if(_toBeImportedServices.begin(), _toBeImportedServices.end(), [&id](auto const &endpoint){
+            return id == endpoint->getEndpointId();
+        }), _toBeImportedServices.end());
 
-    auto instanceIt = _importedServiceInstances.find(id);
-    if (instanceIt == end(_importedServiceInstances)) {
-        return;
+        auto it = _importedServices.find(id);
+        if (it != _importedServices.end()) {
+            tmpStore = std::move(it->second);
+            _importedServices.erase(it);
+        }
     }
-
-    _ctx->getDependencyManager()->removeComponentAsync(instanceIt->second);
-    _importedServiceInstances.erase(instanceIt);
 }
 
-void celix::async_rsa::AsyncAdmin::addImportedServiceFactory(const std::shared_ptr<celix::async_rsa::IImportedServiceFactory>& factory, const std::shared_ptr<const celix::Properties>& properties) {
-    auto interface = properties->get(celix::rsa::Endpoint::EXPORTS);
-
-    if (interface.empty()) {
-        L_DEBUG("Adding service factory but no exported interfaces");
+void celix::async_rsa::AsyncAdmin::addImportedServiceFactory(
+        const std::shared_ptr<celix::rsa::IImportServiceFactory> &factory,
+        const std::shared_ptr<const celix::Properties> &properties) {
+    auto targetServiceName = properties->get(celix::rsa::IImportServiceFactory::TARGET_SERVICE_NAME);
+    if (targetServiceName.empty()) {
+        L_WARN("Adding service factory but missing %s property", celix::rsa::IImportServiceFactory::TARGET_SERVICE_NAME);
         return;
     }
 
-    std::lock_guard l(_m);
 
-    auto existingFactory = _importedServiceFactories.find(interface);
-    if(existingFactory != end(_importedServiceFactories)) {
+    std::lock_guard l(_m);
+    auto existingFactory = _importServiceFactories.find(targetServiceName);
+    if (existingFactory != end(_importServiceFactories)) {
         L_WARN("Adding imported factory but factory already exists");
         return;
     }
 
-    _importedServiceFactories.emplace(interface, factory);
+    _importServiceFactories.emplace(targetServiceName, factory);
 
     createImportServices();
 }
 
-void celix::async_rsa::AsyncAdmin::removeImportedServiceFactory(const std::shared_ptr<celix::async_rsa::IImportedServiceFactory>& /*factory*/, const std::shared_ptr<const celix::Properties>& properties) {
-    auto interface = properties->get(celix::rsa::Endpoint::EXPORTS);
-
-    if (interface.empty()) {
-        L_WARN("Removing service factory but missing exported interfaces");
+void celix::async_rsa::AsyncAdmin::removeImportedServiceFactory(
+        const std::shared_ptr<celix::rsa::IImportServiceFactory> &/*factory*/,
+        const std::shared_ptr<const celix::Properties> &properties) {
+    auto targetServiceName = properties->get(celix::rsa::IImportServiceFactory::TARGET_SERVICE_NAME);
+    if (targetServiceName.empty()) {
+        L_WARN("Removing service factory but missing %s property", celix::rsa::IImportServiceFactory::TARGET_SERVICE_NAME);
         return;
     }
 
     std::lock_guard l(_m);
-    _importedServiceFactories.erase(interface);
+    _importServiceFactories.erase(targetServiceName);
 
-    //TODO TBD are the removal of the imported services also needed when a ImportedServiceFactory is removed (and maybe the bundle is uninstalled?)
+    //TODO remove imported services from this factory ??needed
 }
 
-void celix::async_rsa::AsyncAdmin::addExportedServiceFactory(const std::shared_ptr<celix::async_rsa::IExportedServiceFactory>& factory, const std::shared_ptr<const celix::Properties>& properties) {
-    auto interface = properties->get(celix::rsa::Endpoint::EXPORTS);
-
-    if (interface.empty()) {
-        L_WARN("Adding exported factory but missing exported interfaces");
+void celix::async_rsa::AsyncAdmin::addExportedServiceFactory(
+        const std::shared_ptr<celix::rsa::IExportServiceFactory> &factory,
+        const std::shared_ptr<const celix::Properties> &properties) {
+    auto targetServiceName = properties->get(celix::rsa::IExportServiceFactory::TARGET_SERVICE_NAME);
+    if (targetServiceName.empty()) {
+        L_WARN("Adding service factory but missing %s property", celix::rsa::IExportServiceFactory::TARGET_SERVICE_NAME);
         return;
     }
 
     std::lock_guard<std::mutex> lock{_m};
-    _exportedServiceFactories.emplace(interface, factory);
+    _exportServiceFactories.emplace(targetServiceName, factory);
     createExportServices();
 }
 
-void celix::async_rsa::AsyncAdmin::removeExportedServiceFactory(const std::shared_ptr<celix::async_rsa::IExportedServiceFactory>& /*factory*/, const std::shared_ptr<const celix::Properties>& properties) {
-    auto interface = properties->get(celix::rsa::Endpoint::EXPORTS);
-
-    if(interface.empty()) {
-        L_WARN("Removing imported factory but missing exported interfaces");
+void celix::async_rsa::AsyncAdmin::removeExportedServiceFactory(
+        const std::shared_ptr<celix::rsa::IExportServiceFactory> &/*factory*/,
+        const std::shared_ptr<const celix::Properties> &properties) {
+    auto targetServiceName = properties->get(celix::rsa::IExportServiceFactory::TARGET_SERVICE_NAME);
+    if (targetServiceName.empty()) {
+        L_WARN("Removing service factory but missing %s property", celix::rsa::IExportServiceFactory::TARGET_SERVICE_NAME);
         return;
     }
 
     std::lock_guard l(_m);
-    _exportedServiceFactories.erase(interface);
+    _exportServiceFactories.erase(targetServiceName);
 
-    //TODO TBD are the removal of the exported services also needed when a ExportedServiceFactory is removed (and maybe the bundle is uninstalled?)
+    //TODO remove exported services from this factory ??needed
 }
 
-void celix::async_rsa::AsyncAdmin::addService(const std::shared_ptr<void>& svc, const std::shared_ptr<const celix::Properties>& props) {
-    assert(props->getAsBool(celix::rsa::REMOTE_SERVICE_PROPERTY_NAME, false)); //"only remote services should be tracker by the service tracker");
-
+void celix::async_rsa::AsyncAdmin::addService(const std::shared_ptr<void>& /*svc*/, const std::shared_ptr<const celix::Properties>& props) {
     auto serviceName = props->get(celix::SERVICE_NAME, "");
     if (serviceName.empty()) {
         L_WARN("Adding service to be exported but missing objectclass");
@@ -161,70 +156,71 @@ void celix::async_rsa::AsyncAdmin::addService(const std::shared_ptr<void>& svc,
     }
 
     std::lock_guard<std::mutex> lock{_m};
-    _toBeExportedServices.emplace_back(svc, props);
+    _toBeExportedServices.emplace_back(props);
     createExportServices();
 }
 
 void celix::async_rsa::AsyncAdmin::removeService(const std::shared_ptr<void>& /*svc*/, const std::shared_ptr<const celix::Properties>& props) {
-    assert(props->getAsBool(celix::rsa::REMOTE_SERVICE_PROPERTY_NAME, false)); //"only remote services should be tracker by the service tracker");
-
     long svcId = props->getAsLong(celix::SERVICE_ID, -1);
     if (svcId < 0) {
         L_WARN("Removing service to be exported but missing service.id");
         return;
     }
 
-    std::lock_guard l(_m);
+    std::unique_ptr<celix::rsa::IExportServiceRegistration> tmpStore{}; //to ensure destruction outside of lock
+    {
+        std::lock_guard l(_m);
 
-    //remove export interface (if present)
-    auto instanceIt = _exportedServiceInstances.find(svcId);
-    if (instanceIt != end(_exportedServiceInstances)) {
-        //note cannot remove async, because the svc lifetime needs to extend the lifetime of the component.
-        //TODO improve by creating export service based on svc id instead of svc pointer, so that export service can track its own dependencies.
-        _ctx->getDependencyManager()->removeComponent(instanceIt->second);
-        _exportedServiceInstances.erase(instanceIt);
-    }
+        auto instanceIt = _exportedServices.find(svcId);
+        if (instanceIt != end(_exportedServices)) {
+            tmpStore = std::move(instanceIt->second);
+            _exportedServices.erase(instanceIt);
+        }
 
-    //remove to be exported endpoint (if present)
-    for (auto it = _toBeExportedServices.begin(); it != _toBeExportedServices.end(); ++it) {
-        if (it->second->getAsBool(celix::SERVICE_ID, -1) == svcId) {
-            _toBeExportedServices.erase(it);
-            break;
+        //remove to be exported endpoint (if present)
+        for (auto it = _toBeExportedServices.begin(); it != _toBeExportedServices.end(); ++it) {
+            if ((*it)->getAsBool(celix::SERVICE_ID, -1) == svcId) {
+                _toBeExportedServices.erase(it);
+                break;
+            }
         }
     }
-
 }
 
 void celix::async_rsa::AsyncAdmin::createImportServices() {
-    for (auto it = _toBeImportedServices.begin(); it != _toBeImportedServices.end(); ++it) {
+    auto it = _toBeImportedServices.begin();
+    while (it != _toBeImportedServices.end()) {
         auto interface = (*it)->getExportedInterfaces();
-        auto existingFactory = _importedServiceFactories.find(interface);
-        if (existingFactory == end(_importedServiceFactories)) {
+        auto existingFactory = _importServiceFactories.find(interface);
+        if (existingFactory == end(_importServiceFactories)) {
             L_DEBUG("Adding endpoint to be imported but no factory available yet, delaying import");
+            ++it;
+            continue;
         }
         auto endpointId = (*it)->getEndpointId();
         L_DEBUG("Adding endpoint, created service");
-        _importedServiceInstances.emplace(endpointId, existingFactory->second->create(endpointId).getUUID());
+        _importedServices.emplace(endpointId, existingFactory->second->importService(**it));
         it = _toBeImportedServices.erase(it);
     }
 }
 
 void celix::async_rsa::AsyncAdmin::createExportServices() {
-    for (auto it = _toBeExportedServices.begin(); it != _toBeExportedServices.end(); ++it) {
-        auto serviceName = it->second->get(celix::SERVICE_NAME, "");
-        auto svcId = it->second->getAsLong(celix::SERVICE_ID, -1);
+    auto it = _toBeExportedServices.begin();
+    while (it != _toBeExportedServices.end()) {
+        const auto& svcProperties = **it;
+        auto serviceName = svcProperties.get(celix::SERVICE_NAME, "");
+        auto svcId = svcProperties.getAsLong(celix::SERVICE_ID, -1);
         if (serviceName.empty()) {
             L_WARN("Adding service to be exported but missing objectclass for svc id %li", svcId);
             continue;
         }
-        auto factory = _exportedServiceFactories.find(serviceName);
-        if (factory == end(_exportedServiceFactories)) {
+        auto factory = _exportServiceFactories.find(serviceName);
+        if (factory == end(_exportServiceFactories)) {
             L_DEBUG("Adding service to be exported but no factory available yet, delaying creation");
+            ++it;
             continue;
         }
-        auto endpointId = _ctx->getFramework()->getUUID() + "-" + std::to_string(svcId);
-        auto cmpUUID = factory->second->create(it->first.get(), std::move(endpointId)).getUUID();
-        _exportedServiceInstances.emplace(svcId, std::move(cmpUUID));
+        _exportedServices.emplace(svcId, factory->second->exportService(svcProperties));
         it = _toBeExportedServices.erase(it);
     }
 }
@@ -236,18 +232,18 @@ void celix::async_rsa::AsyncAdmin::setLogger(const std::shared_ptr<celix_log_ser
 class AdminActivator {
 public:
     explicit AdminActivator(const std::shared_ptr<celix::BundleContext>& ctx) {
-        auto admin = std::make_shared<celix::async_rsa::AsyncAdmin>(ctx);
+        auto admin = std::make_shared<celix::async_rsa::AsyncAdmin>();
 
         auto& cmp = ctx->getDependencyManager()->createComponent(admin);
         cmp.createServiceDependency<celix::rsa::Endpoint>()
                 .setRequired(false)
                 .setStrategy(celix::dm::DependencyUpdateStrategy::locking)
                 .setCallbacks(&celix::async_rsa::AsyncAdmin::addEndpoint, &celix::async_rsa::AsyncAdmin::removeEndpoint);
-        cmp.createServiceDependency<celix::async_rsa::IImportedServiceFactory>()
+        cmp.createServiceDependency<celix::rsa::IImportServiceFactory>()
                 .setRequired(false)
                 .setStrategy(celix::dm::DependencyUpdateStrategy::locking)
                 .setCallbacks(&celix::async_rsa::AsyncAdmin::addImportedServiceFactory, &celix::async_rsa::AsyncAdmin::removeImportedServiceFactory);
-        cmp.createServiceDependency<celix::async_rsa::IExportedServiceFactory>()
+        cmp.createServiceDependency<celix::rsa::IExportServiceFactory>()
                 .setRequired(false)
                 .setStrategy(celix::dm::DependencyUpdateStrategy::locking)
                 .setCallbacks(&celix::async_rsa::AsyncAdmin::addExportedServiceFactory, &celix::async_rsa::AsyncAdmin::removeExportedServiceFactory);
@@ -259,8 +255,8 @@ public:
         cmp.build();
 
         //note adding void service dependencies is not supported for the dependency manager, using a service tracker instead.
-        _remoteServiceTracker = ctx->trackServices<void>()
-                .setFilter(std::string{"("}.append(celix::rsa::REMOTE_SERVICE_PROPERTY_NAME).append("=*)"))
+        _remoteServiceTracker = ctx->trackAnyServices()
+                .setFilter(std::string{"("}.append(celix::rsa::REMOTE_SERVICE_EXPORTED_PROPERTY_NAME).append("=*)"))
                 .addAddWithPropertiesCallback([admin](const std::shared_ptr<void>& svc, const std::shared_ptr<const celix::Properties>& properties) {
                     admin->addService(svc, properties);
                 })
diff --git a/bundles/async_remote_services/common/CMakeLists.txt b/bundles/async_remote_services/common/CMakeLists.txt
index 979305c..42888bd 100644
--- a/bundles/async_remote_services/common/CMakeLists.txt
+++ b/bundles/async_remote_services/common/CMakeLists.txt
@@ -21,6 +21,7 @@ target_include_directories(async_rsa_common INTERFACE
         $<INSTALL_INTERFACE:include/celix/async_rsa_common>
         )
 target_compile_options(async_rsa_common INTERFACE -std=c++17)
+target_link_libraries(async_rsa_common INTERFACE Celix::pubsub_spi Celix::pubsub_api Celix::rsa_spi)
 #set_target_properties(async_rsa_common PROPERTIES OUTPUT_NAME "celix_async_rsa_common")
 #target_include_directories(async_rsa_common PRIVATE src)
 #target_link_libraries(async_rsa_common INTERFACE Celix::framework)
diff --git a/bundles/async_remote_services/common/include/ImportedServiceFactory.h b/bundles/async_remote_services/common/include/ImportedServiceFactory.h
index 5783d47..6a342f7 100644
--- a/bundles/async_remote_services/common/include/ImportedServiceFactory.h
+++ b/bundles/async_remote_services/common/include/ImportedServiceFactory.h
@@ -19,7 +19,6 @@
 #pragma once
 
 #include <celix/dm/DependencyManager.h>
-#include <pubsub_endpoint.h>
 
 namespace celix::async_rsa {
     /// Service factory interface.
diff --git a/bundles/async_remote_services/examples/CMakeLists.txt b/bundles/async_remote_services/examples/CMakeLists.txt
index 0935068..3aa8ee4 100644
--- a/bundles/async_remote_services/examples/CMakeLists.txt
+++ b/bundles/async_remote_services/examples/CMakeLists.txt
@@ -48,8 +48,8 @@ celix_bundle_files(hardcoded_example_subscriber
         DESTINATION "META-INF/topics/sub"
         )
 
-target_link_libraries(hardcoded_example_provider PRIVATE Celix::framework Celix::async_rsa_discovery_configured Celix::async_rsa_common Celix::async_rsa)
-target_link_libraries(hardcoded_example_subscriber PRIVATE Celix::framework Celix::async_rsa_discovery_configured Celix::async_rsa_common Celix::async_rsa)
+target_link_libraries(hardcoded_example_provider PRIVATE Celix::framework Celix::async_rsa_common)
+target_link_libraries(hardcoded_example_subscriber PRIVATE Celix::framework Celix::async_rsa_common)
 target_compile_options(hardcoded_example_provider INTERFACE -std=c++17)
 target_compile_options(hardcoded_example_subscriber INTERFACE -std=c++17)
 
@@ -78,7 +78,7 @@ add_celix_container(hardcoded_example_provider_cnt
         Celix::pubsub_protocol_wire_v2
         Celix::async_rsa_discovery_configured
         Celix::async_topology_manager
-        Celix::async_rsa
+        Celix::RemoteServiceAdmin
         hardcoded_example_provider
         PROPERTIES
         "org.osgi.framework.storage=.publisherCache"
@@ -99,7 +99,7 @@ add_celix_container(hardcoded_example_subscriber_cnt
         Celix::pubsub_protocol_wire_v2
         Celix::async_rsa_discovery_configured
         Celix::async_topology_manager
-        Celix::async_rsa
+        Celix::RemoteServiceAdmin
         hardcoded_example_subscriber
         PROPERTIES
         "org.osgi.framework.storage=.subscriberCache"
diff --git a/bundles/async_remote_services/rsa_spi/CMakeLists.txt b/bundles/async_remote_services/rsa_spi/CMakeLists.txt
index 33ed0a5..47568ff 100644
--- a/bundles/async_remote_services/rsa_spi/CMakeLists.txt
+++ b/bundles/async_remote_services/rsa_spi/CMakeLists.txt
@@ -20,7 +20,6 @@ target_include_directories(rsa_spi INTERFACE
     $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
     $<INSTALL_INTERFACE:include/celix/rsa>
 )
-target_link_libraries(rsa_spi INTERFACE Celix::async_rsa_discovery_configured)
 target_compile_options(rsa_spi INTERFACE -std=c++17)
 
 install(TARGETS rsa_spi EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT rsa)
diff --git a/bundles/async_remote_services/rsa_spi/include/celix/rsa/Constants.h b/bundles/async_remote_services/rsa_spi/include/celix/rsa/Constants.h
index 2b5d0c4..5ae1c9f 100644
--- a/bundles/async_remote_services/rsa_spi/include/celix/rsa/Constants.h
+++ b/bundles/async_remote_services/rsa_spi/include/celix/rsa/Constants.h
@@ -23,9 +23,15 @@
 namespace celix::rsa {
 
     /**
-     * @brief Service property (named "remote") to mark a service as a remote service.
+     * @brief Service property (named "service.exported") to mark a service as wanting to be exported (remote).
      * Present means -> export service as a remote service.
      */
-    constexpr const char *const REMOTE_SERVICE_PROPERTY_NAME = "remote";
+    constexpr const char * const REMOTE_SERVICE_EXPORTED_PROPERTY_NAME = "service.exported";
+
+    /**
+     * @brief Service property (named "remote") to mark a service as a imported service.
+     * Present means -> service is a imported service (proxy of a remote service).
+     */
+    constexpr const char * const REMOTE_SERVICE_IMPORTED_PROPERTY_NAME = "service.imported";
 
 }
\ No newline at end of file
diff --git a/bundles/async_remote_services/rsa_spi/include/celix/rsa/Endpoint.h b/bundles/async_remote_services/rsa_spi/include/celix/rsa/Endpoint.h
index 97a81da..6035823 100644
--- a/bundles/async_remote_services/rsa_spi/include/celix/rsa/Endpoint.h
+++ b/bundles/async_remote_services/rsa_spi/include/celix/rsa/Endpoint.h
@@ -31,12 +31,12 @@ namespace celix::rsa {
     class Endpoint {
     public:
         static constexpr const char * const IDENTIFIER = "endpoint.id";
-        static constexpr const char * const IMPORTED = "service.imported";
-        static constexpr const char * const IMPORT_CONFIGS = "service.imported.configs";
+//        static constexpr const char * const IMPORTED = "service.imported";
+//        static constexpr const char * const IMPORT_CONFIGS = "service.imported.configs";
         static constexpr const char * const EXPORTS = "service.exported.interfaces";
-        static constexpr const char * const OBJECTCLASS = "endpoint.objectClass";
-        static constexpr const char * const SCOPE = "endpoint.scope";
-        static constexpr const char * const TOPIC = "endpoint.topic";
+//        static constexpr const char * const OBJECTCLASS = "endpoint.objectClass";
+//        static constexpr const char * const SCOPE = "endpoint.scope";
+//        static constexpr const char * const TOPIC = "endpoint.topic";
 
 
         /**
@@ -59,8 +59,6 @@ namespace celix::rsa {
             return _celixProperties.get(EXPORTS);
         }
 
-
-
     protected:
         celix::dm::Properties _celixProperties;
 
diff --git a/bundles/async_remote_services/rsa_spi/include/celix/rsa/IExportServiceFactory.h b/bundles/async_remote_services/rsa_spi/include/celix/rsa/IExportServiceFactory.h
index b0a4c96..fa5508c 100644
--- a/bundles/async_remote_services/rsa_spi/include/celix/rsa/IExportServiceFactory.h
+++ b/bundles/async_remote_services/rsa_spi/include/celix/rsa/IExportServiceFactory.h
@@ -19,21 +19,17 @@
 #pragma once
 
 #include <memory>
+#include "celix/rsa/Endpoint.h"
 
 namespace celix::rsa {
 
     /**
-     * @brief ExportService class which represent a (opaque) exported service.
+     * @brief ExportServiceRegistration class which represent a (opaque) exported service.
      * The lifetime of this object should be coupled with the lifetime of the exported service.
      */
-    class ExportedService {
+    class IExportServiceRegistration {
     public:
-        virtual ~ExportedService() noexcept = default;
-
-        /**
-         * @brief returns the endpoint for this exported service (to be used in discovery).
-         */
-        virtual const celix::rsa::Endpoint& getEndpoint() const = 0;
+        virtual ~IExportServiceRegistration() noexcept = default;
     };
 
     /**
@@ -45,14 +41,12 @@ namespace celix::rsa {
      */
     class IExportServiceFactory {
     public:
-        static constexpr std::string_view TARGET_SERVICE_NAME = "target.service.name";
-
-        virtual ~IExportServiceFactory() noexcept = default;
-
         /**
          * @brief The service name for which this factory can created exported services.
          */
-        std::string& const getTargetServiceName() const = 0;
+        static constexpr const char * const TARGET_SERVICE_NAME = "target.service.name";
+
+        virtual ~IExportServiceFactory() noexcept = default;
 
         /**
          * @brief Exports the service identified with svcId
@@ -60,6 +54,6 @@ namespace celix::rsa {
          * @return A ExportService.
          * @throws celix::rsa::RemoteServicesException if the export failed.
          */
-        virtual std::unique_ptr<ExportedService> exportService(const celix::Properties& serviceProperties) = 0;
+        virtual std::unique_ptr<celix::rsa::IExportServiceRegistration> exportService(const celix::Properties& serviceProperties) = 0;
     };
 }
\ No newline at end of file
diff --git a/bundles/async_remote_services/rsa_spi/include/celix/rsa/IImportServiceFactory.h b/bundles/async_remote_services/rsa_spi/include/celix/rsa/IImportServiceFactory.h
index 9427146..f62cf23 100644
--- a/bundles/async_remote_services/rsa_spi/include/celix/rsa/IImportServiceFactory.h
+++ b/bundles/async_remote_services/rsa_spi/include/celix/rsa/IImportServiceFactory.h
@@ -19,21 +19,17 @@
 #pragma once
 
 #include <memory>
+#include "celix/rsa/Endpoint.h"
 
 namespace celix::rsa {
 
     /**
-     * @brief ImportService class which represent a (opaque) imported service.
+     * @brief ImportServiceRegistration class which represent a (opaque) imported service.
      * The lifetime of this object should be coupled with the lifetime of the imported service.
      */
-    class ImportedService {
+    class IImportServiceRegistration {
     public:
-        virtual ~ImportedService() noexcept = default;
-
-        /**
-         * @brief returns the endpoint used for this imported service.
-         */
-        virtual const celix::rsa::Endpoint& getEndpoint() const = 0;
+        virtual ~IImportServiceRegistration() noexcept = default;
     };
 
     /**
@@ -45,14 +41,12 @@ namespace celix::rsa {
      */
     class IImportServiceFactory {
     public:
-        static constexpr std::string_view TARGET_SERVICE_NAME = "target.service.name";
-
-        virtual ~IImportServiceFactory() noexcept = default;
-
         /**
          * @brief The service name for which this factory can created exported services.
          */
-        std::string& const getTargetServiceName() const = 0;
+        static constexpr const char * const TARGET_SERVICE_NAME = "target.service.name";
+
+        virtual ~IImportServiceFactory() noexcept = default;
 
         /**
          * @brief Imports the service identified with svcId
@@ -60,6 +54,6 @@ namespace celix::rsa {
          * @return A ImportService.
          * @throws celix::rsa::RemoteServicesException if the import failed.
          */
-        virtual std::unique_ptr<ImportedService> importService(const celix::rsa::Endpoint& endpoint) = 0;
+        virtual std::unique_ptr<celix::rsa::IImportServiceRegistration> importService(const celix::rsa::Endpoint& endpoint) = 0;
     };
 }
\ No newline at end of file
diff --git a/libs/framework/include/celix/ServiceRegistration.h b/libs/framework/include/celix/ServiceRegistration.h
index 38981b0..d3e4d0c 100644
--- a/libs/framework/include/celix/ServiceRegistration.h
+++ b/libs/framework/include/celix/ServiceRegistration.h
@@ -208,6 +208,7 @@ namespace celix {
                         {
                             std::lock_guard<std::mutex> lck{reg->mutex};
                             reg->state = ServiceRegistrationState::UNREGISTERED;
+                            reg->svc.reset();
                         }
                         for (const auto &cb : reg->onUnregisteredCallbacks) {
                             cb(*reg);
@@ -229,6 +230,7 @@ namespace celix {
                     {
                         std::lock_guard<std::mutex> lck{mutex};
                         state = ServiceRegistrationState::UNREGISTERED;
+                        svc.reset();
                     }
                     for (const auto& cb: onUnregisteredCallbacks) {
                         cb(*this);
@@ -262,14 +264,14 @@ namespace celix {
                 std::vector<std::function<void(ServiceRegistration&)>> _onRegisteredCallbacks,
                 std::vector<std::function<void(ServiceRegistration&)>> _onUnregisteredCallbacks) :
                 cCtx{std::move(_cCtx)},
-                svc{std::move(_svc)},
                 name{std::move(_name)},
                 version{std::move(_version)},
                 properties{std::move(_properties)},
                 registerAsync{_registerAsync},
                 unregisterAsync{_unregisterAsync},
                 onRegisteredCallbacks{std::move(_onRegisteredCallbacks)},
-                onUnregisteredCallbacks{std::move(_onUnregisteredCallbacks)} {}
+                onUnregisteredCallbacks{std::move(_onUnregisteredCallbacks)},
+                svc{std::move(_svc)} {}
 
 
         /**
@@ -333,7 +335,6 @@ namespace celix {
         }
 
         const std::shared_ptr<celix_bundle_context_t> cCtx;
-        const std::shared_ptr<void> svc;
         const std::string name;
         const std::string version;
         const celix::Properties properties;
@@ -344,6 +345,7 @@ namespace celix {
 
         mutable std::mutex mutex{}; //protects below
         long svcId{-1};
+        std::shared_ptr<void> svc;
         ServiceRegistrationState state{ServiceRegistrationState::REGISTERING};
         std::weak_ptr<ServiceRegistration> self{}; //weak ptr to self, so that callbacks can receive a shared ptr
     };
diff --git a/libs/framework/include/celix/dm/DependencyManager_Impl.h b/libs/framework/include/celix/dm/DependencyManager_Impl.h
index 86a90c7..6ff1da2 100644
--- a/libs/framework/include/celix/dm/DependencyManager_Impl.h
+++ b/libs/framework/include/celix/dm/DependencyManager_Impl.h
@@ -27,7 +27,7 @@ inline DependencyManager::DependencyManager(celix_bundle_context_t *ctx) :
     cDepMan{celix_bundleContext_getDependencyManager(ctx), [](celix_dependency_manager_t*){/*nop*/}} {}
 
 inline DependencyManager::~DependencyManager() {
-    clear();
+    clearAsync();
 }
 
 template<class T>

[celix] 02/03: Refactors test case to use components instead of svc registrations.

Posted by pn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch feature/cxx_rsa_update
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 10c92193006fddb333e210ab5766893770e142ca
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Thu Apr 15 21:04:34 2021 +0200

    Refactors test case to use components instead of svc registrations.
---
 .../admin/gtest/src/RemoteServiceAdminTestSuite.cc | 116 ++++++++++++++-------
 .../async_remote_services/admin/include/admin.h    |   8 +-
 bundles/async_remote_services/admin/src/admin.cc   |  26 ++---
 .../include/celix/rsa/IExportServiceFactory.h      |  12 +--
 .../include/celix/rsa/IImportServiceFactory.h      |  10 +-
 5 files changed, 102 insertions(+), 70 deletions(-)

diff --git a/bundles/async_remote_services/admin/gtest/src/RemoteServiceAdminTestSuite.cc b/bundles/async_remote_services/admin/gtest/src/RemoteServiceAdminTestSuite.cc
index 20ff87e..22ff43e 100644
--- a/bundles/async_remote_services/admin/gtest/src/RemoteServiceAdminTestSuite.cc
+++ b/bundles/async_remote_services/admin/gtest/src/RemoteServiceAdminTestSuite.cc
@@ -59,48 +59,62 @@ private:
     std::shared_ptr<celix::rsa::Endpoint> endpoint = std::make_shared<celix::rsa::Endpoint>(celix::Properties{}); //can be empty for stub
 };
 
-class StubExportedServiceGuard {
+
+class StubExportedServiceEntry {
 public:
-    explicit StubExportedServiceGuard(std::shared_ptr<celix::ServiceRegistration> _reg) : reg{std::move(_reg)} {}
+    explicit StubExportedServiceEntry(std::shared_ptr<celix::BundleContext> _ctx) : ctx{std::move(_ctx)} {
+        auto& cmp = ctx->getDependencyManager()->createComponent<StubExportedService>();
+        cmp.createProvidedService<celix::rsa::IExportedService>();
+        //NOTE normally add svc dep to the service to be exported publisher
+        //NOTE normally also provide subscriber
+        cmp.buildAsync();
+        cmpUUID = cmp.getUUID();
+    }
 
-    void close() {
-        reg->unregister();
+    ~StubExportedServiceEntry() noexcept {
+        close();
+    }
+
+    void close() noexcept {
+        if (!cmpUUID.empty()) {
+            ctx->getDependencyManager()->removeComponentAsync(cmpUUID);
+        }
+        cmpUUID = "";
     }
 private:
-    const std::shared_ptr<celix::ServiceRegistration> reg;
+    const std::shared_ptr<celix::BundleContext> ctx;
+    std::string cmpUUID{};
 };
 
-class StubExportServiceRegistration : public celix::rsa::IExportServiceRegistration {
+class StubExportServiceGuard : public celix::rsa::IExportServiceGuard {
 public:
-    explicit StubExportServiceRegistration(std::weak_ptr<StubExportedServiceGuard> _guard) : guard{std::move(_guard)} {}
-    ~StubExportServiceRegistration() noexcept override {
-        auto g = guard.lock();
-        if (g) {
-            g->close();
+    explicit StubExportServiceGuard(std::weak_ptr<StubExportedServiceEntry> _entry) : entry{std::move(_entry)} {}
+    ~StubExportServiceGuard() noexcept override {
+        auto e = entry.lock();
+        if (e) {
+            e->close();
         }
     }
 
 private:
-    const std::weak_ptr<StubExportedServiceGuard> guard;
+    const std::weak_ptr<StubExportedServiceEntry> entry;
 };
 
 class StubExportServiceFactory : public celix::rsa::IExportServiceFactory {
 public:
     explicit StubExportServiceFactory(std::shared_ptr<celix::BundleContext> _ctx) : ctx{std::move(_ctx)} {}
 
-    std::unique_ptr<celix::rsa::IExportServiceRegistration> exportService(const celix::Properties& /*serviceProperties*/) override {
-        auto svcReg= ctx->registerService<celix::rsa::IExportedService>(std::make_shared<StubExportedService>()).build();
-        auto guard = std::make_shared<StubExportedServiceGuard>(std::move(svcReg));
-
+    std::unique_ptr<celix::rsa::IExportServiceGuard> exportService(const celix::Properties& /*serviceProperties*/) override {
+        auto entry = std::make_shared<StubExportedServiceEntry>(ctx);
         std::lock_guard<std::mutex> lock{mutex};
-        guards.emplace_back(guard);
-        return std::make_unique<StubExportServiceRegistration>(guard);
+        entries.emplace_back(entry);
+        return std::make_unique<StubExportServiceGuard>(entry);
     }
 
 private:
     const std::shared_ptr<celix::BundleContext> ctx;
     std::mutex mutex{};
-    std::vector<std::shared_ptr<StubExportedServiceGuard>> guards{};
+    std::vector<std::shared_ptr<StubExportedServiceEntry>> entries{};
 };
 
 class IDummyService {
@@ -143,6 +157,9 @@ TEST_F(RemoteServiceAdminTestSuite, exportService) {
     EXPECT_EQ(1, count);
 
 
+    /**
+     * When I remove the export service factory, the IExportService will be removed.
+     */
     reg1->unregister();
 
     //removed factory -> removed exported interface
@@ -189,44 +206,60 @@ TEST_F(RemoteServiceAdminTestSuite, exportServiceDifferentOrder) {
  * the RemoteServiceAdmin.
  */
 
-class StubImportedServiceGuard {
+class StubImportedService : public IDummyService {
 public:
-    explicit StubImportedServiceGuard(std::shared_ptr<celix::ServiceRegistration> _reg) : reg{std::move(_reg)} {}
+    ~StubImportedService() noexcept override = default;
+};
 
-    void close() {
-        reg->unregister();
+class StubImportedServiceEntry {
+public:
+    explicit StubImportedServiceEntry(std::shared_ptr<celix::BundleContext> _ctx) : ctx{std::move(_ctx)} {
+        auto& cmp = ctx->getDependencyManager()->createComponent<StubImportedService>();
+        cmp.createProvidedService<IDummyService>()
+                .addProperty(celix::rsa::REMOTE_SERVICE_IMPORTED_PROPERTY_NAME, true);
+        cmp.buildAsync();
+        cmpUUID = cmp.getUUID();
+    }
+
+    ~StubImportedServiceEntry() noexcept {
+        close();
+    }
+
+    void close() noexcept {
+        if (!cmpUUID.empty()) {
+            ctx->getDependencyManager()->removeComponentAsync(cmpUUID);
+        }
+        cmpUUID = "";
     }
 private:
-    const std::shared_ptr<celix::ServiceRegistration> reg;
+    const std::shared_ptr<celix::BundleContext> ctx;
+    std::string cmpUUID{};
 };
 
-class StubImportServiceRegistration : public celix::rsa::IImportServiceRegistration {
+class StubImportServiceGuard : public celix::rsa::IImportServiceGuard {
 public:
-    explicit StubImportServiceRegistration(std::weak_ptr<StubImportedServiceGuard> _guard) : guard{std::move(_guard)} {}
-    ~StubImportServiceRegistration() noexcept override {
-        auto g = guard.lock();
-        if (g) {
-            g->close();
+    explicit StubImportServiceGuard(std::weak_ptr<StubImportedServiceEntry> _entry) : entry{std::move(_entry)} {}
+    ~StubImportServiceGuard() noexcept override {
+        auto e = entry.lock();
+        if (e) {
+            e->close();
         }
     }
 
 private:
-    const std::weak_ptr<StubImportedServiceGuard> guard;
+    const std::weak_ptr<StubImportedServiceEntry> entry;
 };
 
 class StubImportServiceFactory : public celix::rsa::IImportServiceFactory {
 public:
     explicit StubImportServiceFactory(std::shared_ptr<celix::BundleContext> _ctx) : ctx{std::move(_ctx)} {}
 
-    virtual std::unique_ptr<celix::rsa::IImportServiceRegistration> importService(const celix::rsa::Endpoint& endpoint) {
+    virtual std::unique_ptr<celix::rsa::IImportServiceGuard> importService(const celix::rsa::Endpoint& endpoint) {
            if (endpoint.getExportedInterfaces() == celix::typeName<IDummyService>()) {
-               auto reg = ctx->registerService<IDummyService>(std::make_shared<DummyServiceImpl>())
-                       .addProperty(celix::rsa::REMOTE_SERVICE_IMPORTED_PROPERTY_NAME, true)
-                       .build();
                std::lock_guard<std::mutex> lock{mutex};
-               auto guard = std::make_shared<StubImportedServiceGuard>(std::move(reg));
-               guards.emplace_back(guard);
-               return std::make_unique<StubImportServiceRegistration>(guard);
+               auto entry = std::make_shared<StubImportedServiceEntry>(ctx);
+               entries.emplace_back(entry);
+               return std::make_unique<StubImportServiceGuard>(entry);
            } else {
                return {};
            }
@@ -235,7 +268,7 @@ public:
 private:
     const std::shared_ptr<celix::BundleContext> ctx;
     std::mutex mutex{};
-    std::vector<std::shared_ptr<StubImportedServiceGuard>> guards{};
+    std::vector<std::shared_ptr<StubImportedServiceEntry>> entries{};
 };
 
 TEST_F(RemoteServiceAdminTestSuite, importService) {
@@ -244,7 +277,7 @@ TEST_F(RemoteServiceAdminTestSuite, importService) {
 
     /**
      * When I add a import service factory and register a Endpoint/
-     * RemoteServiceAdmin will create a imported service (proxy for remote service described by the endpoint).
+     * RemoteServiceAdmin will create a imported service through the factory (proxy for remote service described by the endpoint).
      */
     auto count = ctx->useService<IDummyService>()
             .build();
@@ -270,6 +303,9 @@ TEST_F(RemoteServiceAdminTestSuite, importService) {
     EXPECT_EQ(1, count);
 
 
+    /**
+     * When I remove the import service factory, the imported service (proxy) will be removed.
+     */
     reg1->unregister();
 
     //removed factory -> removed imported interface
diff --git a/bundles/async_remote_services/admin/include/admin.h b/bundles/async_remote_services/admin/include/admin.h
index 80be3ad..4d1bd1f 100644
--- a/bundles/async_remote_services/admin/include/admin.h
+++ b/bundles/async_remote_services/admin/include/admin.h
@@ -67,13 +67,13 @@ namespace celix::async_rsa {
 
         std::pmr::unordered_map<std::string, std::shared_ptr<celix::rsa::IExportServiceFactory>> _exportServiceFactories{&_memResource}; //key = service name
         std::pmr::unordered_map<std::string, std::shared_ptr<celix::rsa::IImportServiceFactory>> _importServiceFactories{&_memResource}; //key = service name
-        std::pmr::unordered_map<std::string, std::unique_ptr<celix::rsa::IImportServiceRegistration>> _importedServices{&_memResource}; //key = endpoint id
-        std::pmr::unordered_map<long, std::unique_ptr<celix::rsa::IExportServiceRegistration>> _exportedServices{&_memResource}; //key = service id
+        std::pmr::unordered_map<std::string, std::unique_ptr<celix::rsa::IImportServiceGuard>> _importedServices{&_memResource}; //key = endpoint id
+        std::pmr::unordered_map<long, std::unique_ptr<celix::rsa::IExportServiceGuard>> _exportedServices{&_memResource}; //key = service id
 #else
         std::unordered_map<std::string, std::shared_ptr<celix::rsa::IExportServiceFactory>> _exportServiceFactories{}; //key = service name
         std::unordered_map<std::string, std::shared_ptr<celix::rsa::IImportServiceFactory>> _importServiceFactories{}; //key = service name
-        std::unordered_map<std::string, std::unique_ptr<celix::rsa::IImportServiceRegistration>> _importedServices{}; //key = endpoint id
-        std::unordered_map<long, std::unique_ptr<celix::rsa::IExportServiceRegistration>> _exportedServices{}; //key = service id
+        std::unordered_map<std::string, std::unique_ptr<celix::rsa::IImportServiceGuard>> _importedServices{}; //key = endpoint id
+        std::unordered_map<long, std::unique_ptr<celix::rsa::IExportServiceGuard>> _exportedServices{}; //key = service id
 #endif
         std::vector<std::shared_ptr<celix::rsa::Endpoint>> _toBeImportedServices{};
         std::vector<std::shared_ptr<const celix::Properties>> _toBeExportedServices{};
diff --git a/bundles/async_remote_services/admin/src/admin.cc b/bundles/async_remote_services/admin/src/admin.cc
index 3b92867..ee90ccb 100644
--- a/bundles/async_remote_services/admin/src/admin.cc
+++ b/bundles/async_remote_services/admin/src/admin.cc
@@ -66,7 +66,7 @@ void celix::async_rsa::AsyncAdmin::removeEndpoint(const std::shared_ptr<celix::r
         return;
     }
 
-    std::shared_ptr<celix::rsa::IImportServiceRegistration> tmpStore{}; //to ensure destruction outside of lock
+    std::shared_ptr<celix::rsa::IImportServiceGuard> tmpStore{}; //to ensure destruction outside of lock
     {
         std::lock_guard l(_m);
 
@@ -167,22 +167,18 @@ void celix::async_rsa::AsyncAdmin::removeService(const std::shared_ptr<void>& /*
         return;
     }
 
-    std::unique_ptr<celix::rsa::IExportServiceRegistration> tmpStore{}; //to ensure destruction outside of lock
-    {
-        std::lock_guard l(_m);
+    std::lock_guard l(_m);
 
-        auto instanceIt = _exportedServices.find(svcId);
-        if (instanceIt != end(_exportedServices)) {
-            tmpStore = std::move(instanceIt->second);
-            _exportedServices.erase(instanceIt);
-        }
+    auto instanceIt = _exportedServices.find(svcId);
+    if (instanceIt != end(_exportedServices)) {
+        _exportedServices.erase(instanceIt);
+    }
 
-        //remove to be exported endpoint (if present)
-        for (auto it = _toBeExportedServices.begin(); it != _toBeExportedServices.end(); ++it) {
-            if ((*it)->getAsBool(celix::SERVICE_ID, -1) == svcId) {
-                _toBeExportedServices.erase(it);
-                break;
-            }
+    //remove to be exported endpoint (if present)
+    for (auto it = _toBeExportedServices.begin(); it != _toBeExportedServices.end(); ++it) {
+        if ((*it)->getAsBool(celix::SERVICE_ID, -1) == svcId) {
+            _toBeExportedServices.erase(it);
+            break;
         }
     }
 }
diff --git a/bundles/async_remote_services/rsa_spi/include/celix/rsa/IExportServiceFactory.h b/bundles/async_remote_services/rsa_spi/include/celix/rsa/IExportServiceFactory.h
index fa5508c..7b386fe 100644
--- a/bundles/async_remote_services/rsa_spi/include/celix/rsa/IExportServiceFactory.h
+++ b/bundles/async_remote_services/rsa_spi/include/celix/rsa/IExportServiceFactory.h
@@ -24,12 +24,12 @@
 namespace celix::rsa {
 
     /**
-     * @brief ExportServiceRegistration class which represent a (opaque) exported service.
-     * The lifetime of this object should be coupled with the lifetime of the exported service.
-     */
-    class IExportServiceRegistration {
+     * @brief IExportServiceGuard class which represent a (opaque) exported service.
+     * If lifetime of this object expires it should remove the underlining exported service.
+     * */
+    class IExportServiceGuard {
     public:
-        virtual ~IExportServiceRegistration() noexcept = default;
+        virtual ~IExportServiceGuard() noexcept = default;
     };
 
     /**
@@ -54,6 +54,6 @@ namespace celix::rsa {
          * @return A ExportService.
          * @throws celix::rsa::RemoteServicesException if the export failed.
          */
-        virtual std::unique_ptr<celix::rsa::IExportServiceRegistration> exportService(const celix::Properties& serviceProperties) = 0;
+        virtual std::unique_ptr<celix::rsa::IExportServiceGuard> exportService(const celix::Properties& serviceProperties) = 0;
     };
 }
\ No newline at end of file
diff --git a/bundles/async_remote_services/rsa_spi/include/celix/rsa/IImportServiceFactory.h b/bundles/async_remote_services/rsa_spi/include/celix/rsa/IImportServiceFactory.h
index f62cf23..e3c15c2 100644
--- a/bundles/async_remote_services/rsa_spi/include/celix/rsa/IImportServiceFactory.h
+++ b/bundles/async_remote_services/rsa_spi/include/celix/rsa/IImportServiceFactory.h
@@ -24,12 +24,12 @@
 namespace celix::rsa {
 
     /**
-     * @brief ImportServiceRegistration class which represent a (opaque) imported service.
-     * The lifetime of this object should be coupled with the lifetime of the imported service.
+     * @brief IImportServiceGuard class which represent a (opaque) imported service.
+     * If lifetime of this object expires it should remove the underlining imported service.
      */
-    class IImportServiceRegistration {
+    class IImportServiceGuard {
     public:
-        virtual ~IImportServiceRegistration() noexcept = default;
+        virtual ~IImportServiceGuard() noexcept = default;
     };
 
     /**
@@ -54,6 +54,6 @@ namespace celix::rsa {
          * @return A ImportService.
          * @throws celix::rsa::RemoteServicesException if the import failed.
          */
-        virtual std::unique_ptr<celix::rsa::IImportServiceRegistration> importService(const celix::rsa::Endpoint& endpoint) = 0;
+        virtual std::unique_ptr<celix::rsa::IImportServiceGuard> importService(const celix::rsa::Endpoint& endpoint) = 0;
     };
 }
\ No newline at end of file