Salome HOME
YACS in SSL mode
[modules/kernel.git] / src / Launcher / SALOME_Launcher.cxx
index 0698b184f26f4ef24b46cf5fd1e99edadd5bfe07..11d16abac88d8c318034719f6e118bd37b7cf43b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
+// 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
@@ -58,10 +58,21 @@ const char *SALOME_Launcher::_LauncherNameInNS = "/SalomeLauncher";
  *  \param orb
  */
 //=============================================================================
-SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa) : _l()
+SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa)
 {
   MESSAGE("SALOME_Launcher constructor");
   _NS = new SALOME_NamingService(orb);
+  init(orb,poa);
+  MESSAGE("SALOME_Launcher constructor end");
+}
+
+SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *externalNS):_NS(externalNS)
+{
+  init(orb,poa);
+}
+
+void SALOME_Launcher::init(CORBA::ORB_ptr orb, PortableServer::POA_var poa)
+{
   _ResManager = new SALOME_ResourcesManager(orb,poa,_NS);
   _l.SetResourcesManager(_ResManager->GetImpl());
   _ContManager = new SALOME_ContainerManager(orb,poa,_NS);
@@ -73,9 +84,7 @@ SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa
   PortableServer::ObjectId_var id = _poa->activate_object(this);
   CORBA::Object_var obj = _poa->id_to_reference(id);
   Engines::SalomeLauncher_var refContMan = Engines::SalomeLauncher::_narrow(obj);
-
   _NS->Register(refContMan,_LauncherNameInNS);
-  MESSAGE("SALOME_Launcher constructor end");
 }
 
 //=============================================================================
@@ -232,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)
 {
@@ -373,6 +387,8 @@ SALOME_Launcher::testBatch(const Engines::ResourceParameters& params)
 void SALOME_Launcher::Shutdown()
 {
   MESSAGE("Shutdown");
+  if(!_NS)
+    return;
   _NS->Destroy_Name(_LauncherNameInNS);
   _ContManager->Shutdown();
   _ResManager->Shutdown();
@@ -691,3 +707,20 @@ SALOME_Launcher::JobParameters_CPP2CORBA(const JobParameters_cpp& job_parameters
   result->launcher_args = CORBA::string_dup(job_parameters.launcher_args.c_str());
   return result;
 }
+
+static SALOME_Launcher *_launcher_singleton_ssl = nullptr;
+
+#include "SALOME_Fake_NamingService.hxx"
+
+SALOME_Launcher *KERNEL::getLauncherSA()
+{
+  if(!_launcher_singleton_ssl)
+  {
+    int argc(0);
+    CORBA::ORB_var orb = CORBA::ORB_init(argc,nullptr);
+    PortableServer::POA_var root_poa=PortableServer::POA::_the_root_poa();
+    SALOME_Fake_NamingService *ns=new SALOME_Fake_NamingService(orb);
+    _launcher_singleton_ssl = new SALOME_Launcher(orb,root_poa,ns);//3rd arg is important to skip NS !
+  }
+  return _launcher_singleton_ssl;
+}