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
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):
"""
${CMAKE_CURRENT_SOURCE_DIR}/../Container
${CMAKE_CURRENT_SOURCE_DIR}/../ResourcesManager
${CMAKE_CURRENT_SOURCE_DIR}/../KernelHelpers
+ ${CMAKE_CURRENT_SOURCE_DIR}/../Basics
${CMAKE_CURRENT_SOURCE_DIR}
)
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})
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)
{
}
///////
-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)
{
}
////////
-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));
#include <vector>
#include <list>
-class SALOME_NamingService_Abstract;
+class SALOME_NamingService_Container_Abstract;
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();
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;
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);
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);
#include "SALOME_ContainerManager.hxx"
#include "SALOME_NamingService.hxx"
+#include "SALOME_Embedded_NamingService.hxx"
+#include "KernelBasis.hxx"
#include <sstream>
#include <algorithm>
}
//
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()));
//
// 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 !");
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); });
}
-
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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); });
+}