Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / POA / Deactivate_Object / server.cpp
blob57c35e134baee81fc3b9068b820a7dcc908f9cdf
1 #include "Hello.h"
2 #include "ace/OS_NS_stdio.h"
4 int
5 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
7 try
9 CORBA::ORB_var orb =
10 CORBA::ORB_init (argc, argv);
12 CORBA::Object_var poa_object =
13 orb->resolve_initial_references("RootPOA");
15 PortableServer::POA_var root_poa =
16 PortableServer::POA::_narrow (poa_object.in ());
18 if (CORBA::is_nil (root_poa.in ()))
19 ACE_ERROR_RETURN ((LM_ERROR,
20 " (%P|%t) Panic: nil RootPOA\n"),
21 1);
23 PortableServer::POAManager_var poa_manager =
24 root_poa->the_POAManager ();
26 Hello *hello_impl = 0;
27 ACE_NEW_RETURN (hello_impl,
28 Hello (orb.in ()),
29 1);
31 PortableServer::ServantBase_var owner_transfer(hello_impl);
33 poa_manager->activate ();
35 PortableServer::ObjectId_var obj_id = root_poa->activate_object (hello_impl);
37 CORBA::Object_var obj_var = root_poa->id_to_reference (obj_id.in ());
39 PortableServer::ObjectId_var new_obj_id = root_poa->reference_to_id (obj_var.in ());
41 // Invoke reference_to_servant(). Should retrieve servant.
42 PortableServer::ServantBase_var servant =
43 root_poa->reference_to_servant (obj_var.in ());
45 // Assert correctness.
46 ACE_ASSERT (hello_impl == servant.in());
48 root_poa->deactivate_object (new_obj_id.in ());
50 orb->destroy ();
52 catch (const CORBA::Exception& ex)
54 ex._tao_print_exception ("Exception caught:");
55 return 1;
58 return 0;