From 9fb568813e2a6ce22741e51c2af17396b4a057d5 Mon Sep 17 00:00:00 2001 From: rahuel Date: Mon, 8 Nov 2004 15:07:58 +0000 Subject: [PATCH] Restore without ContainersManager & ContainersManager --- src/TestContainer/TestContainer.cxx | 86 ++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 3 deletions(-) diff --git a/src/TestContainer/TestContainer.cxx b/src/TestContainer/TestContainer.cxx index 14de77051..2cab7ff1d 100644 --- a/src/TestContainer/TestContainer.cxx +++ b/src/TestContainer/TestContainer.cxx @@ -36,6 +36,11 @@ using namespace std; #include "SALOME_NamingService.hxx" #include "OpUtil.hxx" +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" +#include "Utils_SALOME_Exception.hxx" +#include "Utils_CommException.hxx" +using namespace std; int main (int argc, char * argv[]) { @@ -51,9 +56,84 @@ int main (int argc, char * argv[]) //Engines::Container_var iGenFact = Engines::Container::_narrow(obj); // Obtain a reference to the root POA - CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ; - PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ; - + // + long TIMESleep = 250000000; + int NumberOfTries = 40; + int a; + timespec ts_req; + ts_req.tv_nsec=TIMESleep; + ts_req.tv_sec=0; + timespec ts_rem; + ts_rem.tv_nsec=0; + ts_rem.tv_sec=0; + CosNaming::NamingContext_var inc; + PortableServer::POA_var poa; + CORBA::Object_var theObj; + CORBA::Object_var obj; + CORBA::Object_var object; + SALOME_NamingService &naming = *SINGLETON_::Instance() ; + int TEST_CONTAINER=0; + const char * Env = getenv("USE_LOGGER"); + int EnvL =0; + if ((Env!=NULL) && (strlen(Env))) + EnvL=1; + CosNaming::Name name; + name.length(1); + name[0].id=CORBA::string_dup("Logger"); + PortableServer::POAManager_var manager; + for (int i = 1; i<=NumberOfTries; i++) + { + if (i!=1) + a=nanosleep(&ts_req,&ts_rem); + try + { + obj = orb->resolve_initial_references("RootPOA"); + if(!CORBA::is_nil(obj)) + poa = PortableServer::POA::_narrow(obj); + if(!CORBA::is_nil(poa)) + manager = poa->the_POAManager(); + if(!CORBA::is_nil(orb)) + theObj = orb->resolve_initial_references("NameService"); + if (!CORBA::is_nil(theObj)) + inc = CosNaming::NamingContext::_narrow(theObj); + } + catch( CORBA::COMM_FAILURE& ) + { + MESSAGE( "Test Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) + } + if(!CORBA::is_nil(inc)) + { + MESSAGE( "Test Container: Naming Service was found" ) + if(EnvL==1) + { + for(int j=1; j<=NumberOfTries; j++) + { + if (j!=1) + a=nanosleep(&ts_req, &ts_rem); + try + { + object = inc->resolve(name); + } + catch(CosNaming::NamingContext::NotFound) + { + MESSAGE( "Test Container: Logger Server wasn't found" ); + } + catch(...) + { + MESSAGE( "Test Container: Unknown exception" ); + } + if (!CORBA::is_nil(object)) + { + MESSAGE( "Test Container: Loger Server was found" ); + TEST_CONTAINER=1; + break; + } + } + } + } + if ((TEST_CONTAINER==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) + break; + } // Use Name Service to find container SALOME_NamingService _NS(orb) ; string containerName = "/Containers/" ; -- 2.39.2