2 #include "ace/OS_NS_stdio.h"
5 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
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"),
23 PortableServer::POAManager_var poa_manager
=
24 root_poa
->the_POAManager ();
26 Hello
*hello_impl
= 0;
27 ACE_NEW_RETURN (hello_impl
,
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 ());
52 catch (const CORBA::Exception
& ex
)
54 ex
._tao_print_exception ("Exception caught:");