2 #include "MPIContainer_i.hxx"
3 #include "Utils_ORB_INIT.hxx"
4 #include "Utils_SINGLETON.hxx"
7 #include "LocalTraceCollector.hxx"
10 int main(int argc, char* argv[])
14 Engines_MPIContainer_i * myContainer=NULL;
16 MPI_Init(&argc,&argv);
17 MPI_Comm_size(MPI_COMM_WORLD,&nbproc);
18 MPI_Comm_rank(MPI_COMM_WORLD,&numproc);
20 // Initialise the ORB.
21 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
22 CORBA::ORB_var &orb = init( argc , argv ) ;
23 LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb);
25 BEGIN_OF("[" << numproc << "] " << argv[0])
28 // Obtain a reference to the root POA.
29 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
30 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
32 // obtain the root poa manager
33 PortableServer::POAManager_var pman = root_poa->the_POAManager();
35 // define policy objects
36 PortableServer::ImplicitActivationPolicy_var implicitActivation =
37 root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ;
39 // default = NO_IMPLICIT_ACTIVATION
40 PortableServer::ThreadPolicy_var threadPolicy =
41 root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ;
42 // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL
45 CORBA::PolicyList policyList;
47 policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ;
48 policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ;
50 // create the child POA
51 PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ;
52 PortableServer::POA_var factory_poa =
53 root_poa->create_POA("factory_poa", pman, policyList) ;
54 //with nil_mgr instead of pman, a new POA manager is created with the new POA
56 // destroy policy objects
57 implicitActivation->destroy() ;
58 threadPolicy->destroy() ;
60 char *containerName = "";
63 containerName = argv[1] ;
66 MESSAGE("[" << numproc << "] MPIContainer: load MPIContainer servant");
67 myContainer = new Engines_MPIContainer_i(nbproc,numproc,orb,factory_poa, containerName,argc,argv);
75 catch(CORBA::SystemException&){
76 INFOS("Caught CORBA::SystemException.");
78 catch(PortableServer::POA::WrongPolicy&){
79 INFOS("Caught CORBA::WrongPolicyException.");
81 catch(PortableServer::POA::ServantAlreadyActive&){
82 INFOS("Caught CORBA::ServantAlreadyActiveException");
84 catch(CORBA::Exception&){
85 INFOS("Caught CORBA::Exception.");
88 INFOS("Caught unknown exception.");
93 MPI_Initialized(&flag);
97 END_OF("[" << numproc << "] " << argv[0]);