Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / POA / POA_Destruction / POA_Destruction.cpp
blob614d5b2108922f74caf878610f50891555ca95f8
2 //=============================================================================
3 /**
4 * @file POA_Destruction.cpp
6 * This program tests the destruction of a POA while there is an
7 * upcall in progress.
9 * @author Irfan Pyarali
11 //=============================================================================
14 #include "testS.h"
16 class test_i : public POA_test
18 public:
19 void destroy_poa ();
22 void
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,
30 wait_for_completion);
33 int
34 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
36 try
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 ();
55 test_i servant;
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 ();
66 orb->destroy ();
68 catch (const CORBA::Exception& ex)
70 ex._tao_print_exception ("Exception caught");
71 return -1;
74 return 0;