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 ( )
9 } /* end of PersistentPoa::PersistentPoa ( ) */
11 PersistentPoa::~PersistentPoa ( )
14 } /* end of PersistentPoa::~PersistentPoa ( ) */
16 int PersistentPoa::init (int argc
, ACE_TCHAR
*argv
[])
18 ACE_Arg_Shifter
as (argc
, argv
);
19 m_poaName
= std::string (ACE_TEXT_ALWAYS_CHAR (as
.get_current ()));
22 std::string
orbName (ACE_TEXT_ALWAYS_CHAR (as
.get_current()));
25 while (as
.is_anything_left ())
32 // left out all safety checks
33 DllOrb
* p_orb
= ACE_Dynamic_Service
<DllOrb
>::instance (orbName
.c_str ());
34 mv_orb
= p_orb
->orb ();
35 CORBA::Object_var v_poa
= mv_orb
->resolve_initial_references ("RootPOA");
36 mv_rootPOA
= PortableServer::POA::_narrow (v_poa
.in ());
38 // Policies for the new POA
39 CORBA::PolicyList
policies (3);
41 policies
[0] = mv_rootPOA
->create_thread_policy (PortableServer::ORB_CTRL_MODEL
);
42 policies
[1] = mv_rootPOA
->create_lifespan_policy (PortableServer::PERSISTENT
);
43 policies
[2] = mv_rootPOA
->create_id_assignment_policy (PortableServer::USER_ID
);
45 mv_thisPOA
= mv_rootPOA
->create_POA (
47 PortableServer::POAManager::_nil (),
51 mv_poaManager
= mv_thisPOA
->the_POAManager ();
52 mv_poaManager
->activate ();
56 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("activate failed\n")));
60 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("POA activated\n")));
63 } /* end of PersistentPoa::init ( ) */
66 int PersistentPoa::fini (void)
70 mv_poaManager
->deactivate (1, 1);
71 mv_poaManager
= PortableServer::POAManager::_nil ();
73 mv_thisPOA
->destroy (1, 1);
74 mv_thisPOA
= PortableServer::POA::_nil ();
78 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("deactivate failed\n")));
82 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("POA deactivated\n")));
85 } /* end of PersistentPoa::fini ( ) */
88 ACE_FACTORY_DEFINE (bug_3251
, PersistentPoa
)