1 #include "ace/Arg_Shifter.h"
2 #include "tao/PortableServer/POAManager.h"
3 #include "tao/PortableServer/PortableServer.h"
5 #include "PersistentPoa.h"
7 PersistentPoa::PersistentPoa ()
11 PersistentPoa::~PersistentPoa () noexcept
15 int PersistentPoa::init (int argc
, ACE_TCHAR
*argv
[])
17 ACE_Arg_Shifter
as (argc
, argv
);
18 m_poaName
= std::string (ACE_TEXT_ALWAYS_CHAR (as
.get_current ()));
21 std::string
orbName (ACE_TEXT_ALWAYS_CHAR (as
.get_current()));
24 while (as
.is_anything_left ())
31 // left out all safety checks
32 DllOrb
* p_orb
= ACE_Dynamic_Service
<DllOrb
>::instance (orbName
.c_str ());
33 mv_orb
= p_orb
->orb ();
34 CORBA::Object_var v_poa
= mv_orb
->resolve_initial_references ("RootPOA");
35 mv_rootPOA
= PortableServer::POA::_narrow (v_poa
.in ());
37 // Policies for the new POA
38 CORBA::PolicyList
policies (3);
40 policies
[0] = mv_rootPOA
->create_thread_policy (PortableServer::ORB_CTRL_MODEL
);
41 policies
[1] = mv_rootPOA
->create_lifespan_policy (PortableServer::PERSISTENT
);
42 policies
[2] = mv_rootPOA
->create_id_assignment_policy (PortableServer::USER_ID
);
44 mv_thisPOA
= mv_rootPOA
->create_POA (
46 PortableServer::POAManager::_nil (),
49 mv_poaManager
= mv_thisPOA
->the_POAManager ();
50 mv_poaManager
->activate ();
54 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("activate failed\n")));
58 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("POA activated\n")));
64 int PersistentPoa::fini ()
68 mv_poaManager
->deactivate (1, 1);
69 mv_poaManager
= PortableServer::POAManager::_nil ();
71 mv_thisPOA
->destroy (1, 1);
72 mv_thisPOA
= PortableServer::POA::_nil ();
76 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("deactivate failed\n")));
80 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("POA deactivated\n")));
86 ACE_FACTORY_DEFINE (bug_3251
, PersistentPoa
)