2 #include "ace/Arg_Shifter.h"
3 #include "tao/PortableServer/POAManager.h"
4 #include "tao/PortableServer/PortableServer.h"
6 #include "PersistentPOA.h"
9 const ACE_TCHAR
*POAname_
= 0;
10 const ACE_TCHAR
*ORBname_
= 0;
12 PersistentPoa::PersistentPoa ()
16 PersistentPoa::~PersistentPoa () noexcept
20 int PersistentPoa::init (int argc
, ACE_TCHAR
*argv
[])
24 ACE_Arg_Shifter
as(argc
, argv
);
25 POAname_
= as
.get_current();
28 ORBname_
= as
.get_current();
31 while(as
.is_anything_left())
38 DllORB
* p_orb
= ACE_Dynamic_Service
<DllORB
>::instance (ORBname_
);
40 mv_orb
= p_orb
->orb();
42 CORBA::Object_var v_poa
= mv_orb
->resolve_initial_references("RootPOA");
44 mv_rootPOA
= PortableServer::POA::_narrow(v_poa
.in ());
46 if(CORBA::is_nil(mv_rootPOA
.in()))
50 ACE_TEXT ("(%P|%t) init - nil root POA\n")
55 // Policies for the new POA
56 CORBA::PolicyList
policies(3);
60 policies
[0] = mv_rootPOA
->create_thread_policy(PortableServer::ORB_CTRL_MODEL
);
63 policies
[1] = mv_rootPOA
->create_lifespan_policy(PortableServer::PERSISTENT
);
65 // ID assignment policy
66 policies
[2] = mv_rootPOA
->create_id_assignment_policy(PortableServer::USER_ID
);
68 mv_thisPOA
= mv_rootPOA
->create_POA(
69 ACE_TEXT_ALWAYS_CHAR(POAname_
),
70 PortableServer::POAManager::_nil(),
72 if (CORBA::is_nil(mv_thisPOA
.in()))
76 ACE_TEXT ("(%P|%t) init - POA creation failed\n")
84 ACE_TEXT ("(%P|%t) init - POA created\n")
88 mv_poaManager
= mv_thisPOA
->the_POAManager();
90 mv_poaManager
->activate();
93 ACE_TEXT ("(%P|%t) init - activated POA manager\n")
100 ACE_TEXT ("(%P|%t) init - exception\n")
108 ACE_TEXT ("(%P|%t) init - POA activated\n")
115 int PersistentPoa::fini ()
121 mv_poaManager
->deactivate(1, 1);
122 mv_thisPOA
->destroy(1, 1);
123 mv_thisPOA
= PortableServer::POA::_nil();
129 ACE_TEXT ("(%P|%t) init - exception\n")
136 ACE_TEXT ("(%P|%t) fini - POA deactivated\n")
142 ACE_FACTORY_DEFINE (bug2936
, PersistentPoa
)