4 #include "ace/Get_Opt.h"
5 #include "ace/Argv_Type_Converter.h"
6 #include "ace/OS_NS_unistd.h"
8 Client_Worker::Client_Worker ()
9 : Abstract_Worker (ACE_TEXT ("file://test.ior"))
11 // ACE_DEBUG ((LM_DEBUG, "(%P|%t) %@ Client::<ctor>\n", this));
15 Client_Worker::kind () const
17 return ACE_TEXT ("Client");
20 Client_Worker::~Client_Worker ()
22 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) %@ Client::<dtor>\n", this));
26 Client_Worker::parse_args (int argc
, ACE_TCHAR
*argv
[])
28 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"),0);
30 for( int c
= 0; ((c
= get_opts ()) != -1); )
34 this->ior_file_
= get_opts
.opt_arg ();
38 // Indicates successful parsing of the command line
43 Client_Worker::test_main (int argc
, ACE_TCHAR
*argv
[])
47 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
49 if (parse_args (argc
, argv
) != 0)
50 ACE_ERROR_RETURN ((LM_DEBUG
,
51 ACE_TEXT ("(%P|%t) Could not parse the arguments\n")),
54 // Doing this dance to allow the server some time to come up.
55 CORBA::Object_ptr co
= 0;
56 for (int attempts_left
= 5; attempts_left
> 0; --attempts_left
)
59 ACE_TEXT ("(%P|%t) Client is ready to proceed - awaiting the server ...\n")));
64 co
= orb
->string_to_object (ior_file_
.c_str ());
69 ACE_TEXT ("(%P|%t) Unable to obtain object reference yet. Retrying.\n")));
72 CORBA::Object_var
tmp (co
);
74 Test::Hello_var hello
=
75 Test::Hello::_narrow(tmp
.in ());
77 if (CORBA::is_nil (hello
.in ()))
80 ACE_TEXT ("(%P|%t) Nil Test::Hello reference <%s>. Retrying.\n"),
86 ACE_TEXT ("(%P|%t) Successfuly narrowed the Hello interface\n")));
88 CORBA::String_var the_string
=
92 ACE_TEXT ("(%P|%t) String returned from the server <%C>\n"),
97 attempts_left
= 0; // We're done here!
100 catch (const CORBA::TRANSIENT
& ex
)
105 ex
._tao_print_exception ("Temporary problem encountered");
107 ACE_DEBUG ((LM_DEBUG
,
108 ACE_TEXT ("(%P|%t) Client was too quick. Pausing ")
109 ACE_TEXT ("while the server gets ready.\n")));
112 catch (const CORBA::Exception
& ex
)
114 ex
._tao_print_exception("Unexpected CORBA exception caught");
119 ACE_DEBUG ((LM_DEBUG
,
120 ACE_TEXT ("(%P|%t) Pausing for a while.\n")));
125 orb
->shutdown (false);
129 catch (const ::CORBA::Exception
&e
)
131 e
._tao_print_exception("Client_Worker::test_main");