1 #include "simple_test_i.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_stdio.h"
4 #include "tao/ORB_Core.h"
5 #include "tao/IORTable/IORTable.h"
6 #include "tao/LocalObject.h"
7 #include "tao/PortableServer/PortableServer.h"
9 CORBA::String_var testIOR
;
11 //*************************************************************************
13 : public virtual IORTable::Locator
,
14 public virtual CORBA::LocalObject
17 Task (CORBA::ORB_ptr orb
);
19 char * locate (const char *);
26 Task::locate (const char * id
)
28 CORBA::Object_var fwdObj
= orb_
->string_to_object(testIOR
.in ());
29 CORBA::String_var fwdString
= orb_
->object_to_string(fwdObj
.in ());
32 "IN LOCATOR! Forwarding client %C to: %C\n",
36 return fwdString
._retn();
39 Task::Task (CORBA::ORB_ptr orb
)
40 : orb_ (CORBA::ORB::_duplicate (orb
))
45 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
50 CORBA::ORB_init (argc
, argv
);
52 CORBA::Object_var poa_object
=
53 orb
->resolve_initial_references ("RootPOA");
55 PortableServer::POA_var root_poa
=
56 PortableServer::POA::_narrow (poa_object
.in ());
58 if (CORBA::is_nil (root_poa
.in ()))
59 ACE_ERROR_RETURN ((LM_ERROR
,
60 " (%P|%t) Panic: nil RootPOA\n"),
63 PortableServer::POAManager_var poa_manager
= root_poa
->the_POAManager ();
65 Simple_Test_i
*test_impl
= 0;
66 ACE_NEW_RETURN (test_impl
,
67 Simple_Test_i (orb
.in ()),
69 PortableServer::ServantBase_var
owner_transfer (test_impl
);
71 PortableServer::ObjectId_var id
=
72 root_poa
->activate_object (test_impl
);
74 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
76 simple::SimpleTest_T_var theServer
=
77 simple::SimpleTest_T::_narrow (object
.in ());
79 testIOR
= orb
->object_to_string (theServer
.in ());
81 poa_manager
->activate ();
88 IORTable::Locator_var
iorloc_transfer (task
);
90 // Resolve the IORTable and set the locator
91 CORBA::Object_var iorTableObj
=
92 orb
->resolve_initial_references("IORTable");
94 IORTable::Table_var local_ior_table
=
95 IORTable::Table::_narrow (iorTableObj
.in ());
97 local_ior_table
->set_locator (task
);
101 ACE_DEBUG ((LM_DEBUG
, "Server - event loop finished\n"));
103 root_poa
->destroy (true, true);
107 catch (const CORBA::Exception
& ex
)
109 ex
._tao_print_exception ("Server - Exception caught:");