1 // Copyright (C) 2021 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony GEAY (EDF R&D)
21 #include "SALOMESDS_DataScopeServer.hxx"
22 #include "SALOMESDS_DataServerManager.hxx"
23 #include "SALOMESDS_Exception.hxx"
24 #include "SALOME_CPythonHelper.hxx"
25 #include "SALOME_NamingService_Abstract.hxx"
31 CORBA::ORB_var GetCustomORB()
36 char **argv=new char *[3];
37 char *p0(strdup("DTC")),*p1(strdup("-ORBsupportCurrent")),*p2(strdup("0"));
39 argv[1]=p1;// by disabling supportCurrent it make the POAManager::hold_requests work !
41 orb=CORBA::ORB_init(argc,argv);
42 free(p0); free(p1); free(p2);
48 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)
50 CORBA::Object_var obj(orb->resolve_initial_references("RootPOA"));
51 PortableServer::POA_var poa(PortableServer::POA::_narrow(obj));
52 PortableServer::POAManager_var mgr(poa->the_POAManager());
55 SALOMESDS::DataScopeKiller *killer(new SALOMESDS::DataScopeKiller(orb));
56 SALOME::DataScopeKiller_var killerObj(killer->_this());
58 SALOME_CPythonHelper cPyHelper;
59 cPyHelper.initializePython(argc,argv);
61 SALOMESDS::DataScopeServerBase *server(nullptr);
63 server=new SALOMESDS::DataScopeServer(&cPyHelper,orb,killerObj,scopeName,nsGenrator(orb));
65 server=new SALOMESDS::DataScopeServerTransaction(&cPyHelper,orb,killerObj,scopeName,nsGenrator(orb));
67 CORBA::PolicyList policies;
69 PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
70 policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
71 policies[1]=poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION);
72 policies[2]=poa->create_id_uniqueness_policy(PortableServer::UNIQUE_ID);
73 PortableServer::POA_var poa2(poa->create_POA("SingleThPOA4SDS",mgr,policies));
75 server->registerToSalomePiDict();
78 obj=server->activate();
79 SALOME::DataScopeServerBase_var serverPtr(SALOME::DataScopeServerBase::_narrow(obj));
80 server->registerInNS(serverPtr);