2 #include "Terminator.h"
4 #include "tao/IORTable/IORTable.h"
5 #include "tao/PortableServer/Root_POA.h"
6 #include "tao/ImR_Client/ImR_Client.h"
10 PortableServer::POA_ptr
11 createPOA(PortableServer::POA_ptr root_poa
, const char* poa_name
)
13 PortableServer::LifespanPolicy_var life
=
14 root_poa
->create_lifespan_policy(PortableServer::PERSISTENT
);
16 PortableServer::IdAssignmentPolicy_var assign
=
17 root_poa
->create_id_assignment_policy(PortableServer::USER_ID
);
19 CORBA::PolicyList pols
;
21 pols
[0] = PortableServer::LifespanPolicy::_duplicate(life
.in());
22 pols
[1] = PortableServer::IdAssignmentPolicy::_duplicate(assign
.in());
24 PortableServer::POAManager_var mgr
= root_poa
->the_POAManager();
25 PortableServer::POA_var poa
=
26 root_poa
->create_POA(poa_name
, mgr
.in(), pols
);
35 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
38 CORBA::ORB_var orb
= CORBA::ORB_init(argc
, argv
);
40 CORBA::Object_var obj
= orb
->resolve_initial_references("RootPOA");
41 PortableServer::POA_var root_poa
= PortableServer::POA::_narrow(obj
.in());
43 PortableServer::POAManager_var mgr
= root_poa
->the_POAManager();
45 const char* poa_name
= "TestService";
47 PortableServer::POA_var test_poa
= createPOA(root_poa
.in(), poa_name
);
49 Terminator terminator
;
50 if (terminator
.open (0) == -1)
51 ACE_ERROR_RETURN((LM_ERROR
,
52 ACE_TEXT ("main Error opening terminator\n")),-1);
54 PortableServer::Servant_var
<Test_i
> test_servant
=
55 new Test_i(terminator
);
57 PortableServer::ObjectId_var object_id
=
58 PortableServer::string_to_ObjectId("test_object");
60 test_poa
->activate_object_with_id(object_id
.in(), test_servant
.in());
62 TAO_Root_POA
* tpoa
= dynamic_cast<TAO_Root_POA
*>(test_poa
.in());
63 obj
= tpoa
->id_to_reference_i(object_id
.in(), false);
64 CORBA::String_var test_ior
= orb
->object_to_string(obj
.in());
65 obj
= orb
->resolve_initial_references("IORTable");
66 IORTable::Table_var table
= IORTable::Table::_narrow(obj
.in());
67 table
->bind(poa_name
, test_ior
.in());
71 std::cout
<< "Test server ready." << std::endl
;
75 std::cout
<< "Test server shutting down." << std::endl
;
77 root_poa
->destroy(1,1);
80 ACE_Message_Block
*mb
;
81 ACE_NEW_RETURN(mb
, ACE_Message_Block(0, ACE_Message_Block::MB_HANGUP
), -1);
85 catch(const CORBA::Exception
& ex
) {
86 std::cerr
<< "Server main() Caught CORBA::Exception" << ex
<< std::endl
;