1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SALOME ParallelContainerProxyDummy : Proxy of a PaCO++ object using Dummy
23 // File : SALOME_ParallelContainerProxyDummy.cxx
24 // Author : André Ribes, EDF
25 // Module : SALOME PARALLEL
38 //#include "SALOME_ComponentPaCO_Engines_Container_server.h"
39 #include "SALOME_ParallelContainerProxy_i.hxx"
40 #include <paco_omni.h>
41 #include <paco_dummy.h>
43 #include "SALOME_NamingService.hxx"
45 #include "utilities.h"
46 #include "Utils_ORB_INIT.hxx"
47 #include "Utils_SINGLETON.hxx"
48 #include "SALOMETraceCollector.hxx"
56 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
57 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
58 cerr << "SIGSEGV in :" << getpid() << endl;
59 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
60 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
65 int main(int argc, char* argv[])
67 INFOS("Launching a parallel proxy container");
70 signal(SIGSEGV, handler);
72 // Initialise the ORB.
73 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
75 std::string containerName("");
77 containerName = argv[1];
81 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
82 ASSERT(!CORBA::is_nil(obj));
83 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
84 PortableServer::POAManager_var pman = root_poa->the_POAManager();
87 // add this container to the kill list
89 sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxyDummy", getpid());
93 SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
94 // Engines::Container_proxy_impl * proxy =
95 // new Engines::Container_proxy_impl(orb,
96 // new paco_omni_fabrique());
98 Container_proxy_impl_final * proxy =
99 new Container_proxy_impl_final(orb,
100 new paco_omni_fabrique());
102 paco_fabrique_manager* pfm = paco_getFabriqueManager();
103 pfm->register_com("dummy", new paco_dummy_fabrique());
104 proxy->setLibCom("dummy", proxy);
105 pfm->register_thread("omnithread", new paco_omni_fabrique());
106 proxy->setLibThread("omnithread");
107 // Topo of the parallel object
108 PaCO::PacoTopology_t serveur_topo;
109 serveur_topo.total = 1;
110 proxy->setTopology(serveur_topo);
112 PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
113 obj = root_poa->id_to_reference(_id);
115 // In the NamingService
116 string hostname = Kernel_Utils::GetHostname();
117 Engines::Container_var pCont = Engines::Container::_narrow(obj);
118 string _containerName = ns->BuildContainerNameForNS(containerName.c_str(),
120 cerr << "---------" << _containerName << "----------" << endl;
121 ns->Register(pCont, _containerName.c_str());
125 catch (PaCO::PACO_Exception& e)
127 INFOS("Caught PaCO::PACO_Exception");
128 std::cerr << e << std::endl;
130 catch(CORBA::SystemException&)
132 INFOS("Caught CORBA::SystemException.");
134 catch(PortableServer::POA::ServantAlreadyActive&)
136 INFOS("Caught CORBA::ServantAlreadyActiveException");
138 catch(CORBA::Exception&)
140 INFOS("Caught CORBA::Exception.");
142 catch(std::exception& exc)
144 INFOS("Caught std::exception - "<<exc.what());
148 INFOS("Caught unknown exception.");