]> SALOME platform Git repositories - modules/kernel.git/blobdiff - src/Launcher/SALOME_LauncherServer.cxx
Salome HOME
Compilation under Windows: add missing header
[modules/kernel.git] / src / Launcher / SALOME_LauncherServer.cxx
index d1ffcb03b1f57dc1b02dff69bcceb90995d806e0..4692f5e2b8638790b68d98fa08fcb14b0f0b4270 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  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
@@ -22,6 +22,8 @@
 
 #include "SALOME_Launcher.hxx"
 #include "SALOMESDS_DataServerManager.hxx"
+#include "SALOME_ExternalServerLauncher.hxx"
+#include "SALOME_CPythonHelper.hxx"
 #include "utilities.h"
 #include <sstream>
 #include <iostream>
@@ -65,7 +67,7 @@ int main(int argc, char* argv[])
     {
 //       setsig(SIGSEGV,&Handler);
       std::set_terminate(&terminateHandler);
-      std::set_unexpected(&unexpectedHandler);
+      //std::set_unexpected(&unexpectedHandler);
     }
   /* Init libxml 
    * To avoid memory leak, need to call xmlInitParser in the main thread
@@ -76,8 +78,19 @@ int main(int argc, char* argv[])
   PortableServer::POA_var root_poa;
   PortableServer::POAManager_var pman;
   CORBA::Object_var obj;
-
-  CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
+  CORBA::ORB_var orb;
+  {
+    int myArgc(argc+2);
+    char **myArgv(new char *[myArgc]);
+    for(int i=0;i<argc;i++)
+      myArgv[i]=strdup(argv[i]);
+    myArgv[argc+0]=strdup("-ORBsupportCurrent");
+    myArgv[argc+1]=strdup("0");
+    orb = CORBA::ORB_init( myArgc , myArgv ) ;
+    for(int i=0;i<myArgc;i++)
+      free(myArgv[i]);
+    delete [] myArgv;
+  }
   //  LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
   INFOS_COMPILATION;
   BEGIN_OF(argv[0]);
@@ -96,12 +109,24 @@ int main(int argc, char* argv[])
   }
   try
     {
-      SALOME_Launcher *lServ(new SALOME_Launcher(orb,root_poa));
+      CORBA::PolicyList policies;
+      policies.length(1);
+      PortableServer::ThreadPolicy_var threadPol(root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
+      policies[0] = PortableServer::ThreadPolicy::_duplicate(threadPol);
+      PortableServer::POA_var safePOA = root_poa->create_POA("SingleThreadPOA",pman,policies);
+      threadPol->destroy();
+      SALOME_CPythonHelper cPyh;
+      cPyh.initializePython(argc,argv);
+      SALOME_Launcher *lServ(new SALOME_Launcher(orb,safePOA));
+      lServ->DeclareUsingSalomeSession();
       lServ->_remove_ref();
       //
-      SALOMESDS::DataServerManager *dsm(new SALOMESDS::DataServerManager(argc,argv,orb,root_poa));
+      SALOMESDS::DataServerManager *dsm(new SALOMESDS::DataServerManager(&cPyh,orb,root_poa));
       dsm->_remove_ref();
       //
+      SALOME_ExternalServerLauncher *esm(new SALOME_ExternalServerLauncher(&cPyh,orb,safePOA));
+      esm->_remove_ref();
+      //
       orb->run();
       orb->destroy();
     }