1 #include "Receiver_i.h"
2 #include "Client_Task.h"
3 #include "Server_Task.h"
4 #include "ace/Get_Opt.h"
6 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
9 parse_args (int argc
, ACE_TCHAR
*argv
[])
11 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
14 while ((c
= get_opts ()) != -1)
18 ior
= get_opts
.opt_arg ();
22 ACE_ERROR_RETURN ((LM_ERROR
,
29 // Indicates successful parsing of the command line
34 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
39 CORBA::ORB_init (argc
, argv
);
41 CORBA::Object_var poa_object
=
42 orb
->resolve_initial_references("RootPOA");
44 if (CORBA::is_nil (poa_object
.in ()))
45 ACE_ERROR_RETURN ((LM_ERROR
,
46 " (%P|%t) Unable to initialize the POA.\n"),
49 PortableServer::POA_var root_poa
=
50 PortableServer::POA::_narrow (poa_object
.in ());
52 PortableServer::POAManager_var poa_manager
=
53 root_poa
->the_POAManager ();
55 if (parse_args (argc
, argv
) != 0)
58 // Get the sender reference..
59 CORBA::Object_var tmp
=
60 orb
->string_to_object(ior
);
62 Test::Sender_var sender
=
63 Test::Sender::_narrow(tmp
.in ());
65 if (CORBA::is_nil (sender
.in ()))
67 ACE_ERROR_RETURN ((LM_DEBUG
,
68 "Nil coordinator reference <%s>\n",
73 Receiver_i
*receiver_impl
;
74 ACE_NEW_RETURN (receiver_impl
,
75 Receiver_i (orb
.in (),
80 PortableServer::ServantBase_var
receiver_owner_transfer(receiver_impl
);
82 PortableServer::ObjectId_var id
=
83 root_poa
->activate_object (receiver_impl
);
85 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
87 Test::Receiver_var receiver
=
88 Test::Receiver::_narrow (object
.in ());
90 // Activate poa manager
91 poa_manager
->activate ();
93 Client_Task
client_task (sender
.in (),
95 ACE_Thread_Manager::instance (),
98 Server_Task
server_task (orb
.in (),
99 ACE_Thread_Manager::instance ());
101 // Before creating threads we will let the sender know that we
102 // will have two threads that would make invocations..
103 sender
->active_objects ((CORBA::Short
) 2);
105 if (server_task
.activate (THR_NEW_LWP
| THR_JOINABLE
, 2,1) == -1)
107 ACE_ERROR ((LM_ERROR
, "Error activating server task\n"));
110 if (client_task
.activate (THR_NEW_LWP
| THR_JOINABLE
, 2, 1) == -1)
112 ACE_ERROR ((LM_ERROR
, "Error activating client task\n"));
115 // wait for oneway sends and twoway replies to be processed
122 receiver
->shutdown ();
124 // wait for event loop to finish
127 ACE_DEBUG ((LM_DEBUG
,
128 "Event Loop finished\n"));
132 catch (const CORBA::Exception
& ex
)
134 ex
._tao_print_exception ("Exception caught:");