2 //=============================================================================
3 // File : SALOME_Registry_Server.cxx
4 // Created : Mon Nov 5 17:26:23 CET 2001
5 // Author : Pascale NOYRET - Antoine YESSAYAN, EDF
7 // Copyright : EDF 2001
9 //=============================================================================
12 # include <iostream.h>
20 # include "utilities.h"
21 # include "Utils_ORB_INIT.hxx"
22 # include "Utils_SINGLETON.hxx"
23 # include "Utils_SALOME_Exception.hxx"
24 # include "Utils_CommException.hxx"
25 # include "ServiceUnreachable.hxx"
26 # include "SALOME_NamingService.hxx"
27 # include "RegistryService.hxx"
29 int main( int argc , char **argv )
36 MESSAGE("you must provide the Salome session name when you call SALOME_Registry_Server") ;
37 throw CommException("you must provide the Salome session name when you call SALOME_Registry_Server") ;
39 const char *ptrSessionName=0 ;
42 for ( k=1 ; k<argc ; k++ )
44 if( strcmp(argv[k],"--salome_session")==0 )
46 ptrSessionName=argv[k+1] ;
50 ASSERT(ptrSessionName) ;
51 ASSERT(strlen( ptrSessionName )>0) ;
52 const char *registryName = "Registry" ;
57 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
58 CORBA::ORB_var &orb = init( argc , argv ) ;
61 SALOME_NamingService &naming = *SINGLETON_<SALOME_NamingService>::Instance() ;
62 naming.init_orb( orb ) ;
64 RegistryService *ptrRegistry = SINGLETON_<RegistryService>::Instance() ;
65 ptrRegistry->SessionName( ptrSessionName ) ;
66 Registry::Components_var varComponents = ptrRegistry->_this() ;
68 // The RegistryService must not already exist.
72 CORBA::Object_var pipo = naming.Resolve( registryName ) ;
73 if (CORBA::is_nil(pipo) ) throw ServiceUnreachable() ;
74 MESSAGE("RegistryService servant already existing" ) ;
75 exit( EXIT_FAILURE ) ;
77 catch( const ServiceUnreachable &ex )
80 catch( const CORBA::Exception &exx )
83 string absoluteName = string("/") + registryName;
84 naming.Register( varComponents , absoluteName.c_str() ) ;
87 CORBA::Object_var poaObj = orb->resolve_initial_references( "RootPOA" ) ;
88 PortableServer::POA_var poa = PortableServer::POA::_narrow(poaObj) ;
89 PortableServer::POAManager_var manager = poa->the_POAManager() ;
92 MESSAGE("On attend les requetes des clients") ;
96 MESSAGE("Activation du POA") ;
100 MESSAGE("Lancement de l'ORB") ;
103 catch( const CORBA::Exception &ex )
105 MESSAGE("Erreur systeme") ;
106 return EXIT_FAILURE ;
110 catch( const SALOME_Exception &ex )
112 MESSAGE( "Communication Error : " << ex.what() )
113 return EXIT_FAILURE ;