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 ( )
14 } /* end of PersistentPoa::PersistentPoa ( ) */
17 PersistentPoa::~PersistentPoa ( )
20 } /* end of PersistentPoa::~PersistentPoa ( ) */
23 int PersistentPoa::init (int argc
, ACE_TCHAR
*argv
[])
27 ACE_Arg_Shifter
as(argc
, argv
);
28 POAname_
= as
.get_current();
31 ORBname_
= as
.get_current();
34 while(as
.is_anything_left())
41 DllORB
* p_orb
= ACE_Dynamic_Service
<DllORB
>::instance (ORBname_
);
43 mv_orb
= p_orb
->orb();
45 CORBA::Object_var v_poa
= mv_orb
->resolve_initial_references("RootPOA");
47 mv_rootPOA
= PortableServer::POA::_narrow(v_poa
.in ());
49 if(CORBA::is_nil(mv_rootPOA
.in()))
53 ACE_TEXT ("(%P|%t) init - nil root POA\n")
58 // Policies for the new POA
59 CORBA::PolicyList
policies(3);
63 policies
[0] = mv_rootPOA
->create_thread_policy(PortableServer::ORB_CTRL_MODEL
);
66 policies
[1] = mv_rootPOA
->create_lifespan_policy(PortableServer::PERSISTENT
);
68 // ID assignment policy
69 policies
[2] = mv_rootPOA
->create_id_assignment_policy(PortableServer::USER_ID
);
71 mv_thisPOA
= mv_rootPOA
->create_POA(
72 ACE_TEXT_ALWAYS_CHAR(POAname_
),
73 PortableServer::POAManager::_nil(),
76 if (CORBA::is_nil(mv_thisPOA
.in()))
80 ACE_TEXT ("(%P|%t) init - POA creation failed\n")
88 ACE_TEXT ("(%P|%t) init - POA created\n")
92 mv_poaManager
= mv_thisPOA
->the_POAManager();
94 mv_poaManager
->activate();
97 ACE_TEXT ("(%P|%t) init - activated POA manager\n")
104 ACE_TEXT ("(%P|%t) init - exception\n")
112 ACE_TEXT ("(%P|%t) init - POA activated\n")
116 } /* end of PersistentPoa::init ( ) */
119 int PersistentPoa::fini (void)
125 mv_poaManager
->deactivate(1, 1);
126 mv_thisPOA
->destroy(1, 1);
127 mv_thisPOA
= PortableServer::POA::_nil();
133 ACE_TEXT ("(%P|%t) init - exception\n")
140 ACE_TEXT ("(%P|%t) fini - POA deactivated\n")
144 } /* end of PersistentPoa::fini ( ) */
147 ACE_FACTORY_DEFINE (bug2936
, PersistentPoa
)