2 //=============================================================================
4 * @file Non_Servant_Upcalls.cpp
6 * This program tests the users ability to make calls on a POA
7 * during non-servant upcalls. In this example, a servant which
8 * is being destroyed during because of a deactivate_object()
9 * call, tries to deactivate another object in its destructor.
11 * @author Irfan Pyarali
13 //=============================================================================
19 public virtual POA_test
22 test_i (test_i
*other
);
29 test_i::test_i (test_i
*other
)
36 ACE_DEBUG ((LM_DEBUG
, "(%t) test_i::~test_i\n"));
42 PortableServer::POA_var poa
= this->_default_POA ();
44 PortableServer::ObjectId_var id
= poa
->servant_to_id (this->other_
);
46 ACE_DEBUG ((LM_DEBUG
, "(%t) Deactivating other servant\n"));
48 poa
->deactivate_object (id
.in ());
50 catch (const CORBA::Exception
& ex
)
52 ex
._tao_print_exception ("test_i::~test_i");
58 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
62 // Initialize the ORB first.
63 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
65 // Obtain the RootPOA.
66 CORBA::Object_var obj
=
67 orb
->resolve_initial_references ("RootPOA");
69 // Get the POA_var object from Object_var.
70 PortableServer::POA_var root_poa
=
71 PortableServer::POA::_narrow (obj
.in ());
73 // Get the POAManager of the RootPOA.
74 PortableServer::POAManager_var poa_manager
=
75 root_poa
->the_POAManager ();
77 poa_manager
->activate ();
79 test_i
*servant1
= new test_i (0);
80 test_i
*servant2
= new test_i (servant1
);
82 PortableServer::ObjectId_var id1
=
83 root_poa
->activate_object (servant1
);
85 // Give ownership to POA.
86 servant1
->_remove_ref ();
88 PortableServer::ObjectId_var id2
=
89 root_poa
->activate_object (servant2
);
91 // Give ownership to POA.
92 servant2
->_remove_ref ();
94 root_poa
->deactivate_object (id2
.in ());
96 root_poa
->destroy (true, true);
100 catch (const CORBA::Exception
& ex
)
102 ex
._tao_print_exception ("Exception caught");