2 #include "MPIContainer_i.hxx"
3 #include "Utils_ORB_INIT.hxx"
4 #include "Utils_SINGLETON.hxx"
9 int main(int argc, char* argv[])
13 Engines_MPIContainer_i * myContainer=NULL;
18 MESSAGE("Connection MPI");
19 MPI_Init(&argc,&argv);
20 MPI_Comm_size(MPI_COMM_WORLD,&nbproc);
21 MPI_Comm_rank(MPI_COMM_WORLD,&numproc);
23 MESSAGE("[" << numproc << "] Initialisation CORBA");
24 // Initialise the ORB.
25 // CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
26 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
27 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
28 CORBA::ORB_var &orb = init( argc , argv ) ;
30 // Obtain a reference to the root POA.
31 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
32 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
34 // obtain the root poa manager
35 PortableServer::POAManager_var pman = root_poa->the_POAManager();
37 // define policy objects
38 PortableServer::ImplicitActivationPolicy_var implicitActivation =
39 root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ;
41 // default = NO_IMPLICIT_ACTIVATION
42 PortableServer::ThreadPolicy_var threadPolicy =
43 root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ;
44 // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL
47 CORBA::PolicyList policyList;
49 policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ;
50 policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ;
52 // create the child POA
53 PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ;
54 PortableServer::POA_var factory_poa =
55 root_poa->create_POA("factory_poa", pman, policyList) ;
56 //with nil_mgr instead of pman, a new POA manager is created with the new POA
58 // destroy policy objects
59 implicitActivation->destroy() ;
60 threadPolicy->destroy() ;
62 char *containerName = "";
65 containerName = argv[1] ;
68 MESSAGE("[" << numproc << "] Chargement container");
69 myContainer = new Engines_MPIContainer_i(nbproc,numproc,orb,factory_poa, containerName,argc,argv);
77 catch(CORBA::SystemException&){
78 INFOS("Caught CORBA::SystemException.");
80 catch(PortableServer::POA::WrongPolicy&){
81 INFOS("Caught CORBA::WrongPolicyException.");
83 catch(PortableServer::POA::ServantAlreadyActive&){
84 INFOS("Caught CORBA::ServantAlreadyActiveException");
86 catch(CORBA::Exception&){
87 INFOS("Caught CORBA::Exception.");
90 INFOS("Caught unknown exception.");
95 MPI_Initialized(&flag);