2 //=============================================================================
3 // File : TestContainer.cxx
4 // Created : jeu jui 12 13:11:27 CEST 2001
5 // Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
7 // Copyright : EDF 2001
9 //=============================================================================
11 #include "utilities.h"
14 #include <SALOMEconfig.h>
15 #include CORBA_CLIENT_HEADER(SALOME_Component)
16 #include CORBA_CLIENT_HEADER(SALOME_TestComponent)
18 #include "SALOME_NamingService.hxx"
21 int main (int argc, char * argv[])
26 // Initializing omniORB
27 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
29 // use IOR to find container
30 //if (argc != 2) { return 1; }
31 //CORBA::Object_var obj = orb->string_to_object(argv[1]);
32 //Engines::Container_var iGenFact = Engines::Container::_narrow(obj);
34 // Obtain a reference to the root POA
35 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ;
36 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
38 // Use Name Service to find container
39 SALOME_NamingService _NS(orb) ;
40 string containerName = "/Containers/" ;
41 string hostName = GetHostname();
42 containerName += hostName;
44 obj = _NS.Resolve(containerName.c_str()) ;
45 Engines::Container_var iGenFact = Engines::Container::_narrow(obj);
47 Engines::TestComponent_var m1;
49 for (int iter = 0; iter < 3 ; iter++)
51 MESSAGE("----------------------------------------------------" << iter);
53 obj = iGenFact->load_impl("SalomeTestComponent",
54 "../lib/libSalomeTestComponentEngine.so");
55 m1 = Engines::TestComponent::_narrow(obj);
57 SCRUTE(m1->instanceName());
58 MESSAGE("Coucou " << m1->Coucou(1L));
59 iGenFact->remove_impl(m1) ;
60 //iGenFact->finalize_removal() ; // unpredictable results ...
64 iGenFact->finalize_removal() ;
67 catch(CORBA::COMM_FAILURE& ex) {
68 INFOS("Caught system exception COMM_FAILURE -- unable to contact the object.")
70 catch(CORBA::SystemException&) {
71 INFOS("Caught a CORBA::SystemException.")
73 catch(CORBA::Exception&) {
74 INFOS("Caught CORBA::Exception.")
77 INFOS("Caught unknown exception.")