2 #include "tao/IORTable/IORTable.h"
5 public POA_AMI_test::adder
{
7 AdderServant () = default;
9 virtual ~AdderServant () = default;
12 CORBA::Long
add (CORBA::Long a
, CORBA::Long b
)
18 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[]) {
20 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
22 // Get reference to Root POA
24 = orb
->resolve_initial_references ("RootPOA");
26 PortableServer::POA_var rootPOA
= PortableServer::POA::_narrow (obj
.in ());
28 // Activate POA manager
29 PortableServer::POAManager_var mgr
30 = rootPOA
->the_POAManager ();
34 // Create Persistent Lifespan Policy and User Id Policy
35 PortableServer::LifespanPolicy_var lifespan
=
36 rootPOA
->create_lifespan_policy(PortableServer::PERSISTENT
);
37 PortableServer::IdAssignmentPolicy_var idassignment
=
38 rootPOA
->create_id_assignment_policy(PortableServer::USER_ID
);
40 // Stuff them into a policy list
41 CORBA::PolicyList
policies(2);
43 policies
[0] = PortableServer::IdAssignmentPolicy::_duplicate(idassignment
.in());
44 policies
[1] = PortableServer::LifespanPolicy::_duplicate(lifespan
.in());
46 // Create the Child POA
47 PortableServer::POA_var persistentPOA
=
48 rootPOA
->create_POA("persistentPOA", mgr
.in(), policies
);
50 // Policies are no longer needed
51 idassignment
->destroy();
57 PortableServer::ObjectId_var oid
=
58 PortableServer::string_to_ObjectId("Adder");
60 // Activate the object (with id)
61 persistentPOA
->activate_object_with_id(oid
.in(), & servant
);
63 CORBA::Object_var ref
= persistentPOA
->id_to_reference(oid
.in());
64 CORBA::String_var iors
= orb
->object_to_string(ref
.in());
66 CORBA::Object_var tobj
= orb
->resolve_initial_references("IORTable");
67 IORTable::Table_var table
= IORTable::Table::_narrow(tobj
.in());
68 table
->bind("Adder", iors
.in ());
72 ACE_ERROR ((LM_ERROR
, "ERROR: Caught exception in server"));