Salome HOME
WIP
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 17 Aug 2021 14:31:23 +0000 (16:31 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 17 Aug 2021 14:31:23 +0000 (16:31 +0200)
src/KERNEL_PY/__init__.py
src/SALOMESDS/CMakeLists.txt
src/SALOMESDS/SALOMESDS_DataScopeServer.cxx
src/SALOMESDS/SALOMESDS_DataScopeServer.hxx
src/SALOMESDS/SALOMESDS_DataServerManager.cxx
src/SALOMESDS/SALOME_DataScopeServer.cxx
src/SALOMESDS/SALOME_DataScopeServer_Common.cxx [new file with mode: 0644]
src/SALOMESDS/SALOME_DataScopeServer_SSL.cxx [new file with mode: 0644]

index 5c0900e62689a9a8faecc18f3c7453475faacbfa..bf37b0b8f34691a1a0f5e95fe61d9d8972fee849 100644 (file)
@@ -204,7 +204,7 @@ class StandAloneLifecyle:
       return self._rm
 
 def salome_init_without_session():
-    global lcc,naming_service,myStudy,orb,modulcat,sg,cm
+    global lcc,naming_service,myStudy,orb,modulcat,sg,cm,dsm
     import KernelBasis
     KernelBasis.setSSLMode(True)
     import KernelDS
@@ -226,6 +226,8 @@ def salome_init_without_session():
     sg = SalomeOutsideGUI()
     salome_study_init_without_session()
     naming_service = NamingService()
+    from KernelSDS import GetDSMInstance
+    dsm = GetDSMInstance()
 
 def salome_init_with_session(path=None, embedded=False):
     """
index c3195be20c88ca131cb7dfc7d9dad9f2ea43006b..14a3f7d9f3f8993c0a303ce31bf0d79a12f16b02 100644 (file)
@@ -32,6 +32,7 @@ INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_SOURCE_DIR}/../Container
   ${CMAKE_CURRENT_SOURCE_DIR}/../ResourcesManager
   ${CMAKE_CURRENT_SOURCE_DIR}/../KernelHelpers
+  ${CMAKE_CURRENT_SOURCE_DIR}/../Basics
   ${CMAKE_CURRENT_SOURCE_DIR}
 )
 
@@ -62,7 +63,9 @@ INSTALL(TARGETS SalomeSDS EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME
 
 ADD_EXECUTABLE(SALOME_DataScopeServer SALOME_DataScopeServer.cxx)
 TARGET_LINK_LIBRARIES(SALOME_DataScopeServer SalomeSDS)
-INSTALL(TARGETS SALOME_DataScopeServer DESTINATION ${SALOME_INSTALL_BINS})
+ADD_EXECUTABLE(SALOME_DataScopeServer_SSL SALOME_DataScopeServer_SSL.cxx)
+TARGET_LINK_LIBRARIES(SALOME_DataScopeServer_SSL SalomeSDS)
+INSTALL(TARGETS SALOME_DataScopeServer SALOME_DataScopeServer_SSL DESTINATION ${SALOME_INSTALL_BINS})
 INSTALL(FILES SalomeSDSClt.py SALOMEWrappedStdType.py DESTINATION ${SALOME_INSTALL_BINS})
 FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
 INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
index b6c961a275d57acf4381a826027fe2a65c974646..fa7d04a9e3b6fba42781c7fb1d593ec2414affa7 100644 (file)
@@ -71,11 +71,11 @@ void RequestSwitcher::fetchAndGetAccessOfVar(const char *varName, CORBA::String_
   return _ds->fetchAndGetAccessOfVar(varName,access,data);
 }
 
-DataScopeServerBase::DataScopeServerBase(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName, SALOME_NamingService_Abstract *ns):_ns(ns),_pyHelper(pyHelper),_orb(CORBA::ORB::_duplicate(orb)),_name(scopeName),_killer(killer)
+DataScopeServerBase::DataScopeServerBase(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName, SALOME_NamingService_Container_Abstract *ns):_ns(ns),_pyHelper(pyHelper),_orb(CORBA::ORB::_duplicate(orb)),_name(scopeName),_killer(killer)
 {
 }
 
-DataScopeServerBase::DataScopeServerBase(const DataScopeServerBase& other):omniServant(other),ServantBase(other),_ns(other._ns->cloneCoVar()),_pyHelper(other._pyHelper),_name(other._name),_vars(other._vars),_killer(other._killer)
+DataScopeServerBase::DataScopeServerBase(const DataScopeServerBase& other):omniServant(other),ServantBase(other),_ns(other._ns->clone()),_pyHelper(other._pyHelper),_name(other._name),_vars(other._vars),_killer(other._killer)
 {
 }
 
@@ -473,7 +473,7 @@ std::list< std::pair< SALOME::BasicDataServer_var, BasicDataServer * > >::iterat
 
 ///////
 
-DataScopeServer::DataScopeServer(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName, SALOME_NamingService_Abstract *ns):DataScopeServerBase(pyHelper,orb,killer,scopeName,ns)
+DataScopeServer::DataScopeServer(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName, SALOME_NamingService_Container_Abstract *ns):DataScopeServerBase(pyHelper,orb,killer,scopeName,ns)
 {
 }
 
@@ -520,7 +520,7 @@ DataScopeServer::~DataScopeServer()
 
 ////////
 
-DataScopeServerTransaction::DataScopeServerTransaction(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName, SALOME_NamingService_Abstract *ns):DataScopeServerBase(pyHelper,orb,killer,scopeName,ns)
+DataScopeServerTransaction::DataScopeServerTransaction(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName, SALOME_NamingService_Container_Abstract *ns):DataScopeServerBase(pyHelper,orb,killer,scopeName,ns)
 {
   CORBA::Object_var obj(_orb->resolve_initial_references("RootPOA"));
   PortableServer::POA_var poa(PortableServer::POA::_narrow(obj));
index a705946a1d1cd10eb4e295d298ac03e6ef5eb861..e6e466f7b67fc94df537a7a2723cc5662d10771a 100644 (file)
@@ -38,7 +38,7 @@
 #include <vector>
 #include <list>
 
-class SALOME_NamingService_Abstract;
+class SALOME_NamingService_Container_Abstract;
 
 namespace SALOMESDS
 {
@@ -75,7 +75,7 @@ namespace SALOMESDS
   class SALOMESDS_EXPORT DataScopeServerBase : public virtual POA_SALOME::DataScopeServerBase, public POAHolder
   {
   public:
-    DataScopeServerBase(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName, SALOME_NamingService_Abstract *ns);
+    DataScopeServerBase(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName, SALOME_NamingService_Container_Abstract *ns);
     DataScopeServerBase(const DataScopeServerBase& other);
   public: // remote access methods
     void ping();
@@ -117,7 +117,7 @@ namespace SALOMESDS
     std::list< std::pair< SALOME::BasicDataServer_var, BasicDataServer * > >::const_iterator retrieveVarInternal3(const std::string& varName) const;
     std::list< std::pair< SALOME::BasicDataServer_var, BasicDataServer * > >::iterator retrieveVarInternal4(const std::string& varName);
   protected:
-    SALOME_NamingService_Abstract *_ns = nullptr;
+    SALOME_NamingService_Container_Abstract *_ns = nullptr;
     const SALOME_CPythonHelper *_pyHelper = nullptr;
     PortableServer::POA_var _poa;
     CORBA::ORB_var _orb;
@@ -130,7 +130,7 @@ namespace SALOMESDS
   class SALOMESDS_EXPORT DataScopeServer : public DataScopeServerBase, public virtual POA_SALOME::DataScopeServer
   {
   public:
-    DataScopeServer(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName, SALOME_NamingService_Abstract *ns);
+    DataScopeServer(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName, SALOME_NamingService_Container_Abstract *ns);
     DataScopeServer(const DataScopeServer& other);
     SALOME::BasicDataServer_ptr retrieveVar(const char *varName) { return retrieveVarInternal(varName); }
     SALOME::PickelizedPyObjRdOnlyServer_ptr createRdOnlyVar(const char *varName, const SALOME::ByteVec& constValue);
@@ -142,7 +142,7 @@ namespace SALOMESDS
   class SALOMESDS_EXPORT DataScopeServerTransaction : public DataScopeServerBase, public virtual POA_SALOME::DataScopeServerTransaction
   {
   public://not remotely callable
-    DataScopeServerTransaction(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName, SALOME_NamingService_Abstract *ns);
+    DataScopeServerTransaction(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName, SALOME_NamingService_Container_Abstract *ns);
     DataScopeServerTransaction(const DataScopeServerTransaction& other);
     ~DataScopeServerTransaction();
     void createRdOnlyVarInternal(const std::string& varName, const SALOME::ByteVec& constValue);
index 2c2d9b277ff75d117f8dd570e2bf62a1fee1778d..55a6c02365017230f10d268d59d56ba68bae982b 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "SALOME_ContainerManager.hxx"
 #include "SALOME_NamingService.hxx"
+#include "SALOME_Embedded_NamingService.hxx"
+#include "KernelBasis.hxx"
 
 #include <sstream>
 #include <algorithm>
@@ -131,8 +133,19 @@ typename T::PtrType CreateDataScope(const std::string& scopeName, const std::vec
     }
   //
   std::string fullScopeName(DataServerManager::CreateAbsNameInNSFromScopeName(scopeName));
-  std::ostringstream oss; oss << "SALOME_DataScopeServer" << " " << scopeName << " " << isTransactionInt << " ";
-  SALOME_ContainerManager::AddOmninamesParams(oss,&ns);
+  std::ostringstream oss; 
+  if(!getSSLMode())
+  {
+    oss << "SALOME_DataScopeServer" << " " << scopeName << " " << isTransactionInt << " ";
+    SALOME_ContainerManager::AddOmninamesParams(oss,&ns);
+  }
+  else
+  {
+     oss << "SALOME_DataScopeServer_SSL" << " " << scopeName << " " << isTransactionInt << " ";
+     Engines::EmbeddedNamingService_var emb = GetEmbeddedNamingService();
+     CORBA::String_var ior = orb->object_to_string(emb);
+     oss << ior.in();
+  }
   std::string command(oss.str());
   SALOME_ContainerManager::MakeTheCommandToBeLaunchedASync(command);
   int status(SALOME_ContainerManager::SystemThreadSafe(command.c_str()));
index e2daee44aff68148ee33d85b1bc979aceda7a9f1..5f265ad3054103344883ca303e14340ddf594444 100644 (file)
 //
 // Author : Anthony GEAY (EDF R&D)
 
-#include "SALOMESDS_DataScopeServer.hxx"
-#include "SALOMESDS_DataServerManager.hxx"
-#include "SALOMESDS_Exception.hxx"
-#include "SALOME_CPythonHelper.hxx"
+#include "SALOME_DataScopeServer_Common.cxx"
 
 #include "SALOME_NamingService.hxx"
 
-#include <string>
-#include <sstream>
-
 int main(int argc, char *argv[])
 {
+  CORBA::ORB_var orb = GetCustomORB();
   std::string scopeName;
   if(argc<=1)
     throw SALOMESDS::Exception("In the main of SALOME_DataScopeServer.cxx !");
@@ -37,52 +32,5 @@ int main(int argc, char *argv[])
   std::istringstream isTransacSS(argv[2]);
   int isTransac(0);
   isTransacSS >> isTransac;
-  CORBA::ORB_var orb;
-  {
-    int argc(3);
-    char **argv=new char *[3];
-    char *p0(strdup("DTC")),*p1(strdup("-ORBsupportCurrent")),*p2(strdup("0"));
-    argv[0]=p0;
-    argv[1]=p1;// by disabling supportCurrent it make the POAManager::hold_requests work !
-    argv[2]=p2;
-    orb=CORBA::ORB_init(argc,argv);
-    free(p0); free(p1); free(p2);
-    delete [] argv;
-  }
-  CORBA::Object_var obj(orb->resolve_initial_references("RootPOA"));
-  PortableServer::POA_var poa(PortableServer::POA::_narrow(obj));
-  PortableServer::POAManager_var mgr(poa->the_POAManager());
-  mgr->activate();
-  //
-  SALOMESDS::DataScopeKiller *killer(new SALOMESDS::DataScopeKiller(orb));
-  SALOME::DataScopeKiller_var killerObj(killer->_this());
-  //
-  SALOME_CPythonHelper cPyHelper;
-  cPyHelper.initializePython(argc,argv);
-  //
-  SALOMESDS::DataScopeServerBase *server(nullptr);
-  if(!isTransac)
-    server=new SALOMESDS::DataScopeServer(&cPyHelper,orb,killerObj,scopeName,new SALOME_NamingService(orb));
-  else
-    server=new SALOMESDS::DataScopeServerTransaction(&cPyHelper,orb,killerObj,scopeName,new SALOME_NamingService(orb));
-  //
-  CORBA::PolicyList policies;
-  policies.length(3);
-  PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
-  policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
-  policies[1]=poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION);
-  policies[2]=poa->create_id_uniqueness_policy(PortableServer::UNIQUE_ID);
-  PortableServer::POA_var poa2(poa->create_POA("SingleThPOA4SDS",mgr,policies));
-  threadPol->destroy();
-  server->registerToSalomePiDict();
-  //
-  server->setPOA(poa2);
-  obj=server->activate();
-  SALOME::DataScopeServerBase_var serverPtr(SALOME::DataScopeServerBase::_narrow(obj));
-  server->registerInNS(serverPtr);
-  //
-  orb->run();
-  delete killer;
-  return 0;
+  return CommonDataScopeServerMain(argc,argv,orb,scopeName,isTransac,[](CORBA::ORB_ptr orb2) { return new SALOME_NamingService(orb2); });
 }
-
diff --git a/src/SALOMESDS/SALOME_DataScopeServer_Common.cxx b/src/SALOMESDS/SALOME_DataScopeServer_Common.cxx
new file mode 100644 (file)
index 0000000..cf77e09
--- /dev/null
@@ -0,0 +1,85 @@
+// Copyright (C) 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 : Anthony GEAY (EDF R&D)
+
+#include "SALOMESDS_DataScopeServer.hxx"
+#include "SALOMESDS_DataServerManager.hxx"
+#include "SALOMESDS_Exception.hxx"
+#include "SALOME_CPythonHelper.hxx"
+#include "SALOME_NamingService_Abstract.hxx"
+
+#include <string>
+#include <sstream>
+#include <functional>
+
+CORBA::ORB_var GetCustomORB()
+{
+  CORBA::ORB_var orb;
+  {
+    int argc(3);
+    char **argv=new char *[3];
+    char *p0(strdup("DTC")),*p1(strdup("-ORBsupportCurrent")),*p2(strdup("0"));
+    argv[0]=p0;
+    argv[1]=p1;// by disabling supportCurrent it make the POAManager::hold_requests work !
+    argv[2]=p2;
+    orb=CORBA::ORB_init(argc,argv);
+    free(p0); free(p1); free(p2);
+    delete [] argv;
+  }
+  return orb;
+}
+
+int CommonDataScopeServerMain(int argc, char *argv[], CORBA::ORB_var orb, const std::string& scopeName, int isTransac, std::function<SALOME_NamingService_Container_Abstract *(CORBA::ORB_ptr)> nsGenrator)
+{
+  CORBA::Object_var obj(orb->resolve_initial_references("RootPOA"));
+  PortableServer::POA_var poa(PortableServer::POA::_narrow(obj));
+  PortableServer::POAManager_var mgr(poa->the_POAManager());
+  mgr->activate();
+  //
+  SALOMESDS::DataScopeKiller *killer(new SALOMESDS::DataScopeKiller(orb));
+  SALOME::DataScopeKiller_var killerObj(killer->_this());
+  //
+  SALOME_CPythonHelper cPyHelper;
+  cPyHelper.initializePython(argc,argv);
+  //
+  SALOMESDS::DataScopeServerBase *server(nullptr);
+  if(!isTransac)
+    server=new SALOMESDS::DataScopeServer(&cPyHelper,orb,killerObj,scopeName,nsGenrator(orb));
+  else
+    server=new SALOMESDS::DataScopeServerTransaction(&cPyHelper,orb,killerObj,scopeName,nsGenrator(orb));
+  //
+  CORBA::PolicyList policies;
+  policies.length(3);
+  PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
+  policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
+  policies[1]=poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION);
+  policies[2]=poa->create_id_uniqueness_policy(PortableServer::UNIQUE_ID);
+  PortableServer::POA_var poa2(poa->create_POA("SingleThPOA4SDS",mgr,policies));
+  threadPol->destroy();
+  server->registerToSalomePiDict();
+  //
+  server->setPOA(poa2);
+  obj=server->activate();
+  SALOME::DataScopeServerBase_var serverPtr(SALOME::DataScopeServerBase::_narrow(obj));
+  server->registerInNS(serverPtr);
+  //
+  orb->run();
+  delete killer;
+  return 0;
+}
diff --git a/src/SALOMESDS/SALOME_DataScopeServer_SSL.cxx b/src/SALOMESDS/SALOME_DataScopeServer_SSL.cxx
new file mode 100644 (file)
index 0000000..ebd8f1e
--- /dev/null
@@ -0,0 +1,44 @@
+// 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 : Anthony GEAY (EDF R&D)
+
+#include "SALOME_DataScopeServer_Common.cxx"
+
+#include "SALOME_Embedded_NamingService_Client.hxx"
+#include "Utils_SALOME_Exception.hxx"
+
+int main(int argc, char *argv[])
+{
+  CORBA::ORB_var orb = GetCustomORB();
+  std::string scopeName;
+  if(argc<=2)
+    throw SALOMESDS::Exception("In the main of SALOME_DataScopeServer.cxx !");
+  scopeName=argv[1];
+  std::istringstream isTransacSS(argv[2]);
+  int isTransac(0);
+  isTransacSS >> isTransac;
+  std::string IORFakeNS(argv[3]);
+  CORBA::Object_var ns_serv_obj_base = orb->string_to_object(IORFakeNS.c_str());
+  if( CORBA::is_nil(ns_serv_obj_base) )
+    THROW_SALOME_EXCEPTION( "SALOME_DataScopeServer_SSL : argument 3 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_DataScopeServer_SSL : argument 3 is NOT a valid IOR of Engines::EmbeddedNamingService" );
+  return CommonDataScopeServerMain(argc,argv,orb,scopeName,isTransac,[ns_serv_obj](CORBA::ORB_ptr orb) { return new SALOME_Embedded_NamingService_Client(ns_serv_obj); });
+}