1 // Copyright (C) 2007-2020 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 // SALOME ModuleCatalog : implementation of ModuleCatalog server which parsers xml description of modules
24 // File : SALOME_ModuleCatalog_Server.cxx
30 #include "SALOME_NamingService.hxx"
31 #include "SALOME_ModuleCatalog_impl.hxx"
32 #include "utilities.h"
33 #include "Utils_SINGLETON.hxx"
36 #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;
52 ts_req.tv_nsec=TIMESleep;
57 CosNaming::NamingContext_var inc;
58 PortableServer::POA_var poa;
59 CORBA::Object_var theObj;
60 CORBA::Object_var obj;
61 CORBA::Object_var object;
63 const char * Env = getenv("USE_LOGGER");
65 if ((Env!=NULL) && (strlen(Env)))
69 name[0].id=CORBA::string_dup("Logger");
70 PortableServer::POAManager_var mgr;
71 for (int i = 1; i<=NumberOfTries; i++)
75 nanosleep(&ts_req,&ts_rem);
77 Sleep(TIMESleep/1000000);
81 obj = orb->resolve_initial_references("RootPOA");
82 if(!CORBA::is_nil(obj))
83 poa = PortableServer::POA::_narrow(obj);
84 if(!CORBA::is_nil(poa))
85 mgr = poa->the_POAManager();
86 if(!CORBA::is_nil(orb))
87 theObj = orb->resolve_initial_references("NameService");
89 catch( CORBA::SystemException& )
91 INFOS( "Module Catalog Server: CORBA::SystemException: Unable to contact the Naming Service" );
93 if (!CORBA::is_nil(theObj))
95 inc = CosNaming::NamingContext::_narrow(theObj);
96 if(!CORBA::is_nil(inc))
98 INFOS( "Module Catalog Server: Naming Service was found" );
101 CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ;
102 SALOME_NamingService &NS = *SINGLETON_<SALOME_NamingService>::Instance() ;
103 NS.init_orb( orb1 ) ;
104 for(int j=1; j<=NumberOfTries; j++)
108 nanosleep(&ts_req, &ts_rem);
110 Sleep(TIMESleep/1000000);
113 object = inc->resolve(name);}
114 catch(CosNaming::NamingContext::NotFound&)
116 INFOS( "Logger Server wasn't found" );
120 INFOS( "Module Catalog Server: Unknown exception" ) ;
122 if (!CORBA::is_nil(object))
124 INFOS( "Module Catalog Server: Logger Server was found" );
132 if ((MODULE_CATALOG==1)||((EnvL==0)&&(!CORBA::is_nil(inc))))
138 SALOME_ModuleCatalogImpl* Catalogue_i=new SALOME_ModuleCatalogImpl(argc, argv, orb);
139 PortableServer::ObjectId_var cataid = poa->activate_object (Catalogue_i);
141 //activate POA manager
144 CORBA::Object_var myCata = Catalogue_i->_this();
145 Catalogue_i->_remove_ref();
147 // initialise Naming Service
148 SALOME_NamingService _NS(orb);
149 // register Catalog in Naming Service
150 _NS.Register(myCata ,"/Kernel/ModulCatalog");
152 MESSAGE("Running CatalogServer.");
158 timer.ShowAbsolute();
163 // mgr->deactivate(true,true);
164 // poa->destroy(1,1);
167 catch(CORBA::SystemException&) {
168 INFOS("Caught CORBA::SystemException.")
170 catch(CORBA::Exception&) {
171 INFOS("Caught CORBA::Exception.")