1 // SALOME Registry : Registry server implementation
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_Registry_Server.cxx
25 // Author : Pascale NOYRET - Antoine YESSAYAN, EDF
31 # include <iostream.h>
39 # include "utilities.h"
40 # include "Utils_ORB_INIT.hxx"
41 # include "Utils_SINGLETON.hxx"
42 # include "Utils_SALOME_Exception.hxx"
43 # include "Utils_CommException.hxx"
44 # include "ServiceUnreachable.hxx"
45 # include "SALOME_NamingService.hxx"
46 # include "RegistryService.hxx"
50 #include <Utils_Timer.hxx>
53 int main( int argc , char **argv )
60 MESSAGE("you must provide the Salome session name when you call SALOME_Registry_Server") ;
61 throw CommException("you must provide the Salome session name when you call SALOME_Registry_Server") ;
63 const char *ptrSessionName=0 ;
66 for ( k=1 ; k<argc ; k++ )
68 if( strcmp(argv[k],"--salome_session")==0 )
70 ptrSessionName=argv[k+1] ;
74 ASSERT(ptrSessionName) ;
75 ASSERT(strlen( ptrSessionName )>0) ;
76 const char *registryName = "Registry" ;
81 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
82 CORBA::ORB_var &orb = init( argc , argv ) ;
85 SALOME_NamingService &naming = *SINGLETON_<SALOME_NamingService>::Instance() ;
86 naming.init_orb( orb ) ;
88 RegistryService *ptrRegistry = SINGLETON_<RegistryService>::Instance() ;
89 ptrRegistry->SessionName( ptrSessionName ) ;
90 Registry::Components_var varComponents = ptrRegistry->_this() ;
92 // The RegistryService must not already exist.
96 CORBA::Object_var pipo = naming.Resolve( registryName ) ;
97 if (CORBA::is_nil(pipo) ) throw ServiceUnreachable() ;
98 MESSAGE("RegistryService servant already existing" ) ;
99 exit( EXIT_FAILURE ) ;
101 catch( const ServiceUnreachable &ex )
104 catch( const CORBA::Exception &exx )
107 string absoluteName = string("/") + registryName;
108 naming.Register( varComponents , absoluteName.c_str() ) ;
111 CORBA::Object_var poaObj = orb->resolve_initial_references( "RootPOA" ) ;
112 PortableServer::POA_var poa = PortableServer::POA::_narrow(poaObj) ;
113 PortableServer::POAManager_var manager = poa->the_POAManager() ;
116 MESSAGE("On attend les requetes des clients") ;
120 MESSAGE("Activation du POA") ;
121 manager->activate() ;
123 // Lancement de l'ORB
124 MESSAGE("Lancement de l'ORB") ;
129 MESSAGE("SALOME_Registry_Server.cxx - orb->run()");
130 timer.ShowAbsolute();
134 catch( const CORBA::Exception &ex )
136 MESSAGE("Erreur systeme") ;
137 return EXIT_FAILURE ;
141 catch( const SALOME_Exception &ex )
143 MESSAGE( "Communication Error : " << ex.what() )
144 return EXIT_FAILURE ;