1 // Copyright (C) 2007-2008 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.
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
22 // SALOME ModuleCatalog : implementation of ModuleCatalog server which parsers xml description of modules
23 // File : SALOME_ModuleCatalog_Server.cxx
29 #include "SALOME_NamingService.hxx"
30 #include "SALOME_ModuleCatalog_impl.hxx"
31 #include "utilities.h"
32 #include "Utils_SINGLETON.hxx"
35 #include <Utils_Timer.hxx>
39 int main(int argc,char **argv)
42 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
45 CosNaming::NamingContext_var _rootContext, catalogContext;
49 long TIMESleep = 500000000;
50 int NumberOfTries = 40;
53 ts_req.tv_nsec=TIMESleep;
58 CosNaming::NamingContext_var inc;
59 PortableServer::POA_var poa;
60 CORBA::Object_var theObj;
61 CORBA::Object_var obj;
62 CORBA::Object_var object;
64 const char * Env = getenv("USE_LOGGER");
66 if ((Env!=NULL) && (strlen(Env)))
70 name[0].id=CORBA::string_dup("Logger");
71 PortableServer::POAManager_var mgr;
72 for (int i = 1; i<=NumberOfTries; i++)
76 a=nanosleep(&ts_req,&ts_rem);
78 Sleep(TIMESleep/1000000);
82 obj = orb->resolve_initial_references("RootPOA");
83 if(!CORBA::is_nil(obj))
84 poa = PortableServer::POA::_narrow(obj);
85 if(!CORBA::is_nil(poa))
86 mgr = poa->the_POAManager();
87 if(!CORBA::is_nil(orb))
88 theObj = orb->resolve_initial_references("NameService");
90 catch( CORBA::SystemException& )
92 INFOS( "Module Catalog Server: CORBA::SystemException: Unable to contact the Naming Service" );
94 if (!CORBA::is_nil(theObj))
96 inc = CosNaming::NamingContext::_narrow(theObj);
97 if(!CORBA::is_nil(inc))
99 INFOS( "Module Catalog Server: Naming Service was found" );
102 CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ;
103 SALOME_NamingService &NS = *SINGLETON_<SALOME_NamingService>::Instance() ;
104 NS.init_orb( orb1 ) ;
105 for(int j=1; j<=NumberOfTries; j++)
109 a=nanosleep(&ts_req, &ts_rem);
111 Sleep(TIMESleep/1000000);
114 object = inc->resolve(name);}
115 catch(CosNaming::NamingContext::NotFound)
117 INFOS( "Logger Server wasn't found" );
121 INFOS( "Module Catalog Server: Unknown exception" ) ;
123 if (!CORBA::is_nil(object))
125 INFOS( "Module Catalog Server: Logger Server was found" );
133 if ((MODULE_CATALOG==1)||((EnvL==0)&&(!CORBA::is_nil(inc))))
139 SALOME_ModuleCatalogImpl* Catalogue_i=new SALOME_ModuleCatalogImpl(argc, argv, orb);
140 PortableServer::ObjectId_var cataid = poa->activate_object (Catalogue_i);
142 //activate POA manager
145 CORBA::Object_var myCata = Catalogue_i->_this();
146 Catalogue_i->_remove_ref();
148 // initialise Naming Service
149 SALOME_NamingService _NS(orb);
150 // register Catalog in Naming Service
151 _NS.Register(myCata ,"/Kernel/ModulCatalog");
153 MESSAGE("Running CatalogServer.");
159 timer.ShowAbsolute();
164 // mgr->deactivate(true,true);
165 // poa->destroy(1,1);
168 catch(CORBA::SystemException&) {
169 INFOS("Caught CORBA::SystemException.")
171 catch(CORBA::Exception&) {
172 INFOS("Caught CORBA::Exception.")