=default for generated implementation copy ctor
[ACE_TAO.git] / TAO / tests / ORB_Local_Config / Two_DLL_ORB / client.cpp
blobe14fe88085527cde9645268b17e84bebb5426e95
1 #include "Test_i.h"
2 #include "ORB_DLL.h"
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));
14 const ACE_TCHAR *
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));
25 int
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); )
31 switch (c)
33 case 'k':
34 this->ior_file_ = get_opts.opt_arg ();
35 break;
38 // Indicates successful parsing of the command line
39 return 0;
42 int
43 Client_Worker::test_main (int argc, ACE_TCHAR *argv[])
45 try
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")),
52 1);
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)
58 ACE_DEBUG ((LM_DEBUG,
59 ACE_TEXT ("(%P|%t) Client is ready to proceed - awaiting the server ...\n")));
60 ACE_OS::sleep (1);
62 try
64 co = orb->string_to_object (ior_file_.c_str ());
66 if (co == 0)
68 ACE_DEBUG ((LM_DEBUG,
69 ACE_TEXT ("(%P|%t) Unable to obtain object reference yet. Retrying.\n")));
70 continue;
72 CORBA::Object_var tmp (co);
74 Test::Hello_var hello =
75 Test::Hello::_narrow(tmp.in ());
77 if (CORBA::is_nil (hello.in ()))
79 ACE_DEBUG ((LM_DEBUG,
80 ACE_TEXT ("(%P|%t) Nil Test::Hello reference <%s>. Retrying.\n"),
81 ior_file_.c_str ()));
82 continue;
85 ACE_DEBUG ((LM_DEBUG,
86 ACE_TEXT ("(%P|%t) Successfuly narrowed the Hello interface\n")));
88 CORBA::String_var the_string =
89 hello->get_string ();
91 ACE_DEBUG ((LM_DEBUG,
92 ACE_TEXT ("(%P|%t) String returned from the server <%C>\n"),
93 the_string.in ()));
95 hello->shutdown ();
97 attempts_left = 0; // We're done here!
100 catch (const CORBA::TRANSIENT& ex)
102 if (!attempts_left)
103 throw;
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")));
110 ACE_OS::sleep (5);
112 catch (const CORBA::Exception& ex)
114 ex._tao_print_exception("Unexpected CORBA exception caught");
116 if (!attempts_left)
117 throw;
119 ACE_DEBUG ((LM_DEBUG,
120 ACE_TEXT ("(%P|%t) Pausing for a while.\n")));
121 ACE_OS::sleep (5);
125 orb->shutdown (false);
127 orb->destroy ();
129 catch (const ::CORBA::Exception &e)
131 e._tao_print_exception("Client_Worker::test_main");
132 return 1;
135 return 0;