Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / GIOP_Fragments / Java_Big_Reply / client.cpp
blob874a19dddc8e5323181107745259635de7980b39
1 #include "Client_Task.h"
2 #include "ace/Get_Opt.h"
4 static const ACE_TCHAR *ior = ACE_TEXT("file://server.ior");
5 static size_t nthreads = 1;
7 int
8 parse_args (int argc, ACE_TCHAR *argv[])
10 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:n:"));
11 int c;
13 while ((c = get_opts ()) != -1)
14 switch (c)
16 case 'k':
17 ior = get_opts.opt_arg ();
18 break;
19 case 'n':
20 nthreads = ACE_OS::atoi (get_opts.opt_arg ());
21 break;
22 case '?':
23 default:
24 ACE_ERROR_RETURN ((LM_ERROR,
25 "usage: %s "
26 "-k <ior> "
27 "-n <nthreads> "
28 "\n",
29 argv [0]),
30 -1);
32 // Indicates successful parsing of the command line
33 return 0;
36 int
37 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
39 try
41 CORBA::ORB_var orb =
42 CORBA::ORB_init (argc, argv);
44 if (parse_args (argc, argv) != 0)
45 return 1;
47 CORBA::Object_var tmp =
48 orb->string_to_object(ior);
50 Test::Big_Reply_var reply_gen =
51 Test::Big_Reply::_narrow(tmp.in ());
53 if (CORBA::is_nil (reply_gen.in ()))
55 ACE_ERROR_RETURN ((LM_DEBUG,
56 "Nil coordinator reference <%s>\n",
57 ior),
58 1);
62 Client_Task client_task (reply_gen.in (),
63 10,
64 ACE_Thread_Manager::instance ());
66 if (client_task.activate (THR_NEW_LWP | THR_JOINABLE,
67 nthreads, 1) == -1)
69 ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
71 ACE_Thread_Manager::instance ()->wait ();
73 reply_gen->shutdown ();
75 orb->destroy ();
77 catch (const CORBA::Exception& ex)
79 ex._tao_print_exception ("Exception caught:");
80 return 1;
83 return 0;