3 #include "MPIContainer_i.hxx"
7 int main(int argc, char* argv[])
10 MPIContainer_i * myContainer;
15 MESSAGE("Connection MPI");
17 MPI_Init(&argc,&argv);
18 MPI_Comm_size(MPI_COMM_WORLD,&nbproc);
19 MPI_Comm_rank(MPI_COMM_WORLD,&numproc);
21 MESSAGE("Initialisation CORBA");
22 // Initialise the ORB.
23 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
25 // Obtain a reference to the root POA.
26 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
27 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
29 // obtain the root poa manager
30 PortableServer::POAManager_var pman = root_poa->the_POAManager();
32 // define policy objects
33 PortableServer::ImplicitActivationPolicy_var implicitActivation =
34 root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ;
36 // default = NO_IMPLICIT_ACTIVATION
37 PortableServer::ThreadPolicy_var threadPolicy =
38 root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ;
39 // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL
42 CORBA::PolicyList policyList;
44 policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ;
45 policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ;
47 // create the child POA
48 PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ;
49 PortableServer::POA_var factory_poa =
50 root_poa->create_POA("factory_poa", pman, policyList) ;
51 //with nil_mgr instead of pman, a new POA manager is created with the new POA
53 // destroy policy objects
54 implicitActivation->destroy() ;
55 threadPolicy->destroy() ;
57 char *containerName = "";
60 containerName = argv[1] ;
63 MESSAGE("Chargement container sur proc: " << numproc);
64 myContainer = new MPIContainer_i(nbproc,numproc,orb,factory_poa, containerName);
65 MESSAGE("Fin chargement container");
75 catch(CORBA::SystemException&) {
76 INFOS("Caught CORBA::SystemException.")
78 catch(PortableServer::POA::WrongPolicy&)
80 INFOS("Caught CORBA::WrongPolicyException.")
82 catch(PortableServer::POA::ServantAlreadyActive&)
84 INFOS("Caught CORBA::ServantAlreadyActiveException")
86 catch(CORBA::Exception&) {
87 INFOS("Caught CORBA::Exception.")
90 INFOS("Caught unknown exception.")