1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "SALOME_Launcher.hxx"
24 #include "SALOMESDS_DataServerManager.hxx"
25 #include "utilities.h"
29 #include <libxml/parser.h>
31 void AttachDebugger();
32 void terminateHandler(void);
33 void unexpectedHandler(void);
38 if(getenv ("DEBUGGER"))
40 std::stringstream exec;
41 exec << "$DEBUGGER SALOME_LauncherServer " << getpid() << "&";
42 MESSAGE ( exec.str() );
43 system(exec.str().c_str());
49 void terminateHandler(void)
51 MESSAGE ( "Terminate: not managed exception !" );
55 void unexpectedHandler(void)
57 MESSAGE ( "Unexpected: unexpected exception !" );
62 int main(int argc, char* argv[])
64 if(getenv ("DEBUGGER"))
66 // setsig(SIGSEGV,&Handler);
67 std::set_terminate(&terminateHandler);
68 std::set_unexpected(&unexpectedHandler);
71 * To avoid memory leak, need to call xmlInitParser in the main thread
72 * and not call xmlCleanupParser later (cause implicit reinitialization in thread)
76 PortableServer::POA_var root_poa;
77 PortableServer::POAManager_var pman;
78 CORBA::Object_var obj;
82 char **myArgv(new char *[myArgc]);
83 for(int i=0;i<argc;i++)
84 myArgv[i]=strdup(argv[i]);
85 myArgv[argc+0]=strdup("-ORBsupportCurrent");
86 myArgv[argc+1]=strdup("0");
87 orb = CORBA::ORB_init( myArgc , myArgv ) ;
88 for(int i=0;i<myArgc;i++)
92 // LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
96 obj = orb->resolve_initial_references("RootPOA");
97 if(!CORBA::is_nil(obj))
98 root_poa = PortableServer::POA::_narrow(obj);
99 if(!CORBA::is_nil(root_poa))
101 pman = root_poa->the_POAManager();
105 catch(CORBA::COMM_FAILURE&){
106 MESSAGE( "Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" );
110 CORBA::PolicyList policies;
112 PortableServer::ThreadPolicy_var threadPol(root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
113 policies[0] = PortableServer::ThreadPolicy::_duplicate(threadPol);
114 PortableServer::POA_var safePOA = root_poa->create_POA("SingleThreadPOA",pman,policies);
115 threadPol->destroy();
117 SALOME_Launcher *lServ(new SALOME_Launcher(orb,safePOA));
118 lServ->_remove_ref();
120 SALOMESDS::DataServerManager *dsm(new SALOMESDS::DataServerManager(argc,argv,orb,root_poa));
127 catch(CORBA::SystemException&){
128 MESSAGE("Caught CORBA::SystemException.");
129 }catch(PortableServer::POA::WrongPolicy&){
130 MESSAGE("Caught CORBA::WrongPolicyException.");
131 }catch(PortableServer::POA::ServantAlreadyActive&){
132 MESSAGE("Caught CORBA::ServantAlreadyActiveException");
133 }catch(CORBA::Exception&){
134 MESSAGE("Caught CORBA::Exception.");
135 }catch(std::exception& exc){
136 MESSAGE("Caught std::exception - "<<exc.what());
138 MESSAGE("Caught unknown exception.");
141 // delete myThreadTrace;