1 // SALOME Container : implementation of container and engine for Kernel
3 // Copyright (C) 2003 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.
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOME_Container.cxx
25 // Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
33 //#include "Utils_ORB_INIT.hxx"
34 //#include "Utils_SINGLETON.hxx"
36 #include "SALOME_NamingService.hxx"
37 #include "SALOME_Container_i.hxx"
38 #include "utilities.h"
39 #include "SALOMETraceCollector.hxx"
43 #include <Utils_Timer.hxx>
50 #include "Container_init_python.hxx"
54 extern "C" void HandleServerSideSignals(CORBA::ORB_ptr theORB);
56 int main(int argc, char* argv[])
59 MPI_Init(&argc,&argv);
61 // Initialise the ORB.
62 CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
63 SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
69 bool isSupervContainer = false;
70 if (strcmp(argv[1],"SuperVisionContainer") == 0) isSupervContainer = true;
72 if (!isSupervContainer)
76 KERNEL_PYTHON::init_python(argc,argv);
81 PySys_SetArgv( argc , argv ) ;
85 // Obtain a reference to the root POA.
86 // obtain the root poa manager
88 long TIMESleep = 500000000;
89 int NumberOfTries = 40;
92 ts_req.tv_nsec=TIMESleep;
97 CosNaming::NamingContext_var inc;
98 PortableServer::POA_var root_poa;
99 CORBA::Object_var theObj;
100 CORBA::Object_var obj;
101 CORBA::Object_var object;
102 //SALOME_NamingService &naming = *SINGLETON_<SALOME_NamingService>::Instance() ;
104 const char * Env = getenv("USE_LOGGER");
106 if(Env != NULL && strlen(Env))
109 CosNaming::Name name;
111 name[0].id=CORBA::string_dup("Logger");
112 PortableServer::POAManager_var pman;
113 for(int i = 1; i <= NumberOfTries; i++){
115 a=nanosleep(&ts_req,&ts_rem);
117 obj = orb->resolve_initial_references("RootPOA");
118 if(!CORBA::is_nil(obj))
119 root_poa = PortableServer::POA::_narrow(obj);
120 if(!CORBA::is_nil(root_poa))
121 pman = root_poa->the_POAManager();
122 if(!CORBA::is_nil(orb))
123 theObj = orb->resolve_initial_references("NameService");
124 if (!CORBA::is_nil(theObj))
125 inc = CosNaming::NamingContext::_narrow(theObj);
126 }catch(CORBA::SystemException&){
127 MESSAGE( "Container: CORBA::SystemException: Unable to contact the Naming Service" );
129 if(!CORBA::is_nil(inc)){
130 MESSAGE( "Container: Naming Service was found" );
132 for(int j = 1; j <= NumberOfTries; j++){
134 a=nanosleep(&ts_req, &ts_rem);
136 object = inc->resolve(name);
137 }catch(CosNaming::NamingContext::NotFound){
138 MESSAGE( "Container: Logger Server wasn't found" );
140 MESSAGE( "Container: Unknown exception" );
142 if(!CORBA::is_nil(object)){
143 MESSAGE( "Container: Logger Server was found" );
150 if(CONTAINER == 1 || (EnvL == 0 && !CORBA::is_nil(inc)))
154 char *containerName = "";
156 containerName = argv[1] ;
159 Engines_Container_i * myContainer
160 = new Engines_Container_i(orb, root_poa, containerName , argc , argv );
168 MESSAGE("SALOME_Registry_Server.cxx - orb->run()");
169 timer.ShowAbsolute();
172 HandleServerSideSignals(orb);
173 }catch(CORBA::SystemException&){
174 INFOS("Caught CORBA::SystemException.");
175 }catch(PortableServer::POA::WrongPolicy&){
176 INFOS("Caught CORBA::WrongPolicyException.");
177 }catch(PortableServer::POA::ServantAlreadyActive&){
178 INFOS("Caught CORBA::ServantAlreadyActiveException");
179 }catch(CORBA::Exception&){
180 INFOS("Caught CORBA::Exception.");
181 }catch(std::exception& exc){
182 INFOS("Caught std::exception - "<<exc.what());
184 INFOS("Caught unknown exception.");
190 delete myThreadTrace;