2 //=============================================================================
3 // File : TestLifeCycleCORBA.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)
17 #include "SALOME_NamingService.hxx"
18 #include "SALOME_LifeCycleCORBA.hxx"
21 int main (int argc, char * argv[])
26 // Initializing omniORB
27 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
29 // Obtain a reference to the root POA
30 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ;
31 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
33 SALOME_NamingService _NS(orb) ;
35 SALOME_LifeCycleCORBA _LCC(&_NS) ;
37 // get a local container (with a name based on local hostname),
38 // load an engine, and invoque methods on that engine
40 string containerName = GetHostname();
42 Engines::Component_var mycompo =
43 _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
45 ASSERT(!CORBA::is_nil(mycompo));
47 Engines::TestComponent_var m1;
48 m1 = Engines::TestComponent::_narrow(mycompo);
50 ASSERT(!CORBA::is_nil(m1));
52 SCRUTE(m1->instanceName());
53 MESSAGE("Coucou " << m1->Coucou(1L));
55 // get another container (with a fixed name),
56 // load an engine, and invoque methods on that engine
58 string containerName2 = "FactoryServerPy";
60 Engines::Component_var mycompo2 =
61 _LCC.FindOrLoad_Component(containerName2.c_str(),"SALOME_TestComponentPy");
63 ASSERT(!CORBA::is_nil(mycompo2));
65 Engines::TestComponent_var m2;
66 m2 = Engines::TestComponent::_narrow(mycompo2);
68 ASSERT(!CORBA::is_nil(m2));
70 SCRUTE(m2->instanceName());
71 MESSAGE("Coucou " << m2->Coucou(1L));
73 catch(CORBA::COMM_FAILURE& ex)
75 INFOS("Caught system exception COMM_FAILURE -- unable to contact the object.");
77 catch(CORBA::SystemException&)
79 INFOS("Caught a CORBA::SystemException.");
81 catch(CORBA::Exception&)
83 INFOS("Caught CORBA::Exception.");
87 INFOS("Caught unknown exception.");