From: Anthony Geay Date: Thu, 15 Apr 2021 06:35:39 +0000 (+0200) Subject: OK pour modulecatalog dans le NS. On s occupe du server SALOME_Container pour qu... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6639223377e9a2370cb7fbf65fdcf21ef0c2acd9;p=modules%2Fkernel.git OK pour modulecatalog dans le NS. On s occupe du server SALOME_Container pour qu il remonte sa ref au NS SSL ou non SSL --- diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index fe54aa0b4..c8dbc14ec 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -134,10 +134,10 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, char *containerName , int argc , char* argv[], - SALOME_NamingService_Abstract *ns, + SALOME_NamingService_Container_Abstract *ns, bool isServantAloneInProcess ) : - _NS(0),_id(0),_numInstance(0),_isServantAloneInProcess(isServantAloneInProcess) + _NS(nullptr),_id(0),_numInstance(0),_isServantAloneInProcess(isServantAloneInProcess) { _pid = (long)getpid(); @@ -180,19 +180,18 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, { _id = _poa->activate_object(this); + // key point : if ns is nullptr : this servant is alone in its process + // if ns is not null : this servant embedded into single process. _NS = ns==nullptr ? new SALOME_NamingService : ns->clone(); _NS->init_orb( _orb ) ; CORBA::Object_var obj=_poa->id_to_reference(*_id); - Engines::Container_var pCont - = Engines::Container::_narrow(obj); + Engines::Container_var pCont = Engines::Container::_narrow(obj); _remove_ref(); - _containerName = _NS->BuildContainerNameForNS(containerName, - hostname.c_str()); + _containerName = SALOME_NamingService_Abstract::BuildContainerNameForNS(containerName, hostname.c_str()); SCRUTE(_containerName); _NS->Register(pCont, _containerName.c_str()); - MESSAGE("Engines_Container_i::Engines_Container_i : Container name " - << _containerName); + MESSAGE("Engines_Container_i::Engines_Container_i : Container name " << _containerName); // Python: // import SALOME_Container diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index dd86a4925..4ffda5ca6 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -954,7 +954,7 @@ void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream) const void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService_Abstract *ns) { SALOME_NamingService *nsTrad(dynamic_cast(ns)); - if(ns) + if(nsTrad) { CORBA::String_var iorstr(nsTrad->getIORaddr()); fileStream << "ORBInitRef NameService="; diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index 244221993..427c12392 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -48,7 +48,7 @@ #include #include -class SALOME_NamingService_Abstract; +class SALOME_NamingService_Container_Abstract; class CONTAINER_EXPORT Engines_Container_i: public virtual POA_Engines::Container, @@ -60,7 +60,7 @@ public: PortableServer::POA_ptr poa, char * containerName , int argc, char* argv[], - SALOME_NamingService_Abstract *ns = nullptr, + SALOME_NamingService_Container_Abstract *ns = nullptr, bool isServantAloneInProcess = true); virtual ~Engines_Container_i(); @@ -151,7 +151,7 @@ protected: bool _isSupervContainer; - SALOME_NamingService_Abstract *_NS ; + SALOME_NamingService_Container_Abstract *_NS ; std::string _library_path; std::string _containerName; std::string _logfilename; diff --git a/src/ModuleCatalog/KernelModuleCatalog.cxx b/src/ModuleCatalog/KernelModuleCatalog.cxx index bc9237306..4677773f1 100644 --- a/src/ModuleCatalog/KernelModuleCatalog.cxx +++ b/src/ModuleCatalog/KernelModuleCatalog.cxx @@ -22,8 +22,8 @@ std::string GetModuleCatalogInstance(const std::string& listOfCatalogsGrouped) { - SALOME_ModuleCatalog::ModuleCatalog_var study = KERNEL::getModuleComponentServantSA(listOfCatalogsGrouped.c_str()); + SALOME_ModuleCatalog::ModuleCatalog_var cata = KERNEL::getModuleComponentServantSA(listOfCatalogsGrouped.c_str()); CORBA::ORB_ptr orb = KERNEL::getORB(); - CORBA::String_var ior = orb->object_to_string(study); + CORBA::String_var ior = orb->object_to_string(cata); return std::string(ior.in()); } diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx index d60f9f0fc..01819c8bf 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx @@ -147,7 +147,7 @@ int main(int argc,char **argv) // initialise Naming Service SALOME_NamingService _NS(orb); // register Catalog in Naming Service - _NS.Register(myCata ,"/Kernel/ModulCatalog"); + _NS.Register(myCata ,SALOME_ModuleCatalogImpl::ENTRY_IN_NS); MESSAGE("Running CatalogServer."); diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx index f6877ae35..112d0a12e 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -29,6 +29,8 @@ #include "SALOME_ModuleCatalog_impl.hxx" #include "SALOME_ModuleCatalog_Acomponent_impl.hxx" #include "SALOME_ModuleCatalog_Handler.hxx" +#include "SALOME_Fake_NamingService.hxx" + #include #include #include @@ -60,6 +62,8 @@ static int MYDEBUG = 0; static const char* SEPARATOR = "::"; static const char* OLD_SEPARATOR = ":"; +const char SALOME_ModuleCatalogImpl::ENTRY_IN_NS[] = "/Kernel/ModulCatalog"; + SALOME_ModuleCatalog::ModuleCatalog_ptr KERNEL::getModuleComponentServantSA(const char *listOfCatalogs) { static SALOME_ModuleCatalog::ModuleCatalog_var moduleCata; @@ -72,6 +76,8 @@ SALOME_ModuleCatalog::ModuleCatalog_ptr KERNEL::getModuleComponentServantSA(cons argv[2] = const_cast(listOfCatalogs); SALOME_ModuleCatalogImpl *servant = new SALOME_ModuleCatalogImpl(NB_OF_ELT_IN_CMD,argv,orb); moduleCata = servant->_this(); + SALOME_Fake_NamingService NS; + NS.Register(moduleCata,SALOME_ModuleCatalogImpl::ENTRY_IN_NS); } return SALOME_ModuleCatalog::ModuleCatalog::_duplicate(moduleCata); } diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx index 05ccfd864..88f9118fa 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx @@ -132,6 +132,8 @@ public: //! shutdown server void shutdown(); + static const char ENTRY_IN_NS[]; + private: //! method to parse arguments to get general and personal catalog files /*! diff --git a/src/NamingService/SALOME_Fake_NamingService.cxx b/src/NamingService/SALOME_Fake_NamingService.cxx index 658058c61..841a10e69 100644 --- a/src/NamingService/SALOME_Fake_NamingService.cxx +++ b/src/NamingService/SALOME_Fake_NamingService.cxx @@ -20,6 +20,8 @@ #include "SALOME_Fake_NamingService.hxx" #include "Utils_SALOME_Exception.hxx" +#include + std::mutex SALOME_Fake_NamingService::_mutex; std::map SALOME_Fake_NamingService::_map; @@ -27,6 +29,17 @@ SALOME_Fake_NamingService::SALOME_Fake_NamingService(CORBA::ORB_ptr orb) { } +std::string SALOME_Fake_NamingService::repr() +{ + std::lock_guard g(_mutex); + std::ostringstream oss; + for(auto it : _map) + { + oss << it.first << std::endl; + } + return oss.str(); +} + void SALOME_Fake_NamingService::init_orb(CORBA::ORB_ptr orb) { } diff --git a/src/NamingService/SALOME_Fake_NamingService.hxx b/src/NamingService/SALOME_Fake_NamingService.hxx index 32ae31d3e..64a107937 100644 --- a/src/NamingService/SALOME_Fake_NamingService.hxx +++ b/src/NamingService/SALOME_Fake_NamingService.hxx @@ -32,6 +32,7 @@ class NAMINGSERVICE_EXPORT SALOME_Fake_NamingService : public SALOME_NamingServi public: SALOME_Fake_NamingService(CORBA::ORB_ptr orb); SALOME_Fake_NamingService() = default; + std::string repr() override; void init_orb(CORBA::ORB_ptr orb=0) override; void Register(CORBA::Object_ptr ObjRef, const char* Path) override; CORBA::Object_ptr Resolve(const char* Path) override; diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index 8e4b40517..d3f62fddd 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -92,6 +92,11 @@ SALOME_NamingService::~SALOME_NamingService() //MESSAGE("SALOME_NamingService destruction"); } +std::string SALOME_NamingService::repr() +{ + return std::string(); +} + // ============================================================================ /*! \brief initializes ORB reference and naming service root context. * diff --git a/src/NamingService/SALOME_NamingService.hxx b/src/NamingService/SALOME_NamingService.hxx index 14380e96f..78a62fc44 100644 --- a/src/NamingService/SALOME_NamingService.hxx +++ b/src/NamingService/SALOME_NamingService.hxx @@ -51,7 +51,7 @@ public: SALOME_NamingService(CORBA::ORB_ptr orb); virtual ~SALOME_NamingService(); - + std::string repr() override; void init_orb(CORBA::ORB_ptr orb=0) override; void Register(CORBA::Object_ptr ObjRef, const char* Path) override; CORBA::Object_ptr Resolve(const char* Path) override; diff --git a/src/NamingService/SALOME_NamingService_Abstract.cxx b/src/NamingService/SALOME_NamingService_Abstract.cxx index ff2561b14..d77e2af59 100644 --- a/src/NamingService/SALOME_NamingService_Abstract.cxx +++ b/src/NamingService/SALOME_NamingService_Abstract.cxx @@ -18,8 +18,20 @@ // #include "SALOME_NamingService_Abstract.hxx" +#include "Utils_SALOME_Exception.hxx" #include +#include + +SALOME_NamingService_Abstract *SALOME_NamingService_Abstract::cloneCoVar() +{ + std::unique_ptr ret(this->clone()); + SALOME_NamingService_Abstract *ret2(dynamic_cast(ret.get())); + if(!ret2) + throw SALOME_Exception(std::string("SALOME_NamingService_Abstract::cloneCoVar : clone is expected to return a SALOME_NamingService_Abstract type !")); + ret.release(); + return ret2; +} // ============================================================================ /*! \brief provide a default container name if empty. diff --git a/src/NamingService/SALOME_NamingService_Abstract.hxx b/src/NamingService/SALOME_NamingService_Abstract.hxx index ebf584c3c..2314b3c19 100644 --- a/src/NamingService/SALOME_NamingService_Abstract.hxx +++ b/src/NamingService/SALOME_NamingService_Abstract.hxx @@ -28,21 +28,28 @@ #include #include -class NAMINGSERVICE_EXPORT SALOME_NamingService_Abstract +class NAMINGSERVICE_EXPORT SALOME_NamingService_Container_Abstract { public: virtual void init_orb(CORBA::ORB_ptr orb=0) = 0; + virtual SALOME_NamingService_Container_Abstract *clone() = 0; virtual void Register(CORBA::Object_ptr ObjRef, const char* Path) = 0; + virtual void Destroy_FullDirectory(const char* Path) = 0; + virtual void Destroy_Name(const char* Path) = 0; virtual CORBA::Object_ptr Resolve(const char* Path) = 0; virtual CORBA::Object_ptr ResolveFirst(const char* Path) = 0; - virtual void Destroy_Name(const char* Path) = 0; +}; + +class NAMINGSERVICE_EXPORT SALOME_NamingService_Abstract : public SALOME_NamingService_Container_Abstract +{ +public: + SALOME_NamingService_Abstract *cloneCoVar(); + virtual std::string repr() = 0; virtual void Destroy_Directory(const char* Path) = 0; - virtual void Destroy_FullDirectory(const char* Path) = 0; virtual bool Change_Directory(const char* Path) = 0; virtual std::vector list_subdirs() = 0; virtual std::vector list_directory() = 0; virtual std::vector list_directory_recurs() = 0; - virtual SALOME_NamingService_Abstract *clone() = 0; virtual CORBA::Object_ptr ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc=0) = 0; virtual ~SALOME_NamingService_Abstract() { } static std::string ContainerName(const Engines::ContainerParameters& params); diff --git a/src/SALOMEDS/SALOMEDS_Driver_i.cxx b/src/SALOMEDS/SALOMEDS_Driver_i.cxx index 693f257ff..3ea2c2761 100644 --- a/src/SALOMEDS/SALOMEDS_Driver_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Driver_i.cxx @@ -356,7 +356,7 @@ SALOMEDS_DriverFactory_i::SALOMEDS_DriverFactory_i(CORBA::ORB_ptr theORB, bool i SALOMEDS_DriverFactory_i::SALOMEDS_DriverFactory_i(CORBA::ORB_ptr theORB, SALOME_NamingService_Abstract *ns):_orb( CORBA::ORB::_duplicate(theORB) ) { - _name_service = ns->clone(); + _name_service = ns->cloneCoVar(); } SALOMEDS_DriverFactory_i::~SALOMEDS_DriverFactory_i()