Salome HOME
YACS in SSL mode
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 14 Apr 2021 19:56:39 +0000 (21:56 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 22 Apr 2021 11:25:22 +0000 (13:25 +0200)
58 files changed:
CMakeLists.txt
SalomeKERNELConfig.cmake.in
idl/CMakeLists.txt
idl/SALOME_Component.idl
idl/SALOME_Embedded_NamingService.idl [new file with mode: 0644]
src/Basics/CMakeLists.txt
src/Basics/KernelBasis.cxx [new file with mode: 0644]
src/Basics/KernelBasis.hxx [new file with mode: 0644]
src/Basics/KernelBasis.i [new file with mode: 0644]
src/Container/CMakeLists.txt
src/Container/Container_i.cxx
src/Container/SALOME_ComponentPy.py
src/Container/SALOME_Container.cxx
src/Container/SALOME_ContainerManager.cxx
src/Container/SALOME_ContainerManager.hxx
src/Container/SALOME_Container_Common.cxx [new file with mode: 0644]
src/Container/SALOME_Container_Common.hxx [new file with mode: 0644]
src/Container/SALOME_Container_No_NS_Serv.cxx [new file with mode: 0644]
src/Container/SALOME_Container_i.hxx
src/KERNEL_PY/__init__.py
src/KernelHelpers/CMakeLists.txt
src/KernelHelpers/SALOME_KernelORB.cxx [new file with mode: 0644]
src/KernelHelpers/SALOME_KernelORB.hxx [new file with mode: 0644]
src/KernelHelpers/SALOME_KernelServices.cxx
src/KernelHelpers/SALOME_KernelServices.hxx
src/Launcher/CMakeLists.txt
src/Launcher/KernelLauncher.cxx [new file with mode: 0644]
src/Launcher/KernelLauncher.hxx [new file with mode: 0644]
src/Launcher/KernelLauncher.i [new file with mode: 0644]
src/Launcher/SALOME_Launcher.cxx
src/Launcher/SALOME_Launcher.hxx
src/Launcher/SALOME_LauncherServer.cxx
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx
src/ModuleCatalog/KernelModuleCatalog.cxx
src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx
src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx
src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx
src/NamingService/CMakeLists.txt
src/NamingService/NamingService.i [new file with mode: 0644]
src/NamingService/SALOME_Embedded_NamingService.cxx [new file with mode: 0644]
src/NamingService/SALOME_Embedded_NamingService.hxx [new file with mode: 0644]
src/NamingService/SALOME_Embedded_NamingService_Client.cxx [new file with mode: 0644]
src/NamingService/SALOME_Embedded_NamingService_Client.hxx [new file with mode: 0644]
src/NamingService/SALOME_Embedded_NamingService_ClientPy.py [new file with mode: 0644]
src/NamingService/SALOME_Embedded_NamingService_Common.cxx [new file with mode: 0644]
src/NamingService/SALOME_Embedded_NamingService_Common.hxx [new file with mode: 0644]
src/NamingService/SALOME_Fake_NamingService.cxx
src/NamingService/SALOME_Fake_NamingService.hxx
src/NamingService/SALOME_NamingService.cxx
src/NamingService/SALOME_NamingService.hxx
src/NamingService/SALOME_NamingService.i [deleted file]
src/NamingService/SALOME_NamingService_Abstract.cxx
src/NamingService/SALOME_NamingService_Abstract.hxx
src/ResourcesManager/SALOME_ResourcesManager.cxx
src/ResourcesManager/SALOME_ResourcesManager.hxx
src/ResourcesManager/SALOME_ResourcesManager_Client.cxx
src/ResourcesManager/SALOME_ResourcesManager_Client.hxx
src/SALOMEDS/SALOMEDS_Driver_i.cxx

index 473aab7013f2d9d13347493b8035f4a627fb364f..de93261422d287fc4fd7e522b8f4708505450646 100755 (executable)
@@ -218,7 +218,7 @@ IF(NOT SALOME_LIGHT_ONLY)
     DF SalomeLoggerServer with_loggerTraceCollector SalomeNS SalomeGenericObj
     Registry SalomeCatalog ResourcesManager SalomeResourcesManager
     SalomeNotification SalomeContainer SalomeSDS Launcher SalomeLauncher
-    SalomeLifeCycleCORBA SalomeDSClient TOOLSDS SalomeKernelHelpers
+    SalomeLifeCycleCORBA SalomeDSClient TOOLSDS SalomeKernelHelpers SalomeORB
     SalomeDSImpl SalomeDS SalomeCommunication SalomeDSCContainer)
   # Temporary solution for package src\DSC on windows
   IF(NOT WIN32)
index 58751735314c4aab260c03297c402149346213a5..2e2c0b9d0a780fccc97a2b0b4b1a5b183cd6900d 100644 (file)
@@ -187,3 +187,4 @@ SET(KERNEL_TOOLSDS TOOLSDS)
 SET(KERNEL_UtilsTest UtilsTest)
 SET(KERNEL_with_loggerTraceCollector with_loggerTraceCollector)
 SET(KERNEL_SalomeKernelHelpers SalomeKernelHelpers)
+SET(KERNEL_SalomeORB SalomeORB)
index 2ca550e40b99cfd74952fc418f1f60d65ac319b1..de7f9d9ee63adc76396469107c548064ad7b3cea 100644 (file)
@@ -55,6 +55,7 @@ SET(SalomeIDLKernel_IDLSOURCES
   SALOME_TestModuleCatalog.idl
   SALOME_CommonTypes.idl
   SALOME_ExternalServerLauncher.idl
+  SALOME_Embedded_NamingService.idl
   ${CMAKE_CURRENT_BINARY_DIR}/Calcium_Ports.idl
 )
 
index 9767490ac41672454f684b10d5b902bcb15c7488..89b97011b1c3e9b1c36131a62e8d6d2b8ced08e7 100644 (file)
@@ -30,6 +30,7 @@
 #include "SALOMEDS.idl"
 #include "SALOME_Exception.idl"
 #include "SALOME_PyNode.idl"
+#include "SALOME_Embedded_NamingService.idl"
 
 /*! \file SALOME_Component.idl \brief interfaces for EngineComponent and Container
 */
@@ -147,6 +148,9 @@ module Engines
       \param component_i     Component to be removed
     */
     void remove_impl(in EngineComponent component_i);
+    
+    //! In case of SSL mode Returns entry to Embedded NS
+    EmbeddedNamingService get_embedded_NS_if_ssl();
 
     //!  Unload component libraries from the container.
     void finalize_removal() ;
diff --git a/idl/SALOME_Embedded_NamingService.idl b/idl/SALOME_Embedded_NamingService.idl
new file mode 100644 (file)
index 0000000..c8c4020
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef _SALOME_EMBEDDED_NAMINGSERVICE_IDL_
+#define _SALOME_EMBEDDED_NAMINGSERVICE_IDL_
+
+module Engines
+{
+  typedef sequence<octet> IORType;
+
+  interface EmbeddedNamingService
+  {
+    void Register(in IORType ObjRef, in string Path);
+    void Destroy_FullDirectory(in string Path);
+    void Destroy_Name(in string Path);
+    IORType Resolve(in string Path);
+    IORType ResolveFirst(in string Path);
+  };
+};
+
+#endif
index e3d8550962c0597276cbf94177c83659c1734c47..9bffcca3f508df5d649f3fd97ed4992793f1484a 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
+include(${SWIG_USE_FILE})
+
 INCLUDE_DIRECTORIES(
   ${PTHREAD_INCLUDE_DIR}
+  ${PYTHON_INCLUDE_DIRS}
+  ${CMAKE_CURRENT_SOURCE_DIR}
 )
 
 SET(SALOMEBasics_SOURCES
@@ -29,6 +33,7 @@ SET(SALOMEBasics_SOURCES
   BasicsGenericDestructor.hxx
   Basics_Utils.hxx
   Basics_DirUtils.hxx
+  KernelBasis.cxx
 )
 
 ADD_LIBRARY(SALOMEBasics ${SALOMEBasics_SOURCES})
@@ -39,4 +44,21 @@ TARGET_LINK_LIBRARIES(SALOMEBasics ${PLATFORM_LIBS} ${PTHREAD_LIBRARIES})
 FILE(GLOB SALOMEBasics_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
 INSTALL(FILES ${SALOMEBasics_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
 
-SALOME_CONFIGURE_FILE(smIdType.hxx.in smIdType.hxx INSTALL ${SALOME_INSTALL_HEADERS})
\ No newline at end of file
+SET(KernelBasis_HEADERS KernelBasis.hxx KernelBasis.i)
+SET(KernelBasis_SOURCES ${KernelBasis_HEADERS})
+SET_SOURCE_FILES_PROPERTIES(KernelBasis.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(KernelBasis.i PROPERTIES SWIG_FLAGS "-py3")
+SET_SOURCE_FILES_PROPERTIES(KernelBasis_wrap.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H")
+SET(_swig_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/KernelBasis.py )
+IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") 
+  SWIG_ADD_MODULE(KernelBasis python ${KernelBasis_SOURCES})
+ELSE()
+  SWIG_ADD_LIBRARY(KernelBasis LANGUAGE python SOURCES ${KernelBasis_SOURCES})
+ENDIF()
+SWIG_LINK_LIBRARIES(KernelBasis ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} SALOMEBasics)
+install(TARGETS _KernelBasis DESTINATION ${SALOME_INSTALL_LIBS})
+install(FILES ${KernelBasis_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
+SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}"  ${SALOME_INSTALL_BINS} EXTRA_DPYS "${SWIG_MODULE_KernelBasis_REAL_NAME}")
+
+SALOME_CONFIGURE_FILE(smIdType.hxx.in smIdType.hxx INSTALL ${SALOME_INSTALL_HEADERS})
+
diff --git a/src/Basics/KernelBasis.cxx b/src/Basics/KernelBasis.cxx
new file mode 100644 (file)
index 0000000..b634f72
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "KernelBasis.hxx"
+
+static bool DEFAULT_SSL_MODE = false;
+
+bool getSSLMode()
+{
+  return DEFAULT_SSL_MODE;
+}
+
+void setSSLMode(bool sslMode)
+{
+  DEFAULT_SSL_MODE = sslMode;
+}
diff --git a/src/Basics/KernelBasis.hxx b/src/Basics/KernelBasis.hxx
new file mode 100644 (file)
index 0000000..184fb99
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include "SALOME_Basics.hxx"
+
+bool BASICS_EXPORT getSSLMode();
+void BASICS_EXPORT setSSLMode(bool sslMode);
diff --git a/src/Basics/KernelBasis.i b/src/Basics/KernelBasis.i
new file mode 100644 (file)
index 0000000..44b2e22
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module KernelBasis
+
+%{
+#include "KernelBasis.hxx"
+%}
+
+bool getSSLMode();
+void setSSLMode(bool sslMode);
index 01a46f711d981a7da40bd0aaff98b61d7fa089c9..7ff7cf0da217aa1b659709de38e3bc5c703d92a6 100644 (file)
@@ -33,6 +33,7 @@ INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_SOURCE_DIR}/../HDFPersist
   ${CMAKE_CURRENT_SOURCE_DIR}/../GenericObj
   ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMETraceCollector/Test
+  ${CMAKE_CURRENT_SOURCE_DIR}/../KernelHelpers
   ${PROJECT_BINARY_DIR}/idl
 )
 
@@ -96,14 +97,21 @@ SET(SALOME_Container_LIBS
   ${MPI_LIBRARIES}
 )
 
-ADD_EXECUTABLE(SALOME_Container SALOME_Container.cxx SALOME_Container_SignalsHandler.cxx)
-TARGET_LINK_LIBRARIES(SALOME_Container ${SALOME_Container_LIBS})
+ADD_LIBRARY(SalomeContainerServer SALOME_Container_Common.cxx SALOME_Container_SignalsHandler.cxx)
+TARGET_LINK_LIBRARIES(SalomeContainerServer ${SALOME_Container_LIBS})
+INSTALL(TARGETS SalomeContainerServer EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
+
+ADD_EXECUTABLE(SALOME_Container SALOME_Container.cxx)
+TARGET_LINK_LIBRARIES(SALOME_Container SalomeContainerServer)
+
+ADD_EXECUTABLE(SALOME_Container_No_NS_Serv SALOME_Container_No_NS_Serv.cxx)
+TARGET_LINK_LIBRARIES(SALOME_Container_No_NS_Serv SalomeContainerServer)
 
 IF(SALOME_BUILD_TESTS)
   ADD_EXECUTABLE(TestSalome_file TestSalome_file.cxx)
   TARGET_LINK_LIBRARIES(TestSalome_file SALOMETraceCollectorTest ${SALOME_Container_LIBS})
 ENDIF()
-INSTALL(TARGETS SALOME_Container DESTINATION ${SALOME_INSTALL_BINS})
+INSTALL(TARGETS SALOME_Container SALOME_Container_No_NS_Serv DESTINATION ${SALOME_INSTALL_BINS})
 
 # Executable scripts to be installed
 SALOME_INSTALL_SCRIPTS("${SCRIPTS}" ${SALOME_INSTALL_SCRIPT_PYTHON})
index fe54aa0b4908ea6daf7f5f7776e30e26771c8227..315f7cee6c1e5f8ea7fa975b6c0d21c19892f304 100644 (file)
@@ -55,6 +55,7 @@ int SIGUSR1 = 1000;
 #include "Salome_file_i.hxx"
 #include "SALOME_NamingService.hxx"
 #include "SALOME_Fake_NamingService.hxx"
+#include "SALOME_Embedded_NamingService_Client.hxx"
 #include "Basics_Utils.hxx"
 
 #ifdef _XOPEN_SOURCE
@@ -134,10 +135,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 +181,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
@@ -379,8 +379,17 @@ void Engines_Container_i::Shutdown()
   }
   _listInstances_map.clear();
 
-  _NS->Destroy_FullDirectory(_containerName.c_str());
-  _NS->Destroy_Name(_containerName.c_str());
+  // NS unregistering may throw in SSL mode if master process hosting SALOME_Embedded_NamingService servant has vanished
+  // In this case it's skip it and still continue.
+  try
+  {
+    _NS->Destroy_FullDirectory(_containerName.c_str());
+    _NS->Destroy_Name(_containerName.c_str());
+  }
+  catch(...)
+  {
+  }
+  //
   if(_isServantAloneInProcess)
   {
     MESSAGE("Effective Shutdown of container Begins...");
@@ -1228,6 +1237,20 @@ Engines_Container_i::load_impl( const char* genericRegisterName,
   return iobject._retn();
 }
 
+Engines::EmbeddedNamingService_ptr Engines_Container_i::get_embedded_NS_if_ssl()
+{
+  SALOME_Embedded_NamingService_Client *nsc(dynamic_cast<SALOME_Embedded_NamingService_Client *>(this->_NS));
+  if(nsc)
+  {
+    Engines::EmbeddedNamingService_var obj = nsc->GetObject();
+    return Engines::EmbeddedNamingService::_duplicate(obj);
+  }
+  else
+  {
+    return Engines::EmbeddedNamingService::_nil();
+  } 
+}
+
 //=============================================================================
 //! Finds an already existing component instance or create a new instance
 /*!
index 2ddb033d7af515c424835b4063f3159dd9916d0b..635f7e87e4d9e671133ff416404dcebaa2d51097 100644 (file)
@@ -41,6 +41,7 @@ import Engines, Engines__POA
 import Registry
 from Utils_Identity import *
 from SALOME_NamingServicePy import *
+from SALOME_Embedded_NamingService_ClientPy import SALOME_Embedded_NamingService_ClientPy
 from libNOTIFICATION import *
 
 from SALOME_utilities import *
@@ -296,12 +297,16 @@ class SALOME_ComponentPy_i(SALOME_ComponentPy_Gen_i):
     """
     def __init__ (self, orb, poa, contID, containerName, instanceName, interfaceName, notif=False):
         SALOME_ComponentPy_Gen_i.__init__(self, orb, poa, contID, containerName, instanceName, interfaceName, notif)
-        naming_service = SALOME_NamingServicePy_i(self._orb)
+        emb_ns = self._contId.get_embedded_NS_if_ssl()
+        if CORBA.is_nil(emb_ns):
+            self._naming_service = SALOME_NamingServicePy_i(self._orb)
+        else:
+            self._naming_service = SALOME_Embedded_NamingService_ClientPy(emb_ns)
         Component_path = self._containerName + "/" + self._instanceName
         MESSAGE(  'SALOME_ComponentPy_i Register' + str( Component_path ) )
-        naming_service.Register(self._compo_o, Component_path)
+        self._naming_service.Register(self._compo_o, Component_path)
         # Add componentinstance to registry
-        obj = naming_service.Resolve('/Registry')
+        obj = self._naming_service.Resolve('/Registry')
         if obj is None:
             MESSAGE(  "Registry Reference is invalid" )
         else:
index 7c9c937c8f270a10ada928adf1c9c753c7b8360f..aee7f06dd992458f8531100652835fd03763871c 100644 (file)
@@ -1,7 +1,4 @@
-// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2021  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-//  SALOME Container : implementation of container and engine for Kernel
-//  File   : SALOME_Container.cxx
-//  Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
-//  Module : SALOME
-//  $Header$
-//
-#ifdef _MPI_SEQ_CONTAINER_
-  #ifdef HAVE_MPI2
-#include <mpi.h>
-  #endif
-#endif
-
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <stdio.h>
-#include <time.h>
-#ifndef WIN32
-# include <sys/time.h>
-# include <dlfcn.h>
-#endif
-
-
-#ifndef WIN32
-#include <unistd.h>
-#else
-#include <process.h>
-#endif
-#include "SALOME_Container_i.hxx"
-#include "utilities.h"
-#include "Utils_ORB_INIT.hxx"
-#include "Utils_SINGLETON.hxx"
-#include "OpUtil.hxx"
-
-#ifdef CHECKTIME
-#include <Utils_Timer.hxx>
-#endif
-
-#include "Container_init_python.hxx"
-
-extern "C" void HandleServerSideSignals(CORBA::ORB_ptr theORB);
-
-#include <stdexcept>
-#include <signal.h>
-#include <sys/types.h>
-#ifndef WIN32
-# include <sys/wait.h>
-#endif
-
-void AttachDebugger();
-void Handler(int);
-void terminateHandler();
-void unexpectedHandler();
-
-#ifndef WIN32
-void (* setsig(int, void (*)(int)))(int);
-
-typedef void (*sighandler_t)(int);
-sighandler_t setsig(int sig, sighandler_t handler)
-{
-  struct sigaction context, ocontext;
-  context.sa_handler = handler;
-  sigemptyset(&context.sa_mask);
-  context.sa_flags = 0;
-  if (sigaction(sig, &context, &ocontext) == -1)
-    return SIG_ERR;
-  return ocontext.sa_handler;
-}
-#endif //WIN32
-
-void AttachDebugger()
-{
-#ifndef WIN32
-  if(getenv ("DEBUGGER"))
-    {
-      std::stringstream exec;
-      exec << "$DEBUGGER SALOME_Container " << getpid() << "&";
-      std::cerr << exec.str() << std::endl;
-      system(exec.str().c_str());
-      while(1);
-    }
-#endif
-}
-
-void Handler(int theSigId)
-{
-  std::cerr << "Signal= "<< theSigId  << std::endl;
-  AttachDebugger();
-  //to exit or not to exit
-  _exit(1);
-}
-
-void terminateHandler(void)
-{
-  std::cerr << "Terminate: not managed exception !"  << std::endl;
-  AttachDebugger();
-}
-
-void unexpectedHandler(void)
-{
-  std::cerr << "Unexpected: unexpected exception !"  << std::endl;
-  AttachDebugger();
-}
+#include "SALOME_Container_Common.hxx"
+#include "SALOME_NamingService.hxx"
 
 int main(int argc, char* argv[])
 {
-#ifdef _MPI_SEQ_CONTAINER_
-  #ifdef HAVE_MPI2
-  MPI_Init(&argc,&argv);
-  #endif
-#endif  
-
-#ifndef WIN32
-  if(getenv ("DEBUGGER"))
-    {
-      setsig(SIGSEGV,&Handler);
-      setsig(SIGFPE,&Handler);
-      std::set_terminate(&terminateHandler);
-      std::set_unexpected(&unexpectedHandler);
-    }
-#endif
-
-  // Initialise the ORB.
-  //SRN: BugID: IPAL9541, it's necessary to set a size of one message to be at least 100Mb
-  //CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
-  ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
-  ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-  CORBA::ORB_ptr orb = init(argc , argv ) ;
-
-  //  LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
-  INFOS_COMPILATION;
-  BEGIN_OF(argv[0]);
-
-  ASSERT(argc > 1);
-  SCRUTE(argv[1]);
-
-  KERNEL_PYTHON::init_python(argc,argv);
-    
-  char *containerName = (char *)"";
-  if(argc > 1)
-    {
-      containerName = argv[1] ;
-    }
-
-  try
-    {  
-      CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
-      ASSERT(!CORBA::is_nil(obj));
-      PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
-
-      PortableServer::POAManager_var pman = root_poa->the_POAManager();
-
-      // add new container to the kill list
-#ifndef WIN32
-      std::stringstream aCommand ;
-      aCommand << "addToKillList.py " << getpid() << " SALOME_Container" << std::ends ;
-      system(aCommand.str().c_str());
-#endif
-      
-      new Engines_Container_i(orb, root_poa, containerName , argc , argv );
-      
-      pman->activate();
-      
-#ifdef CHECKTIME
-      Utils_Timer timer;
-      timer.Start();
-      timer.Stop();
-      timer.ShowAbsolute();
-#endif
-
-      HandleServerSideSignals(orb);
-
-//#define MEMORYLEAKS
-#ifdef MEMORYLEAKS
-        PyGILState_Ensure();
-        //Destroy orb from python (for chasing memory leaks)
-        PyRun_SimpleString("from omniORB import CORBA");
-        PyRun_SimpleString("orb=CORBA.ORB_init([''], CORBA.ORB_ID)");
-        PyRun_SimpleString("orb.destroy()");
-        Py_Finalize();
-#endif
-    }
-  catch(CORBA::SystemException&)
-    {
-      INFOS("Caught CORBA::SystemException.");
-    }
-  catch(PortableServer::POA::ServantAlreadyActive&)
-    {
-      INFOS("Caught CORBA::ServantAlreadyActiveException");
-    }
-  catch(CORBA::Exception&)
-    {
-      INFOS("Caught CORBA::Exception.");
-    }
-  catch(std::exception& exc)
-    {
-      INFOS("Caught std::exception - "<<exc.what()); 
-    }
-  catch(...)
-    {
-      INFOS("Caught unknown exception.");
-    }
-
-#ifdef _MPI_SEQ_CONTAINER_
-  #ifdef HAVE_MPI2
-  MPI_Finalize();
-  #endif
-#endif  
-
-  return 0 ;
+  std::unique_ptr<SALOME_NamingService_Container_Abstract> ns;
+  return container_common_main(argc,argv,std::move(ns));
 }
-
index 4129ea512642ab1ceb9580b5d78518732e5a9acf..f709319f22cb268909d9a7ea7b2b1e8894c400f9 100644 (file)
@@ -25,6 +25,7 @@
 #include "SALOME_LoadRateManager.hxx"
 #include "SALOME_NamingService.hxx"
 #include "SALOME_ResourcesManager_Client.hxx"
+#include "SALOME_Embedded_NamingService.hxx"
 #include "SALOME_ModuleCatalog.hh"
 #include "Basics_Utils.hxx"
 #include "Basics_DirUtils.hxx"
@@ -81,7 +82,7 @@ Utils_Mutex SALOME_ContainerManager::_systemMutex;
  */
 //=============================================================================
 
-SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns)
+SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns)
   : _nbprocUsed(1)
 {
   MESSAGE("constructor");
@@ -469,7 +470,7 @@ SALOME_ContainerManager::LaunchContainer(const Engines::ContainerParameters& par
     // Mpi already tested in step 5, specific code on BuildCommandToLaunch Local/Remote Container methods
     // TODO -> separates Mpi from Classic/Exe
     // Classic or Exe ?
-    std::string container_exe = "SALOME_Container"; // Classic container
+    std::string container_exe = this->_isSSL ? "SALOME_Container_No_NS_Serv" : "SALOME_Container"; // Classic container
     Engines::ContainerParameters local_params(params);
     int found=0;
     try
@@ -864,11 +865,21 @@ std::string SALOME_ContainerManager::BuildCommandToLaunchLocalContainer(const En
         o << container_exe + " ";
 
     }
+  
+  o << _NS->ContainerName(params) << " ";
 
-  o << _NS->ContainerName(params);
-  o << " -";
-  AddOmninamesParams(o);
-
+  if( this->_isSSL )
+  {
+    Engines::EmbeddedNamingService_var ns = GetEmbeddedNamingService();
+    CORBA::String_var iorNS = _orb->object_to_string(ns);
+    o << iorNS;
+  }
+  else
+  {
+    o << "-";
+    AddOmninamesParams(o);
+  }
+  
   std::ofstream command_file( tmpFileName.c_str() );
   command_file << o.str();
   command_file.close();
@@ -951,11 +962,15 @@ void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream) const
  */
 //=============================================================================
 
-void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService *ns)
+void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService_Abstract *ns)
 {
-  CORBA::String_var iorstr(ns->getIORaddr());
-  fileStream << "ORBInitRef NameService=";
-  fileStream << iorstr;
+  SALOME_NamingService *nsTrad(dynamic_cast<SALOME_NamingService *>(ns));
+  if(nsTrad)
+  {
+    CORBA::String_var iorstr(nsTrad->getIORaddr());
+    fileStream << "ORBInitRef NameService=";
+    fileStream << iorstr;
+  }
 }
 
 void SALOME_ContainerManager::MakeTheCommandToBeLaunchedASync(std::string& command)
index 946b6c8d496763cdbfec661e6a775393c0238c81..bc8587ce36454af41a1b65deca30f6f4326d0dbe 100644 (file)
 #include <string>
 #include <set>
 
-class SALOME_NamingService;
+class SALOME_NamingService_Abstract;
 class SALOME_ResourcesManager_Client;
 
 class CONTAINER_EXPORT SALOME_ContainerManager : public POA_Engines::ContainerManager
 {
 
 public:
-  SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns);
+  SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns);
   ~SALOME_ContainerManager();
 
   // Corba Methods
@@ -53,6 +53,8 @@ public:
   // C++ Methods
   void Shutdown();
 
+  void DeclareUsingSalomeSession() { _isSSL = false; }
+
   static const char *_ContainerManagerNameInNS;
 
 protected:
@@ -106,7 +108,7 @@ protected:
   PortableServer::POA_var _poa;
 
   SALOME_ResourcesManager_Client *_resManager;
-  SALOME_NamingService *_NS;
+  SALOME_NamingService_Abstract *_NS;
 
   //! different behaviour if $APPLI exists (SALOME Application)
   bool _isAppliSalomeDefined;
@@ -114,6 +116,9 @@ protected:
   //! attribute that contains the number of processes used in batch mode by MPI containers
   int _nbprocUsed;
 
+  //! attribute that specifies the launch mode.
+  bool _isSSL = true;
+
   static omni_mutex _numInstanceMutex ; // lib and instance protection
 
   //! attributes to allow concurrency for // GiveContainer
@@ -163,7 +168,7 @@ public:
   static std::string GetenvThreadSafeAsString(const char *name);
   static int SystemThreadSafe(const char *command);
   static long SystemWithPIDThreadSafe(const std::vector<std::string>& command);
-  static void AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService *ns);
+  static void AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService_Abstract *ns);
   static void MakeTheCommandToBeLaunchedASync(std::string& command);
   static int GetTimeOutToLoaunchServer();
   static void SleepInSecond(int ellapseTimeInSecond);
diff --git a/src/Container/SALOME_Container_Common.cxx b/src/Container/SALOME_Container_Common.cxx
new file mode 100644 (file)
index 0000000..be0512a
--- /dev/null
@@ -0,0 +1,237 @@
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  SALOME Container : implementation of container and engine for Kernel
+//  File   : SALOME_Container.cxx
+//  Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
+//  Module : SALOME
+//  $Header$
+//
+#ifdef _MPI_SEQ_CONTAINER_
+  #ifdef HAVE_MPI2
+#include <mpi.h>
+  #endif
+#endif
+
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <stdio.h>
+#include <time.h>
+#ifndef WIN32
+# include <sys/time.h>
+# include <dlfcn.h>
+#endif
+
+
+#ifndef WIN32
+#include <unistd.h>
+#else
+#include <process.h>
+#endif
+#include "SALOME_Container_i.hxx"
+#include "utilities.h"
+#include "Utils_ORB_INIT.hxx"
+#include "Utils_SINGLETON.hxx"
+#include "OpUtil.hxx"
+
+#ifdef CHECKTIME
+#include <Utils_Timer.hxx>
+#endif
+
+#include "Container_init_python.hxx"
+
+extern "C" void HandleServerSideSignals(CORBA::ORB_ptr theORB);
+
+#include <stdexcept>
+#include <signal.h>
+#include <sys/types.h>
+#ifndef WIN32
+# include <sys/wait.h>
+#endif
+
+#include <memory>
+
+void AttachDebugger();
+void Handler(int);
+void terminateHandler();
+void unexpectedHandler();
+
+#ifndef WIN32
+void (* setsig(int, void (*)(int)))(int);
+
+typedef void (*sighandler_t)(int);
+sighandler_t setsig(int sig, sighandler_t handler)
+{
+  struct sigaction context, ocontext;
+  context.sa_handler = handler;
+  sigemptyset(&context.sa_mask);
+  context.sa_flags = 0;
+  if (sigaction(sig, &context, &ocontext) == -1)
+    return SIG_ERR;
+  return ocontext.sa_handler;
+}
+#endif //WIN32
+
+void AttachDebugger()
+{
+#ifndef WIN32
+  if(getenv ("DEBUGGER"))
+    {
+      std::stringstream exec;
+      exec << "$DEBUGGER SALOME_Container " << getpid() << "&";
+      std::cerr << exec.str() << std::endl;
+      system(exec.str().c_str());
+      while(1);
+    }
+#endif
+}
+
+void Handler(int theSigId)
+{
+  std::cerr << "Signal= "<< theSigId  << std::endl;
+  AttachDebugger();
+  //to exit or not to exit
+  _exit(1);
+}
+
+void terminateHandler(void)
+{
+  std::cerr << "Terminate: not managed exception !"  << std::endl;
+  AttachDebugger();
+}
+
+void unexpectedHandler(void)
+{
+  std::cerr << "Unexpected: unexpected exception !"  << std::endl;
+  AttachDebugger();
+}
+
+int container_common_main(int argc, char* argv[], std::unique_ptr<SALOME_NamingService_Container_Abstract> ns)
+{
+#ifdef _MPI_SEQ_CONTAINER_
+  #ifdef HAVE_MPI2
+  MPI_Init(&argc,&argv);
+  #endif
+#endif  
+
+#ifndef WIN32
+  if(getenv ("DEBUGGER"))
+    {
+      setsig(SIGSEGV,&Handler);
+      setsig(SIGFPE,&Handler);
+      std::set_terminate(&terminateHandler);
+      std::set_unexpected(&unexpectedHandler);
+    }
+#endif
+
+  // Initialise the ORB.
+  //SRN: BugID: IPAL9541, it's necessary to set a size of one message to be at least 100Mb
+  //CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
+  ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+  ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
+  CORBA::ORB_ptr orb = init(argc , argv ) ;
+
+  //  LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
+  INFOS_COMPILATION;
+  BEGIN_OF(argv[0]);
+
+  ASSERT(argc > 1);
+  SCRUTE(argv[1]);
+
+  KERNEL_PYTHON::init_python(argc,argv);
+    
+  char *containerName = (char *)"";
+  if(argc > 1)
+    {
+      containerName = argv[1] ;
+    }
+
+  try
+    {  
+      CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+      ASSERT(!CORBA::is_nil(obj));
+      PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
+
+      PortableServer::POAManager_var pman = root_poa->the_POAManager();
+
+      // add new container to the kill list
+#ifndef WIN32
+      std::stringstream aCommand ;
+      aCommand << "addToKillList.py " << getpid() << " SALOME_Container" << std::ends ;
+      system(aCommand.str().c_str());
+#endif
+      
+      new Engines_Container_i(orb, root_poa, containerName , argc , argv, ns.get() );
+      ns.release();
+
+      pman->activate();
+      
+#ifdef CHECKTIME
+      Utils_Timer timer;
+      timer.Start();
+      timer.Stop();
+      timer.ShowAbsolute();
+#endif
+
+      HandleServerSideSignals(orb);
+
+//#define MEMORYLEAKS
+#ifdef MEMORYLEAKS
+        PyGILState_Ensure();
+        //Destroy orb from python (for chasing memory leaks)
+        PyRun_SimpleString("from omniORB import CORBA");
+        PyRun_SimpleString("orb=CORBA.ORB_init([''], CORBA.ORB_ID)");
+        PyRun_SimpleString("orb.destroy()");
+        Py_Finalize();
+#endif
+    }
+  catch(CORBA::SystemException&)
+    {
+      INFOS("Caught CORBA::SystemException.");
+    }
+  catch(PortableServer::POA::ServantAlreadyActive&)
+    {
+      INFOS("Caught CORBA::ServantAlreadyActiveException");
+    }
+  catch(CORBA::Exception&)
+    {
+      INFOS("Caught CORBA::Exception.");
+    }
+  catch(std::exception& exc)
+    {
+      INFOS("Caught std::exception - "<<exc.what()); 
+    }
+  catch(...)
+    {
+      INFOS("Caught unknown exception.");
+    }
+
+#ifdef _MPI_SEQ_CONTAINER_
+  #ifdef HAVE_MPI2
+  MPI_Finalize();
+  #endif
+#endif  
+
+  return 0 ;
+}
+
diff --git a/src/Container/SALOME_Container_Common.hxx b/src/Container/SALOME_Container_Common.hxx
new file mode 100644 (file)
index 0000000..eed8ca8
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include "SALOME_Container.hxx"
+#include "SALOME_NamingService_Abstract.hxx"
+
+#include <memory>
+
+int CONTAINER_EXPORT container_common_main(int argc, char* argv[], std::unique_ptr<SALOME_NamingService_Container_Abstract> ns);
diff --git a/src/Container/SALOME_Container_No_NS_Serv.cxx b/src/Container/SALOME_Container_No_NS_Serv.cxx
new file mode 100644 (file)
index 0000000..6d80184
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SALOME_Container_Common.hxx"
+#include "SALOME_Embedded_NamingService_Client.hxx"
+#include "Utils_SALOME_Exception.hxx"
+#include "SALOME_KernelORB.hxx"
+
+int main(int argc, char* argv[])
+{
+  if(argc<3)
+    THROW_SALOME_EXCEPTION( "SALOME_Container_No_NS_Serv : requires 2 input arguments <containerName> <IOR of Engines::EmbeddedNamingService>" );
+  CORBA::ORB_ptr orb(KERNEL::getORB());
+  CORBA::Object_var ns_serv_obj_base = orb->string_to_object(argv[2]);
+  if( CORBA::is_nil(ns_serv_obj_base) )
+    THROW_SALOME_EXCEPTION( "SALOME_Container_No_NS_Serv : argument 2 is NOT a valid IOR" );
+  Engines::EmbeddedNamingService_var ns_serv_obj = Engines::EmbeddedNamingService::_narrow(ns_serv_obj_base);
+  if( CORBA::is_nil(ns_serv_obj) )
+    THROW_SALOME_EXCEPTION( "SALOME_Container_No_NS_Serv : argument 2 is NOT a valid IOR of Engines::EmbeddedNamingService" );
+  std::unique_ptr<SALOME_NamingService_Container_Abstract> ns( new SALOME_Embedded_NamingService_Client(ns_serv_obj) );
+  return container_common_main(argc,argv,std::move(ns));
+}
index 244221993c540819dd5239f36e68bcce9b62da94..f0a8e4e76eb699704af031d416ebcc068edbbff6 100644 (file)
@@ -48,7 +48,7 @@
 #include <list>
 #include <string>
 
-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();
 
@@ -87,6 +87,7 @@ public:
   load_impl(const char* nameToRegister,
             const char* componentName);
 
+  Engines::EmbeddedNamingService_ptr get_embedded_NS_if_ssl() override;
 
   void remove_impl(Engines::EngineComponent_ptr component_i);
   void finalize_removal();
@@ -151,7 +152,7 @@ protected:
 
   bool _isSupervContainer;
 
-  SALOME_NamingService_Abstract *_NS ;
+  SALOME_NamingService_Container_Abstract *_NS ;
   std::string _library_path;
   std::string _containerName;
   std::string _logfilename;
index 5952cc924ae4b279845628b68fc782dd0f77214a..cbe51e8e04e3cb8bf575c08e0ddd21ac21a9ef50 100644 (file)
@@ -177,7 +177,11 @@ def salome_init(path=None, embedded=False):
     if __EMB_SERVANT_ENV_VAR_NAME in os.environ:
         salome_init_without_session()
     else:
-        salome_init_with_session(path, embedded)
+        import KernelBasis
+        if KernelBasis.getSSLMode():
+            salome_init_without_session()
+        else:
+            salome_init_with_session(path, embedded)
 
 class StandAloneLifecyle:
     def FindOrLoadComponent(self,contName,moduleName):
@@ -190,8 +194,10 @@ class StandAloneLifecyle:
         #raise RuntimeError("Undealed situation cont = {} module = {}".format(contName,moduleName))
 
 def salome_init_without_session():
-    global lcc,myStudy,orb,modulcat,sg
+    global lcc,myStudy,orb,modulcat,sg,cm
     lcc = StandAloneLifecyle()
+    import KernelBasis
+    KernelBasis.setSSLMode(True)
     import KernelDS
     myStudy = KernelDS.myStudy()
     import CORBA
@@ -200,6 +206,8 @@ def salome_init_without_session():
     import SALOME_ModuleCatalog
     from salome_kernel import list_of_catalogs_regarding_environement
     modulcat = KernelModuleCatalog.myModuleCatalog( list_of_catalogs_regarding_environement() )
+    import KernelLauncher
+    cm = KernelLauncher.myContainerManager()
     # activate poaManager to accept co-localized CORBA calls.
     poa = orb.resolve_initial_references("RootPOA")
     poaManager = poa._get_the_POAManager()
@@ -226,7 +234,8 @@ def salome_init_with_session(path=None, embedded=False):
     global orb, lcc, naming_service, cm, esm, dsm, modulcat
     global sg
     global myStudy, myStudyName
-
+    import KernelBasis
+    KernelBasis.setSSLMode(False)
     try:
         if salome_initial:
             salome_initial=False
index 9c8ce0461d2fa38fd7de53484b4a890a0feb2b05..f03b04cd7e70207d3346983e70dfff4178141f7e 100644 (file)
@@ -36,8 +36,16 @@ INCLUDE_DIRECTORIES(
   ${PROJECT_BINARY_DIR}/idl
 )
 
+SET(SalomeORB_SOURCES
+  SALOME_KernelORB.cxx
+)
+
+ADD_LIBRARY(SalomeORB ${SalomeORB_SOURCES})
+TARGET_LINK_LIBRARIES(SalomeORB ${OMNIORB_LIBRARIES})
+INSTALL(TARGETS SalomeORB EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
+
 SET(SalomeKernelHelpers_LIBS
-  ${OMNIORB_LIBRARIES}
+  SalomeORB
   SalomeNS
   SALOMELocalTrace
   SALOMEBasics
diff --git a/src/KernelHelpers/SALOME_KernelORB.cxx b/src/KernelHelpers/SALOME_KernelORB.cxx
new file mode 100644 (file)
index 0000000..ed8b9da
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SALOME_KernelORB.hxx"
+
+namespace KERNEL {
+  /**
+   * This function returns a static reference to the orb. The orb can
+   * be used for example to initialize CORBA variables or to serialize
+   * and unserialize the CORBA objet to/from an IOR string.
+   */
+  CORBA::ORB_ptr getORB() {
+    static CORBA::ORB_ptr orb;
+    if(CORBA::is_nil(orb)){
+      int argc=0;
+      orb = CORBA::ORB_init(argc,0);
+    }
+    return orb;
+  }
+}
diff --git a/src/KernelHelpers/SALOME_KernelORB.hxx b/src/KernelHelpers/SALOME_KernelORB.hxx
new file mode 100644 (file)
index 0000000..4c09809
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// Author: Guillaume Boulant (EDF/R&D) 
+
+#pragma once
+
+#include "KernelHelpers.hxx"
+
+#include <omniORB4/CORBA.h>
+
+namespace KERNEL
+{
+  KERNELHELPERS_EXPORT CORBA::ORB_ptr getORB();
+}
index 61e59350bbe43c9d579094175d2d5e1cb1fbc76b..efc9bf85e2a708816763c10c3dd0be1a3e7780b9 100644 (file)
@@ -31,20 +31,6 @@ std::unique_ptr<SALOME_NamingService_Abstract> _naming_service;
 
 namespace KERNEL {
   
-  /**
-   * This function returns a static reference to the orb. The orb can
-   * be used for example to initialize CORBA variables or to serialize
-   * and unserialize the CORBA objet to/from an IOR string.
-   */
-  CORBA::ORB_ptr getORB() {
-    static CORBA::ORB_ptr orb;
-    if(CORBA::is_nil(orb)){
-      int argc=0;
-      orb = CORBA::ORB_init(argc,0);
-    }
-    return orb;
-  }
-  
   void assignNamingServiceSL()
   {
     if ( !_naming_service.get() )
index decc6fd17225b16f01237ac3a9208ea9b0b70ca1..42f8dc63868037cdb90e55d332095b11f54015e9 100644 (file)
 #include "SALOME_NamingService.hxx"
 #include "SALOME_LifeCycleCORBA.hxx"
 
+#include "SALOME_KernelORB.hxx"
+
 namespace KERNEL {
 
   // ---------------------------------------------
   // SALOME KERNEL main services
-  KERNELHELPERS_EXPORT CORBA::ORB_ptr                getORB();
   KERNELHELPERS_EXPORT SALOME_NamingService_Abstract *getNamingService();
   KERNELHELPERS_EXPORT void assignNamingServiceSL();
   KERNELHELPERS_EXPORT SALOME_LifeCycleCORBA *       getLifeCycleCORBA();
index 47ee394cff67e8512c53983a8df6cadfdbf953d8..f1460e4724e08aad134ed3b8708a60f8c3960e39 100644 (file)
@@ -17,6 +17,8 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
+include(${SWIG_USE_FILE})
+
 IF(SALOME_BUILD_TESTS)
   ADD_SUBDIRECTORY(Test)
 ENDIF(SALOME_BUILD_TESTS)
@@ -38,7 +40,10 @@ INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_SOURCE_DIR}/../Container
   ${CMAKE_CURRENT_SOURCE_DIR}/../ResourcesManager
   ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMESDS
+  ${CMAKE_CURRENT_SOURCE_DIR}/../LifeCycleCORBA
+  ${CMAKE_CURRENT_SOURCE_DIR}/../KernelHelpers
   ${PROJECT_BINARY_DIR}/idl
+  ${CMAKE_CURRENT_SOURCE_DIR}
 )
 
 ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} ${BOOST_DEFINITIONS} ${OMNIORB_DEFINITIONS})
@@ -131,12 +136,30 @@ SET(COMMON_HEADERS_HXX
   SALOME_Launcher_defs.hxx
   SALOME_ExternalServerLauncher.hxx
   SALOME_LauncherException.hxx
+  KernelLauncher.hxx
 )
 
 SET(LAUNCHER_PYTHON_SCRIPTS
   launcher_proxy.py
 )
 
+SET(KernelLauncher_HEADERS KernelLauncher.hxx KernelLauncher.i)
+SET(KernelLauncher_SOURCES KernelLauncher.cxx ${KernelLauncher_HEADERS})
+SET_SOURCE_FILES_PROPERTIES(KernelLauncher.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(KernelLauncher.i PROPERTIES SWIG_FLAGS "-py3")
+SET_SOURCE_FILES_PROPERTIES(KernelLauncher_wrap.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H")
+SET(_swig_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/KernelLauncher.py )
+IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") 
+  SWIG_ADD_MODULE(KernelLauncher python ${KernelLauncher_SOURCES})
+ELSE()
+  SWIG_ADD_LIBRARY(KernelLauncher LANGUAGE python SOURCES ${KernelLauncher_SOURCES})
+ENDIF()
+SWIG_LINK_LIBRARIES(KernelLauncher ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} SalomeDS SalomeKernelHelpers)
+install(TARGETS _KernelLauncher DESTINATION ${SALOME_INSTALL_LIBS})
+install(FILES ${KernelLauncher_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
+SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}"  ${SALOME_INSTALL_BINS} EXTRA_DPYS "${SWIG_MODULE_KernelLauncher_REAL_NAME}")
+
+
 INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
 INSTALL(FILES testLauncher.xml DESTINATION ${SALOME_KERNEL_INSTALL_RES_DATA})
 SALOME_INSTALL_SCRIPTS("${LAUNCHER_PYTHON_SCRIPTS}" ${SALOME_INSTALL_PYTHON})
diff --git a/src/Launcher/KernelLauncher.cxx b/src/Launcher/KernelLauncher.cxx
new file mode 100644 (file)
index 0000000..05213a8
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "KernelLauncher.hxx"
+
+#include "SALOME_Launcher.hxx"
+#include "SALOME_ContainerManager.hxx"
+#include "SALOME_Fake_NamingService.hxx"
+#include "SALOME_KernelServices.hxx"
+
+#include <cstring>
+
+std::string GetContainerManagerInstance()
+{
+  SALOME_Launcher *launcher = KERNEL::getLauncherSA();
+  SALOME_Fake_NamingService ns;
+  CORBA::Object_var cm = ns.Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS);
+  CORBA::ORB_ptr orb = KERNEL::getORB();
+  CORBA::String_var ior = orb->object_to_string(cm);
+  return std::string(ior.in());
+}
diff --git a/src/Launcher/KernelLauncher.hxx b/src/Launcher/KernelLauncher.hxx
new file mode 100644 (file)
index 0000000..378843b
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include <string>
+
+std::string GetContainerManagerInstance();
diff --git a/src/Launcher/KernelLauncher.i b/src/Launcher/KernelLauncher.i
new file mode 100644 (file)
index 0000000..013758c
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module KernelLauncher
+
+%include "std_string.i"
+
+%{
+#include "KernelLauncher.hxx"
+%}
+
+%inline
+{
+  std::string GetContainerManagerInstance();
+}
+
+%pythoncode %{
+def myContainerManager():
+  import Engines
+  import CORBA
+  orb=CORBA.ORB_init([''])
+  return orb.string_to_object(GetContainerManagerInstance())
+%}
index 6001ca9444171cdc6844bacdbc09fe3f917da983..11d16abac88d8c318034719f6e118bd37b7cf43b 100644 (file)
@@ -73,9 +73,9 @@ SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa
 
 void SALOME_Launcher::init(CORBA::ORB_ptr orb, PortableServer::POA_var poa)
 {
-  _ResManager = new SALOME_ResourcesManager(orb,poa,tradNS());
+  _ResManager = new SALOME_ResourcesManager(orb,poa,_NS);
   _l.SetResourcesManager(_ResManager->GetImpl());
-  _ContManager = new SALOME_ContainerManager(orb,poa,tradNS());
+  _ContManager = new SALOME_ContainerManager(orb,poa,_NS);
   _ResManager->_remove_ref();
   _ContManager->_remove_ref();
 
@@ -241,6 +241,11 @@ SALOME_Launcher::getJobWorkFile(CORBA::Long job_id, const char * work_file, cons
   return rtn;
 }
 
+void SALOME_Launcher::DeclareUsingSalomeSession()
+{
+  this->_ContManager->DeclareUsingSalomeSession();
+}
+
 void
 SALOME_Launcher::removeJob(CORBA::Long job_id)
 {
index cd72c7a168a6759f5c6b9d58c609bfc0d888bf5c..9fcbc2023bdd0d8fcd1b0cf5f7e7270d189415ff 100644 (file)
@@ -77,6 +77,8 @@ public:
   // Save and load methods
   virtual void loadJobs(const char* jobs_file);
   virtual void saveJobs(const char* jobs_file);
+  
+  void DeclareUsingSalomeSession();
 
   static const char *_LauncherNameInNS;
 
@@ -86,8 +88,6 @@ public:
   static Engines::JobParameters_var
     JobParameters_CPP2CORBA(const JobParameters_cpp& job_parameters);
 
-  SALOME_NamingService *tradNS() { return SALOME_NamingService::GetTraditionalNS(_NS); }
-
 protected:
   // Internal methods
   virtual void notifyObservers(const std::string & event_name, const std::string & event_data);
index 34d6e55418e0dc50abbbed9be5a44600643a91f4..4692f5e2b8638790b68d98fa08fcb14b0f0b4270 100644 (file)
@@ -118,6 +118,7 @@ int main(int argc, char* argv[])
       SALOME_CPythonHelper cPyh;
       cPyh.initializePython(argc,argv);
       SALOME_Launcher *lServ(new SALOME_Launcher(orb,safePOA));
+      lServ->DeclareUsingSalomeSession();
       lServ->_remove_ref();
       //
       SALOMESDS::DataServerManager *dsm(new SALOMESDS::DataServerManager(&cPyh,orb,root_poa));
index aa7ed44800b46d9bd817375ff02332af0d99a661..08223ade7cec6f02c61e67296d59eb984d7a01f1 100644 (file)
@@ -104,7 +104,7 @@ SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService_Abstract *ns)
   // not enough: set a current directory in naming service is not thread safe
   // if naming service instance is shared among several threads...
   // ==> always use absolute path and don't rely on current directory!
-  if( dynamic_cast<SALOME_NamingService *>(_NS) )
+  //if( dynamic_cast<SALOME_NamingService *>(_NS) )
   {
     CORBA::Object_var obj =
       _NS->Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS);
index bc9237306daf5f63f6ccae38f111ed532cb43123..4677773f1af20dcd5e8c22043522cf5c5654cf36 100644 (file)
@@ -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());
 }
index d60f9f0fc78cf5b13470f3e48664e06459ea9901..01819c8bf4a7d2128c641501df280bda65fbb4e3 100644 (file)
@@ -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.");
 
index f6877ae3541eebcc79f5eff329765e69dc9a07aa..112d0a12e1f1331512e3187f27696a6a259e435a 100644 (file)
@@ -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 <libxml/parser.h>
 #include <fstream>
 #include <map>
@@ -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<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);
 }
index 05ccfd8645bb42f1f8d7a33b29f6fd46ba3db238..88f9118fae6902262ede78e78370f79de0988424 100644 (file)
@@ -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
   /*!
index 7009bac9aeb03a101b5a38d1ba10896c2460983a..051bfb4bba39dcede1c46c397695374977a28f0a 100644 (file)
@@ -17,6 +17,8 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
+include(${SWIG_USE_FILE})
+
 INCLUDE_DIRECTORIES(
   ${OMNIORB_INCLUDE_DIR}
   ${PTHREAD_INCLUDE_DIR}
@@ -24,7 +26,11 @@ INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_SOURCE_DIR}/../Basics
   ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace
   ${CMAKE_CURRENT_SOURCE_DIR}/../Utils
+  ${CMAKE_CURRENT_SOURCE_DIR}/../KernelHelpers
+  ${CMAKE_CURRENT_SOURCE_DIR}/../LifeCycleCORBA
+  ${CMAKE_CURRENT_SOURCE_DIR}
   ${PROJECT_BINARY_DIR}/idl
+  ${PYTHON_INCLUDE_DIRS}
   )
 
 SET(SalomeNS_SOURCES
@@ -33,18 +39,37 @@ SET(SalomeNS_SOURCES
   NamingService_WaitForServerReadiness.cxx
   SALOME_Fake_NamingService.cxx
   SALOME_NamingService_Abstract.cxx
+  SALOME_Embedded_NamingService.cxx
+  SALOME_Embedded_NamingService_Common.cxx
+  SALOME_Embedded_NamingService_Client.cxx
 )
 
-
 ADD_DEFINITIONS(${OMNIORB_DEFINITIONS})
 ADD_LIBRARY(SalomeNS ${SalomeNS_SOURCES})
 ADD_DEPENDENCIES(SalomeNS SalomeIDLKernel)
-TARGET_LINK_LIBRARIES(SalomeNS OpUtil)
+TARGET_LINK_LIBRARIES(SalomeNS OpUtil SalomeORB)
 
 INSTALL(TARGETS SalomeNS EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
 
 # Executable scripts to be installed
 SALOME_INSTALL_SCRIPTS(SALOME_NamingServicePy.py ${SALOME_INSTALL_SCRIPT_PYTHON})
+SALOME_INSTALL_SCRIPTS(SALOME_Embedded_NamingService_ClientPy.py ${SALOME_INSTALL_SCRIPT_PYTHON})
 
 FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
 INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
+
+SET(NamingService_HEADERS NamingService.i)
+SET(NamingService_SOURCES ${NamingService_HEADERS})
+SET_SOURCE_FILES_PROPERTIES(NamingService.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(NamingService.i PROPERTIES SWIG_FLAGS "-py3")
+SET_SOURCE_FILES_PROPERTIES(NamingService_wrap.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H")
+SET(_swig_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/NamingService.py )
+IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") 
+  SWIG_ADD_MODULE(NamingService python ${NamingService_SOURCES})
+ELSE()
+  SWIG_ADD_LIBRARY(NamingService LANGUAGE python SOURCES ${NamingService_SOURCES})
+ENDIF()
+SWIG_LINK_LIBRARIES(NamingService ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} SalomeNS)
+install(TARGETS _NamingService DESTINATION ${SALOME_INSTALL_LIBS})
+install(FILES ${NamingService_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
+SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}"  ${SALOME_INSTALL_BINS} EXTRA_DPYS "${SWIG_MODULE_NamingService_REAL_NAME}")
diff --git a/src/NamingService/NamingService.i b/src/NamingService/NamingService.i
new file mode 100644 (file)
index 0000000..08b58d9
--- /dev/null
@@ -0,0 +1,138 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module NamingService
+
+%{
+#include "SALOME_Fake_NamingService.hxx"
+#include "SALOME_Embedded_NamingService.hxx"
+#include "SALOME_KernelORB.hxx"
+#include "Utils_SALOME_Exception.hxx"
+%}
+
+%include "std_string.i"
+%include "std_vector.i"
+
+%rename(NamingService) SALOME_Fake_NamingService ;
+
+%template(svec) std::vector<std::string>;
+
+%exceptionclass SALOME_Exception;
+
+class SALOME_Exception
+{
+public:
+  SALOME_Exception(const std::string& text);
+  ~SALOME_Exception() noexcept;
+  const char *what() const noexcept;
+  %extend
+  {
+    std::string __str__() const
+    {
+      return std::string(self->what());
+    }
+  }
+};
+
+%exception {
+  try {
+    $action
+  }
+  catch (SALOME_Exception& _e) {
+    // Reraise with SWIG_Python_Raise
+    SWIG_Python_Raise(SWIG_NewPointerObj((new SALOME_Exception(static_cast< const SALOME_Exception& >(_e))),SWIGTYPE_p_SALOME_Exception,SWIG_POINTER_OWN), "SALOME_Exception", SWIGTYPE_p_SALOME_Exception);
+    SWIG_fail;
+  }
+}
+
+class SALOME_Fake_NamingService
+{
+public:
+  SALOME_Fake_NamingService();
+  std::vector< std::string > repr();
+  static std::string GetLogContainersFile();
+  static void FlushLogContainersFile();
+  %extend {
+    static void SetLogContainersFileInternal(const std::string& logFileName)
+    {
+      SALOME_Fake_NamingService::SetLogContainersFile(logFileName);
+    }
+    std::string _ResolveInternal(const char *Path)
+    {
+      CORBA::Object_var obj = self->Resolve(Path);
+      CORBA::ORB_ptr orb = KERNEL::getORB();
+      CORBA::String_var ior = orb->object_to_string(obj);
+      return std::string(ior);
+    }
+    void _RegisterInternal(const char *ior, const char* Path)
+    {
+      CORBA::ORB_ptr orb = KERNEL::getORB();
+      CORBA::Object_var obj = orb->string_to_object(ior);
+      self->Register(obj,Path);
+    }
+    static std::string IOROfNS()
+    {
+      CORBA::ORB_ptr orb = KERNEL::getORB();
+      Engines::EmbeddedNamingService_var ns = GetEmbeddedNamingService();
+      CORBA::String_var ior = orb->object_to_string(ns);
+      return std::string(ior);
+    }
+  }
+};
+
+%pythoncode %{
+def NamingService_Resolve(self,Path):
+  ret = self._ResolveInternal(Path)
+  import CORBA
+  orb=CORBA.ORB_init([''])
+  return orb.string_to_object(ret)
+def NamingService_Register(self,obj,Path):
+  import CORBA
+  orb=CORBA.ORB_init([''])
+  self._RegisterInternal( orb.object_to_string(obj) , Path)
+NamingService.Resolve = NamingService_Resolve
+NamingService.Register = NamingService_Register
+def NamingService_SetLogContainersFile(cls,logFileName = None):
+  if logFileName is None:
+    import tempfile
+    with tempfile.NamedTemporaryFile() as f:
+      logFileName = f.name
+  cls.SetLogContainersFileInternal(logFileName)
+NamingService.SetLogContainersFile = classmethod(NamingService_SetLogContainersFile)
+def NamingService_RefOfNS(cls):
+  ret = cls.IOROfNS()
+  import Engines
+  import CORBA
+  orb=CORBA.ORB_init([''])
+  return orb.string_to_object(ret)
+NamingService.RefOfNS = classmethod(NamingService_RefOfNS)
+def NamingService_KillContainersInFile(cls,logFileName):
+  import Engines
+  import CORBA
+  orb=CORBA.ORB_init([''])
+  with open(logFileName) as f:
+    cont_to_kill = [elt.split(" : ") for elt in f]
+    for name,ior in cont_to_kill:
+      try:
+        ref = orb.string_to_object(ior)
+        ref.Shutdown()
+      except Exception as e:
+        print("Failed to kill container remotely \"{}\"".format(name))
+NamingService.KillContainersInFile = classmethod(NamingService_KillContainersInFile)
+%}
diff --git a/src/NamingService/SALOME_Embedded_NamingService.cxx b/src/NamingService/SALOME_Embedded_NamingService.cxx
new file mode 100644 (file)
index 0000000..ed4066c
--- /dev/null
@@ -0,0 +1,71 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SALOME_Embedded_NamingService.hxx"
+#include "SALOME_Embedded_NamingService_Common.hxx"
+#include "SALOME_Fake_NamingService.hxx"
+
+#include <memory>
+#include <cstring>
+
+static Engines::EmbeddedNamingService_var _embedded_ns_singleton;
+
+Engines::EmbeddedNamingService_var GetEmbeddedNamingService()
+{
+  if( CORBA::is_nil(_embedded_ns_singleton) )
+  {
+    std::unique_ptr<SALOME_Embedded_NamingService> servant(new SALOME_Embedded_NamingService);
+    _embedded_ns_singleton = servant->_this();
+    servant->_remove_ref();
+    servant.release();
+  }
+  return _embedded_ns_singleton;
+}
+
+void SALOME_Embedded_NamingService::Register(const Engines::IORType& ObjRef, const char *Path)
+{
+  SALOME_Fake_NamingService ns;
+  ns.Register(IORToObject(ObjRef),Path);
+}
+
+void SALOME_Embedded_NamingService::Destroy_FullDirectory(const char *Path)
+{
+  SALOME_Fake_NamingService ns;
+  ns.Destroy_FullDirectory(Path);
+}
+
+void SALOME_Embedded_NamingService::Destroy_Name(const char *Path)
+{
+  SALOME_Fake_NamingService ns;
+  ns.Destroy_Name(Path);
+}
+
+Engines::IORType *SALOME_Embedded_NamingService::Resolve(const char *Path)
+{
+  SALOME_Fake_NamingService ns;
+  CORBA::Object_var obj = ns.Resolve(Path);
+  return ObjectToIOR(obj);
+}
+
+Engines::IORType *SALOME_Embedded_NamingService::ResolveFirst(const char *Path)
+{
+  SALOME_Fake_NamingService ns;
+  CORBA::Object_var obj = ns.ResolveFirst(Path);
+  return ObjectToIOR(obj);
+}
diff --git a/src/NamingService/SALOME_Embedded_NamingService.hxx b/src/NamingService/SALOME_Embedded_NamingService.hxx
new file mode 100644 (file)
index 0000000..1fde6b3
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include "SALOME_NamingService_defs.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOME_Embedded_NamingService)
+
+Engines::EmbeddedNamingService_var NAMINGSERVICE_EXPORT GetEmbeddedNamingService();
+
+class NAMINGSERVICE_EXPORT SALOME_Embedded_NamingService : public virtual POA_Engines::EmbeddedNamingService
+{
+public:
+  void Register(const Engines::IORType& ObjRef, const char *Path) override;
+  void Destroy_FullDirectory(const char *Path) override;
+  void Destroy_Name(const char *Path) override;
+  Engines::IORType *Resolve(const char *Path) override;
+  Engines::IORType *ResolveFirst(const char *Path) override;
+};
diff --git a/src/NamingService/SALOME_Embedded_NamingService_Client.cxx b/src/NamingService/SALOME_Embedded_NamingService_Client.cxx
new file mode 100644 (file)
index 0000000..9ec02a7
--- /dev/null
@@ -0,0 +1,62 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SALOME_Embedded_NamingService_Client.hxx"
+#include "SALOME_Embedded_NamingService_Common.hxx"
+
+#include <memory>
+
+void SALOME_Embedded_NamingService_Client::init_orb(CORBA::ORB_ptr orb)
+{
+}
+
+SALOME_NamingService_Container_Abstract *SALOME_Embedded_NamingService_Client::clone()
+{
+  return new SALOME_Embedded_NamingService_Client(*this);
+}
+
+void SALOME_Embedded_NamingService_Client::Register(CORBA::Object_ptr ObjRef, const char* Path)
+{
+  std::unique_ptr<Engines::IORType> ior( ObjectToIOR(ObjRef) );
+  this->_remote_ns_serv->Register( *(ior.get()), Path);
+}
+
+void SALOME_Embedded_NamingService_Client::Destroy_FullDirectory(const char* Path)
+{
+  this->_remote_ns_serv->Destroy_FullDirectory(Path);
+}
+
+void SALOME_Embedded_NamingService_Client::Destroy_Name(const char* Path)
+{
+  this->_remote_ns_serv->Destroy_Name(Path);
+}
+
+CORBA::Object_ptr SALOME_Embedded_NamingService_Client::Resolve(const char* Path)
+{
+  std::unique_ptr<Engines::IORType> ior( this->_remote_ns_serv->Resolve(Path) );
+  CORBA::Object_var ret( IORToObject( *(ior.get()) ) );
+  return CORBA::Object::_duplicate(ret);
+}
+
+CORBA::Object_ptr SALOME_Embedded_NamingService_Client::ResolveFirst(const char* Path)
+{
+  std::unique_ptr<Engines::IORType> ior( this->_remote_ns_serv->ResolveFirst(Path) );
+  CORBA::Object_var ret( IORToObject( *(ior.get()) ) );
+  return CORBA::Object::_duplicate(ret);
+}
diff --git a/src/NamingService/SALOME_Embedded_NamingService_Client.hxx b/src/NamingService/SALOME_Embedded_NamingService_Client.hxx
new file mode 100644 (file)
index 0000000..e493e13
--- /dev/null
@@ -0,0 +1,45 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include "SALOME_NamingService_defs.hxx"
+#include "SALOME_NamingService_Abstract.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOME_Embedded_NamingService)
+
+class NAMINGSERVICE_EXPORT SALOME_Embedded_NamingService_Client : public SALOME_NamingService_Container_Abstract
+{
+public:
+  SALOME_Embedded_NamingService_Client(Engines::EmbeddedNamingService_var remoteNSServ):_remote_ns_serv(remoteNSServ) { }
+  void init_orb(CORBA::ORB_ptr orb=0) override;
+  SALOME_NamingService_Container_Abstract *clone() override;
+  void Register(CORBA::Object_ptr ObjRef, const char* Path) override;
+  void Destroy_FullDirectory(const char* Path) override;
+  void Destroy_Name(const char* Path)  override;
+  CORBA::Object_ptr Resolve(const char* Path) override;
+  CORBA::Object_ptr ResolveFirst(const char* Path) override;
+public:
+  Engines::EmbeddedNamingService_var GetObject() const { return _remote_ns_serv; }
+private:
+  SALOME_Embedded_NamingService_Client(const SALOME_Embedded_NamingService_Client& other) = default;
+private:
+  Engines::EmbeddedNamingService_var _remote_ns_serv;
+};
diff --git a/src/NamingService/SALOME_Embedded_NamingService_ClientPy.py b/src/NamingService/SALOME_Embedded_NamingService_ClientPy.py
new file mode 100644 (file)
index 0000000..8e53810
--- /dev/null
@@ -0,0 +1,43 @@
+#! /usr/bin/env python3
+#  -*- coding: iso-8859-1 -*-
+# Copyright (C) 2021  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from omniORB import CORBA
+
+class SALOME_Embedded_NamingService_ClientPy:
+  """
+    A python client class to handle remote servant of SALOME_Embedded_NamingService
+  """
+  #-------------------------------------------------------------------------
+
+  def __init__(self, serv):
+    self._orb=CORBA.ORB_init([''], CORBA.ORB_ID)
+    self._obj = serv
+  #-------------------------------------------------------------------------
+
+  def Register(self,ObjRef, Path):
+    ior = bytes(self._orb.object_to_string(ObjRef),encoding="utf-8")
+    self._obj.Register(ior,Path)
+
+  #-------------------------------------------------------------------------
+
+  def Resolve(self, Path):
+      ret = self._obj.Resolve(Path)
+      return self._orb.string_to_object(ret.decode())
diff --git a/src/NamingService/SALOME_Embedded_NamingService_Common.cxx b/src/NamingService/SALOME_Embedded_NamingService_Common.cxx
new file mode 100644 (file)
index 0000000..46675b4
--- /dev/null
@@ -0,0 +1,48 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SALOME_Embedded_NamingService_Common.hxx"
+#include "SALOME_KernelORB.hxx"
+
+#include <memory>
+#include <cstring>
+
+CORBA::Object_var IORToObject(const Engines::IORType& ObjRef)
+{
+  CORBA::ORB_ptr orb(KERNEL::getORB());
+  CORBA::ULong size(ObjRef.length());
+  std::unique_ptr<char[]> pt(new char[size+1]);
+  pt[size] = '\0';
+  for(CORBA::ULong i = 0 ; i < size ; ++i)
+    pt[i] = ObjRef[i];
+  CORBA::Object_var obj = orb->string_to_object(pt.get());
+  return obj;
+}
+
+Engines::IORType *ObjectToIOR(CORBA::Object_ptr obj)
+{
+  std::unique_ptr<Engines::IORType> ret(new Engines::IORType);
+  CORBA::ORB_ptr orb(KERNEL::getORB());
+  CORBA::String_var ior = orb->object_to_string(obj);
+  auto len( strlen(ior) );
+  ret->length( len );
+  for(std::size_t i = 0 ; i < len ; ++i)
+    (*ret)[i] = ior[i];
+  return ret.release();
+}
diff --git a/src/NamingService/SALOME_Embedded_NamingService_Common.hxx b/src/NamingService/SALOME_Embedded_NamingService_Common.hxx
new file mode 100644 (file)
index 0000000..3707cdd
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include "SALOME_NamingService_defs.hxx"
+
+#include <SALOMEconfig.h>
+
+#include CORBA_CLIENT_HEADER(SALOME_Embedded_NamingService)
+
+CORBA::Object_var IORToObject(const Engines::IORType& ObjRef);
+
+Engines::IORType *ObjectToIOR(CORBA::Object_ptr obj);
index f521034a2a98fa6286b21d76a520860d92532246..e9e19f30d489934edb247937cef95c1ffc612de8 100644 (file)
 
 #include "SALOME_Fake_NamingService.hxx"
 #include "Utils_SALOME_Exception.hxx"
+#include "SALOME_KernelORB.hxx"
+
+#include CORBA_CLIENT_HEADER(SALOME_Component)
+
+#include <sstream>
+#include <fstream>
 
 std::mutex SALOME_Fake_NamingService::_mutex;
 std::map<std::string,CORBA::Object_var> SALOME_Fake_NamingService::_map;
+bool SALOME_Fake_NamingService::_log_container_file_thread_launched = false;
+std::string SALOME_Fake_NamingService::_log_container_file_name;
 
 SALOME_Fake_NamingService::SALOME_Fake_NamingService(CORBA::ORB_ptr orb)
 {
 }
 
+std::vector< std::string > SALOME_Fake_NamingService::repr()
+{
+  std::lock_guard<std::mutex> g(_mutex);
+  std::vector< std::string > ret;
+  for(auto it : _map)
+  {
+    ret.push_back( it.first );
+  }
+  return ret;
+}
+
 void SALOME_Fake_NamingService::init_orb(CORBA::ORB_ptr orb)
 {
 }
@@ -36,6 +55,7 @@ void SALOME_Fake_NamingService::Register(CORBA::Object_ptr ObjRef, const char* P
   std::lock_guard<std::mutex> g(_mutex);
   CORBA::Object_var ObjRefAuto = CORBA::Object::_duplicate(ObjRef);
   _map[Path] = ObjRefAuto;
+  FlushLogContainersFile_NoThreadSafe();
 }
 
 void SALOME_Fake_NamingService::Destroy_Name(const char* Path)
@@ -65,8 +85,14 @@ std::vector<std::string> SALOME_Fake_NamingService::list_directory()
   return std::vector<std::string>();
 }
 
+std::vector<std::string> SALOME_Fake_NamingService::list_directory_recurs()
+{
+  return std::vector<std::string>();
+}
+
 CORBA::Object_ptr SALOME_Fake_NamingService::Resolve(const char* Path)
 {
+  std::lock_guard<std::mutex> g(_mutex);
   std::string pathCpp(Path);
   auto it = _map.find(pathCpp);
   if( it != _map.end() )
@@ -86,5 +112,76 @@ SALOME_NamingService_Abstract *SALOME_Fake_NamingService::clone()
 
 CORBA::Object_ptr SALOME_Fake_NamingService::ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc)
 {
-  THROW_SALOME_EXCEPTION("SALOME_Fake_NamingService::ResolveComponent : " << hostname << " " << containerName << " " << componentName << " " << nbproc);
+  std::ostringstream oss;
+  oss << SEP << "Containers" << SEP << hostname << SEP << containerName << SEP << componentName;
+  std::string entryToFind(oss.str());
+  return Resolve(entryToFind.c_str());
+}
+
+std::vector< std::pair< std::string, Engines::Container_var> > SALOME_Fake_NamingService::ListOfContainersInNS_NoThreadSafe()
+{
+  std::vector< std::pair< std::string, Engines::Container_var> > ret;
+  for(auto it : _map)
+  {
+    Engines::Container_var elt = Engines::Container::_narrow(it.second);
+    if(!CORBA::is_nil(elt))
+      ret.push_back({it.first,elt});
+  }
+  return ret;
+}
+
+std::string SALOME_Fake_NamingService::ReprOfContainersIORS_NoThreadSafe()
+{
+  std::vector< std::pair< std::string, Engines::Container_var> > conts( ListOfContainersInNS_NoThreadSafe() );
+  std::ostringstream oss;
+  CORBA::ORB_ptr orb = KERNEL::getORB();
+  char SEP[2] = { '\0', '\0' };
+  constexpr char SEP2[] = " : ";
+  for(auto it : conts)
+  {
+    CORBA::String_var ior(orb->object_to_string(it.second));
+    oss << SEP << it.first << SEP2 << ior;
+    SEP[0] = '\n';
+  }
+  return oss.str();
+}
+
+std::string SALOME_Fake_NamingService::ReprOfContainersIORS()
+{
+  std::lock_guard<std::mutex> g(_mutex);
+  return ReprOfContainersIORS_NoThreadSafe();
+}
+
+std::string SALOME_Fake_NamingService::GetLogContainersFile()
+{
+  return _log_container_file_name;
+}
+
+void SALOME_Fake_NamingService::FlushLogContainersFile()
+{
+  std::lock_guard<std::mutex> g(_mutex);
+  FlushLogContainersFile_NoThreadSafe();
+}
+
+void SALOME_Fake_NamingService::FlushLogContainersFile_NoThreadSafe()
+{
+  if(!_log_container_file_name.empty())
+  {
+    std::string content( ReprOfContainersIORS_NoThreadSafe() );
+    std::ofstream ofs(_log_container_file_name);
+    ofs.write(content.c_str(),content.length());
+  }
+}
+
+void SALOME_Fake_NamingService::SetLogContainersFile(const std::string& logFileName)
+{
+  if(logFileName.empty())
+    THROW_SALOME_EXCEPTION("SALOME_Fake_NamingService::SetLogContainersFile : empty log name !");
+  constexpr char EXPT_CONTENT[] = "SALOME_Fake_NamingService::SetLogContainersFile : input logFileName write access failed ! no log file set !";
+  {
+    std::ofstream ofs(logFileName);
+    if(!ofs)
+      THROW_SALOME_EXCEPTION(EXPT_CONTENT);
+  }
+  _log_container_file_name = logFileName;
 }
index f60e1480e66cb95df04bb6252080da4ea9e4d494..509c3181f6d70517344e1653d9c5524ca2f6ac69 100644 (file)
 #include "SALOME_NamingService_Abstract.hxx"
 
 #include <mutex>
+#include <utility>
 #include <string>
 #include <map>
 
 class NAMINGSERVICE_EXPORT SALOME_Fake_NamingService : public SALOME_NamingService_Abstract
 {
 public:
-    SALOME_Fake_NamingService(CORBA::ORB_ptr orb);
-    SALOME_Fake_NamingService() = default;
-    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;
-    CORBA::Object_ptr ResolveFirst(const char* Path) override;
-    void Destroy_Name(const char* Path) override;
-    void Destroy_Directory(const char* Path) override;
-    void Destroy_FullDirectory(const char* Path) override;
-    bool Change_Directory(const char* Path) override;
-    std::vector<std::string> list_subdirs() override;
-    std::vector<std::string> list_directory() override;
-    SALOME_NamingService_Abstract *clone() override;
-    CORBA::Object_ptr ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc=0) override;
+  SALOME_Fake_NamingService(CORBA::ORB_ptr orb);
+  SALOME_Fake_NamingService() = default;
+  static void SetLogContainersFile(const std::string& logFileName);
+  static std::string GetLogContainersFile();
+  static void FlushLogContainersFile();
+  std::vector< 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;
+  CORBA::Object_ptr ResolveFirst(const char* Path) override;
+  void Destroy_Name(const char* Path) override;
+  void Destroy_Directory(const char* Path) override;
+  void Destroy_FullDirectory(const char* Path) override;
+  bool Change_Directory(const char* Path) override;
+  std::vector<std::string> list_subdirs() override;
+  std::vector<std::string> list_directory() override;
+  std::vector<std::string> list_directory_recurs() override;
+  SALOME_NamingService_Abstract *clone() override;
+  CORBA::Object_ptr ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc=0) override;
 private:
-    static std::mutex _mutex;
-    static std::map<std::string,CORBA::Object_var> _map;
+  static std::string ReprOfContainersIORS_NoThreadSafe();
+  static std::string ReprOfContainersIORS();
+  static std::vector< std::pair< std::string, Engines::Container_var> > ListOfContainersInNS_NoThreadSafe();
+  static void FlushLogContainersFile_NoThreadSafe();
+private:
+  static std::mutex _mutex;
+  static std::map<std::string,CORBA::Object_var> _map;
+  static bool _log_container_file_thread_launched;
+  static std::string _log_container_file_name;
 };
index 47be7be070bfa8bb3d7e51ce6bda1e9c0e667892..898a83c163bd2dcd6055ca2d028f6ec1061c9242 100644 (file)
@@ -92,10 +92,9 @@ SALOME_NamingService::~SALOME_NamingService()
   //MESSAGE("SALOME_NamingService destruction");
 }
 
-SALOME_NamingService *SALOME_NamingService::GetTraditionalNS(SALOME_NamingService_Abstract *ns)
+std::vector< std::string > SALOME_NamingService::repr()
 {
-  SALOME_NamingService *nsc(dynamic_cast<SALOME_NamingService *>(ns));
-  return nsc;
+  return std::vector< std::string >();
 }
 
 // ============================================================================
@@ -559,64 +558,6 @@ SALOME_NamingService::ResolveComponent(const char* hostname,
     }
 }
 
-// ============================================================================
-/*! \brief build a container name, given a ContainerParameters struct.
- *
- *  Build a container name with a ContainerParameters struct. In case of multi
- *  processor machine, container name is suffixed with number of processors.
- * \param params struct from which we get container name (may be empty) and
- *               number of processors.
- * \return a container name without the path.
- * \sa BuildContainerNameForNS(const Engines::ContainerParameters& params,
- *                             const char *hostname)
- */
-// ============================================================================
-
-std::string SALOME_NamingService::ContainerName(const Engines::ContainerParameters& params)
-{
-  int nbproc;
-
-  if ( !params.isMPI )
-    nbproc = 0;
-  else if ( params.nb_proc <= 0 )
-    nbproc = 1;
-  else
-    nbproc = params.nb_proc;
-
-  std::string ret(SALOME_NamingService_Abstract::ContainerName(params.container_name));
-
-  if ( nbproc >= 1 )
-    {
-          std::ostringstream suffix;
-          suffix << "_" << nbproc;
-      ret += suffix.str();
-    }
-
-  return ret;
-}
-
-// ============================================================================
-/*! \brief build a string representing a container in Naming Service.
- *
- *  Build a string representing the absolute pathname of a container in
- *  SALOME_NamingService.
- * \param params used as it is, or replaced by FactoryServer if empty.
- * \param hostname name of the host of the container, without domain names.
- * \return the path under the form /Containers/hostname/containerName
- * \sa ContainerName(const char *containerName)
- */
-// ============================================================================
-
-std::string SALOME_NamingService::BuildContainerNameForNS(const Engines::ContainerParameters& params, const char *hostname)
-{
-  std::string ret("/Containers/");
-  ret += hostname;
-  ret += "/";
-  ret += ContainerName(params);
-
-  return ret;
-}
-
 // ============================================================================
 /*! \brief search a name in current directory.
  *
index 6599e99c898370d436d989c906dd5b35e39122ca..ec19bb7b7a89f55667d0a73ca9bd4572d6ed3f65 100644 (file)
@@ -51,9 +51,7 @@ public:
   SALOME_NamingService(CORBA::ORB_ptr orb);
 
   virtual ~SALOME_NamingService();
-  
-  static SALOME_NamingService *GetTraditionalNS(SALOME_NamingService_Abstract *ns);
-
+  std::vector< 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; 
@@ -62,8 +60,6 @@ public:
                                      const char* containerName,
                                      const char* componentName,
                                      const int nbproc=0) override;
-  std::string ContainerName(const Engines::ContainerParameters& params);
-  std::string BuildContainerNameForNS(const Engines::ContainerParameters& params, const char *hostname);
 
   int Find(const char* name) ;
   bool Create_Directory(const char* Path) ;
@@ -72,7 +68,7 @@ public:
   void list() ;
   std::vector<std::string> list_directory() override;
   std::vector<std::string> list_subdirs() override;
-  std::vector<std::string> list_directory_recurs() ;
+  std::vector<std::string> list_directory_recurs() override ;
   void Destroy_Name(const char* Path) override;
   void Destroy_Directory(const char* Path) override;
   void Destroy_FullDirectory(const char* Path) override;
diff --git a/src/NamingService/SALOME_NamingService.i b/src/NamingService/SALOME_NamingService.i
deleted file mode 100644 (file)
index 9369d02..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-//  SALOME NamingService : wrapping NamingService services
-//  File   : SALOME_NamingService.i
-//  Author : Paul RASCLE, EDF
-//  Module : SALOME
-//  $Header$
-//
-%{
-#include "SALOME_NamingService.hxx"
-//#include <omniORB4/CORBA.h>
-#include <omniORB3/CORBA.h>
-#include "ServiceUnreachable.hxx"
-%}
-
-%except(python)
-{
-  try 
-    {
-      $function
-    }
-  catch (ServiceUnreachable)
-    {
-      PyErr_SetString(PyExc_IndexError,"Naming Service Unreacheable");
-      return NULL;
-    }
-}
-
-class SALOME_NamingService
-{
-public:
-
-  //! standard constructor
-  SALOME_NamingService();
-
-  //! standard destructor
-  virtual ~SALOME_NamingService();
-
-  //! initialize ORB reference after default constructor
-  void init_orb(CORBA::ORB_ptr orb);
-
-  //! method to create an association in the NamingService between an object reference and a path
-  void Register(CORBA::Object_ptr ObjRef, const char* Path)
-    throw(ServiceUnreachable);
-
-  //! method to get the ObjRef of a symbolic name
-  CORBA::Object_ptr Resolve(const char* Path)
-    throw( ServiceUnreachable);
-
-  //! method to research a name from the naming service's current directory
-  int Find(const char* name)
-    throw(ServiceUnreachable);
-
-  //! method to create a directory from the current directory
-  bool Create_Directory(const char* Path)
-    throw(ServiceUnreachable);
-
-  //! method to change the current directory to the directory Path indicated in "in" Parameter
-  bool Change_Directory(const char* Path)
-    throw(ServiceUnreachable);
-
-  //!method to get the current directory
-  char* Current_Directory()
-    throw(ServiceUnreachable);
-
-  //!method to print all the contexts contained from the current directory
-  void list()
-    throw(ServiceUnreachable);
-
-  //! method to destroy an association Path-Object Reference
-  void Destroy_Name(const char* Path)
-    throw(ServiceUnreachable);
-  //! method to destroy a directory if it is empty
-  virtual void Destroy_Directory(const char* Path)
-    throw(ServiceUnreachable);
-};
-
index 4469dfed101e816cecf7598dadb77f9920f6386d..d77e2af5984fc122cc84dc0b73fe4cebfeb5e8aa 100644 (file)
 //
 
 #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.
@@ -65,3 +79,61 @@ std::string SALOME_NamingService_Abstract::BuildContainerNameForNS(const char *c
 
   return ret;
 }
+
+// ============================================================================
+/*! \brief build a container name, given a ContainerParameters struct.
+ *
+ *  Build a container name with a ContainerParameters struct. In case of multi
+ *  processor machine, container name is suffixed with number of processors.
+ * \param params struct from which we get container name (may be empty) and
+ *               number of processors.
+ * \return a container name without the path.
+ * \sa BuildContainerNameForNS(const Engines::ContainerParameters& params,
+ *                             const char *hostname)
+ */
+// ============================================================================
+
+std::string SALOME_NamingService_Abstract::ContainerName(const Engines::ContainerParameters& params)
+{
+  int nbproc;
+
+  if ( !params.isMPI )
+    nbproc = 0;
+  else if ( params.nb_proc <= 0 )
+    nbproc = 1;
+  else
+    nbproc = params.nb_proc;
+
+  std::string ret(SALOME_NamingService_Abstract::ContainerName(params.container_name));
+
+  if ( nbproc >= 1 )
+    {
+          std::ostringstream suffix;
+          suffix << "_" << nbproc;
+      ret += suffix.str();
+    }
+
+  return ret;
+}
+
+// ============================================================================
+/*! \brief build a string representing a container in Naming Service.
+ *
+ *  Build a string representing the absolute pathname of a container in
+ *  SALOME_NamingService.
+ * \param params used as it is, or replaced by FactoryServer if empty.
+ * \param hostname name of the host of the container, without domain names.
+ * \return the path under the form /Containers/hostname/containerName
+ * \sa ContainerName(const char *containerName)
+ */
+// ============================================================================
+
+std::string SALOME_NamingService_Abstract::BuildContainerNameForNS(const Engines::ContainerParameters& params, const char *hostname)
+{
+  std::string ret("/Containers/");
+  ret += hostname;
+  ret += "/";
+  ret += ContainerName(params);
+
+  return ret;
+}
index ce7301c7909ad9e3baa7a5c06a7457c88c26c614..fdd6ae0d4775879511021845cca60d04b451a5a9 100644 (file)
 
 #include "SALOME_NamingService_defs.hxx"
 
-#include "omniORB4/CORBA.h"
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
+#include CORBA_CLIENT_HEADER(SALOME_Component)
 
 #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 CORBA::Object_ptr Resolve(const char* Path) = 0;
-  virtual CORBA::Object_ptr ResolveFirst(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;
+  static constexpr char SEP = '/';
+};
+
+class NAMINGSERVICE_EXPORT SALOME_NamingService_Abstract : public SALOME_NamingService_Container_Abstract
+{
+public:
+  SALOME_NamingService_Abstract *cloneCoVar();
+  virtual std::vector< 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 SALOME_NamingService_Abstract *clone() = 0;
+  virtual std::vector<std::string> list_directory_recurs() = 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);
   static std::string ContainerName(const char *ContainerName);
   static std::string BuildContainerNameForNS(const char *ContainerName, const char *hostname);
+  static std::string BuildContainerNameForNS(const Engines::ContainerParameters& params, const char *hostname);
 };
index 1a57e5faf2373b77726de1b97c517854ad33555e..5b168e26557d0bc0d8c4567d93b2d8e99666dc21 100644 (file)
@@ -58,7 +58,7 @@ const char *SALOME_ResourcesManager::_ResourcesManagerNameInNS = "/ResourcesMana
 
 SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb,
                                                  PortableServer::POA_var poa,
-                                                 SALOME_NamingService *ns,
+                                                 SALOME_NamingService_Abstract *ns,
                                                  const char *xmlFilePath)
 : _rm(new ResourcesManager_cpp(xmlFilePath))
 {
@@ -94,7 +94,7 @@ SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb,
 
 SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb, 
                                                  PortableServer::POA_var poa, 
-                                                 SALOME_NamingService *ns) : _rm(new ResourcesManager_cpp())
+                                                 SALOME_NamingService_Abstract *ns) : _rm(new ResourcesManager_cpp())
 {
   MESSAGE("SALOME_ResourcesManager constructor");
   _NS = ns;
index e0e362280030d307856b85fdce89dcae33676c92..e309a3cbfc4d699c527f960d70751d441674d55c 100644 (file)
@@ -26,7 +26,7 @@
 #include "Utils_SALOME_Exception.hxx"
 #include "utilities.h"
 #include <SALOMEconfig.h>
-#include "SALOME_NamingService.hxx"
+#include "SALOME_NamingService_Abstract.hxx"
 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
 #include <string>
 #include <fstream>
@@ -53,8 +53,8 @@ class SALOMERESOURCESMANAGER_EXPORT SALOME_ResourcesManager:
 
   public:
 
-    SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns, const char *xmlFilePath);
-    SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns);
+    SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns, const char *xmlFilePath);
+    SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns);
 
     ~SALOME_ResourcesManager();
 
@@ -82,7 +82,7 @@ class SALOMERESOURCESMANAGER_EXPORT SALOME_ResourcesManager:
     static const char *_ResourcesManagerNameInNS;
   protected:
 
-    SALOME_NamingService *_NS;
+    SALOME_NamingService_Abstract *_NS;
     CORBA::ORB_var _orb;
     PortableServer::POA_var _poa;
     std::shared_ptr<ResourcesManager_cpp> _rm;
index 63467c13fc8f5562d0a6cf1a040a809a85e8c22c..e13aeb3f0539eef9d790ad9555a7e401df0070d0 100644 (file)
 
 #include "SALOME_ResourcesManager_Client.hxx"
 #include "SALOME_ResourcesManager.hxx"
+#include "SALOME_NamingService_Abstract.hxx"
 
 using namespace std;
 
-SALOME_ResourcesManager_Client::SALOME_ResourcesManager_Client(SALOME_NamingService *ns)
+SALOME_ResourcesManager_Client::SALOME_ResourcesManager_Client(SALOME_NamingService_Abstract *ns)
   : _rm(Engines::ResourcesManager::_nil())
 {
   CORBA::Object_var objRM = ns->Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
index b81fe8b49455f8f8d1b23547df75ec1bb5405228..792709ade2b4d36ea145613c4f701a4ce3480527 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "SALOME_ResourcesManager_Common.hxx"
 
-class SALOME_NamingService;
+class SALOME_NamingService_Abstract;
 
 // This class is fully thread-safe because the ResourcesManager CORBA object
 // runs in a single-thread POA.
@@ -33,7 +33,7 @@ class SALOMERESOURCESMANAGER_EXPORT SALOME_ResourcesManager_Client
 {
 public:
 
-  SALOME_ResourcesManager_Client(SALOME_NamingService *ns);
+  SALOME_ResourcesManager_Client(SALOME_NamingService_Abstract *ns);
   ~SALOME_ResourcesManager_Client();
 
   std::vector<std::string> GetFittingResources(const resourceParams& params);
index 693f257ffb99eb5450e5cd6dc2e4173aec4daeac..3ea2c2761c18540c9e3f8d7b5444b9d3acfac04d 100644 (file)
@@ -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()