summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Rauwolf <rauwolf@itestra.de>2013-03-01 10:52:37 +0100
committerPhilip Rauwolf <rauwolf@itestra.de>2013-03-01 10:52:37 +0100
commit6dd41e838d1a8df79e9c98c83e5e1605efb42890 (patch)
tree98fce204c55ea4ddd6602318e9c47fcb63a8de6e
parent8163ace5ed58e8c84f864be5d26afb8179ef8956 (diff)
downloadgenivi-common-api-runtime-6dd41e838d1a8df79e9c98c83e5e1605efb42890.tar.gz
Moved service management down to middleware implementation. Added a
variant for service-deregistration for splitted CommonAPI Addresses.
-rw-r--r--src/CommonAPI/Factory.h33
-rw-r--r--src/CommonAPI/Stub.h3
2 files changed, 10 insertions, 26 deletions
diff --git a/src/CommonAPI/Factory.h b/src/CommonAPI/Factory.h
index bacda21..47dda82 100644
--- a/src/CommonAPI/Factory.h
+++ b/src/CommonAPI/Factory.h
@@ -105,24 +105,11 @@ class Factory {
const std::string& domain) {
std::shared_ptr<StubBase> stubBase = std::dynamic_pointer_cast<StubBase>(stub);
- std::shared_ptr<CommonAPI::StubAdapter> stubAdapter = createAdapter(stubBase, _Stub::StubAdapterType::getInterfaceId(), participantId, serviceName, domain);
- if(!stubAdapter) {
- return false;
- }
-
- std::string address = domain + ":" + serviceName + ":" + participantId;
- registeredServices_.insert( {std::move(address), stubAdapter} );
-
- return true;
+ return registerAdapter(stubBase, _Stub::StubAdapterType::getInterfaceId(), participantId, serviceName, domain);
}
template<typename _Stub>
bool registerService(std::shared_ptr<_Stub> stub, const std::string& serviceAddress) {
-
- if(registeredServices_.find(serviceAddress) != registeredServices_.end()) {
- return false;
- }
-
std::string domain;
std::string serviceName;
std::string participantId;
@@ -133,14 +120,15 @@ class Factory {
return registerService<_Stub>(stub, participantId, serviceName, domain);
}
+ virtual bool unregisterService(const std::string& participantId, const std::string& serviceName, const std::string& domain) = 0;
inline bool unregisterService(const std::string& serviceAddress) {
- auto foundStubAdapter = registeredServices_.find(serviceAddress);
- if(foundStubAdapter != registeredServices_.end()) {
- std::shared_ptr<CommonAPI::StubAdapter> stubAdapter = foundStubAdapter->second;
- stubAdapter->deinit();
- return registeredServices_.erase(serviceAddress);
- }
- return false;
+ std::string domain;
+ std::string serviceName;
+ std::string participantId;
+ if(!splitValidAddress(serviceAddress, domain, serviceName, participantId)) {
+ return false;
+ }
+ return unregisterService(participantId, serviceName, domain);
}
virtual std::vector<std::string> getAvailableServiceInstances(const std::string& serviceName, const std::string& serviceDomainName = "local") = 0;
@@ -150,11 +138,10 @@ class Factory {
protected:
virtual std::shared_ptr<Proxy> createProxy(const char* interfaceId, const std::string& participantId, const std::string& serviceName, const std::string& domain) = 0;
- virtual std::shared_ptr<StubAdapter> createAdapter(std::shared_ptr<StubBase> stubBase, const char* interfaceId, const std::string& participantId, const std::string& serivceName, const std::string& domain) = 0;
+ virtual bool registerAdapter(std::shared_ptr<StubBase> stubBase, const char* interfaceId, const std::string& participantId, const std::string& serivceName, const std::string& domain) = 0;
private:
std::shared_ptr<Runtime> runtime_;
- std::unordered_map<std::string, std::shared_ptr<CommonAPI::StubAdapter>> registeredServices_;
const MiddlewareInfo* middlewareInfo_;
diff --git a/src/CommonAPI/Stub.h b/src/CommonAPI/Stub.h
index 740cc7a..7353f54 100644
--- a/src/CommonAPI/Stub.h
+++ b/src/CommonAPI/Stub.h
@@ -21,8 +21,6 @@ class StubAdapter {
virtual const std::string& getDomain() const = 0;
virtual const std::string& getServiceId() const = 0;
virtual const std::string& getInstanceId() const = 0;
-
- virtual void deinit() = 0;
};
struct StubBase {
@@ -39,7 +37,6 @@ class Stub : public StubBase {
virtual ~Stub() { }
virtual _StubRemoteEventHandler* initStubAdapter(const std::shared_ptr<_StubAdapter>& stubAdapter) = 0;
- virtual void deinitStubAdapter() = 0;
};
} // namespace CommonAPI