From 04d8345280963cfbbadff891ea99ba362bff960a Mon Sep 17 00:00:00 2001 From: prascle Date: Thu, 11 Dec 2003 16:49:30 +0000 Subject: [PATCH] PR: Bug KERNEL4778 : first step --- bin/runSalome.py | 23 +- src/Container/Makefile.in | 2 +- src/Container/SALOME_Container.cxx | 290 +++++++++-------- src/DataTypeCatalog/Makefile.in | 2 +- .../SALOME_DataTypeCatalog_Server.cxx | 196 +++++------ src/LifeCycleCORBA/Makefile.in | 2 +- src/Loader/Makefile.in | 2 +- src/Loader/SALOME_Session_Loader.cxx | 1 + src/Makefile.in | 15 +- src/ModuleCatalog/Makefile.in | 2 +- .../SALOME_ModuleCatalog_Server.cxx | 217 ++++++------ src/Notification/Makefile.in | 2 +- src/Registry/Makefile.in | 2 +- src/Registry/SALOME_Registry_Server.cxx | 308 +++++++++--------- src/RessourcesCatalog/Makefile.in | 2 +- .../SALOME_RessourcesCatalog_Server.cxx | 183 ++++++----- src/SALOMEDS/Makefile.in | 2 +- src/SALOMEDS/SALOMEDS_Server.cxx | 244 +++++++------- src/SALOMELocalTrace/Makefile.in | 49 +++ src/SALOMELocalTrace/SALOME_Log.cxx | 57 ++++ src/SALOMELocalTrace/SALOME_Log.hxx | 85 +++++ src/SALOMELogger/Makefile.in | 50 +++ src/SALOMELogger/SALOME_LoggerClient.cxx | 154 +++++++++ src/Session/Makefile.in | 2 +- src/Session/SALOME_Session_Server.cxx | 181 +++++----- src/TOOLSDS/Makefile.in | 2 +- src/TestContainer/Makefile.in | 2 +- src/TestContainer/TestContainer.cxx | 139 ++++---- src/Utils/Makefile.in | 2 +- src/Utils/Utils_SALOME_Exception.cxx | 2 +- src/Utils/utilities.h | 130 +++----- 31 files changed, 1406 insertions(+), 944 deletions(-) create mode 100644 src/SALOMELocalTrace/Makefile.in create mode 100644 src/SALOMELocalTrace/SALOME_Log.cxx create mode 100644 src/SALOMELocalTrace/SALOME_Log.hxx create mode 100644 src/SALOMELogger/Makefile.in create mode 100644 src/SALOMELogger/SALOME_LoggerClient.cxx diff --git a/bin/runSalome.py b/bin/runSalome.py index d7c7a496c..d4a702a52 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -255,6 +255,20 @@ add_path(os.path.join(kernel_root_dir,"bin","salome")) for module in liste_modules: module_root_dir=modules_root_dir[module] add_ld_library_path(os.path.join(module_root_dir,"lib","salome")) + +if with_logger: + locdir=os.environ['PWD'] + libtracedir=os.path.join(locdir,"libSalomeTrace") + libtrace = os.path.join(kernel_root_dir,"lib","salome","libSALOMELoggerClient.so.0.0.0") + libtraceln = os.path.join(libtracedir,"libSALOMELocalTrace.so") + aCommand = 'rm -rf ' + libtracedir + "; " + aCommand += 'mkdir ' + libtracedir + "; " + aCommand += 'ln -s ' + libtrace + " " + libtraceln + "; " + aCommand += 'ln -s ' + libtrace + " " + libtraceln + ".0; " + aCommand += 'ln -s ' + libtrace + " " + libtraceln + ".0.0.0; " + os.system(aCommand) + add_ld_library_path(libtracedir) + #print "LD_LIBRARY_PATH=",os.environ["LD_LIBRARY_PATH"] # @@ -376,6 +390,11 @@ def startSalome(): import SALOME session=clt.waitNS("/Kernel/Session",SALOME.Session) + + theComputer = os.getenv("HOSTNAME") + computerSplitName = theComputer.split('.') + theComputer = computerSplitName[0] + # # Lancement Container C++ local # @@ -386,10 +405,6 @@ def startSalome(): # Attente de la disponibilité du Container C++ local dans le Naming Service # - theComputer = os.getenv("HOSTNAME") - computerSplitName = theComputer.split('.') - theComputer = computerSplitName[0] - clt.waitNS("/Containers/" + theComputer + "/FactoryServer") # diff --git a/src/Container/Makefile.in b/src/Container/Makefile.in index fdf28da44..87f372867 100644 --- a/src/Container/Makefile.in +++ b/src/Container/Makefile.in @@ -53,7 +53,7 @@ BIN_SERVER_IDL = SALOME_Component.idl CPPFLAGS+= $(PYTHON_INCLUDES) -LDFLAGS+= -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSalomeLoggerServer +LDFLAGS+= -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSALOMELocalTrace LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS) diff --git a/src/Container/SALOME_Container.cxx b/src/Container/SALOME_Container.cxx index ce8c05628..77a06b9de 100644 --- a/src/Container/SALOME_Container.cxx +++ b/src/Container/SALOME_Container.cxx @@ -26,194 +26,202 @@ // Module : SALOME // $Header$ -using namespace std; -using namespace std; #include -# include "Utils_ORB_INIT.hxx" -# include "Utils_SINGLETON.hxx" +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" #include "SALOME_NamingService.hxx" #include "SALOME_Container_i.hxx" #include #include #include "utilities.h" +using namespace std; -//#define CHECKTIME #ifdef CHECKTIME #include #endif #include -static PyMethodDef MethodPyVoidMethod[] = { - { NULL, NULL } -}; +static PyMethodDef MethodPyVoidMethod[] = + { + { NULL, NULL } + }; int main(int argc, char* argv[]) { INFOS_COMPILATION; BEGIN_OF(argv[0]) - Py_Initialize() ; + Py_Initialize() ; PySys_SetArgv( argc , argv ) ; Py_InitModule( "InitPyRunMethod" , MethodPyVoidMethod ) ; - try { + try + { - // Initialise the ORB. -// CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init( argc , argv ) ; + // Initialise the ORB. + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + CORBA::ORB_var &orb = init( argc , argv ) ; - // Obtain a reference to the root POA. - // obtain the root poa manager - // - 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 root_poa; - CORBA::Object_var theObj; - CORBA::Object_var obj; - CORBA::Object_var object; - SALOME_Logger::Logger_var log; - SALOME_NamingService &naming = *SINGLETON_::Instance() ; - int 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 pman; - 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)) - root_poa = PortableServer::POA::_narrow(obj); - if(!CORBA::is_nil(root_poa)) - pman = root_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& ) + // Obtain a reference to the root POA. + // obtain the root poa manager + // + 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 root_poa; + CORBA::Object_var theObj; + CORBA::Object_var obj; + CORBA::Object_var object; + SALOME_NamingService &naming = *SINGLETON_::Instance() ; + int 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 pman; + for (int i = 1; i<=NumberOfTries; i++) { - MESSAGE( "Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) + if (i!=1) + a=nanosleep(&ts_req,&ts_rem); + try + { + obj = orb->resolve_initial_references("RootPOA"); + if(!CORBA::is_nil(obj)) + root_poa = PortableServer::POA::_narrow(obj); + if(!CORBA::is_nil(root_poa)) + pman = root_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( "Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); } - if(!CORBA::is_nil(inc)) { - MESSAGE( "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( "Container: Logger Server wasn't found" ) } - catch(...){ MESSAGE( "Container: Unknown exception" ) } - if (!CORBA::is_nil(object)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "Container: Logger Server was found" ) - log->ping(); - CONTAINER=1; - break; - } - }} - } - if ((CONTAINER==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) + if(!CORBA::is_nil(inc)) + { + MESSAGE( "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( "Container: Logger Server wasn't found" ); + } + catch(...) + { + MESSAGE( "Container: Unknown exception" ); + } + if (!CORBA::is_nil(object)) + { + MESSAGE( "Container: Logger Server was found" ); + CONTAINER=1; + break; + } + } + } + } + if ((CONTAINER==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) break; - } + } - // - // define policy objects - PortableServer::ImplicitActivationPolicy_var implicitActivation = - root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ; + // define policy objects + PortableServer::ImplicitActivationPolicy_var implicitActivation = + root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ; - // default = NO_IMPLICIT_ACTIVATION - PortableServer::ThreadPolicy_var threadPolicy = - root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ; - // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL + // default = NO_IMPLICIT_ACTIVATION + PortableServer::ThreadPolicy_var threadPolicy = + root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ; + // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL - // create policy list - CORBA::PolicyList policyList; - policyList.length(2); - policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ; - policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ; - - // create the child POA - PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ; - PortableServer::POA_var factory_poa = - root_poa->create_POA("factory_poa", pman, policyList) ; + // create policy list + CORBA::PolicyList policyList; + policyList.length(2); + policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ; + policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ; + + // create the child POA + PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ; + PortableServer::POA_var factory_poa = + root_poa->create_POA("factory_poa", pman, policyList) ; //with nil_mgr instead of pman, a new POA manager is created with the new POA - // destroy policy objects - implicitActivation->destroy() ; - threadPolicy->destroy() ; + // destroy policy objects + implicitActivation->destroy() ; + threadPolicy->destroy() ; - char *containerName = ""; - if (argc >1) - { - containerName = argv[1] ; - } + char *containerName = ""; + if (argc >1) + { + containerName = argv[1] ; + } - Engines_Container_i * myContainer - = new Engines_Container_i(orb, factory_poa, containerName , argc , argv ); + Engines_Container_i * myContainer + = new Engines_Container_i(orb, factory_poa, containerName , argc , argv ); -// Engines_Container_i * myContainer -// = new Engines_Container_i(string(argv[1]),string(argv[2]), orb, factory_poa); + // Engines_Container_i * myContainer + // = new Engines_Container_i(string(argv[1]),string(argv[2]), orb, factory_poa); - // use naming service -// myContainer->_NS.init_orb(orb); -// Engines::Container_ptr pCont = Engines::Container::_narrow(myContainer->_this()); -// myContainer->_NS.Register(pCont, argv[2]); + // use naming service + // myContainer->_NS.init_orb(orb); + // Engines::Container_ptr pCont = Engines::Container::_narrow(myContainer->_this()); + // myContainer->_NS.Register(pCont, argv[2]); - pman->activate(); + pman->activate(); #ifdef CHECKTIME - Utils_Timer timer; - timer.Start(); - timer.Stop(); - MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); - timer.ShowAbsolute(); + Utils_Timer timer; + timer.Start(); + timer.Stop(); + MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); + timer.ShowAbsolute(); #endif - orb->run(); + orb->run(); - orb->destroy(); - } + orb->destroy(); + } catch(CORBA::SystemException&) - { - INFOS("Caught CORBA::SystemException.") - } + { + INFOS("Caught CORBA::SystemException.") + } catch(PortableServer::POA::WrongPolicy&) - { - INFOS("Caught CORBA::WrongPolicyException.") - } + { + INFOS("Caught CORBA::WrongPolicyException.") + } catch(PortableServer::POA::ServantAlreadyActive&) - { - INFOS("Caught CORBA::ServantAlreadyActiveException") - } + { + INFOS("Caught CORBA::ServantAlreadyActiveException") + } catch(CORBA::Exception&) - { - INFOS("Caught CORBA::Exception.") - } + { + INFOS("Caught CORBA::Exception.") + } catch(...) - { - INFOS("Caught unknown exception.") - } + { + INFOS("Caught unknown exception.") + } END_OF(argv[0]); } diff --git a/src/DataTypeCatalog/Makefile.in b/src/DataTypeCatalog/Makefile.in index 1017cafe0..5759b3b46 100644 --- a/src/DataTypeCatalog/Makefile.in +++ b/src/DataTypeCatalog/Makefile.in @@ -54,6 +54,6 @@ BIN_SERVER_IDL = SALOME_DataTypeCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) CXXFLAGS+= -LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSalomeLoggerServer +LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx index 95c4ce6a1..a29401c51 100644 --- a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx @@ -26,120 +26,132 @@ // Module : SALOME // $Header$ -using namespace std; #include #include "SALOME_NamingService.hxx" #include "SALOME_DataTypeCatalog_impl.hxx" #include "utilities.h" -# include "Utils_SINGLETON.hxx" +#include "Utils_SINGLETON.hxx" +using namespace std; + int main(int argc,char **argv) { - try { - CosNaming::NamingContext_var _rootContext, catalogContext; - // initialize the ORB - CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); - // initialize POA - // - 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_Logger::Logger_var log; - int DATA_TYPE_CATALOG=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 mgr; + try + { + CosNaming::NamingContext_var _rootContext, catalogContext; + // initialize the ORB + CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); + // initialize POA + // + 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; + int DATA_TYPE_CATALOG=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 mgr; - 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)) - mgr = 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( "Data Type Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) - } - if(!CORBA::is_nil(inc)) { - MESSAGE( "Data Type Catalog: Naming Service was found" ) - if(EnvL==1){ - CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; - SALOME_NamingService &NS = *SINGLETON_::Instance() ; - NS.init_orb( orb1 ) ; - 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( "Data Type Catalog: Logger Server wasn't found" ) } - catch(...){ MESSAGE( "Data Type Catalog: Unknown exception" ) } - if (!CORBA::is_nil(object)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "Data Type Catalog: Logger Server was found" ) - log->ping(); - DATA_TYPE_CATALOG=1; - break; + 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)) + mgr = 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( "Data Type Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); } + if(!CORBA::is_nil(inc)) + { + MESSAGE( "Data Type Catalog: Naming Service was found" ); + if(EnvL==1) + { + CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; + SALOME_NamingService &NS = *SINGLETON_::Instance() ; + NS.init_orb( orb1 ) ; + 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( "Data Type Catalog: Logger Server wasn't found" ); + } + catch(...) + { + MESSAGE( "Data Type Catalog: Unknown exception" ); + } + if (!CORBA::is_nil(object)) + { + MESSAGE( "Data Type Catalog: Logger Server was found" ); + DATA_TYPE_CATALOG=1; + break; + } - }} - } - if ((DATA_TYPE_CATALOG==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) - break; + } + } } + if ((DATA_TYPE_CATALOG==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) + break; + } - // - // Active catalog + // Active catalog - SALOME_DataTypeCatalogImpl* Catalogue_i = new SALOME_DataTypeCatalogImpl(argc, argv); - poa->activate_object (Catalogue_i); + SALOME_DataTypeCatalogImpl* Catalogue_i = new SALOME_DataTypeCatalogImpl(argc, argv); + poa->activate_object (Catalogue_i); - mgr->activate(); + mgr->activate(); - CORBA::Object_ptr myCata = Catalogue_i->_this(); + CORBA::Object_ptr myCata = Catalogue_i->_this(); - // initialise Naming Service - SALOME_NamingService *_NS; - _NS = new SALOME_NamingService(orb); - // register Catalog in Naming Service - _NS->Register(myCata ,"/Kernel/DataTypeCatalog"); + // initialise Naming Service + SALOME_NamingService *_NS; + _NS = new SALOME_NamingService(orb); + // register Catalog in Naming Service + _NS->Register(myCata ,"/Kernel/DataTypeCatalog"); - MESSAGE("Running DataType Catalog Server.") + MESSAGE("Running DataType Catalog Server.") - orb->run(); + orb->run(); - poa->destroy(1,1); + poa->destroy(1,1); - } - catch(CORBA::SystemException&) { + } + catch(CORBA::SystemException&) { INFOS("Caught CORBA::SystemException.") - } - catch(CORBA::Exception&) { + } + catch(CORBA::Exception&) { INFOS("Caught CORBA::Exception.") - } + } return 0; } diff --git a/src/LifeCycleCORBA/Makefile.in b/src/LifeCycleCORBA/Makefile.in index 6f4a461ea..33ee1ac81 100644 --- a/src/LifeCycleCORBA/Makefile.in +++ b/src/LifeCycleCORBA/Makefile.in @@ -51,7 +51,7 @@ BIN_SRC = BIN_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl \ SALOME_ModuleCatalog.idl -LDFLAGS += -lSalomeNS -lOpUtil -lSalomeLoggerServer +LDFLAGS += -lSalomeNS -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/Loader/Makefile.in b/src/Loader/Makefile.in index dd736d4ed..6caf10e2c 100644 --- a/src/Loader/Makefile.in +++ b/src/Loader/Makefile.in @@ -31,7 +31,7 @@ BIN_CLIENT_IDL = SALOME_Session.idl \ CPPFLAGS+=$(QT_MT_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSalomeLoggerServer +LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/Loader/SALOME_Session_Loader.cxx b/src/Loader/SALOME_Session_Loader.cxx index acd0ea377..3aff04564 100644 --- a/src/Loader/SALOME_Session_Loader.cxx +++ b/src/Loader/SALOME_Session_Loader.cxx @@ -13,6 +13,7 @@ using namespace std; #include #include CORBA_CLIENT_HEADER(SALOME_Session) +#include CORBA_CLIENT_HEADER(Logger) #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" diff --git a/src/Makefile.in b/src/Makefile.in index ed8d2f4ec..89f82d775 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -32,10 +32,17 @@ VPATH=.:@srcdir@ @COMMENCE@ -SUBDIRS = MSG2QM Logger Utils PatchQt NamingService Registry ModuleCatalog DataTypeCatalog \ - RessourcesCatalog Notification NOTIFICATION_SWIG Container TestContainer LifeCycleCORBA \ - HDFPersist VTKFilter OBJECT TOOLSDS SALOMEDS SALOMEGUI Plot2d VTKViewer OCCViewer SUPERVGraph \ - Session SALOME_SWIG TOOLSGUI SALOME_PY RegistryDisplay ModuleGenerator SALOME_PYQT Loader +SUBDIRS = MSG2QM SALOMELocalTrace Logger SALOMELogger Utils PatchQt \ + NamingService Registry \ + ModuleCatalog DataTypeCatalog RessourcesCatalog \ + Notification NOTIFICATION_SWIG \ + Container TestContainer LifeCycleCORBA HDFPersist \ + VTKFilter OBJECT \ + TOOLSDS SALOMEDS \ + SALOMEGUI Plot2d VTKViewer OCCViewer \ + SUPERVGraph \ + Session SALOME_SWIG TOOLSGUI SALOME_PY \ + RegistryDisplay ModuleGenerator SALOME_PYQT Loader ifeq (@WITHMPICH@,yes) SUBDIRS+= MPIContainer diff --git a/src/ModuleCatalog/Makefile.in b/src/ModuleCatalog/Makefile.in index c61ad8487..97a1d9816 100644 --- a/src/ModuleCatalog/Makefile.in +++ b/src/ModuleCatalog/Makefile.in @@ -57,6 +57,6 @@ BIN_SERVER_IDL = SALOME_ModuleCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) CXXFLAGS+= -ftemplate-depth-42 -LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSalomeLoggerServer +LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx index 65d7566b5..c590e990c 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx @@ -24,141 +24,146 @@ // File : SALOME_ModuleCatalog_Server.cxx // Module : SALOME -using namespace std; /* $Header$ */ #include #include "SALOME_NamingService.hxx" #include "SALOME_ModuleCatalog_impl.hxx" #include "utilities.h" -# include "Utils_SINGLETON.hxx" - -//#define CHECKTIME -#ifdef CHECKTIME -#include -#endif +#include "Utils_SINGLETON.hxx" -//#define CHECKTIME #ifdef CHECKTIME #include #endif +using namespace std; int main(int argc,char **argv) { - try { - CosNaming::NamingContext_var _rootContext, catalogContext; + try + { + CosNaming::NamingContext_var _rootContext, catalogContext; - // initialize the ORB + // initialize the ORB - CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); + CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); - // initialize POA - // - 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_Logger::Logger_var log; - int MODULE_CATALOG=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 mgr; - 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)) - mgr = poa->the_POAManager(); - if(!CORBA::is_nil(orb)) - theObj = orb->resolve_initial_references("NameService"); - } - catch( CORBA::COMM_FAILURE& ) - { - MESSAGE( "Module Catalog Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) - } - if (!CORBA::is_nil(theObj)){ - inc = CosNaming::NamingContext::_narrow(theObj); - if(!CORBA::is_nil(inc)) { - MESSAGE( "Module Catalog Server: Naming Service was found" ) - if(EnvL==1){ - CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; - SALOME_NamingService &NS = *SINGLETON_::Instance() ; - NS.init_orb( orb1 ) ; - 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( "Logger Server wasn't found" ) } - catch(...){ MESSAGE( "Module Catalog Server: Unknown exception" ) } - if (!CORBA::is_nil(object)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "Module Catalog Server: Logger Server was found" ) - log->ping(); - MODULE_CATALOG=1; - break; - } - }} - }} - if ((MODULE_CATALOG==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) - break; - } + // initialize POA + // + 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; + int MODULE_CATALOG=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 mgr; + 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)) + mgr = poa->the_POAManager(); + if(!CORBA::is_nil(orb)) + theObj = orb->resolve_initial_references("NameService"); + } + catch( CORBA::COMM_FAILURE& ) + { + MESSAGE( "Module Catalog Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + } + if (!CORBA::is_nil(theObj)) + { + inc = CosNaming::NamingContext::_narrow(theObj); + if(!CORBA::is_nil(inc)) + { + MESSAGE( "Module Catalog Server: Naming Service was found" ); + if(EnvL==1) + { + CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; + SALOME_NamingService &NS = *SINGLETON_::Instance() ; + NS.init_orb( orb1 ) ; + 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( "Logger Server wasn't found" ); + } + catch(...) + { + MESSAGE( "Module Catalog Server: Unknown exception" ) ; + } + if (!CORBA::is_nil(object)) + { + MESSAGE( "Module Catalog Server: Logger Server was found" ); + MODULE_CATALOG=1; + break; + } + } + } + } + } + if ((MODULE_CATALOG==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) + break; + } - // - // Active catalog + // Active catalog - SALOME_ModuleCatalogImpl* Catalogue_i = new SALOME_ModuleCatalogImpl(argc, argv); - poa->activate_object (Catalogue_i); + SALOME_ModuleCatalogImpl* Catalogue_i = new SALOME_ModuleCatalogImpl(argc, argv); + poa->activate_object (Catalogue_i); - mgr->activate(); + mgr->activate(); - CORBA::Object_ptr myCata = Catalogue_i->_this(); + CORBA::Object_ptr myCata = Catalogue_i->_this(); - // initialise Naming Service - SALOME_NamingService *_NS; - _NS = new SALOME_NamingService(orb); - // register Catalog in Naming Service - _NS->Register(myCata ,"/Kernel/ModulCatalog"); + // initialise Naming Service + SALOME_NamingService *_NS; + _NS = new SALOME_NamingService(orb); + // register Catalog in Naming Service + _NS->Register(myCata ,"/Kernel/ModulCatalog"); - MESSAGE("Running CatalogServer."); + MESSAGE("Running CatalogServer."); #ifdef CHECKTIME - Utils_Timer timer; - timer.Start(); - timer.Stop(); - MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); - timer.ShowAbsolute(); + Utils_Timer timer; + timer.Start(); + timer.Stop(); + MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); + timer.ShowAbsolute(); #endif - orb->run(); + orb->run(); - poa->destroy(1,1); + poa->destroy(1,1); - } - catch(CORBA::SystemException&) { + } + catch(CORBA::SystemException&) { INFOS("Caught CORBA::SystemException.") - } - catch(CORBA::Exception&) { + } + catch(CORBA::Exception&) { INFOS("Caught CORBA::Exception.") - } + } return 0; } diff --git a/src/Notification/Makefile.in b/src/Notification/Makefile.in index 0da007a70..4d43c67a5 100644 --- a/src/Notification/Makefile.in +++ b/src/Notification/Makefile.in @@ -47,7 +47,7 @@ LIB_SRC = NOTIFICATION.cxx \ NOTIFICATION_Supplier.cxx \ NOTIFICATION_Consumer.cxx -LDFLAGS+= -lOpUtil +LDFLAGS+= -lOpUtil -lSALOMELocalTrace OMNIORB_IDLCXXFLAGS+= -Wbtp @CONCLUDE@ diff --git a/src/Registry/Makefile.in b/src/Registry/Makefile.in index 823ac6241..5ff83cb1d 100644 --- a/src/Registry/Makefile.in +++ b/src/Registry/Makefile.in @@ -50,6 +50,6 @@ BIN = SALOME_Registry_Server BIN_SRC = RegistryService.cxx BIN_SERVER_IDL = SALOME_Registry.idl -LDFLAGS+= -lSalomeNS -lOpUtil -lSalomeLoggerServer +LDFLAGS+= -lSalomeNS -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/Registry/SALOME_Registry_Server.cxx b/src/Registry/SALOME_Registry_Server.cxx index e4aee0f7d..3e5a5b636 100644 --- a/src/Registry/SALOME_Registry_Server.cxx +++ b/src/Registry/SALOME_Registry_Server.cxx @@ -26,181 +26,189 @@ // Module : SALOME // $Header$ -using namespace std; -# include -# include -# include +#include +#include +#include extern "C" { # include } -# include "utilities.h" -# include "Utils_ORB_INIT.hxx" -# include "Utils_SINGLETON.hxx" -# include "Utils_SALOME_Exception.hxx" -# include "Utils_CommException.hxx" -# include "ServiceUnreachable.hxx" -# include "SALOME_NamingService.hxx" -# include "RegistryService.hxx" +#include "utilities.h" +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" +#include "Utils_SALOME_Exception.hxx" +#include "Utils_CommException.hxx" +#include "ServiceUnreachable.hxx" +#include "SALOME_NamingService.hxx" +#include "RegistryService.hxx" -//#define CHECKTIME #ifdef CHECKTIME #include #endif +using namespace std; int main( int argc , char **argv ) { - BEGIN_OF( argv[0] ) - INFOS_COMPILATION - SCRUTE(argc) - if( argc<3 ) + BEGIN_OF( argv[0] ) + INFOS_COMPILATION + SCRUTE(argc) + if( argc<3 ) + { + MESSAGE("you must provide the Salome session name when you call SALOME_Registry_Server") ; + throw CommException("you must provide the Salome session name when you call SALOME_Registry_Server") ; + } + const char *ptrSessionName=0 ; + + int k=0 ; + for ( k=1 ; k0) ; + const char *registryName = "Registry" ; + ORB_INIT &init = *SINGLETON_::Instance() ; + CORBA::ORB_var &orb = init( argc , argv ) ; + // + 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() ; + Registry::Components_var varComponents; + int REGISTRY=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& ) { - if( strcmp(argv[k],"--salome_session")==0 ) - { - ptrSessionName=argv[k+1] ; - break ; - } + MESSAGE( "Registry Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); } - ASSERT(ptrSessionName) ; - ASSERT(strlen( ptrSessionName )>0) ; - const char *registryName = "Registry" ; - ORB_INIT &init = *SINGLETON_::Instance() ; - CORBA::ORB_var &orb = init( argc , argv ) ; - // - 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_Logger::Logger_var log; - SALOME_NamingService &naming = *SINGLETON_::Instance() ; - Registry::Components_var varComponents; - int REGISTRY=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& ) + if(!CORBA::is_nil(inc)) + { + MESSAGE( "Registry Server: Naming Service was found" ); + if(EnvL==1) { - MESSAGE( "Registry Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) - } - if(!CORBA::is_nil(inc)) { - MESSAGE( "Registry Server: Naming Service was found" ) - if(EnvL==1){ - for(int j=1; j<=NumberOfTries; j++){ + 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( "Registry Server: Logger Server wasn't found" ) } - catch(...){ MESSAGE( "Registry Server: Unknown exception" ) } - + try + { + object = inc->resolve(name); + } + catch(CosNaming::NamingContext::NotFound) + { + MESSAGE( "Registry Server: Logger Server wasn't found" ); + } + catch(...) + { + MESSAGE( "Registry Server: Unknown exception" ); + } if (!CORBA::is_nil(object)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "Registry Server: Logger Server was found" ) - log->ping(); - REGISTRY=1; - break; - } - }} - } - if ((REGISTRY==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) - break; - } - // - try - { - naming.init_orb( orb ) ; - RegistryService *ptrRegistry = SINGLETON_::Instance() ; - ptrRegistry->SessionName( ptrSessionName ) ; - varComponents = ptrRegistry->_this() ; - // The RegistryService must not already exist. + { + MESSAGE( "Module Catalog Server: Logger Server was found" ); + REGISTRY=1; + break; + } + } + } + } + if ((REGISTRY==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) + break; + } + + try + { + naming.init_orb( orb ) ; + RegistryService *ptrRegistry = SINGLETON_::Instance() ; + ptrRegistry->SessionName( ptrSessionName ) ; + varComponents = ptrRegistry->_this() ; + // The RegistryService must not already exist. - try - { - CORBA::Object_var pipo = naming.Resolve( registryName ) ; - if (CORBA::is_nil(pipo) ) throw ServiceUnreachable() ; - MESSAGE("RegistryService servant already existing" ) ; - exit( EXIT_FAILURE ) ; - } - catch( const ServiceUnreachable &ex ) - { - } - catch( const CORBA::Exception &exx ) - { - } - string absoluteName = string("/") + registryName; - naming.Register( varComponents , absoluteName.c_str() ) ; - MESSAGE("On attend les requetes des clients") ; - try - { - // Activation du POA - MESSAGE("Activation du POA") ; - manager->activate() ; + try + { + CORBA::Object_var pipo = naming.Resolve( registryName ) ; + if (CORBA::is_nil(pipo) ) throw ServiceUnreachable() ; + MESSAGE("RegistryService servant already existing" ) ; + exit( EXIT_FAILURE ) ; + } + catch( const ServiceUnreachable &ex ) + { + } + catch( const CORBA::Exception &exx ) + { + } + string absoluteName = string("/") + registryName; + naming.Register( varComponents , absoluteName.c_str() ) ; + MESSAGE("On attend les requetes des clients") ; + try + { + // Activation du POA + MESSAGE("Activation du POA") ; + manager->activate() ; - // Lancement de l'ORB - MESSAGE("Lancement de l'ORB") ; + // Lancement de l'ORB + MESSAGE("Lancement de l'ORB") ; #ifdef CHECKTIME - Utils_Timer timer; - timer.Start(); - timer.Stop(); - MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); - timer.ShowAbsolute(); + Utils_Timer timer; + timer.Start(); + timer.Stop(); + MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); + timer.ShowAbsolute(); #endif - orb->run() ; - } - catch( const CORBA::Exception &ex ) - { - MESSAGE("Erreur systeme") ; - return EXIT_FAILURE ; - } + orb->run() ; + } + catch( const CORBA::Exception &ex ) + { + MESSAGE("Erreur systeme") ; + return EXIT_FAILURE ; + } - } - catch( const SALOME_Exception &ex ) - { - MESSAGE( "Communication Error : " << ex.what() ) - return EXIT_FAILURE ; - } + } + catch( const SALOME_Exception &ex ) + { + MESSAGE( "Communication Error : " << ex.what() ) + return EXIT_FAILURE ; + } - END_OF( argv[0] ) ; - return 0 ; + END_OF( argv[0] ) ; + return 0 ; } diff --git a/src/RessourcesCatalog/Makefile.in b/src/RessourcesCatalog/Makefile.in index a98eab8bf..c129dad04 100644 --- a/src/RessourcesCatalog/Makefile.in +++ b/src/RessourcesCatalog/Makefile.in @@ -54,7 +54,7 @@ BIN_SERVER_IDL = SALOME_RessourcesCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) CXXFLAGS+= -LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSalomeLoggerServer +LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx index 827efd482..e9a16146c 100644 --- a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx @@ -26,117 +26,128 @@ // Module : SALOME // $Header$ -using namespace std; #include #include "SALOME_NamingService.hxx" #include "SALOME_RessourcesCatalog_impl.hxx" #include "utilities.h" -# include "Utils_SINGLETON.hxx" +#include "Utils_SINGLETON.hxx" +using namespace std; + int main(int argc,char **argv) { - try { - CosNaming::NamingContext_var _rootContext, catalogContext; + try + { + CosNaming::NamingContext_var _rootContext, catalogContext; - // initialize the ORB + // initialize the ORB - CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); + CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); - // initialize POA - // - 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_Logger::Logger_var log; - SALOME_NamingService &naming = *SINGLETON_::Instance() ; - int RESSOURCES_CATALOG=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 mgr; - for (int i = 1; i<=NumberOfTries; i++){ + // initialize POA + // + 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 RESSOURCES_CATALOG=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 mgr; + 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)) - mgr = poa->the_POAManager(); - if(!CORBA::is_nil(orb)) - theObj = orb->resolve_initial_references("NameService"); - if (!CORBA::is_nil(theObj)) - inc = CosNaming::NamingContext::_narrow(theObj); + try + { + obj = orb->resolve_initial_references("RootPOA"); + if(!CORBA::is_nil(obj)) + poa = PortableServer::POA::_narrow(obj); + if(!CORBA::is_nil(poa)) + mgr = 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( "Ressources Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) + MESSAGE( "Ressources Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + } + if(!CORBA::is_nil(inc)) + { + MESSAGE( "Ressources Catalog: 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( "Ressources Catalog: Logger Server wasn't found" ); + } + catch(...) + { + MESSAGE( "Ressources Catalog: Unknown exception" ); + } + if (!CORBA::is_nil(object)) + { + MESSAGE( "Ressources Catalog: Loger Server was found" ); + RESSOURCES_CATALOG=1; + break; + } + } } - if(!CORBA::is_nil(inc)) { - MESSAGE( "Ressources Catalog: 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( "Ressources Catalog: Logger Server wasn't found" ) } - catch(...){ MESSAGE( "Ressources Catalog: Unknown exception" ) } - if (!CORBA::is_nil(object)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "Ressources Catalog: Loger Server was found" ) - log->ping(); - RESSOURCES_CATALOG=1; - break; - } - }} - } + } if ((RESSOURCES_CATALOG==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) break; - } - // - // Active catalog + } + + // Active catalog - SALOME_RessourcesCatalogImpl* Catalogue_i = new SALOME_RessourcesCatalogImpl(argc, argv); - poa->activate_object (Catalogue_i); - mgr->activate(); - CORBA::Object_ptr myCata = Catalogue_i->_this(); + SALOME_RessourcesCatalogImpl* Catalogue_i = new SALOME_RessourcesCatalogImpl(argc, argv); + poa->activate_object (Catalogue_i); + mgr->activate(); + CORBA::Object_ptr myCata = Catalogue_i->_this(); - // initialise Naming Service - SALOME_NamingService *_NS; - _NS = new SALOME_NamingService(orb); - // register Catalog in Naming Service - _NS->Register(myCata ,"/Kernel/RessourcesCatalog"); + // initialise Naming Service + SALOME_NamingService *_NS; + _NS = new SALOME_NamingService(orb); + // register Catalog in Naming Service + _NS->Register(myCata ,"/Kernel/RessourcesCatalog"); - MESSAGE("Running Ressources Catalog Server.") + MESSAGE("Running Ressources Catalog Server.") - orb->run(); + orb->run(); - poa->destroy(1,1); + poa->destroy(1,1); - } - catch(CORBA::SystemException&) { + } + catch(CORBA::SystemException&) { INFOS("Caught CORBA::SystemException.") - } - catch(CORBA::Exception&) { + } + catch(CORBA::Exception&) { INFOS("Caught CORBA::Exception.") - } + } return 0; } diff --git a/src/SALOMEDS/Makefile.in b/src/SALOMEDS/Makefile.in index 873929b80..4fe2c6f90 100644 --- a/src/SALOMEDS/Makefile.in +++ b/src/SALOMEDS/Makefile.in @@ -107,7 +107,7 @@ BIN_CLIENT_IDL = CPPFLAGS+=$(OCC_INCLUDES) $(HDF5_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+= $(HDF5_LIBS) -lTOOLSDS -lSalomeNS -lSalomeHDFPersist -lOpUtil -lSalomeLoggerServer $(CAS_LDPATH) -lTKCAF +LDFLAGS+= $(HDF5_LIBS) -lTOOLSDS -lSalomeNS -lSalomeHDFPersist -lOpUtil -lSALOMELocalTrace $(CAS_LDPATH) -lTKCAF @CONCLUDE@ diff --git a/src/SALOMEDS/SALOMEDS_Server.cxx b/src/SALOMEDS/SALOMEDS_Server.cxx index 238dd2450..11be22065 100644 --- a/src/SALOMEDS/SALOMEDS_Server.cxx +++ b/src/SALOMEDS/SALOMEDS_Server.cxx @@ -26,17 +26,17 @@ // Module : SALOME // $Header$ -using namespace std; #include #include CORBA_SERVER_HEADER(SALOMEDS) #include "SALOMEDS_StudyManager_i.hxx" #include "utilities.h" -# include "Utils_SINGLETON.hxx" +#include "Utils_SINGLETON.hxx" #include "SALOME_NamingService.hxx" -//#define CHECKTIME + #ifdef CHECKTIME #include #endif +using namespace std; // extern "C" // { // for ccmalloc memory debug @@ -47,126 +47,142 @@ using namespace std; ////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) { -// ccmalloc_static_initialization(); + // ccmalloc_static_initialization(); MESSAGE("SALOMEDS_Server - main"); - try { - // Initialise the ORB. - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3"); - omniORB::MaxMessageSize(100 * 1024 * 1024); - // Obtain a reference to the root POA. - // - 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_Logger::Logger_var log; - int SALOMEDS=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 pman; - 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)) - pman = poa->the_POAManager(); - if(!CORBA::is_nil(orb)) - theObj = orb->resolve_initial_references("NameService"); - if (!CORBA::is_nil(theObj)){ - inc = CosNaming::NamingContext::_narrow(theObj); - if(!CORBA::is_nil(inc)) { - MESSAGE( "SalomeDS Server: Naming Service was found" ) - if(EnvL==1){ - CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; - SALOME_NamingService &NS = *SINGLETON_::Instance() ; - NS.init_orb( orb1 ) ; - 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( "SalomeDS Server: Logger Server wasn't found" ) } - catch(...){ MESSAGE( "SalomeDS Server: Unknown exception" ) } - if (!CORBA::is_nil(object)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "SalomeDS Server: Logger Server was found" ) - log->ping(); - SALOMEDS=1; - break; - } - }} - }} - - } - catch( const SALOME_Exception &ex ) + try + { + // Initialise the ORB. + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3"); + omniORB::MaxMessageSize(100 * 1024 * 1024); + // Obtain a reference to the root POA. + // + 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; + int SALOMEDS=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 pman; + for (int i = 1; i<=NumberOfTries; i++) { - MESSAGE( "Communication Error : " << ex.what() ) - return EXIT_FAILURE ; + 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)) + pman = poa->the_POAManager(); + if(!CORBA::is_nil(orb)) + theObj = orb->resolve_initial_references("NameService"); + if (!CORBA::is_nil(theObj)){ + inc = CosNaming::NamingContext::_narrow(theObj); + if(!CORBA::is_nil(inc)) + { + MESSAGE( "SalomeDS Server: Naming Service was found" ); + if(EnvL==1) + { + CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; + SALOME_NamingService &NS = *SINGLETON_::Instance() ; + NS.init_orb( orb1 ) ; + 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( "SalomeDS Server: Logger Server wasn't found" ); } + + catch(...) + { + MESSAGE( "SalomeDS Server: Unknown exception" ); + } + if (!CORBA::is_nil(object)) + { + MESSAGE( "SalomeDS Server: Logger Server was found" ); + SALOMEDS=1; + break; + } + } + } + } + } + + } + catch( const SALOME_Exception &ex ) + { + MESSAGE( "Communication Error : " << ex.what() ); + return EXIT_FAILURE ; + } + if ((SALOMEDS==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) + break; } - if ((SALOMEDS==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) - break; - } - // - // We allocate the objects on the heap. Since these are reference - // counted objects, they will be deleted by the POA when they are no - // longer needed. - SALOMEDS_StudyManager_i * myStudyManager_i = new SALOMEDS_StudyManager_i(orb); + // We allocate the objects on the heap. Since these are reference + // counted objects, they will be deleted by the POA when they are no + // longer needed. + SALOMEDS_StudyManager_i * myStudyManager_i = new SALOMEDS_StudyManager_i(orb); - // Activate the objects. This tells the POA that the objects are - // ready to accept requests. - PortableServer::ObjectId_var myStudyManager_iid = poa->activate_object(myStudyManager_i); - myStudyManager_i->register_name("/myStudyManager"); + // Activate the objects. This tells the POA that the objects are + // ready to accept requests. + PortableServer::ObjectId_var myStudyManager_iid = poa->activate_object(myStudyManager_i); + myStudyManager_i->register_name("/myStudyManager"); - // Obtain a POAManager, and tell the POA to start accepting - // requests on its objects. - pman = poa->the_POAManager(); - pman->activate(); + // Obtain a POAManager, and tell the POA to start accepting + // requests on its objects. + pman = poa->the_POAManager(); + pman->activate(); #ifdef CHECKTIME - Utils_Timer timer; - timer.Start(); - timer.Stop(); - MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); - timer.ShowAbsolute(); + Utils_Timer timer; + timer.Start(); + timer.Stop(); + MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); + timer.ShowAbsolute(); #endif - orb->run(); - orb->destroy(); - } - catch(CORBA::SystemException&) { - MESSAGE( "Caught CORBA::SystemException." ) - } - catch(CORBA::Exception&) { - MESSAGE( "Caught CORBA::Exception." ) - } - catch(omniORB::fatalException& fe) { - MESSAGE( "Caught omniORB::fatalException:" ) - MESSAGE( " file: " << fe.file() ) - MESSAGE( " line: " << fe.line() ) - MESSAGE( " mesg: " << fe.errmsg() ) - } - catch(...) { - MESSAGE( "Caught unknown exception." ) - } + orb->run(); + orb->destroy(); + } + catch(CORBA::SystemException&) + { + MESSAGE( "Caught CORBA::SystemException." ); + } + catch(CORBA::Exception&) + { + MESSAGE( "Caught CORBA::Exception." ); + } + catch(omniORB::fatalException& fe) + { + MESSAGE( "Caught omniORB::fatalException:" ); + MESSAGE( " file: " << fe.file() ); + MESSAGE( " line: " << fe.line() ); + MESSAGE( " mesg: " << fe.errmsg() ); + } + catch(...) + { + MESSAGE( "Caught unknown exception." ); + } return 0; } diff --git a/src/SALOMELocalTrace/Makefile.in b/src/SALOMELocalTrace/Makefile.in new file mode 100644 index 000000000..6e3674a3e --- /dev/null +++ b/src/SALOMELocalTrace/Makefile.in @@ -0,0 +1,49 @@ +# SALOMELocalTrace : log on local machine +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Paul RASCLE (EDF) +# Module : SALOME +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= SALOME_Log.hxx + +EXPORT_PYSCRIPTS = + +# Libraries targets + +LIB = libSALOMELocalTrace.la +LIB_SRC = SALOME_Log.cxx + +LDFLAGS+= + +@CONCLUDE@ diff --git a/src/SALOMELocalTrace/SALOME_Log.cxx b/src/SALOMELocalTrace/SALOME_Log.cxx new file mode 100644 index 000000000..476d987f4 --- /dev/null +++ b/src/SALOMELocalTrace/SALOME_Log.cxx @@ -0,0 +1,57 @@ +// SALOME_LocalTrace : log on local machine +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOME_Log.hxx +// Author : Vasily Rusyaev, Paul RASCLE, EDF +// Module : KERNEL +// $Header$ + +#include +#include + +using namespace std; + +#include "SALOME_Log.hxx" + +SALOME_Log::SALOME_Log() +{ +} + +SALOME_Log::~SALOME_Log() +{ +} + +SALOME_Log& SALOME_Log::Instance() +{ + static SALOME_Log instance; + return instance; +} + +void SALOME_Log::putMessage(std::ostream& msg) +{ + cout << std::flush; + cerr <freeze(false); + seekp(0); +} + diff --git a/src/SALOMELocalTrace/SALOME_Log.hxx b/src/SALOMELocalTrace/SALOME_Log.hxx new file mode 100644 index 000000000..043d1e1c2 --- /dev/null +++ b/src/SALOMELocalTrace/SALOME_Log.hxx @@ -0,0 +1,85 @@ +// SALOME Utils : general SALOME's definitions and tools +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOME_Log.hxx +// Author : Vasily Rusyaev (OCN), Paul RASCLE (EDF) +// Module : KERNEL +// $Header$ + +#ifndef _SALOME_LOG_HXX_ +#define _SALOME_LOG_HXX_ + +//these declarations for files don't using OCC includes (for example HDF) +# ifdef WNT + +# ifndef Standard_EXPORT +# define Standard_EXPORT __declspec( dllexport ) +// For global variables : +# define Standard_EXPORTEXTERN __declspec( dllexport ) extern +# define Standard_EXPORTEXTERNC extern "C" __declspec( dllexport ) +# endif /* Standard_EXPORT */ + +# ifndef Standard_IMPORT +# define Standard_IMPORT __declspec( dllimport ) extern +# define Standard_IMPORTC extern "C" __declspec( dllimport ) +# endif /* Standard_IMPORT */ + +# else /* WNT */ + +# ifndef Standard_EXPORT +# define Standard_EXPORT +// For global variables : +# define Standard_EXPORTEXTERN extern +# define Standard_EXPORTEXTERNC extern "C" +# endif /* Standard_EXPORT */ + +# ifndef Standard_IMPORT +# define Standard_IMPORT extern +# define Standard_IMPORTC extern "C" +# endif /* Standard_IMPORT */ + +# endif /* WNT */ + + +using namespace std; + +#include +#include + + +class SALOME_Log : public ostrstream +{ +public: + virtual ~SALOME_Log(); + static Standard_EXPORT SALOME_Log& Instance(); + Standard_EXPORT void putMessage(std::ostream& msg); + +protected: + //disable creation of instances: force use static SALOME_Log& Instance() + SALOME_Log(); +}; + + +#define SLog SALOME_Log::Instance() + +#endif diff --git a/src/SALOMELogger/Makefile.in b/src/SALOMELogger/Makefile.in new file mode 100644 index 000000000..2a9f4f5e4 --- /dev/null +++ b/src/SALOMELogger/Makefile.in @@ -0,0 +1,50 @@ +# SALOMELogger : CORBA distributed log +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Paul RASCLE (EDF) +# Module : SALOME +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= + +EXPORT_PYSCRIPTS = + +# Libraries targets + +LIB = libSALOMELoggerClient.la +LIB_SRC = SALOME_LoggerClient.cxx +LIB_CLIENT_IDL = Logger.idl + +LDFLAGS+= + +@CONCLUDE@ diff --git a/src/SALOMELogger/SALOME_LoggerClient.cxx b/src/SALOMELogger/SALOME_LoggerClient.cxx new file mode 100644 index 000000000..70f765038 --- /dev/null +++ b/src/SALOMELogger/SALOME_LoggerClient.cxx @@ -0,0 +1,154 @@ +// SALOME_LoggerClient : CORBA distributed log +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOME_Loggerclient.hxx +// Author : Vasily Rusyaev, Paul RASCLE, EDF +// Module : KERNEL +// $Header$ + +#include +#include + +using namespace std; + +#include "SALOME_Log.hxx" + +#include +#include CORBA_CLIENT_HEADER(Logger) + +// class SALOME_LoggerClient : public SALOME_Log +// { +// protected: +// SALOME_Logger::Logger_var m_pInterfaceLogger; // object reference on Logger server +// }; + +SALOME_Logger::Logger_ptr m_pInterfaceLogger; // object reference on Logger server + +SALOME_Log::SALOME_Log() +{ + cout << "SALOME_LoggerClient: constructor" << endl; + //get reference on object reference from NS + //and initialize m_pInterfaceLogger + + int argc = 1; + char* argv[1] = {"application"}; + try + { + //NB. You can't use SALOME_NamingService class because it uses MESSAGE macro + //Otherwise, you will get segmentation fault. + + //Initialize the ORB + CORBA::ORB_var orb = CORBA::ORB_init(argc,argv); + 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; + CORBA::Object_var theObj; + CORBA::Object_var obj; + CosNaming::Name name; + name.length(1); + name[0].id = CORBA::string_dup("Logger"); + for (int i = 1; i<=NumberOfTries; i++) + { + if (i!=1) + a=nanosleep(&ts_req,&ts_rem); + try + { + 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& ) + { + cout<<"SALOME_LoggerClient: CORBA::COMM_FAILURE: Unable to contact the Naming Service"<resolve(name); + m_pInterfaceLogger = SALOME_Logger::Logger::_narrow(obj); + if (!CORBA::is_nil(m_pInterfaceLogger)) + cout<<"SALOME_LoggerClient: Logger Server was found"<freeze(false); + seekp(0); + + if (CORBA::is_nil(m_pInterfaceLogger)) + cout << LogMsg << std::flush; + else + m_pInterfaceLogger-> putMessage (LogMsg) ; + } + diff --git a/src/Session/Makefile.in b/src/Session/Makefile.in index 9e95d0c62..36ba65dde 100644 --- a/src/Session/Makefile.in +++ b/src/Session/Makefile.in @@ -51,7 +51,7 @@ BIN_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Component.idl SALOM CPPFLAGS+=$(QT_MT_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lSalomeGUI -lSalomeObject -lSalomeLifeCycleCORBA -lqsplitterP -lOpUtil -lSalomeLoggerServer -lPlot2d -lSalomeVTKFilter +LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lSalomeGUI -lSalomeObject -lSalomeLifeCycleCORBA -lqsplitterP -lOpUtil -lPlot2d -lSalomeVTKFilter -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 99482aa36..2b00367c2 100644 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -26,9 +26,9 @@ // Module : SALOME // $Header$ -# include "Utils_ORB_INIT.hxx" -# include "Utils_SINGLETON.hxx" -# include "SALOME_NamingService.hxx" +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" +#include "SALOME_NamingService.hxx" #include #include using namespace std; @@ -57,110 +57,117 @@ int main(int argc, char **argv) try { - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init( argc , argv ) ; + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + CORBA::ORB_var &orb = init( argc , argv ) ; - // - 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_Logger::Logger_var log; - SALOME_NamingService &naming = *SINGLETON_::Instance() ; - int SESSION=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 pman; - for (int i = 1; i<=NumberOfTries; i++){ - if (i!=1) - a=nanosleep(&ts_req,&ts_rem); - try{ + // + 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 SESSION=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 pman; + 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); + poa = PortableServer::POA::_narrow(obj); if(!CORBA::is_nil(poa)) - pman = poa->the_POAManager(); - if(!CORBA::is_nil(orb)) - theObj = orb->resolve_initial_references("NameService"); + pman = 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( "Session Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) - } - if(!CORBA::is_nil(inc)) { - MESSAGE( "Session Server: 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( "Session Server: Logger Server wasn't found" ) } - catch(...){ MESSAGE( "Session Server: Unknown exception" ) } - if (!CORBA::is_nil(object)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "Session Server: Loger Server was found" ) - log->ping(); - SESSION=1; - break; - } - }} } - if ((SESSION==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) - break; + catch( CORBA::COMM_FAILURE& ) + { + MESSAGE( "Session Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + } + if(!CORBA::is_nil(inc)) + { + MESSAGE( "Session Server: 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( "Session Server: Logger Server wasn't found" ); + } + catch(...) + { + MESSAGE( "Session Server: Unknown exception" ); + } + if (!CORBA::is_nil(object)) + { + MESSAGE( "Session Server: Loger Server was found" ); + SESSION=1; + break; + } + } } - // + } + if ((SESSION==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) + break; + } - // servant - SALOME_Session_i * mySALOME_Session = new SALOME_Session_i(argc, argv, orb, poa) ; - PortableServer::ObjectId_var mySALOME_Sessionid = poa->activate_object(mySALOME_Session) ; - MESSAGE("poa->activate_object(mySALOME_Session)") + // servant + SALOME_Session_i * mySALOME_Session = new SALOME_Session_i(argc, argv, orb, poa) ; + PortableServer::ObjectId_var mySALOME_Sessionid = poa->activate_object(mySALOME_Session) ; + MESSAGE("poa->activate_object(mySALOME_Session)") - obj = mySALOME_Session->_this() ; - CORBA::String_var sior(orb->object_to_string(obj)) ; + obj = mySALOME_Session->_this() ; + CORBA::String_var sior(orb->object_to_string(obj)) ; - mySALOME_Session->NSregister(); + mySALOME_Session->NSregister(); - mySALOME_Session->_remove_ref() ; + mySALOME_Session->_remove_ref() ; - //DECOMMENT PortableServer::POAManager_var pman = poa->the_POAManager() ; - pman->activate() ; - MESSAGE("pman->activate()") + //DECOMMENT PortableServer::POAManager_var pman = poa->the_POAManager() ; + pman->activate() ; + MESSAGE("pman->activate()") - orb->run() ; - orb->destroy() ; + orb->run() ; + orb->destroy() ; } - catch (CORBA::SystemException&) + catch (CORBA::SystemException&) { - INFOS("Caught CORBA::SystemException.") + INFOS("Caught CORBA::SystemException."); } - catch (CORBA::Exception&) + catch (CORBA::Exception&) { - INFOS("Caught CORBA::Exception.") + INFOS("Caught CORBA::Exception."); } - catch (...) + catch (...) { - INFOS("Caught unknown exception.") + INFOS("Caught unknown exception."); } return 0 ; } diff --git a/src/TOOLSDS/Makefile.in b/src/TOOLSDS/Makefile.in index 41f346ded..a3d0a4fdc 100644 --- a/src/TOOLSDS/Makefile.in +++ b/src/TOOLSDS/Makefile.in @@ -29,7 +29,7 @@ BIN_CLIENT_IDL = CPPFLAGS+=$(OCC_INCLUDES) $(HDF5_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+= -lOpUtil -lSalomeLoggerServer $(CAS_LDPATH) -lTKernel +LDFLAGS+= -lOpUtil $(CAS_LDPATH) -lTKernel @CONCLUDE@ diff --git a/src/TestContainer/Makefile.in b/src/TestContainer/Makefile.in index 8d2709d60..8ee409d99 100644 --- a/src/TestContainer/Makefile.in +++ b/src/TestContainer/Makefile.in @@ -45,7 +45,7 @@ LIB_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl BIN = TestContainer TestLogger BIN_SRC = -LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeContainer -lRegistry -lOpUtil -lSalomeLoggerServer +LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/TestContainer/TestContainer.cxx b/src/TestContainer/TestContainer.cxx index 9849ce584..d1f1c35bb 100644 --- a/src/TestContainer/TestContainer.cxx +++ b/src/TestContainer/TestContainer.cxx @@ -26,7 +26,6 @@ // Module : SALOME // $Header$ -using namespace std; #include "utilities.h" #include #include @@ -36,10 +35,12 @@ 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" +#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[]) { @@ -55,74 +56,84 @@ int main (int argc, char * argv[]) // Obtain a reference to the root POA // - 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_Logger::Logger_var log; - SALOME_NamingService &naming = *SINGLETON_::Instance() ; - int TEST_CONTAINER=0; - const char * Env = getenv("USE_LOGGER"); + 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)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "Test Container: Loger Server was found" ) - log->ping(); - TEST_CONTAINER=1; - break; + 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/" ; diff --git a/src/Utils/Makefile.in b/src/Utils/Makefile.in index aec4b20ab..86ebc70ef 100644 --- a/src/Utils/Makefile.in +++ b/src/Utils/Makefile.in @@ -57,7 +57,7 @@ LIB_SRC = OpUtil.cxx Utils_Timer.cxx duplicate.cxx \ Utils_Identity.cxx Utils_ORB_INIT.cxx \ Utils_DESTRUCTEUR_GENERIQUE.cxx -LDFLAGS+= -lSalomeLoggerServer +LDFLAGS+= @CONCLUDE@ diff --git a/src/Utils/Utils_SALOME_Exception.cxx b/src/Utils/Utils_SALOME_Exception.cxx index 59b79a764..06f4a26f4 100644 --- a/src/Utils/Utils_SALOME_Exception.cxx +++ b/src/Utils/Utils_SALOME_Exception.cxx @@ -42,7 +42,7 @@ const char* duplicate( const char *const str ) ; SALOME_Exception::SALOME_Exception( void ): exception() , _text(0) { - MESSAGE( "You must user the standard builder : SALOME_Exception::SALOME_Exception( const char *text )" ) ; + MESSAGE( "You must use the standard builder: SALOME_Exception::SALOME_Exception( const char *text )" ) ; INTERRUPTION(1) ; } diff --git a/src/Utils/utilities.h b/src/Utils/utilities.h index 52256eae8..015e84e58 100644 --- a/src/Utils/utilities.h +++ b/src/Utils/utilities.h @@ -28,101 +28,67 @@ /* --- Definition macros file to print informations if _DEBUG_ is defined --- */ -# ifndef UTILITIES_H -# define UTILITIES_H +#ifndef UTILITIES_H +#define UTILITIES_H -# include -# include - - - -//VRV: T2.4 - replacement macro for using special CORBA server -#include "SALOME_Trace.hxx" -//VRV: T2.4 - replacement macro for using special CORBA server +#include +#include +#include "SALOME_Log.hxx" /* --- INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */ -//VRV: T2.4 - replacement of these macros for using special CORBA server - -#define INFOS(msg) { GLogger.putMessage(GLogger << __FILE__<< " [" << __LINE__ << "] : " << msg<< endl << ends ); } -#define PYSCRIPT(msg) { GLogger.putMessage(GLogger<<"---PYSCRIPT--- "<