1 // SALOME RessourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl)
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_RessourcesCatalog_Server.cxx
25 // Author : Estelle Deville
30 #include "SALOME_NamingService.hxx"
31 #include "SALOME_RessourcesCatalog_impl.hxx"
32 #include "utilities.h"
33 #include "LocalTraceCollector.hxx"
34 #include "Utils_SINGLETON.hxx"
37 int main(int argc,char **argv)
40 CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv);
41 LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb);
44 CosNaming::NamingContext_var _rootContext, catalogContext;
48 long TIMESleep = 250000000;
49 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;
62 SALOME_NamingService &naming = *SINGLETON_<SALOME_NamingService>::Instance() ;
63 int RESSOURCES_CATALOG=0;
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++)
75 a=nanosleep(&ts_req,&ts_rem);
78 obj = orb->resolve_initial_references("RootPOA");
79 if(!CORBA::is_nil(obj))
80 poa = PortableServer::POA::_narrow(obj);
81 if(!CORBA::is_nil(poa))
82 mgr = poa->the_POAManager();
83 if(!CORBA::is_nil(orb))
84 theObj = orb->resolve_initial_references("NameService");
85 if (!CORBA::is_nil(theObj))
86 inc = CosNaming::NamingContext::_narrow(theObj);
88 catch( CORBA::COMM_FAILURE& )
90 INFOS( "Ressources Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" );
92 if(!CORBA::is_nil(inc))
94 MESSAGE( "Ressources Catalog: Naming Service was found" );
97 for(int j=1; j<=NumberOfTries; j++)
100 a=nanosleep(&ts_req, &ts_rem);
102 object = inc->resolve(name);
104 catch(CosNaming::NamingContext::NotFound)
106 INFOS( "Ressources Catalog: Logger Server wasn't found" );
110 INFOS( "Ressources Catalog: Unknown exception" );
112 if (!CORBA::is_nil(object))
114 MESSAGE( "Ressources Catalog: Loger Server was found" );
115 RESSOURCES_CATALOG=1;
121 if ((RESSOURCES_CATALOG==1)||((EnvL==0)&&(!CORBA::is_nil(inc))))
127 SALOME_RessourcesCatalogImpl* Catalogue_i = new SALOME_RessourcesCatalogImpl(argc, argv);
128 poa->activate_object (Catalogue_i);
130 CORBA::Object_ptr myCata = Catalogue_i->_this();
132 // initialise Naming Service
133 SALOME_NamingService *_NS;
134 _NS = new SALOME_NamingService(orb);
135 // register Catalog in Naming Service
136 _NS->Register(myCata ,"/Kernel/RessourcesCatalog");
138 MESSAGE("Running Ressources Catalog Server.")
145 catch(CORBA::SystemException&) {
146 INFOS("Caught CORBA::SystemException.")
148 catch(CORBA::Exception&) {
149 INFOS("Caught CORBA::Exception.")
152 delete myThreadTrace;