1 // SALOME LifeCycleCORBA : implementation of containers and engines life cycle both in Python and C++
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 : TestLifeCycleCORBA.cxx
25 // Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
29 #include "utilities.h"
32 #include <SALOMEconfig.h>
33 #include CORBA_CLIENT_HEADER(SALOME_Component)
34 #include CORBA_CLIENT_HEADER(SALOME_TestComponent)
35 #include "SALOME_NamingService.hxx"
36 #include "SALOME_LifeCycleCORBA.hxx"
40 int main (int argc, char * argv[])
45 // Initializing omniORB
46 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
48 // Obtain a reference to the root POA
49 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ;
50 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
52 SALOME_NamingService _NS(orb) ;
54 SALOME_LifeCycleCORBA _LCC(&_NS) ;
56 // get a local container (with a name based on local hostname),
57 // load an engine, and invoque methods on that engine
59 string containerName = GetHostname();
61 Engines::Component_var mycompo =
62 _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
64 ASSERT(!CORBA::is_nil(mycompo));
66 Engines::TestComponent_var m1;
67 m1 = Engines::TestComponent::_narrow(mycompo);
69 ASSERT(!CORBA::is_nil(m1));
71 SCRUTE(m1->instanceName());
72 MESSAGE("Coucou " << m1->Coucou(1L));
74 // get another container (with a fixed name),
75 // load an engine, and invoque methods on that engine
77 string containerName2 = "FactoryServerPy";
79 Engines::Component_var mycompo2 =
80 _LCC.FindOrLoad_Component(containerName2.c_str(),"SALOME_TestComponentPy");
82 ASSERT(!CORBA::is_nil(mycompo2));
84 Engines::TestComponent_var m2;
85 m2 = Engines::TestComponent::_narrow(mycompo2);
87 ASSERT(!CORBA::is_nil(m2));
89 SCRUTE(m2->instanceName());
90 MESSAGE("Coucou " << m2->Coucou(1L));
92 catch(CORBA::COMM_FAILURE& ex)
94 INFOS("Caught system exception COMM_FAILURE -- unable to contact the object.");
96 catch(CORBA::SystemException&)
98 INFOS("Caught a CORBA::SystemException.");
100 catch(CORBA::Exception&)
102 INFOS("Caught CORBA::Exception.");
106 INFOS("Caught unknown exception.");