More tests update
[ACE_TAO.git] / TAO / tests / Bug_3251_Regression / PersistentPoa.cpp
blobfa78847117a7ab9ca83c861c453d1c192744a77a
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 ( )
12 throw ()
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 ()));
20 as.ignore_arg ();
22 std::string orbName (ACE_TEXT_ALWAYS_CHAR (as.get_current()));
23 as.ignore_arg ();
25 while (as.is_anything_left ())
27 as.ignore_arg();
30 try
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);
40 policies.length (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 (
46 m_poaName.c_str (),
47 PortableServer::POAManager::_nil (),
48 policies
51 mv_poaManager = mv_thisPOA->the_POAManager ();
52 mv_poaManager->activate ();
54 catch (...)
56 ACE_DEBUG ((LM_ERROR, ACE_TEXT ("activate failed\n")));
57 return -1;
60 ACE_DEBUG ((LM_ERROR, ACE_TEXT ("POA activated\n")));
62 return 0;
63 } /* end of PersistentPoa::init ( ) */
66 int PersistentPoa::fini (void)
68 try
70 mv_poaManager->deactivate (1, 1);
71 mv_poaManager = PortableServer::POAManager::_nil ();
73 mv_thisPOA->destroy (1, 1);
74 mv_thisPOA = PortableServer::POA::_nil ();
76 catch(...)
78 ACE_DEBUG ((LM_ERROR, ACE_TEXT ("deactivate failed\n")));
79 return -1;
82 ACE_DEBUG ((LM_ERROR, ACE_TEXT ("POA deactivated\n")));
84 return 0;
85 } /* end of PersistentPoa::fini ( ) */
88 ACE_FACTORY_DEFINE (bug_3251, PersistentPoa)