Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Bug_2345_Regression / server.cpp
blobadc4efac59f1b1c875bf912bb8de744ae82cc036
1 #include "tao/PortableServer/PortableServer.h"
2 #include "tao/ImR_Client/ImR_Client.h"
4 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
6 // Put orb outside try scope since there will be an
7 // exception and it will not be possible to call
8 // orb->destroy() at the end, hence memory leak.
9 CORBA::ORB_var orb = CORBA::ORB::_nil();
11 try
13 // Initialize the ORB.
15 orb = CORBA::ORB_init(argc, argv);
16 CORBA::Object_var poa_obj = orb->resolve_initial_references("RootPOA");
17 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(poa_obj.in ());
19 // Create a PERSISTENT POA
21 // Create the policy list
22 CORBA::PolicyList policies(2);
23 policies.length(2);
24 policies[0] = root_poa->create_lifespan_policy(PortableServer::PERSISTENT);
25 policies[1] = root_poa->create_id_assignment_policy(PortableServer::USER_ID);
27 // create the poa.
28 // for ORBUseIMR=1 -ORBDefaultInitRef corbaloc:iiop:<HOST>:<PORT>
29 // this will cause an access violation if no IMR server is found.
30 // The access violation WILL NOT HAPPEN if a POAManager is created and
31 // given as a parameter to create_POA (instead of a nil POAManager)
32 PortableServer::POA_var persistent_poa =
33 root_poa->create_POA("myPoa", PortableServer::POAManager::_nil(), policies);
35 return 0;
37 catch (const CORBA::Exception&)
39 // ... normally print an error here
42 orb->destroy ();
43 return 0;