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"
42 #include <Utils_Timer.hxx>
53 extern "C" void HandleServerSideSignals(CORBA::ORB_ptr theORB);
55 static PyMethodDef MethodPyVoidMethod[] = {{ NULL, NULL }};
57 int main(int argc, char* argv[])
60 MPI_Init(&argc,&argv);
62 // Initialise the ORB.
63 //ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
64 CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
65 SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
70 PySys_SetArgv( argc , argv ) ;
71 Py_InitModule( "InitPyRunMethod" , MethodPyVoidMethod ) ;
74 // Obtain a reference to the root POA.
75 // obtain the root poa manager
77 long TIMESleep = 500000000;
78 int NumberOfTries = 40;
81 ts_req.tv_nsec=TIMESleep;
86 CosNaming::NamingContext_var inc;
87 PortableServer::POA_var root_poa;
88 CORBA::Object_var theObj;
89 CORBA::Object_var obj;
90 CORBA::Object_var object;
91 //SALOME_NamingService &naming = *SINGLETON_<SALOME_NamingService>::Instance() ;
93 const char * Env = getenv("USE_LOGGER");
95 if(Env != NULL && strlen(Env))
100 name[0].id=CORBA::string_dup("Logger");
101 PortableServer::POAManager_var pman;
102 for(int i = 1; i <= NumberOfTries; i++){
104 a=nanosleep(&ts_req,&ts_rem);
106 obj = orb->resolve_initial_references("RootPOA");
107 if(!CORBA::is_nil(obj))
108 root_poa = PortableServer::POA::_narrow(obj);
109 if(!CORBA::is_nil(root_poa))
110 pman = root_poa->the_POAManager();
111 if(!CORBA::is_nil(orb))
112 theObj = orb->resolve_initial_references("NameService");
113 if (!CORBA::is_nil(theObj))
114 inc = CosNaming::NamingContext::_narrow(theObj);
115 }catch(CORBA::SystemException&){
116 MESSAGE( "Container: CORBA::SystemException: Unable to contact the Naming Service" );
118 if(!CORBA::is_nil(inc)){
119 MESSAGE( "Container: Naming Service was found" );
121 for(int j = 1; j <= NumberOfTries; j++){
123 a=nanosleep(&ts_req, &ts_rem);
125 object = inc->resolve(name);
126 }catch(CosNaming::NamingContext::NotFound){
127 MESSAGE( "Container: Logger Server wasn't found" );
129 MESSAGE( "Container: Unknown exception" );
131 if(!CORBA::is_nil(object)){
132 MESSAGE( "Container: Logger Server was found" );
139 if(CONTAINER == 1 || (EnvL == 0 && !CORBA::is_nil(inc)))
143 char *containerName = "";
145 containerName = argv[1] ;
148 Engines_Container_i * myContainer
149 = new Engines_Container_i(orb, root_poa, containerName , argc , argv );
157 MESSAGE("SALOME_Registry_Server.cxx - orb->run()");
158 timer.ShowAbsolute();
161 HandleServerSideSignals(orb);
162 }catch(CORBA::SystemException&){
163 INFOS("Caught CORBA::SystemException.");
164 }catch(PortableServer::POA::WrongPolicy&){
165 INFOS("Caught CORBA::WrongPolicyException.");
166 }catch(PortableServer::POA::ServantAlreadyActive&){
167 INFOS("Caught CORBA::ServantAlreadyActiveException");
168 }catch(CORBA::Exception&){
169 INFOS("Caught CORBA::Exception.");
170 }catch(std::exception& exc){
171 INFOS("Caught std::exception - "<<exc.what());
173 INFOS("Caught unknown exception.");
179 delete myThreadTrace;