2 //=============================================================================
4 * @file POA_Destruction.cpp
6 * This program tests the destruction of a POA while there is an
9 * @author Irfan Pyarali
11 //=============================================================================
16 class test_i
: public POA_test
23 test_i::destroy_poa ()
25 PortableServer::POA_var poa
= this->_default_POA ();
27 CORBA::Boolean etherealize_objects
= 1;
28 CORBA::Boolean wait_for_completion
= 0;
29 poa
->destroy (etherealize_objects
,
34 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
38 // Initialize the ORB first.
39 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
41 // Obtain the RootPOA.
42 CORBA::Object_var obj
=
43 orb
->resolve_initial_references ("RootPOA");
45 // Get the POA_var object from Object_var.
46 PortableServer::POA_var root_poa
=
47 PortableServer::POA::_narrow (obj
.in ());
49 // Get the POAManager of the RootPOA.
50 PortableServer::POAManager_var poa_manager
=
51 root_poa
->the_POAManager ();
53 poa_manager
->activate ();
57 PortableServer::ObjectId_var id
=
58 root_poa
->activate_object (&servant
);
60 CORBA::Object_var object_act
= root_poa
->id_to_reference (id
.in ());
62 test_var test_object
= test::_narrow (object_act
.in ());
64 test_object
->destroy_poa ();
68 catch (const CORBA::Exception
& ex
)
70 ex
._tao_print_exception ("Exception caught");