X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSALOMESDS%2FSALOME_DataScopeServer.cxx;h=e2daee44aff68148ee33d85b1bc979aceda7a9f1;hb=f4fd1701433a617d0a8789cf5e90c78029842d4c;hp=a5061c38402b0d73359328fe0d67f48a384866de;hpb=09dcd16dea7c5439cdd708de6824237ea4382fb9;p=modules%2Fkernel.git diff --git a/src/SALOMESDS/SALOME_DataScopeServer.cxx b/src/SALOMESDS/SALOME_DataScopeServer.cxx index a5061c384..e2daee44a 100644 --- a/src/SALOMESDS/SALOME_DataScopeServer.cxx +++ b/src/SALOMESDS/SALOME_DataScopeServer.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// 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 @@ -21,6 +21,7 @@ #include "SALOMESDS_DataScopeServer.hxx" #include "SALOMESDS_DataServerManager.hxx" #include "SALOMESDS_Exception.hxx" +#include "SALOME_CPythonHelper.hxx" #include "SALOME_NamingService.hxx" @@ -33,28 +34,55 @@ int main(int argc, char *argv[]) if(argc<=1) throw SALOMESDS::Exception("In the main of SALOME_DataScopeServer.cxx !"); scopeName=argv[1]; - CORBA::ORB_var orb(CORBA::ORB_init(argc,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::DataScopeServer *server(new SALOMESDS::DataScopeServer(orb,scopeName)); + // + 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(1); + 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->initializePython(argc,argv);// agy : Very important ! invoke this method BEFORE activation ! server->registerToSalomePiDict(); - PortableServer::ObjectId_var id(poa2->activate_object(server)); - obj=poa2->id_to_reference(id); - SALOME::DataScopeServer_var serverPtr(SALOME::DataScopeServer::_narrow(obj)); - server->setPOAAndRegister(poa2,serverPtr); + // + server->setPOA(poa2); + obj=server->activate(); + SALOME::DataScopeServerBase_var serverPtr(SALOME::DataScopeServerBase::_narrow(obj)); + server->registerInNS(serverPtr); // orb->run(); - server->_remove_ref(); + delete killer; return 0; }