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();
{
_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
void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService_Abstract *ns)
{
SALOME_NamingService *nsTrad(dynamic_cast<SALOME_NamingService *>(ns));
- if(ns)
+ if(nsTrad)
{
CORBA::String_var iorstr(nsTrad->getIORaddr());
fileStream << "ORBInitRef NameService=";
#include <list>
#include <string>
-class SALOME_NamingService_Abstract;
+class SALOME_NamingService_Container_Abstract;
class CONTAINER_EXPORT Engines_Container_i:
public virtual POA_Engines::Container,
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();
bool _isSupervContainer;
- SALOME_NamingService_Abstract *_NS ;
+ SALOME_NamingService_Container_Abstract *_NS ;
std::string _library_path;
std::string _containerName;
std::string _logfilename;
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());
}
// 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.");
#include "SALOME_ModuleCatalog_impl.hxx"
#include "SALOME_ModuleCatalog_Acomponent_impl.hxx"
#include "SALOME_ModuleCatalog_Handler.hxx"
+#include "SALOME_Fake_NamingService.hxx"
+
#include <libxml/parser.h>
#include <fstream>
#include <map>
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;
argv[2] = const_cast<char*>(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);
}
//! shutdown server
void shutdown();
+ static const char ENTRY_IN_NS[];
+
private:
//! method to parse arguments to get general and personal catalog files
/*!
#include "SALOME_Fake_NamingService.hxx"
#include "Utils_SALOME_Exception.hxx"
+#include <sstream>
+
std::mutex SALOME_Fake_NamingService::_mutex;
std::map<std::string,CORBA::Object_var> SALOME_Fake_NamingService::_map;
{
}
+std::string SALOME_Fake_NamingService::repr()
+{
+ std::lock_guard<std::mutex> 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)
{
}
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;
//MESSAGE("SALOME_NamingService destruction");
}
+std::string SALOME_NamingService::repr()
+{
+ return std::string();
+}
+
// ============================================================================
/*! \brief initializes ORB reference and naming service root context.
*
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;
//
#include "SALOME_NamingService_Abstract.hxx"
+#include "Utils_SALOME_Exception.hxx"
#include <sstream>
+#include <memory>
+
+SALOME_NamingService_Abstract *SALOME_NamingService_Abstract::cloneCoVar()
+{
+ std::unique_ptr<SALOME_NamingService_Container_Abstract> ret(this->clone());
+ SALOME_NamingService_Abstract *ret2(dynamic_cast<SALOME_NamingService_Abstract *>(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.
#include <vector>
#include <string>
-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<std::string> list_subdirs() = 0;
virtual std::vector<std::string> list_directory() = 0;
virtual std::vector<std::string> 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);
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()